Skip to content

Commit ca69e23

Browse files
feat: revert "use directive transition wrappers" (#586)
# Motivation Revert #574 because thanks to a different way of mocking the transitions for test purposes (without vite), those workaround are not needed anymore. # Resources - Mock tested in dfinity/nns-dapp#6404 - New solution to mock the animation for test purposes with Svelte v5 providing by Testing Library in testing-library/svelte-testing-library#284 (comment) # Changes - Revert #574 and use Svelte transitions --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 0283e18 commit ca69e23

8 files changed

+20
-33
lines changed
Loading

src/lib/components/Backdrop.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { testSafeFade } from "$lib/directives/transition.directives";
2+
import { fade } from "svelte/transition";
33
import { createEventDispatcher } from "svelte";
44
import { i18n } from "$lib/stores/i18n";
55
import { handleKeyPress } from "$lib/utils/keyboard.utils";
@@ -18,8 +18,8 @@
1818
role="button"
1919
tabindex="-1"
2020
aria-label={$i18n.core.close}
21-
in:testSafeFade|global={{ duration: FADE_IN_DURATION }}
22-
out:testSafeFade|global={{ duration: FADE_OUT_DURATION }}
21+
in:fade|global={{ duration: FADE_IN_DURATION }}
22+
out:fade|global={{ duration: FADE_OUT_DURATION }}
2323
class="backdrop"
2424
class:visible={!invisible}
2525
on:click|stopPropagation={close}

src/lib/components/BusyScreen.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script lang="ts">
2-
import { testSafeFade } from "$lib/directives/transition.directives";
2+
import { fade } from "svelte/transition";
33
import { busy, busyMessage } from "$lib/stores/busy.store";
44
import Spinner from "$lib/components/Spinner.svelte";
55
import { nonNullish } from "@dfinity/utils";
66
</script>
77

88
<!-- Display spinner and lock UI if busyStore is not empty -->
99
{#if $busy}
10-
<div data-tid="busy" transition:testSafeFade|global>
10+
<div data-tid="busy" transition:fade|global>
1111
<div class="content">
1212
{#if nonNullish($busyMessage)}
1313
<p>{$busyMessage}</p>

src/lib/components/Modal.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { testSafeFade } from "$lib/directives/transition.directives";
2+
import { fade } from "svelte/transition";
33
import { createEventDispatcher } from "svelte";
44
import { i18n } from "$lib/stores/i18n";
55
import IconClose from "$lib/icons/IconClose.svelte";
@@ -46,7 +46,7 @@
4646
{#if visible}
4747
<div
4848
class="modal"
49-
transition:testSafeFade|global={{ duration: 25 }}
49+
transition:fade|global={{ duration: 25 }}
5050
on:introend
5151
{role}
5252
data-tid={testId}
@@ -56,8 +56,8 @@
5656
>
5757
<Backdrop {disablePointerEvents} on:nnsClose />
5858
<div
59-
in:testSafeFade|global={{ duration: FADE_IN_DURATION }}
60-
out:testSafeFade|global={{ duration: FADE_OUT_DURATION }}
59+
in:fade|global={{ duration: FADE_IN_DURATION }}
60+
out:fade|global={{ duration: FADE_OUT_DURATION }}
6161
class={`wrapper ${role}`}
6262
>
6363
{#if showHeader}

src/lib/components/Popover.svelte

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<!-- https://github.com/papyrs/papyrs/blob/main/src/lib/components/ui/Popover.svelte -->
22
<script lang="ts">
3-
import {
4-
testSafeFade,
5-
testSafeScale,
6-
} from "$lib/directives/transition.directives";
3+
import { fade, scale } from "svelte/transition";
74
import { quintOut } from "svelte/easing";
85
import { i18n } from "$lib/stores/i18n";
96
import Backdrop from "./Backdrop.svelte";
@@ -33,7 +30,7 @@
3330
<div
3431
role="menu"
3532
aria-orientation="vertical"
36-
transition:testSafeFade|global
33+
transition:fade|global
3734
class="popover"
3835
tabindex="-1"
3936
style="--popover-top: {`${bottom}px`}; --popover-left: {`${left}px`}; --popover-right: {`${
@@ -48,11 +45,7 @@
4845
invisible={invisibleBackdrop}
4946
/>
5047
<div
51-
transition:testSafeScale|global={{
52-
delay: 25,
53-
duration: 150,
54-
easing: quintOut,
55-
}}
48+
transition:scale|global={{ delay: 25, duration: 150, easing: quintOut }}
5649
class="wrapper"
5750
class:with-border={invisibleBackdrop}
5851
class:rtl={direction === "rtl"}

src/lib/components/ThemeToggleButton.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { i18n } from "$lib/stores/i18n";
55
import IconLightMode from "$lib/icons/IconLightMode.svelte";
66
import IconDarkMode from "$lib/icons/IconDarkMode.svelte";
7-
import { testSafeFade } from "$lib/directives/transition.directives";
7+
import { fade } from "svelte/transition";
88
99
const switchTheme = () => {
1010
themeStore.select($themeStore === Theme.LIGHT ? Theme.DARK : Theme.LIGHT);
@@ -21,11 +21,11 @@
2121
aria-label={$i18n.theme.switch_theme}
2222
>
2323
{#if isDarkMode}
24-
<span in:testSafeFade|global>
24+
<span in:fade|global>
2525
<IconLightMode />
2626
</span>
2727
{:else}
28-
<span in:testSafeFade|global>
28+
<span in:fade|global>
2929
<IconDarkMode />
3030
</span>
3131
{/if}

src/lib/components/Toast.svelte

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<script lang="ts">
22
import { toastsStore } from "$lib/stores/toasts.store";
3-
import {
4-
testSafeFade,
5-
testSafeFly,
6-
} from "$lib/directives/transition.directives";
3+
import { fade, fly } from "svelte/transition";
74
import { i18n } from "$lib/stores/i18n";
85
import type {
96
ToastLevel,
@@ -95,11 +92,8 @@
9592
data-tid="toast-component"
9693
role="dialog"
9794
class={`toast ${theme ?? "themed"}`}
98-
in:testSafeFly|global={{
99-
y: (position === "top" ? -1 : 1) * 100,
100-
duration: 200,
101-
}}
102-
out:testSafeFade|global={{ delay: 100 }}
95+
in:fly|global={{ y: (position === "top" ? -1 : 1) * 100, duration: 200 }}
96+
out:fade|global={{ delay: 100 }}
10397
>
10498
<div class="icon {level}" aria-hidden="true">
10599
{#if spinner}

src/lib/components/WizardTransition.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { testSafeFly } from "$lib/directives/transition.directives";
2+
import { fly } from "svelte/transition";
33
44
// Instead of a number an object is used to make svelte notice any updates need rerender
55
export let transition: { diff: number } = { diff: 0 };
@@ -19,7 +19,7 @@
1919
{#key transition}
2020
<div
2121
bind:clientWidth={absolutOffset}
22-
in:testSafeFly|global={{ x: slideOffset, duration: ANIMATION_DURATION }}
22+
in:fly|global={{ x: slideOffset, duration: ANIMATION_DURATION }}
2323
class="transition"
2424
>
2525
<slot />

0 commit comments

Comments
 (0)