@@ -8,7 +8,7 @@ import { remSize, prop } from '../theme';
88const kinds = {
99 block : 'block' ,
1010 icon : 'icon' ,
11- inline : 'inline' ,
11+ inline : 'inline'
1212} ;
1313
1414// The '&&&' will increase the specificity of the
@@ -34,7 +34,7 @@ const StyledButton = styled.button`
3434 svg * {
3535 fill: ${ prop ( 'Button.default.foreground' ) } ;
3636 }
37-
37+
3838 &:hover:not(:disabled) {
3939 color: ${ prop ( 'Button.hover.foreground' ) } ;
4040 background-color: ${ prop ( 'Button.hover.background' ) } ;
@@ -115,7 +115,7 @@ const StyledIconButton = styled.button`
115115 border-radius: 50%;
116116 padding: ${ remSize ( 8 ) } ${ remSize ( 25 ) } ;
117117 line-height: 1;
118-
118+
119119 &:hover:not(:disabled) {
120120 color: ${ prop ( 'Button.hover.foreground' ) } ;
121121 background-color: ${ prop ( 'Button.hover.background' ) } ;
@@ -150,10 +150,24 @@ const StyledIconButton = styled.button`
150150 * A Button performs an primary action
151151 */
152152const Button = ( {
153- children, href, kind, iconBefore, iconAfter, 'aria-label' : ariaLabel , to, type, ...props
153+ children,
154+ href,
155+ kind,
156+ iconBefore,
157+ iconAfter,
158+ 'aria-label' : ariaLabel ,
159+ to,
160+ type,
161+ ...props
154162} ) => {
155163 const hasChildren = React . Children . count ( children ) > 0 ;
156- const content = < > { iconBefore } { hasChildren && < span > { children } </ span > } { iconAfter } </ > ;
164+ const content = (
165+ < >
166+ { iconBefore }
167+ { hasChildren && < span > { children } </ span > }
168+ { iconAfter }
169+ </ >
170+ ) ;
157171 let StyledComponent = StyledButton ;
158172
159173 if ( kind === kinds . inline ) {
@@ -177,22 +191,36 @@ const Button = ({
177191 }
178192
179193 if ( to ) {
180- return < StyledComponent kind = { kind } as = { Link } aria-label = { ariaLabel } to = { to } { ...props } > { content } </ StyledComponent > ;
194+ return (
195+ < StyledComponent
196+ kind = { kind }
197+ as = { Link }
198+ aria-label = { ariaLabel }
199+ to = { to }
200+ { ...props }
201+ >
202+ { content }
203+ </ StyledComponent >
204+ ) ;
181205 }
182206
183- return < StyledComponent kind = { kind } aria-label = { ariaLabel } type = { type } { ...props } > { content } </ StyledComponent > ;
207+ return (
208+ < StyledComponent kind = { kind } aria-label = { ariaLabel } type = { type } { ...props } >
209+ { content }
210+ </ StyledComponent >
211+ ) ;
184212} ;
185213
186214Button . defaultProps = {
187- ' children' : null ,
188- ' disabled' : false ,
189- ' iconAfter' : null ,
190- ' iconBefore' : null ,
191- ' kind' : kinds . block ,
192- ' href' : null ,
215+ children : null ,
216+ disabled : false ,
217+ iconAfter : null ,
218+ iconBefore : null ,
219+ kind : kinds . block ,
220+ href : null ,
193221 'aria-label' : null ,
194- 'to' : null ,
195- ' type' : 'button' ,
222+ to : null ,
223+ type : 'button'
196224} ;
197225
198226Button . kinds = kinds ;
@@ -202,39 +230,39 @@ Button.propTypes = {
202230 * The visible part of the button, telling the user what
203231 * the action is
204232 */
205- ' children' : PropTypes . element ,
233+ children : PropTypes . element ,
206234 /**
207235 If the button can be activated or not
208236 */
209- ' disabled' : PropTypes . bool ,
237+ disabled : PropTypes . bool ,
210238 /**
211239 * SVG icon to place after child content
212240 */
213- ' iconAfter' : PropTypes . element ,
241+ iconAfter : PropTypes . element ,
214242 /**
215243 * SVG icon to place before child content
216244 */
217- ' iconBefore' : PropTypes . element ,
245+ iconBefore : PropTypes . element ,
218246 /**
219247 * The kind of button - determines how it appears visually
220248 */
221- ' kind' : PropTypes . oneOf ( Object . values ( kinds ) ) ,
249+ kind : PropTypes . oneOf ( Object . values ( kinds ) ) ,
222250 /**
223251 * Specifying an href will use an <a> to link to the URL
224252 */
225- ' href' : PropTypes . string ,
253+ href : PropTypes . string ,
226254 /*
227255 * An ARIA Label used for accessibility
228256 */
229257 'aria-label' : PropTypes . string ,
230258 /**
231259 * Specifying a to URL will use a react-router Link
232260 */
233- 'to' : PropTypes . string ,
261+ to : PropTypes . string ,
234262 /**
235263 * If using a button, then type is defines the type of button
236264 */
237- ' type' : PropTypes . oneOf ( [ 'button' , 'submit' ] ) ,
265+ type : PropTypes . oneOf ( [ 'button' , 'submit' ] )
238266} ;
239267
240268export default Button ;
0 commit comments