-
Notifications
You must be signed in to change notification settings - Fork 646
Dropdown #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown #57
Changes from all commits
4246955
8e9a197
31c7601
49fa5fb
1531c5c
0aa8ab7
0ec80eb
c9e401c
58cddff
f821318
df6b0f7
c7c1d16
7bce127
038e491
7f0ce42
deaa7b5
19c877f
9314948
6ed7a1a
b090fdd
c0349b8
a835b3b
330e1d0
6c15a2b
d571e6e
903675f
ee38f4b
5382a37
3d4b87b
110ec87
ee5c3d9
d0abe8b
fe8b23f
8ffe5bc
acc07eb
c031939
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,47 @@ | ||
| import React from 'react' | ||
| import classnames from 'classnames' | ||
| import PropTypes from 'prop-types' | ||
|
|
||
| const Button = ({ | ||
| block, | ||
| function Button({ | ||
| tag: Tag = 'button', | ||
| children, | ||
| disabled, | ||
| size, | ||
| block, | ||
| linkStyle, | ||
| onClick, | ||
| grouped, | ||
| scheme, | ||
| size | ||
| }) => ( | ||
| <button | ||
| disabled={disabled} | ||
| onClick={disabled ? undefined : onClick} | ||
| type="button" | ||
| className={classnames( | ||
| linkStyle ? 'btn-link' : 'btn', | ||
| scheme ? `btn-${scheme}` : null, | ||
| { | ||
| 'btn-sm': size === 'small', | ||
| 'btn-large': size === 'large', | ||
| 'btn-block': block, | ||
| } | ||
| )} | ||
| > | ||
| onClick, | ||
| disabled, | ||
| ...props | ||
| }) { | ||
| const classes = classnames( | ||
| { | ||
| 'btn': !linkStyle, | ||
| 'btn-link': linkStyle, | ||
| 'btn-sm': size === 'sm', | ||
| 'btn-large': size === 'large', | ||
| 'btn-block': block, | ||
| 'BtnGroup-item': grouped, | ||
| }, | ||
| scheme ? `btn-${scheme}` : null | ||
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. semicolon!! 😱
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have we decided not to use semicolons as a team?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's pretty much the house style at GitHub; see the prettier config in
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh dang! I'd love to work on that a bit more to see if we can get linting set up sometime this week! :D I'll take a look! |
||
|
|
||
| return ( | ||
| <Tag {...props} type="button" disabled={disabled} onClick={disabled ? undefined : onClick} className={classes}> | ||
| {children} | ||
| </button> | ||
| ) | ||
| </Tag> | ||
| ) | ||
| } | ||
|
|
||
| Button.propTypes = { | ||
| block: PropTypes.bool, | ||
| grouped: PropTypes.bool, | ||
| scheme: PropTypes.string, | ||
| size: PropTypes.oneOf(['sm', 'large']), | ||
| tag: PropTypes.oneOf(['button', 'a', 'summary']), | ||
| linkStyle: PropTypes.bool, | ||
| disabled: PropTypes.bool, | ||
| onClick: PropTypes.func | ||
| } | ||
|
|
||
| export default Button | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,6 @@ | ||
| import React from 'react' | ||
| import classnames from 'classnames' | ||
| import Button from './Button' | ||
|
|
||
| const ButtonPrimary = ({ size, disabled, block, linkStyle, onClick, children }) => ( | ||
| <button | ||
| disabled={disabled} | ||
| onClick={onClick} | ||
| type="button" | ||
| className={classnames( | ||
| 'btn-primary', | ||
| { | ||
| 'btn': !linkStyle, | ||
| 'btn-link': linkStyle, | ||
| 'btn-sm': size === 'small', | ||
| 'btn-large': size === 'large', | ||
| 'btn-block': block, | ||
| } | ||
| )} | ||
| > | ||
| {children} | ||
| </button> | ||
| ) | ||
| const ButtonPrimary = props => <Button {...props} scheme='primary' /> | ||
|
|
||
| export default ButtonPrimary |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shawnbot I ended up using classnames here instead of the classifier method because I was having trouble getting it to work while also transforming the Tag prop 🤔 I went back and forth a bunch, but I also feel like this method is a bit more straightforward to read so going to go forward with it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries! Let's nix the
import map, { classifier } from './props'above then.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schwoops! i'll nix that