Skip to content

Commit

Permalink
Group GSAP stories
Browse files Browse the repository at this point in the history
  • Loading branch information
leroykorterink committed Nov 10, 2023
1 parent 21638f5 commit d90983e
Show file tree
Hide file tree
Showing 29 changed files with 47 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/gsap/components/SplitTextWrapper/SplitTextWrapper.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, Canvas, Controls } from '@storybook/blocks';
import * as stories from './SplitTextWrapper.stories';

<Meta title="components/SplitTextWrapper" of={stories} />
<Meta title="GSAP / Components / SplitTextWrapper" of={stories} />

# SplitTextWrapper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useAnimation } from '../../hooks/useAnimation/useAnimation.js';
import { SplitTextWrapper } from './SplitTextWrapper.js';

const meta = {
title: 'components/SplitTextWrapper',
title: 'GSAP / Components / SplitTextWrapper',
component: SplitTextWrapper,
} as Meta;

Expand Down
2 changes: 1 addition & 1 deletion src/gsap/hooks/useAnimation/useAnimation.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, Canvas } from '@storybook/blocks';
import * as stories from './useAnimation.stories';

<Meta title="hooks/useAnimation" />
<Meta title="GSAP / Hooks / useAnimation" />

# useAnimation

Expand Down
2 changes: 1 addition & 1 deletion src/gsap/hooks/useAnimation/useAnimation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useCallback, useRef, type ReactElement } from 'react';
import { useAnimation } from './useAnimation.js';

export default {
title: 'hooks/useAnimation',
title: 'GSAP / Hooks / useAnimation',
component: Timeline,
};

Expand Down
2 changes: 1 addition & 1 deletion src/gsap/hooks/useExposeAnimation/useExposeAnimation.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta } from '@storybook/blocks';
import { UseExposeAnimation } from './useExposeAnimation.stories';

<Meta title="hooks/useExposeAnimation" />
<Meta title="GSAP / Hooks / useExposeAnimation" />

# useExposeAnimation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useAnimation } from '../useAnimation/useAnimation.js';
import { useExposeAnimation } from '../useExposeAnimation/useExposeAnimation.js';

const meta = {
title: 'hooks/useExposeAnimation',
title: 'GSAP / Hooks / useExposeAnimation',
} satisfies Meta;

export default meta;
Expand Down
2 changes: 1 addition & 1 deletion src/gsap/hooks/useExposedAnimation/useExposedAnimation.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, Canvas } from '@storybook/blocks';
import * as stories from './useExposedAnimation.stories';

<Meta title="hooks/useExposedAnimation" />
<Meta title="GSAP / Hooks / useExposedAnimation" />

# useExposedAnimation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useExposeAnimation } from '../useExposeAnimation/useExposeAnimation.js'
import { useExposedAnimation } from './useExposedAnimation.js';

const meta = {
title: 'hooks/useExposedAnimation',
title: 'GSAP / Hooks / useExposedAnimation',
} satisfies Meta;

export default meta;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from '@storybook/blocks';

<Meta title="hooks/useExposedAnimations" />
<Meta title="GSAP / Hooks / useExposedAnimations" />

# useExposedAnimations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useScrollAnimation } from '../useScrollAnimation/useScrollAnimation.js'
import { useExposedAnimations } from './useExposedAnimations.js';

export default {
title: 'hooks/useExposedAnimations',
title: 'GSAP / Hooks / useExposedAnimations',
};

// Forces a re-render, useful to test for unwanted side-effects
Expand Down
2 changes: 1 addition & 1 deletion src/gsap/hooks/useFlip/useFlip.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, Canvas } from '@storybook/blocks';
import * as stories from './useFlip.stories';

<Meta title="components/useFlip" of={stories} />
<Meta title="GSAP / Hooks / useFlip" of={stories} />

# useFlip

Expand Down
2 changes: 1 addition & 1 deletion src/gsap/hooks/useFlip/useFlip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useToggle } from '../../../hooks/useToggle/useToggle.js';
import { useFlip } from './useFlip.js';

const meta = {
title: 'hooks/useFlip',
title: 'GSAP / Hooks / useFlip',
} as Meta;

export default meta;
Expand Down
2 changes: 1 addition & 1 deletion src/gsap/hooks/useScrollAnimation/useScrollAnimation.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, Canvas } from '@storybook/blocks';
import * as stories from './useScrollAnimation.stories';

<Meta title="hooks/useScrollAnimation" />
<Meta title="GSAP / hooks / useScrollAnimation" />

# useScrollAnimation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useRef, type ReactElement } from 'react';
import { useScrollAnimation } from './useScrollAnimation.js';

export default {
title: 'hooks/useScrollAnimation',
title: 'GSAP / Hooks / useScrollAnimation',
parameters: {
layout: 'fullscreen',
},
Expand Down
2 changes: 1 addition & 1 deletion src/gsap/hooks/useScrollAnimation/useScrollAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (typeof window !== 'undefined') {
* when the global animations map is updated.
*
* Note: do not scrub a React component's root because React won't know what element to
* unmount when the component with a pinned animation is must removed from the vDOM.
* unmount when the component with a pinned animation is removed from the vDOM.
*/
export function useScrollAnimation<T extends gsap.core.Animation>(
callback: () => T | undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/gsap/utils/getAnimation/getAnimation.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from '@storybook/blocks';

<Meta title="hooks/getAnimation" />
<Meta title="GSAP / Hooks / getAnimation" />

# useExposeAnimation

Expand Down
2 changes: 1 addition & 1 deletion src/gsap/utils/getAnimation/getAnimation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useExposeAnimation } from '../../hooks/useExposeAnimation/useExposeAnim
import { getAnimation } from './getAnimation.js';

export default {
title: 'hooks/getAnimation',
title: 'GSAP / Hooks / getAnimation',
};

const Child = ensuredForwardRef<HTMLDivElement, unknown>((_, ref): ReactElement => {
Expand Down
21 changes: 18 additions & 3 deletions src/lifecycle/components/CrossFlow/CrossFlow.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable react/no-multi-comp, react/jsx-no-literals, react-hooks/rules-of-hooks */
import type { Meta, StoryObj } from '@storybook/react';
import { Fragment, useRef, useState, type ReactElement } from 'react';
import { Fragment, useLayoutEffect, useRef, useState, type ReactElement } from 'react';
import { useBeforeUnmount } from '../../hooks/useBeforeUnmount/useBeforeUnmount.js';
import { CrossFlow } from './CrossFlow.js';

const meta = {
title: 'Lifecycle / components/CrossFlow',
title: 'Lifecycle / Components/CrossFlow',
argTypes: {
children: {
description: 'ReactElement | null',
Expand All @@ -31,13 +31,28 @@ type ChildProps = {
function Child({ background, onClick, duration = 1000 }: ChildProps): ReactElement {
const ref = useRef<HTMLButtonElement>(null);

useLayoutEffect(() => {
if (!ref.current) {
return;
}

const animation = ref.current.animate([{ opacity: 0 }, { opacity: 1 }], {
duration,
fill: 'forwards',
});

return () => {
animation.cancel();
};
}, [duration]);

// show visible animation during "before unmount" lifecycle
useBeforeUnmount(async (abortSignal) => {
if (!ref.current) {
return;
}

const animation = ref.current.animate([{ opacity: 1 }, { opacity: 0 }], {
const animation = ref.current.animate([{ opacity: 0 }], {
duration,
fill: 'forwards',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useBeforeUnmount } from '../../hooks/useBeforeUnmount/useBeforeUnmount.
import { TransitionPresence } from './TransitionPresence.js';

const meta = {
title: 'Lifecycle / components / TransitionPresence',
title: 'Lifecycle / Components / TransitionPresence',
} satisfies Meta;

export default meta;
Expand Down Expand Up @@ -42,7 +42,7 @@ function Child({ background, onClick }: ChildProps): ReactElement {
return;
}

const animation = ref.current.animate([{ opacity: 1 }, { opacity: 0 }], {
const animation = ref.current.animate([{ opacity: 0 }], {
duration: 500,
fill: 'forwards',
});
Expand Down
2 changes: 1 addition & 1 deletion src/lifecycle/hooks/useBeforeMount/useBeforeMount.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from '@storybook/blocks';

<Meta title="Lifecycle / hooks / useBeforeMount" />
<Meta title="Lifecycle / Hooks / useBeforeMount" />

# useBeforeMount

Expand Down
2 changes: 1 addition & 1 deletion src/lifecycle/hooks/useBeforeUnmount/useBeforeUnmount.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Canvas, Meta } from '@storybook/blocks';
import * as transitionPrescenseStories from '../../components/TransitionPresence/TransitionPresence.stories';

<Meta title="Lifecycle / hooks / useBeforeUnmount" />
<Meta title="Lifecycle / Hooks / useBeforeUnmount" />

# useBeforeUnmount

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { TransitionPresence } from '../../components/TransitionPresence/Transiti
import { useBeforeUnmount } from './useBeforeUnmount.js';

const meta = {
title: 'Lifecycle / hooks / useBeforeUnmount',
title: 'Lifecycle / Hooks / useBeforeUnmount',
} satisfies Meta;

export default meta;
Expand Down
2 changes: 1 addition & 1 deletion src/lifecycle/hooks/useIsMounted/useIsMounted.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from '@storybook/blocks';

<Meta title="Lifecycle / hooks / useIsMounted" />
<Meta title="Lifecycle / Hooks / useIsMounted" />

# useIsMounted

Expand Down
2 changes: 1 addition & 1 deletion src/lifecycle/hooks/useIsMounted/useIsMounted.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useIsMountedState } from '../useIsMountedState/useIsMountedState.js';
import { useIsMounted } from './useIsMounted.js';

const meta = {
title: 'Lifecycle / hooks / useIsMounted',
title: 'Lifecycle / Hooks / useIsMounted',
} satisfies Meta;

export default meta;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from '@storybook/blocks';

<Meta title="Lifecycle / hooks / useIsMountedState" />
<Meta title="Lifecycle / Hooks / useIsMountedState" />

# useIsMountedState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useForceRerender } from '../../../hooks/useForceRerender/useForceRerend
import { useIsMountedState } from './useIsMountedState.js';

const meta = {
title: 'Lifecycle / hooks / useIsMountedState',
title: 'Lifecycle / Hooks / useIsMountedState',
} satisfies Meta;

export default meta;
Expand Down
2 changes: 1 addition & 1 deletion src/lifecycle/hooks/useMount/useMount.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from '@storybook/blocks';

<Meta title="Lifecycle / hooks / useMount" />
<Meta title="Lifecycle / Hooks / useMount" />

# useMount

Expand Down
2 changes: 1 addition & 1 deletion src/lifecycle/hooks/useUnmount/useUnmount.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from '@storybook/blocks';

<Meta title="Lifecycle / hooks / useUnmount" />
<Meta title="Lifecycle / Hooks / useUnmount" />

# useUnmount

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from '@storybook/blocks';

<Meta title="NextJS / hooks / useIsomorphicLayoutEffect" />
<Meta title="NextJS / Hooks / useIsomorphicLayoutEffect" />

# useIsomorphicLayoutEffect

Expand Down

0 comments on commit d90983e

Please sign in to comment.