|
1 | 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. |
2 | 2 |
|
3 | | -import type {CSSProperties} from 'react'; |
| 3 | +/** |
| 4 | + * @file Spinner.stories.tsx |
| 5 | + * @input Spinner, React state, and theme fixtures |
| 6 | + * @output Spinner examples and a repeatable conditional-announcement scenario |
| 7 | + * @position Storybook visual and assistive-technology verification surface |
| 8 | + */ |
| 9 | + |
| 10 | +import {StrictMode, useState, type CSSProperties} from 'react'; |
4 | 11 | import type {Meta, StoryObj} from '@storybook/react'; |
5 | 12 | import {Spinner} from '@astryxdesign/core/Spinner'; |
| 13 | +import {Button} from '@astryxdesign/core/Button'; |
6 | 14 | import {Text} from '@astryxdesign/core/Text'; |
7 | 15 | import {HStack, VStack} from '@astryxdesign/core/Layout'; |
8 | 16 | import {Theme, defineTheme} from '@astryxdesign/core/theme'; |
@@ -49,6 +57,31 @@ export const Default: Story = { |
49 | 57 | }, |
50 | 58 | }; |
51 | 59 |
|
| 60 | +export const ConditionalAppearance: Story = { |
| 61 | + render: function ConditionalAppearance() { |
| 62 | + const [isLoading, setIsLoading] = useState(false); |
| 63 | + const [renderCount, setRenderCount] = useState(0); |
| 64 | + return ( |
| 65 | + <StrictMode> |
| 66 | + <VStack gap={4}> |
| 67 | + <HStack gap={2}> |
| 68 | + <Button |
| 69 | + label={isLoading ? 'Finish loading' : 'Start loading'} |
| 70 | + onClick={() => setIsLoading(value => !value)} |
| 71 | + /> |
| 72 | + <Button |
| 73 | + label="Rerender" |
| 74 | + onClick={() => setRenderCount(value => value + 1)} |
| 75 | + /> |
| 76 | + </HStack> |
| 77 | + <Text>Rerenders: {renderCount}</Text> |
| 78 | + {isLoading && <Spinner label="Loading results" />} |
| 79 | + </VStack> |
| 80 | + </StrictMode> |
| 81 | + ); |
| 82 | + }, |
| 83 | +}; |
| 84 | + |
52 | 85 | export const Sizes: Story = { |
53 | 86 | render: () => ( |
54 | 87 | <HStack gap={4} vAlign="center"> |
|
0 commit comments