-
Notifications
You must be signed in to change notification settings - Fork 507
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
Button and ButtonLink β¨ #30
Changes from 6 commits
9060132
29b4025
745797b
7aa1eef
78d460c
a3d877c
49e8935
00f8b05
fab588c
3ba597e
e4c4127
a48afe0
4255ad4
28f21ef
83fad62
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.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
import React from 'react' | ||
import classnames from 'classnames' | ||
|
||
const Button = props => ( | ||
const Button = ({ size, type, disabled, block, linkStyle, onClick, children }) => ( | ||
<button | ||
{...props} | ||
disabled={disabled} | ||
onClick={onClick} | ||
type="button" | ||
className={classnames( | ||
props.className, | ||
'btn', { | ||
'btn-sm': props.small, | ||
'btn-large': props.large, | ||
{ | ||
'btn': !linkStyle, | ||
'btn-link': linkStyle, | ||
'btn-sm': size === 'small', | ||
'btn-large': size === 'large', | ||
'btn-primary': type === 'primary', | ||
'btn-danger': type === 'danger', | ||
'btn-outline': type === 'outline', | ||
'btn-block': block, | ||
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. I know a lot of people like do this with buttons because it feels good to dry up the code, but I think it actually makes a simpler api to keep buttons separate around their theme. It does mean there are more components to know about, but it means there are fewer props to use with a single button component. Instead of It also means we can be very intentional with which props we make available to which button themes. Later (which we will!) when we want to add new button variations or props (especially for marketing), we can be more deliberate and choose what props are available for each button. For example, we might never want to use an Octicon in a I think there are definitely cases where we want color themes to be props such as for States, but buttons are pretty complex and we're likely to add onto this component. |
||
} | ||
)} | ||
/> | ||
> | ||
{children} | ||
</button> | ||
) | ||
|
||
export default Button |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import classnames from 'classnames' | ||
|
||
const ButtonLink = ({ size, type, block, href, children }) => ( | ||
<button | ||
href={href} | ||
role="button" | ||
className={classnames( | ||
'btn', | ||
{ | ||
'btn-sm': size === 'small', | ||
'btn-large': size === 'large', | ||
'btn-primary': type === 'primary', | ||
'btn-danger': type === 'danger', | ||
'btn-outline': type === 'outline', | ||
'btn-block': block, | ||
} | ||
)} | ||
> | ||
{children} | ||
</button> | ||
) | ||
|
||
export default ButtonLink |
This file was deleted.
This file was deleted.
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.
Lol so I totally copy-pasted this from another project and did not mean to include. Do y'all want to us to list contributors here? If we do, does that mean we update when anyone else contributes too? I'm worried that could get hairy.
If you keep it please can you update my email to my github email please π¬
broccolini@github.com
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.
I'm π on it, personally I don't want my email in there. Feels like I might get spammed