1
- import React , { useState } from 'react' ;
2
- import { Grid2 , Typography } from '../../base' ;
3
- import { ExternalLinkIcon } from '../../icons' ;
4
- import { Modal , ModalBody , ModalButtonPrimary , ModalButtonSecondary , ModalFooter } from '../Modal' ;
5
- import { CopyToClipboard } from '../ResourceDetailFormatters/Component' ;
1
+ import React from 'react' ;
2
+ import { Typography } from '../../base' ;
6
3
import {
7
4
Card2 ,
8
5
CardActive ,
@@ -12,8 +9,7 @@ import {
12
9
CardLink ,
13
10
CardParent ,
14
11
CardSubdata ,
15
- CardWrapper ,
16
- OwnLearningCard
12
+ CardWrapper
17
13
} from './style' ;
18
14
19
15
interface Tutorial {
@@ -35,43 +31,17 @@ interface Props {
35
31
path ?: string ;
36
32
courseCount : number ;
37
33
courseType : string ;
38
- orgId ?: string ;
39
- modalContent ?: string ;
40
34
}
41
35
42
- const OptionalLink : React . FC < React . PropsWithChildren < { path ?: string ; isExternal ?: boolean } > > = ( {
43
- path,
44
- children,
45
- isExternal
46
- } ) => {
36
+ const OptionalLink : React . FC < React . PropsWithChildren < { path ?: string } > > = ( { path, children } ) => {
47
37
if ( ! path ) {
48
38
return < > { children } </ > ;
49
39
}
50
40
51
- return (
52
- < CardLink
53
- href = { path }
54
- target = { isExternal ? '_blank' : undefined }
55
- rel = { isExternal ? 'noopener noreferrer' : undefined }
56
- >
57
- { children }
58
- </ CardLink >
59
- ) ;
41
+ return < CardLink href = { path } > { children } </ CardLink > ;
60
42
} ;
61
43
62
- const LearningCard : React . FC < Props > = ( {
63
- tutorial,
64
- path,
65
- courseCount,
66
- courseType,
67
- orgId,
68
- modalContent
69
- } ) => {
70
- const isCreateLearningPath = courseType === 'learning-card' ;
71
- const [ modalOpen , setModalOpen ] = useState ( false ) ;
72
-
73
- const handleModalOpen = ( ) => setModalOpen ( true ) ;
74
- const handleModalClose = ( ) => setModalOpen ( false ) ;
44
+ const LearningCard : React . FC < Props > = ( { tutorial, path, courseCount, courseType } ) => {
75
45
return (
76
46
< CardWrapper >
77
47
{ tutorial . frontmatter . disabled === 'yes' ? (
@@ -98,120 +68,50 @@ const LearningCard: React.FC<Props> = ({
98
68
</ CardParent >
99
69
</ Card2 >
100
70
) : (
101
- < >
102
- { isCreateLearningPath ? (
103
- < OwnLearningCard onClick = { handleModalOpen } style = { { cursor : 'pointer' } } >
104
- < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
105
- < div >
106
- < CardHead >
107
- < h3 >
108
- { tutorial . frontmatter . title
109
- ? tutorial . frontmatter . title
110
- : tutorial . frontmatter . courseTitle }
111
- </ h3 >
112
- { isCreateLearningPath && path && (
113
- < ExternalLinkIcon width = "24px" height = "24px" />
114
- ) }
115
- { tutorial . frontmatter . status ? (
116
- < p >
117
- < span > New</ span >
118
- </ p >
119
- ) : null }
120
- </ CardHead >
121
- < CardDesc >
122
- < p className = "summary" > { tutorial . frontmatter . description } </ p >
123
- </ CardDesc >
124
- < CardImage >
125
- < img src = { tutorial . frontmatter . cardImage } />
126
- </ CardImage >
127
- </ div >
128
- </ CardParent >
129
- </ OwnLearningCard >
130
- ) : (
131
- < OptionalLink path = { path } isExternal = { isCreateLearningPath } >
132
- < CardActive >
133
- < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
134
- < div >
135
- < CardHead style = { { flexDirection : 'column' } } >
136
- < Typography variant = "body1" color = "textSecondary" >
137
- { tutorial . frontmatter . type }
138
- </ Typography >
139
- < h3 style = { { margin : '0.2rem 0.1rem' } } >
140
- { tutorial . frontmatter . title
141
- ? tutorial . frontmatter . title
142
- : tutorial . frontmatter . courseTitle }
143
- </ h3 >
71
+ < OptionalLink path = { path } >
72
+ < CardActive >
73
+ < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
74
+ < div >
75
+ < CardHead style = { { flexDirection : 'column' } } >
76
+ < Typography variant = "body1" color = "textSecondary" >
77
+ { tutorial . frontmatter . type }
78
+ </ Typography >
79
+ < h3 style = { { margin : '0.2rem 0.1rem' } } >
80
+ { tutorial . frontmatter . title
81
+ ? tutorial . frontmatter . title
82
+ : tutorial . frontmatter . courseTitle }
83
+ </ h3 >
144
84
145
- { tutorial . frontmatter . status ? (
146
- < p >
147
- < span > New</ span >
148
- </ p >
149
- ) : null }
150
- </ CardHead >
151
- < CardDesc >
152
- < p className = "summary" > { tutorial . frontmatter . description } </ p >
153
- </ CardDesc >
154
- { ! isCreateLearningPath && (
155
- < CardSubdata className = "card-subdata" >
156
- < p >
157
- { courseCount } { courseType }
158
- { courseCount > 1 ? 's' : '' }
159
- </ p >
160
- < p >
161
- Level:{ ' ' }
162
- { tutorial ?. frontmatter ?. level
163
- ? tutorial . frontmatter . level . charAt ( 0 ) . toUpperCase ( ) +
164
- tutorial . frontmatter . level . slice ( 1 )
165
- : '' }
166
- </ p >
167
- </ CardSubdata >
168
- ) }
169
- < CardImage >
170
- < img src = { tutorial . frontmatter . cardImage } />
171
- </ CardImage >
172
- </ div >
173
- </ CardParent >
174
- </ CardActive >
175
- </ OptionalLink >
176
- ) }
177
- </ >
85
+ { tutorial . frontmatter . status ? (
86
+ < p >
87
+ < span > New</ span >
88
+ </ p >
89
+ ) : null }
90
+ </ CardHead >
91
+ < CardDesc >
92
+ < p className = "summary" > { tutorial . frontmatter . description } </ p >
93
+ </ CardDesc >
94
+ < CardSubdata className = "card-subdata" >
95
+ < p >
96
+ { courseCount } { courseType }
97
+ { courseCount > 1 ? 's' : '' }
98
+ </ p >
99
+ < p >
100
+ Level:{ ' ' }
101
+ { tutorial ?. frontmatter ?. level
102
+ ? tutorial . frontmatter . level . charAt ( 0 ) . toUpperCase ( ) +
103
+ tutorial . frontmatter . level . slice ( 1 )
104
+ : '' }
105
+ </ p >
106
+ </ CardSubdata >
107
+ < CardImage >
108
+ < img src = { tutorial . frontmatter . cardImage } />
109
+ </ CardImage >
110
+ </ div >
111
+ </ CardParent >
112
+ </ CardActive >
113
+ </ OptionalLink >
178
114
) }
179
-
180
- < Modal
181
- open = { modalOpen }
182
- closeModal = { handleModalClose }
183
- title = { tutorial . frontmatter . title || tutorial . frontmatter . courseTitle }
184
- maxWidth = "sm"
185
- >
186
- < ModalBody >
187
- < Typography variant = "body1" > { modalContent } </ Typography >
188
- { orgId && (
189
- < Grid2 container direction = "row" alignItems = "center" spacing = { 1 } >
190
- < Grid2 >
191
- < Typography variant = "body1" color = "textSecondary" >
192
- Your Organization ID: { orgId }
193
- </ Typography >
194
- </ Grid2 >
195
- < Grid2 >
196
- < CopyToClipboard data = { orgId } />
197
- </ Grid2 >
198
- </ Grid2 >
199
- ) }
200
- </ ModalBody >
201
- < ModalFooter variant = "filled" >
202
- < ModalButtonSecondary onClick = { handleModalClose } > Close</ ModalButtonSecondary >
203
- { path && (
204
- < ModalButtonPrimary
205
- onClick = { ( ) => {
206
- window . open ( path , '_blank' ) ;
207
- handleModalClose ( ) ;
208
- } }
209
- >
210
- Visit Docs
211
- </ ModalButtonPrimary >
212
- ) }
213
- </ ModalFooter >
214
- </ Modal >
215
115
</ CardWrapper >
216
116
) ;
217
117
} ;
0 commit comments