Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Remove HomepageSection height animations
Sebastian Martinez committed 2 years ago
commit 1ad85ac2c39e4fbbf9d788f85095ab635559d82f
parent 192524fe90c7275cf402603906a22e30202c4e62
2 files changed +15 -133
deleted src/components/TransitionedHeight.svelte
@@ -1,114 +0,0 @@
-
<script lang="ts">
-
  import type { Tweened } from "svelte/motion";
-

-
  import { onMount } from "svelte";
-
  import { cubicInOut } from "svelte/easing";
-
  import { tweened } from "svelte/motion";
-

-
  // Force a height of 0, and optionally apply `negativeMarginWhileCollapsed`.
-
  export let collapsed = false;
-

-
  // If true, all content height changes are transitioned. If false, only
-
  // collapsing and expanding the content is transitioned.
-
  export let transitionHeightChanges = false;
-

-
  // Force a negative margin while collapsed. This is useful when you use
-
  // `transitionedHeight` in the context of some layout where there's further
-
  // content below.
-
  export let negativeMarginWhileCollapsed: string | undefined = undefined;
-

-
  let contentContainerElem: HTMLDivElement;
-
  let fitContent = !collapsed;
-

-
  let containerHeight: Tweened<number> | undefined;
-
  onMount(() => {
-
    if (collapsed) {
-
      containerHeight = tweened(0);
-
    } else {
-
      containerHeight = tweened(
-
        contentContainerElem.getBoundingClientRect().height,
-
      );
-
    }
-
  });
-

-
  let animating = false;
-
  let zeroHeight = collapsed;
-
  let previouslyCollapsed = collapsed;
-

-
  async function updateHeight() {
-
    if (!containerHeight) return;
-

-
    const newHeight = collapsed
-
      ? 0
-
      : contentContainerElem.getBoundingClientRect().height;
-

-
    const collapsedChanged = previouslyCollapsed !== collapsed;
-

-
    const shouldTransition = transitionHeightChanges || collapsedChanged;
-

-
    if (collapsed && !collapsedChanged) return;
-

-
    // Setting fitContent to false so that we can smoothly animate the
-
    // container height.
-
    if (shouldTransition) {
-
      fitContent = false;
-
      animating = true;
-
    }
-

-
    void containerHeight.set(
-
      newHeight,
-
      shouldTransition ? { duration: 300, easing: cubicInOut } : undefined,
-
    );
-

-
    if (shouldTransition && !collapsed) {
-
      setTimeout(() => {
-
        fitContent = true;
-
        animating = false;
-
      }, 300);
-
    }
-

-
    zeroHeight = newHeight === 0;
-

-
    previouslyCollapsed = collapsed;
-
  }
-
  $: {
-
    collapsed;
-
    void updateHeight();
-
  }
-

-
  let sizeObserver: ResizeObserver | undefined;
-
  onMount(() => {
-
    sizeObserver = new ResizeObserver(updateHeight);
-
    sizeObserver.observe(contentContainerElem);
-

-
    return () => sizeObserver?.disconnect();
-
  });
-

-
  $: heightStyleString = fitContent ? "fit-content" : `${$containerHeight}px`;
-
</script>
-

-
<style>
-
  .transitioned-height {
-
    width: 100%;
-
    transition: margin-bottom 0.3s;
-
    position: relative;
-
  }
-

-
  .animating,
-
  .zero-height {
-
    overflow: hidden;
-
  }
-
</style>
-

-
<div
-
  class="transitioned-height"
-
  class:animating
-
  class:zero-height={zeroHeight}
-
  style:margin-bottom={negativeMarginWhileCollapsed && zeroHeight === true
-
    ? negativeMarginWhileCollapsed
-
    : undefined}
-
  style:height={heightStyleString}>
-
  <div class="inner" bind:this={contentContainerElem}>
-
    <slot />
-
  </div>
-
</div>
modified src/views/home/components/HomepageSection.svelte
@@ -1,6 +1,5 @@
<script lang="ts">
  import Loading from "@app/components/Loading.svelte";
-
  import TransitionedHeight from "@app/components/TransitionedHeight.svelte";

  export let title: string;
  export let subtitle: string;
@@ -47,7 +46,6 @@

  .empty-container > .inner {
    max-width: 36rem;
-
    min-height: 14rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
@@ -65,23 +63,21 @@
    </div>
  </div>

-
  <TransitionedHeight transitionHeightChanges>
-
    {#if loading}
-
      <div class="empty-container">
-
        <div class="inner">
-
          <Loading small />
-
        </div>
+
  {#if loading}
+
    <div class="empty-container">
+
      <div class="inner">
+
        <Loading small />
      </div>
-
    {:else if empty}
-
      <div class="empty-container">
-
        <div class="inner">
-
          <slot name="empty" />
-
        </div>
-
      </div>
-
    {:else}
-
      <div>
-
        <slot />
+
    </div>
+
  {:else if empty}
+
    <div class="empty-container">
+
      <div class="inner">
+
        <slot name="empty" />
      </div>
-
    {/if}
-
  </TransitionedHeight>
+
    </div>
+
  {:else}
+
    <div>
+
      <slot />
+
    </div>
+
  {/if}
</section>