import preview from "#.storybook/preview"; import { AnimationParams } from "animejs"; import { Component, createSignal, For, Show } from "solid-js"; import { Anime } from "../../src/ts/components/common/anime/Anime"; import { AnimePresence } from "../../src/ts/components/common/anime/AnimePresence"; const meta = preview.meta({ title: "Common/Anime/AnimePresence", component: AnimePresence as Component, parameters: { layout: "centered", }, tags: ["autodocs"], }); const box = { padding: "16px 24px", "background-color": "var(--sub-alt-color)", color: "var(--text-color)", "border-radius": "8px", "margin-bottom": "8px", }; export const SingleToggle = meta.story({ render: () => { const [show, setShow] = createSignal(true); return (
} animate={ { opacity: 1, scale: 1, duration: 300 } as AnimationParams } exit={ { opacity: 0, scale: 0.8, duration: 300 } as AnimationParams } >
Content with enter and exit animations
); }, }); export const ExitBeforeEnter = meta.story({ render: () => { const [view, setView] = createSignal<"a" | "b">("a"); const buttonStyle = (active: boolean) => ({ padding: "8px 16px", cursor: "pointer", "background-color": active ? "var(--main-color)" : "var(--sub-alt-color)", color: active ? "var(--bg-color)" : "var(--text-color)", border: "none", "border-radius": "8px", }); return (
} animate={ { opacity: 1, translateX: 0, duration: 300 } as AnimationParams } exit={ { opacity: 0, translateX: 20, duration: 300 } as AnimationParams } >
View A - exits before B enters
} animate={ { opacity: 1, translateX: 0, duration: 300 } as AnimationParams } exit={ { opacity: 0, translateX: 20, duration: 300 } as AnimationParams } >
View B - exits before A enters
); }, }); export const ListMode = meta.story({ render: () => { const [items, setItems] = createSignal([1, 2, 3]); let nextId = 4; return (
{(item) => ( } animate={ { opacity: 1, translateX: 0, duration: 200, } as AnimationParams } exit={ { opacity: 0, translateX: 10, duration: 200, } as AnimationParams } >
Item {item}
)}
); }, });