@@ -2,10 +2,11 @@ import React, {Suspense} from 'react'
2
2
import type { Meta } from '@storybook/react-vite'
3
3
import type { ComponentProps } from '../utils/types'
4
4
import { SkeletonText } from '../SkeletonText'
5
- import { Avatar , Box , Button , IconButton , Text } from '../'
5
+ import { Avatar , Button , IconButton , Text } from '../'
6
6
import { SkeletonAvatar } from '../SkeletonAvatar'
7
7
import { VisuallyHidden } from '../VisuallyHidden'
8
8
import { KebabHorizontalIcon } from '@primer/octicons-react'
9
+ import classes from './Skeleton.examples.stories.module.css'
9
10
10
11
export default {
11
12
title : 'Components/Skeleton/Examples' ,
@@ -21,37 +22,10 @@ const mockData = {
21
22
avatarSrc : 'https://avatars.githubusercontent.com/u/7143434?v=4' ,
22
23
}
23
24
24
- const CommentCard = ( { children} : { children : React . ReactNode } ) => (
25
- < Box
26
- sx = { {
27
- borderWidth : '1px' ,
28
- borderColor : 'border.default' ,
29
- borderStyle : 'solid' ,
30
- borderRadius : 2 ,
31
- fontSize : 1 ,
32
- lineHeight : 'default' ,
33
- p : 3 ,
34
- } }
35
- >
36
- { children }
37
- </ Box >
38
- )
25
+ const CommentCard = ( { children} : { children : React . ReactNode } ) => < div className = { classes . CommentCard } > { children } </ div >
39
26
40
27
const CommentCardHeading = ( { children} : { children : React . ReactNode } ) => (
41
- < Box
42
- className = "CommentCardHeading"
43
- sx = { {
44
- alignItems : 'center' ,
45
- display : 'flex' ,
46
- gap : 2 ,
47
- mb : 3 ,
48
- '.CommentCardHeading__text' : {
49
- flexGrow : 1 ,
50
- } ,
51
- } }
52
- >
53
- { children }
54
- </ Box >
28
+ < div className = { classes . CommentCardHeading } > { children } </ div >
55
29
)
56
30
57
31
export const CommentsLoading = ( ) => {
@@ -69,7 +43,7 @@ export const CommentsLoading = () => {
69
43
{ loading ? < VisuallyHidden > Comments are loading</ VisuallyHidden > : null }
70
44
{ /** when loading is completed, it should be announced by the screen-reader */ }
71
45
< VisuallyHidden aria-live = "polite" > { loadingFinished ? 'Comments are loaded' : null } </ VisuallyHidden >
72
- < Box sx = { { '> * + *' : { marginBlockStart : '1rem' } } } >
46
+ < div className = { classes . CommentsSpacing } >
73
47
< Button onClick = { toggleLoadingState } > { loading ? 'Stop loading' : 'Start loading' } </ Button >
74
48
{ Array . from ( { length : COMMENT_LIST_LENGTH } , ( _ , index ) => (
75
49
/* aria-busy is passed so the screenreader doesn't announce the skeleton state */
@@ -78,36 +52,29 @@ export const CommentsLoading = () => {
78
52
{ loading ? (
79
53
< >
80
54
< SkeletonAvatar size = { 32 } />
81
- < SkeletonText maxWidth = "80px" className = "CommentCardHeading__text" />
55
+ < SkeletonText maxWidth = "80px" className = { classes . CommentCardHeadingText } />
82
56
</ >
83
57
) : (
84
58
< >
85
59
< Avatar src = { mockData . avatarSrc } size = { 32 } />
86
- < Box sx = { { alignItems : 'center' , display : 'flex' , flexGrow : 1 , gap : 1 } } >
60
+ < div className = { classes . CommentCardUserMeta } >
87
61
< Text > { mockData . username } </ Text >
88
- < Text
89
- sx = { {
90
- color : 'fg.muted' ,
91
- flexGrow : 1 ,
92
- } }
93
- >
94
- { mockData . date }
95
- </ Text >
62
+ < Text className = { classes . CommentCardDate } > { mockData . date } </ Text >
96
63
{ /* buttons and interactive elements should not be represented as skeleton items or shown in any way until they're ready to accept input */ }
97
64
< IconButton
98
65
icon = { KebabHorizontalIcon }
99
66
size = "small"
100
67
aria-label = "Comment actions"
101
68
variant = "invisible"
102
69
/>
103
- </ Box >
70
+ </ div >
104
71
</ >
105
72
) }
106
73
</ CommentCardHeading >
107
74
{ loading ? < SkeletonText lines = { 2 } /> : < Text > { mockData . comment } </ Text > }
108
75
</ CommentCard >
109
76
) ) }
110
- </ Box >
77
+ </ div >
111
78
</ >
112
79
)
113
80
}
@@ -137,15 +104,15 @@ export const CommentsLoadingWithSuspense = () => {
137
104
< VisuallyHidden aria-live = "polite" > { loadingStatus === 'fulfilled' ? 'Comments are loaded' : null } </ VisuallyHidden >
138
105
139
106
{ /* aria-busy is passed so the screenreader doesn't announce the skeleton state */ }
140
- < Box sx = { { '> * + *' : { marginBlockStart : '1rem' } } } aria-busy = { loadingStatus === 'pending' } >
107
+ < div className = { classes . CommentsSpacing } aria-busy = { loadingStatus === 'pending' } >
141
108
{ Array . from ( { length : COMMENT_LIST_LENGTH } , ( _ , index ) => (
142
109
< CommentCard key = { index } >
143
110
< Suspense
144
111
fallback = {
145
112
< >
146
113
< CommentCardHeading >
147
114
< SkeletonAvatar size = { 32 } />
148
- < SkeletonText maxWidth = "80px" className = "CommentCardHeading__text" />
115
+ < SkeletonText maxWidth = "80px" className = { classes . CommentCardHeadingText } />
149
116
</ CommentCardHeading >
150
117
< SkeletonText lines = { 2 } />
151
118
</ >
@@ -155,7 +122,7 @@ export const CommentsLoadingWithSuspense = () => {
155
122
</ Suspense >
156
123
</ CommentCard >
157
124
) ) }
158
- </ Box >
125
+ </ div >
159
126
</ >
160
127
)
161
128
}
@@ -167,19 +134,12 @@ const SuspendedCommentCardContent = ({promise}: {promise: Promise<typeof mockDat
167
134
< >
168
135
< CommentCardHeading >
169
136
< Avatar src = { fetchedData . avatarSrc } size = { 32 } />
170
- < Box sx = { { alignItems : 'center' , display : 'flex' , flexGrow : 1 , gap : 1 } } >
137
+ < div className = { classes . CommentCardUserMeta } >
171
138
< Text > { fetchedData . username } </ Text >
172
- < Text
173
- sx = { {
174
- color : 'fg.muted' ,
175
- flexGrow : 1 ,
176
- } }
177
- >
178
- { fetchedData . date }
179
- </ Text >
139
+ < Text className = { classes . CommentCardDate } > { fetchedData . date } </ Text >
180
140
{ /* buttons and interactive elements should not be represented as skeleton items or shown in any way until they're ready to accept input */ }
181
141
< IconButton icon = { KebabHorizontalIcon } size = "small" aria-label = "Comment actions" variant = "invisible" />
182
- </ Box >
142
+ </ div >
183
143
</ CommentCardHeading >
184
144
< Text > { fetchedData . comment } </ Text >
185
145
</ >
0 commit comments