-
Notifications
You must be signed in to change notification settings - Fork 1
More form fixes #83
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
Merged
Merged
More form fixes #83
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7bd43e3
export more styled components
TomWoodward a2e4cb1
version
TomWoodward 98324b2
export button style helpers
TomWoodward d008f63
:camera:
TomWoodward a1fa3e9
:shirt:
TomWoodward a1a7fb6
rems for button style
TomWoodward e31fb2f
:camera:
TomWoodward File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ import styled, {css} from "styled-components"; | |
import theme from '../../src/theme'; | ||
import { applyButtonVariantStyles, ButtonVariant } from "../theme/buttons"; | ||
|
||
const StyledButton = styled.button<{ variant: ButtonVariant }>` | ||
${props => applyButtonVariantStyles(props.variant)} | ||
export { applyButtonVariantStyles }; | ||
export const buttonCss = css<{variant?: ButtonVariant}>` | ||
${props => applyButtonVariantStyles(props.variant || 'primary')} | ||
|
||
font-size: 1.6rem; | ||
line-height: 2rem; | ||
|
@@ -23,13 +24,6 @@ const StyledButton = styled.button<{ variant: ButtonVariant }>` | |
user-select: none; | ||
white-space: nowrap; | ||
|
||
${props => props.variant === 'primary' ? ` | ||
&:focus { | ||
outline: solid ${theme.colors.palette.white}; | ||
box-shadow: inset 0 0 0 3px ${theme.colors.palette.black}; | ||
} | ||
`: ''} | ||
|
||
&:not([disabled]) { | ||
cursor: pointer; | ||
} | ||
|
@@ -59,27 +53,31 @@ interface WaitingButtonProps extends ButtonBase { | |
waitingText: string; | ||
} | ||
|
||
export const Button = (props: ButtonProps | WaitingButtonProps) => { | ||
export const Button = styled((props: ButtonProps | WaitingButtonProps) => { | ||
const { | ||
disabled, | ||
isWaiting, | ||
waitingText, | ||
children, | ||
variant = 'primary', | ||
variant, | ||
...otherProps | ||
} = props; | ||
|
||
return <StyledButton | ||
return <button | ||
{...otherProps} | ||
disabled={isWaiting || disabled} | ||
variant={variant} | ||
> | ||
{(isWaiting && waitingText) || children} | ||
</StyledButton>; | ||
} | ||
|
||
export const LinkButton = ({ variant = 'primary', ...props}: LinkButtonBase) => | ||
<StyledButton {...props} as='a' variant={variant}>{props.children}</StyledButton> | ||
</button>; | ||
})` | ||
${buttonCss} | ||
` | ||
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 don't think we have the linter set up for this, but missing trailing semicolon |
||
|
||
export const LinkButton = styled(({ variant, ...props}: LinkButtonBase) => | ||
<a {...props}>{props.children}</a> | ||
)` | ||
${buttonCss} | ||
`; | ||
|
||
export const linkStyle = css` | ||
color: ${theme.colors.link.color}; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Probably just me, but pushing it out makes it a bit longer to tell what the default is and do variant-y stuff inside the component in the future
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.
we're not able to set the default before its used in the styles, so having a default here seemed confusing (because it would only be defaulted within the component, not in the styles)