Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
better prop names (#1637)
Browse files Browse the repository at this point in the history
1. kind > $type
2. size > $size
  • Loading branch information
W3stside committed Nov 20, 2020
1 parent 7b5dd8c commit e23e076
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions src/components/common/Button/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default {
decorators: [ThemeToggler],
argTypes: {
label: { control: 'text' },
kind: { control: 'radio' },
size: { control: 'inline-radio' },
$type: { control: 'radio' },
$size: { control: 'inline-radio' },
as: { control: null },
theme: { control: null },
forwardedAs: { control: null },
Expand All @@ -27,56 +27,56 @@ const Template: Story<ButtonBaseProps & { label?: string | React.ReactNode }> =
export const PrimaryButton = Template.bind({})
PrimaryButton.args = {
label: 'Main Button',
kind: 'default',
$type: 'default',
}

export const SecondaryButton = Template.bind({})
SecondaryButton.args = {
label: 'Secondary Button',
kind: 'secondary',
$type: 'secondary',
}

export const SuccessButton = Template.bind({})
SuccessButton.args = {
label: 'Success Button',
kind: 'success',
$type: 'success',
}

export const WarningButton = Template.bind({})
WarningButton.args = {
label: 'Warning Button',
kind: 'warning',
$type: 'warning',
}

export const DangerButton = Template.bind({})
DangerButton.args = {
label: 'Danger Button',
kind: 'danger',
$type: 'danger',
}

export const CancelButton = Template.bind({})
CancelButton.args = {
label: 'Cancel Button',
kind: 'cancel',
$type: 'cancel',
}

export const DisabledButton = Template.bind({})
DisabledButton.args = {
label: 'Disabled Button',
kind: 'disabled',
$type: 'disabled',
disabled: true,
}

export const BigButton = Template.bind({})
BigButton.args = {
label: 'Big Button',
kind: 'primary',
size: 'big',
$type: 'primary',
$size: 'big',
}

export const SmolButton = Template.bind({})
SmolButton.args = {
label: 'Smol Button',
kind: 'primary',
size: 'small',
$type: 'primary',
$size: 'small',
}
8 changes: 4 additions & 4 deletions src/components/common/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import StyledButton, { ButtonVariations, ButtonSizeVariations } from 'styles/com
import styles from 'styles/styles'

export interface ButtonBaseProps extends React.ButtonHTMLAttributes<Element> {
kind?: ButtonVariations
size?: ButtonSizeVariations
$type?: ButtonVariations
$size?: ButtonSizeVariations
}

export const ButtonBase = styled(StyledButton)<ButtonBaseProps>`
Expand Down Expand Up @@ -40,11 +40,11 @@ const ThemeButtonToggleWrapper = styled.div<{ $mode: boolean }>`

export const ThemeButton: React.FC<
ButtonBaseProps & {
mode: boolean
$mode: boolean
}
> = (props) => {
return (
<ThemeButtonToggleWrapper $mode={props.mode}>
<ThemeButtonToggleWrapper $mode={props.$mode}>
<ButtonBase {...props} />
</ThemeButtonToggleWrapper>
)
Expand Down
2 changes: 1 addition & 1 deletion src/storybook/decorators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const ThemeToggler = (DecoratedStory: () => JSX.Element): JSX.Element =>
<ThemeProvider theme={theme}>
<Frame style={{ background: darkMode ? COLOURS.bgDark : COLOURS.bgLight }}>{DecoratedStory()}</Frame>
{/* Cheeky use of ButtonBase here :P */}
<ThemeButton size="small" kind="theme" onClick={handleDarkMode} mode={darkMode}>
<ThemeButton $size="small" $type="theme" onClick={handleDarkMode} $mode={darkMode}>
<FontAwesomeIcon icon={darkMode ? faMoon : faSun} />
</ThemeButton>
<br />
Expand Down
4 changes: 2 additions & 2 deletions src/styles/common/StyledButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export type ButtonSizeVariations = 'default' | 'small' | 'big'
// Create our variated Button Theme
// 'kind' refers to a prop on button
// <ButtonBase kind="danger" />
export const ButtonTheme = variants<'kind', ButtonVariations>('mode', 'kind', {
export const ButtonTheme = variants<'$type', ButtonVariations>('mode', '$type', {
default: {
light: css`
color: ${white};
Expand Down Expand Up @@ -204,7 +204,7 @@ export const ButtonTheme = variants<'kind', ButtonVariations>('mode', 'kind', {
})

// Created a 'size' prop on buttons, default | small | big
const ButtonSizes = variants('component', 'size', {
const ButtonSizes = variants('component', '$size', {
default: {
buttons: '',
},
Expand Down

0 comments on commit e23e076

Please sign in to comment.