@@ -2,7 +2,6 @@ import React, {Component} from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import _ from 'lodash' ;
4
4
import Link from 'gatsby-link' ;
5
- import Layout from '../components/layout' ;
6
5
7
6
import './components.scss' ;
8
7
@@ -49,31 +48,55 @@ export default class ComponentTemplate extends Component {
49
48
return _ . map ( extendedComponents , ( component , index ) => {
50
49
const isLast = index === _ . size ( extendedComponents ) - 1 ;
51
50
const text = < b > { `${ component } ${ ! isLast ? ', ' : '' } ` } </ b > ;
52
- const extendedComponent = _ . find ( allComponents , c => c . node . displayName . trim ( ) === component . trim ( ) ) ;
53
- const path = ! extendedComponent && componentInfo . extendsLink ? componentInfo . extendsLink : `/docs/${ component } ` ;
51
+ const extendedComponent = _ . find (
52
+ allComponents ,
53
+ c => c . node . displayName . trim ( ) === component . trim ( )
54
+ ) ;
55
+ const path =
56
+ ! extendedComponent && componentInfo . extendsLink
57
+ ? componentInfo . extendsLink
58
+ : `/docs/${ component } ` ;
54
59
55
60
return (
56
61
< span className = "inline" key = { component } >
57
62
{ ! extendedComponent && componentInfo . extendsLink ? (
58
- < a href = { componentInfo . extendsLink } rel = "noopener noreferrer" target = "_blank" >
63
+ < a
64
+ href = { componentInfo . extendsLink }
65
+ rel = "noopener noreferrer"
66
+ target = "_blank"
67
+ >
59
68
{ text }
60
69
</ a >
61
70
) : (
62
71
< Link to = { path } > { text } </ Link >
63
72
) }
64
73
{ componentInfo . extendsnotes }
65
- < br />
74
+ < br />
66
75
</ span >
67
76
) ;
68
77
} ) ;
69
78
}
70
79
71
80
renderImage ( image , index ) {
72
- return < img key = { index } alt = { '' } src = { image } style = { { marginRight : 20 , width : 320 , border : '1px solid black' } } /> ;
81
+ return (
82
+ < img
83
+ key = { index }
84
+ alt = { '' }
85
+ src = { image }
86
+ style = { { marginRight : 20 , width : 320 , border : '1px solid black' } }
87
+ />
88
+ ) ;
73
89
}
74
90
75
91
renderGif ( image , index ) {
76
- return < img key = { index } alt = { '' } src = { image } style = { { marginRight : 20 , width : 320 } } /> ;
92
+ return (
93
+ < img
94
+ key = { index }
95
+ alt = { '' }
96
+ src = { image }
97
+ style = { { marginRight : 20 , width : 320 } }
98
+ />
99
+ ) ;
77
100
}
78
101
79
102
renderImages ( images , type ) {
@@ -88,9 +111,14 @@ export default class ComponentTemplate extends Component {
88
111
renderImportant ( componentInfo ) {
89
112
return (
90
113
< div alt = { '' } style = { { marginBottom : 10 } } >
91
- < span style = { { fontWeight : '700' } } > IMPORTANT: </ span > { componentInfo . important }
114
+ < span style = { { fontWeight : '700' } } > IMPORTANT: </ span > { ' ' }
115
+ { componentInfo . important }
92
116
{ componentInfo . importantLink && (
93
- < a target = "_blank" rel = "noopener noreferrer" href = { componentInfo . importantLink } >
117
+ < a
118
+ target = "_blank"
119
+ rel = "noopener noreferrer"
120
+ href = { componentInfo . importantLink }
121
+ >
94
122
here
95
123
</ a >
96
124
) }
@@ -114,10 +142,16 @@ export default class ComponentTemplate extends Component {
114
142
const { pageContext} = this . props ;
115
143
const selectedComponent = pageContext . componentNode ;
116
144
const componentInfo = this . extractComponentsInfo ( selectedComponent ) ;
117
- const componentProps = _ . orderBy ( _ . get ( selectedComponent , 'props' ) , prop => prop . name . toLowerCase ( ) ) ;
145
+ const componentProps = _ . orderBy ( _ . get ( selectedComponent , 'props' ) , prop =>
146
+ prop . name . toLowerCase ( )
147
+ ) ;
118
148
const gifs = componentInfo . gif ? componentInfo . gif . split ( ',' ) : undefined ;
119
- const imgs = componentInfo . image ? componentInfo . image . split ( ',' ) : undefined ;
120
- const notes = componentInfo . notes ? componentInfo . notes . split ( ';' ) : undefined ;
149
+ const imgs = componentInfo . image
150
+ ? componentInfo . image . split ( ',' )
151
+ : undefined ;
152
+ const notes = componentInfo . notes
153
+ ? componentInfo . notes . split ( ';' )
154
+ : undefined ;
121
155
122
156
return (
123
157
< div className = "docs-page" >
@@ -126,7 +160,12 @@ export default class ComponentTemplate extends Component {
126
160
{ componentInfo . example && (
127
161
< span className = "code-example" >
128
162
(
129
- < a className = "inline" target = "_blank" rel = "noopener noreferrer" href = { componentInfo . example } >
163
+ < a
164
+ className = "inline"
165
+ target = "_blank"
166
+ rel = "noopener noreferrer"
167
+ href = { componentInfo . example }
168
+ >
130
169
code example
131
170
</ a >
132
171
)
@@ -137,14 +176,17 @@ export default class ComponentTemplate extends Component {
137
176
{ componentInfo . extends && (
138
177
< div >
139
178
Extends: { this . renderLink ( componentInfo ) }
140
- < div > (meaning you can pass the super component's props as well).</ div >
179
+ < div >
180
+ (meaning you can pass the super component's props as well).
181
+ </ div >
141
182
</ div >
142
183
) }
143
184
{ componentInfo . modifiers && (
144
185
< div >
145
186
< p >
146
- Supported modifiers: < b > { componentInfo . modifiers } </ b > . < br />
147
- Read more about modifiers < Link to = "/foundation/modifiers" > here</ Link > .
187
+ Supported modifiers: < b > { componentInfo . modifiers } </ b > . < br />
188
+ Read more about modifiers{ ' ' }
189
+ < Link to = "/foundation/modifiers" > here</ Link > .
148
190
</ p >
149
191
</ div >
150
192
) }
@@ -155,19 +197,23 @@ export default class ComponentTemplate extends Component {
155
197
{ this . renderNotes ( notes ) }
156
198
</ div >
157
199
) }
158
- { componentInfo . important && < div > { this . renderImportant ( componentInfo ) } </ div > }
200
+ { componentInfo . important && (
201
+ < div > { this . renderImportant ( componentInfo ) } </ div >
202
+ ) }
159
203
{ componentProps . length > 0 && (
160
204
< div >
161
205
< h3 > PROPS</ h3 >
162
- < Props props = { componentProps } />
206
+ < Props props = { componentProps } />
163
207
</ div >
164
208
) }
165
209
166
210
{ imgs && (
167
211
< div className = "container" >
168
212
< h3 > EXAMPLE</ h3 >
169
213
< div className = "row" >
170
- < div className = "col-sm-12 text-center" > { this . renderImages ( imgs , IMAGE_TYPES . PNG ) } </ div >
214
+ < div className = "col-sm-12 text-center" >
215
+ { this . renderImages ( imgs , IMAGE_TYPES . PNG ) }
216
+ </ div >
171
217
</ div >
172
218
</ div >
173
219
) }
@@ -176,7 +222,9 @@ export default class ComponentTemplate extends Component {
176
222
< div className = "container" >
177
223
< h3 > LIVE EXAMPLE</ h3 >
178
224
< div className = "row" >
179
- < div className = "col-sm-12 text-center" > { this . renderImages ( gifs , IMAGE_TYPES . GIF ) } </ div >
225
+ < div className = "col-sm-12 text-center" >
226
+ { this . renderImages ( gifs , IMAGE_TYPES . GIF ) }
227
+ </ div >
180
228
</ div >
181
229
</ div >
182
230
) }
@@ -188,19 +236,17 @@ export default class ComponentTemplate extends Component {
188
236
render ( ) {
189
237
const isIntro = ! _ . get ( this . props , 'pageContext.componentNode' ) ;
190
238
return (
191
- < Layout { ...this . props } showSidebar >
192
- < div >
193
- { isIntro && (
194
- < div className = "docs-page" >
195
- < div className = "docs-page__content" >
196
- < div > Select a component from the left sidebar</ div >
197
- </ div >
239
+ < div >
240
+ { isIntro && (
241
+ < div className = "docs-page" >
242
+ < div className = "docs-page__content" >
243
+ < div > Select a component from the left sidebar</ div >
198
244
</ div >
199
- ) }
245
+ </ div >
246
+ ) }
200
247
201
- { ! isIntro && this . renderComponentPage ( ) }
202
- </ div >
203
- </ Layout >
248
+ { ! isIntro && this . renderComponentPage ( ) }
249
+ </ div >
204
250
) ;
205
251
}
206
252
}
0 commit comments