Skip to content

Commit 67446d5

Browse files
committed
docs(motion): demo Collapse + Stagger + Skeleton
1 parent 3780b28 commit 67446d5

File tree

1 file changed

+125
-5
lines changed

1 file changed

+125
-5
lines changed

packages/react-components/react-motion-components-preview/stories/src/Collapse/CollapseDefault.stories.tsx

+125-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
1-
import { Field, makeStyles, tokens, Switch, PresenceComponentProps } from '@fluentui/react-components';
2-
import { Collapse } from '@fluentui/react-motion-components-preview';
1+
import {
2+
Field,
3+
makeStyles,
4+
tokens,
5+
Switch,
6+
PresenceComponentProps,
7+
Skeleton,
8+
SkeletonItem,
9+
} from '@fluentui/react-components';
10+
import {
11+
Blur,
12+
Collapse,
13+
CollapseDelayed,
14+
CollapseRelaxed,
15+
ScaleRelaxed,
16+
Slide,
17+
SlideRelaxed,
18+
} from '@fluentui/react-motion-components-preview';
319
import * as React from 'react';
20+
import { PresenceStagger, Stagger } from '../Experiments/Stagger';
21+
import { SlideUnder } from '../Experiments/SlideUnder';
22+
import { Hold, Series } from '../Experiments/Series';
423

524
const useClasses = makeStyles({
625
container: {
@@ -11,6 +30,7 @@ const useClasses = makeStyles({
1130
card: {
1231
gridArea: 'card',
1332
padding: '10px',
33+
overflow: 'hidden',
1434
},
1535
controls: {
1636
display: 'flex',
@@ -27,6 +47,28 @@ const useClasses = makeStyles({
2747
},
2848
});
2949

50+
const useStyles = makeStyles({
51+
invertedWrapper: {
52+
backgroundColor: tokens.colorNeutralBackground1,
53+
},
54+
firstRow: {
55+
alignItems: 'center',
56+
display: 'grid',
57+
paddingBottom: '10px',
58+
position: 'relative',
59+
gap: '10px',
60+
gridTemplateColumns: 'min-content 80%',
61+
},
62+
secondThirdRow: {
63+
alignItems: 'center',
64+
display: 'grid',
65+
paddingBottom: '10px',
66+
position: 'relative',
67+
gap: '10px',
68+
gridTemplateColumns: 'min-content 20% 20% 15% 15%',
69+
},
70+
});
71+
3072
const LoremIpsum = () => (
3173
<>
3274
{'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. '.repeat(
@@ -37,8 +79,73 @@ const LoremIpsum = () => (
3779

3880
export const Default = (props: React.ComponentProps<typeof Collapse>) => {
3981
const classes = useClasses();
82+
const styles = useStyles();
83+
4084
const [visible, setVisible] = React.useState<boolean>(false);
4185

86+
const RowMotion = () => (
87+
<Slide.In>
88+
<div className={styles.firstRow}>
89+
<SkeletonItem shape="circle" size={24} />
90+
<SkeletonItem shape="rectangle" size={16} />
91+
</div>
92+
</Slide.In>
93+
);
94+
95+
const SkeletonRowCustom = () => (
96+
<div className={styles.firstRow}>
97+
<SkeletonItem shape="circle" size={28} />
98+
<SkeletonItem shape="rectangle" size={20} />
99+
</div>
100+
);
101+
102+
const ContentRow = ({
103+
index = 0,
104+
text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
105+
}: { index?: number; text?: string } = {}) => (
106+
<div key={index} className={styles.firstRow}>
107+
<div style={{ width: '28px', height: '28px', backgroundColor: 'grey', borderRadius: '50%' }} />
108+
<div style={{ width: '100%', height: '28px', paddingTop: '5px' }}>{text}</div>
109+
</div>
110+
);
111+
112+
const ContentRowPresence = ({ visible = false }: { visible?: boolean }) => (
113+
// <ScaleRelaxed visible={visible} duration={1000}>
114+
// <div>
115+
// <Blur visible={visible} enterDuration={700} radius="50px">
116+
<SlideUnder visible={visible}>
117+
<div className={styles.firstRow}>
118+
{visible ? <ContentRow /> : <div style={{ width: '100%', height: '28px' }} />}
119+
</div>
120+
</SlideUnder>
121+
// </Blur>
122+
// </div>
123+
// </ScaleRelaxed>
124+
);
125+
126+
const SkeletonRowPresence = ({ visible = false }: { visible?: boolean }) => (
127+
// <ScaleRelaxed visible={visible} duration={1000}>
128+
// <div>
129+
// <Blur visible={visible} enterDuration={700} radius="50px">
130+
<SlideUnder visible={visible}>
131+
{visible ? (
132+
<div style={{ height: '36px' }}>
133+
<Series>
134+
<Hold duration={3000}>
135+
<SkeletonRowCustom />
136+
</Hold>
137+
<Slide.In>{ContentRow()}</Slide.In>
138+
</Series>
139+
</div>
140+
) : (
141+
<div style={{ width: '100%', height: '36px' }} />
142+
)}
143+
</SlideUnder>
144+
// </Blur>
145+
// </div>
146+
// </ScaleRelaxed>
147+
);
148+
42149
return (
43150
<div className={classes.container}>
44151
<div className={classes.controls}>
@@ -47,11 +154,24 @@ export const Default = (props: React.ComponentProps<typeof Collapse>) => {
47154
</Field>
48155
</div>
49156

50-
<Collapse visible={visible}>
157+
<CollapseDelayed visible={visible} unmountOnExit animateOpacity={false}>
51158
<div className={classes.card}>
52-
<LoremIpsum />
159+
{
160+
<Skeleton>
161+
<PresenceStagger delay={70} mode={visible ? 'enterReverse' : 'exitReverse'}>
162+
<SkeletonRowPresence />
163+
<SkeletonRowPresence />
164+
<SkeletonRowPresence />
165+
<SkeletonRowPresence />
166+
<SkeletonRowPresence />
167+
<SkeletonRowPresence />
168+
<SkeletonRowPresence />
169+
<SkeletonRowPresence />
170+
</PresenceStagger>
171+
</Skeleton>
172+
}
53173
</div>
54-
</Collapse>
174+
</CollapseDelayed>
55175
</div>
56176
);
57177
};

0 commit comments

Comments
 (0)