1
1
import React from 'react' ;
2
+ import { ExternalLinkIcon } from '../../icons' ;
2
3
import {
3
4
Card2 ,
4
5
CardActive ,
8
9
CardLink ,
9
10
CardParent ,
10
11
CardSubdata ,
11
- CardWrapper
12
+ CardWrapper ,
13
+ OwnLearningCard
12
14
} from './style' ;
13
15
14
16
interface Tutorial {
@@ -28,17 +30,32 @@ interface Props {
28
30
path ?: string ;
29
31
courseCount : number ;
30
32
courseType : string ;
33
+ cardKey ?: string ;
31
34
}
32
35
33
- const OptionalLink : React . FC < React . PropsWithChildren < { path ?: string } > > = ( { path, children } ) => {
36
+ const OptionalLink : React . FC < React . PropsWithChildren < { path ?: string ; isExternal ?: boolean } > > = ( {
37
+ path,
38
+ children,
39
+ isExternal
40
+ } ) => {
34
41
if ( ! path ) {
35
42
return < > { children } </ > ;
36
43
}
37
44
38
- return < CardLink href = { path } > { children } </ CardLink > ;
45
+ return (
46
+ < CardLink
47
+ href = { path }
48
+ target = { isExternal ? '_blank' : undefined }
49
+ rel = { isExternal ? 'noopener noreferrer' : undefined }
50
+ >
51
+ { children }
52
+ </ CardLink >
53
+ ) ;
39
54
} ;
40
55
41
- const LearningCard : React . FC < Props > = ( { tutorial, path, courseCount, courseType } ) => {
56
+ const LearningCard : React . FC < Props > = ( { tutorial, path, courseCount, courseType, cardKey } ) => {
57
+ const isCreateLearningPath = cardKey === 'create-learning-path' ;
58
+
42
59
return (
43
60
< CardWrapper >
44
61
{ tutorial . frontmatter . disabled === 'yes' ? (
@@ -65,37 +82,69 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
65
82
</ CardParent >
66
83
</ Card2 >
67
84
) : (
68
- < OptionalLink path = { path } >
69
- < CardActive >
70
- < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
71
- < div >
72
- < CardHead >
73
- < h3 >
74
- { tutorial . frontmatter . title
75
- ? tutorial . frontmatter . title
76
- : tutorial . frontmatter . courseTitle }
77
- </ h3 >
78
- { tutorial . frontmatter . status ? (
79
- < p >
80
- < span > New</ span >
81
- </ p >
82
- ) : null }
83
- </ CardHead >
84
- < CardDesc >
85
- < p className = "summary" > { tutorial . frontmatter . description } </ p >
86
- </ CardDesc >
87
- < CardSubdata className = "card-subdata" >
88
- < p >
89
- { courseCount } { courseType }
90
- { courseCount > 1 ? 's' : '' }
91
- </ p >
92
- </ CardSubdata >
93
- < CardImage >
94
- < img src = { tutorial . frontmatter . cardImage } />
95
- </ CardImage >
96
- </ div >
97
- </ CardParent >
98
- </ CardActive >
85
+ < OptionalLink path = { path } isExternal = { isCreateLearningPath } >
86
+ { isCreateLearningPath ? (
87
+ < OwnLearningCard >
88
+ < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
89
+ < div >
90
+ < CardHead >
91
+ < h3 >
92
+ { tutorial . frontmatter . title
93
+ ? tutorial . frontmatter . title
94
+ : tutorial . frontmatter . courseTitle }
95
+ </ h3 >
96
+ { isCreateLearningPath && path && (
97
+ < ExternalLinkIcon width = "24px" height = "24px" />
98
+ ) }
99
+ { tutorial . frontmatter . status ? (
100
+ < p >
101
+ < span > New</ span >
102
+ </ p >
103
+ ) : null }
104
+ </ CardHead >
105
+ < CardDesc >
106
+ < p className = "summary" > { tutorial . frontmatter . description } </ p >
107
+ </ CardDesc >
108
+ < CardImage >
109
+ < img src = { tutorial . frontmatter . cardImage } />
110
+ </ CardImage >
111
+ </ div >
112
+ </ CardParent >
113
+ </ OwnLearningCard >
114
+ ) : (
115
+ < CardActive >
116
+ < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
117
+ < div >
118
+ < CardHead >
119
+ < h3 >
120
+ { tutorial . frontmatter . title
121
+ ? tutorial . frontmatter . title
122
+ : tutorial . frontmatter . courseTitle }
123
+ </ h3 >
124
+ { tutorial . frontmatter . status ? (
125
+ < p >
126
+ < span > New</ span >
127
+ </ p >
128
+ ) : null }
129
+ </ CardHead >
130
+ < CardDesc >
131
+ < p className = "summary" > { tutorial . frontmatter . description } </ p >
132
+ </ CardDesc >
133
+ { ! isCreateLearningPath && (
134
+ < CardSubdata className = "card-subdata" >
135
+ < p >
136
+ { courseCount } { courseType }
137
+ { courseCount > 1 ? 's' : '' }
138
+ </ p >
139
+ </ CardSubdata >
140
+ ) }
141
+ < CardImage >
142
+ < img src = { tutorial . frontmatter . cardImage } />
143
+ </ CardImage >
144
+ </ div >
145
+ </ CardParent >
146
+ </ CardActive >
147
+ ) }
99
148
</ OptionalLink >
100
149
) }
101
150
</ CardWrapper >
0 commit comments