@@ -8,13 +8,11 @@ import {
8
8
ListItem ,
9
9
ModalBody ,
10
10
ModalHeader ,
11
- SkeletonText ,
12
11
UnorderedList ,
13
- useBreakpointValue ,
14
12
VStack ,
15
13
} from "@chakra-ui/react"
16
14
17
- import type { Author , Lang } from "@/lib/types"
15
+ import type { ChildOnlyProp , FileContributor , Lang } from "@/lib/types"
18
16
19
17
import { Button } from "@/components/Buttons"
20
18
import InlineLink from "@/components/Link"
@@ -25,76 +23,50 @@ import Translation from "@/components/Translation"
25
23
import { trackCustomEvent } from "@/lib/utils/matomo"
26
24
import { getLocaleTimestamp } from "@/lib/utils/time"
27
25
28
- // TODO: skeletons are not part of the DS, so these should be replaced once we
29
- // implement the new designs. Thats the reason we haven't define these styles in
30
- // the theme config file
31
- const skeletonColorProps = {
32
- startColor : "lightBorder" ,
33
- endColor : "searchBackgroundEmpty" ,
34
- }
35
-
36
- const Skeleton = ( props ) => < SkeletonText { ...skeletonColorProps } { ...props } />
37
-
38
- const ContributorList = ( { children } : { children : React . ReactNode } ) => {
39
- return (
40
- < UnorderedList maxH = "2xs" m = { 0 } mt = { 6 } overflowY = "scroll" >
41
- { children }
42
- </ UnorderedList >
43
- )
44
- }
45
-
46
- const Contributor = ( { contributor } : { contributor : Author } ) => {
47
- return (
48
- < ListItem p = { 2 } display = "flex" alignItems = "center" >
49
- < Avatar
50
- height = "40px"
51
- width = "40px"
52
- src = { contributor . avatarUrl }
53
- name = { contributor . name }
54
- me = { 2 }
55
- />
56
- { contributor . user && (
57
- < InlineLink href = { contributor . user . url } >
58
- @{ contributor . user . login }
59
- </ InlineLink >
60
- ) }
61
- { ! contributor . user && < span > { contributor . name } </ span > }
62
- </ ListItem >
63
- )
64
- }
26
+ const ContributorList = ( { children } : Required < ChildOnlyProp > ) => (
27
+ < UnorderedList maxH = "2xs" m = { 0 } mt = { 6 } overflowY = "scroll" >
28
+ { children }
29
+ </ UnorderedList >
30
+ )
31
+
32
+ type ContributorProps = { contributor : FileContributor }
33
+ const Contributor = ( { contributor } : ContributorProps ) => (
34
+ < ListItem p = { 2 } display = "flex" alignItems = "center" >
35
+ < Avatar
36
+ height = "40px"
37
+ width = "40px"
38
+ src = { contributor . avatar_url }
39
+ name = { contributor . login }
40
+ me = { 2 }
41
+ />
42
+ < InlineLink href = { "https://github.com/" + contributor . login } >
43
+ @{ contributor . login }
44
+ </ InlineLink >
45
+ </ ListItem >
46
+ )
65
47
66
48
export type FileContributorsProps = FlexProps & {
67
49
editPath ?: string
68
- contributors : Author [ ]
69
- loading : boolean
70
- error ?: boolean
50
+ contributors : FileContributor [ ]
71
51
lastEdit : string
72
52
}
73
53
74
54
const FileContributors = ( {
75
55
contributors,
76
- loading,
77
- error,
78
56
lastEdit,
79
57
...props
80
58
} : FileContributorsProps ) => {
81
59
const [ isModalOpen , setModalOpen ] = useState ( false )
82
60
const { locale } = useRouter ( )
83
61
84
- const isDesktop = useBreakpointValue ( { base : false , md : true } )
85
-
86
- if ( error ) return null
87
- const lastContributor : Author = contributors . length
62
+ const lastContributor : FileContributor = contributors . length
88
63
? contributors [ 0 ]
89
- : {
90
- name : "" ,
91
- email : "" ,
92
- avatarUrl : "" ,
93
- user : {
94
- login : "" ,
95
- url : "" ,
96
- } ,
97
- }
64
+ : ( {
65
+ avatar_url : "" ,
66
+ login : "" ,
67
+ html_url : "" ,
68
+ date : Date . now ( ) . toString ( ) ,
69
+ } as FileContributor )
98
70
99
71
return (
100
72
< >
@@ -107,18 +79,12 @@ const FileContributors = ({
107
79
108
80
< ModalBody >
109
81
< Translation id = "contributors-thanks" />
110
- < Skeleton noOfLines = "4" mt = "4" isLoaded = { ! loading } >
111
- { contributors ? (
112
- < ContributorList >
113
- { contributors . map ( ( contributor ) => (
114
- < Contributor
115
- contributor = { contributor }
116
- key = { contributor . email }
117
- />
118
- ) ) }
119
- </ ContributorList >
120
- ) : null }
121
- </ Skeleton >
82
+
83
+ < ContributorList >
84
+ { contributors . map ( ( contributor ) => (
85
+ < Contributor contributor = { contributor } key = { contributor . login } />
86
+ ) ) }
87
+ </ ContributorList >
122
88
</ ModalBody >
123
89
</ Modal >
124
90
@@ -130,29 +96,22 @@ const FileContributors = ({
130
96
p = { { base : 0 , md : 2 } }
131
97
{ ...props }
132
98
>
133
- < Flex me = { 4 } alignItems = "center" flex = "1" >
134
- { isDesktop && (
135
- < >
136
- < Avatar
137
- height = "40px"
138
- width = "40px"
139
- src = { lastContributor . avatarUrl }
140
- name = { lastContributor . name }
141
- me = { 2 }
142
- />
143
-
144
- < Text m = { 0 } color = "text200" >
145
- < Translation id = "last-edit" /> :{ " " }
146
- { lastContributor . user ?. url && (
147
- < InlineLink href = { lastContributor . user . url } >
148
- @{ lastContributor . user . login }
149
- </ InlineLink >
150
- ) }
151
- { ! lastContributor . user && < span > { lastContributor . name } </ span > } ,{ " " }
152
- { getLocaleTimestamp ( locale as Lang , lastEdit ) }
153
- </ Text >
154
- </ >
155
- ) }
99
+ < Flex me = { 4 } alignItems = "center" flex = "1" hideBelow = "md" >
100
+ < Avatar
101
+ height = "40px"
102
+ width = "40px"
103
+ src = { lastContributor . avatar_url }
104
+ name = { lastContributor . login }
105
+ me = { 2 }
106
+ />
107
+
108
+ < Text m = { 0 } color = "text200" >
109
+ < Translation id = "last-edit" /> :{ " " }
110
+ < InlineLink href = { "https://github.com/" + lastContributor . login } >
111
+ @{ lastContributor . login }
112
+ </ InlineLink >
113
+ , { getLocaleTimestamp ( locale as Lang , lastEdit ) }
114
+ </ Text >
156
115
</ Flex >
157
116
158
117
< VStack align = "stretch" justifyContent = "space-between" spacing = { 2 } >
0 commit comments