Skip to content

feat(SwitchButton): refactor component #5222

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

Open
wants to merge 3 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/wet-queens-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@ultraviolet/ui": minor
"@ultraviolet/form": minor
---
**Breaking changes**
`SwitchButton`: New version of the component:
- props `leftButton` and `rightButton` removed
- Use `SwitchButton.Option` to add buttons/options
- More than 2 options possible now !
- New sizes
- New prop `sentiment`
19 changes: 6 additions & 13 deletions examples/next/src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,13 @@ const Home = () => {
return (
<StyledPage>
<StyledSwitchButton
name="switch button"
leftButton={{
label: 'Log In',
value: 'login',
}}
rightButton={{
label: 'Sign Up',
value: 'signup',
}}
value="login"
onChange={event =>
setTab((event.currentTarget as HTMLInputElement).value)
}
/>
name="switch button"
onChange={event => setTab((event.target as HTMLInputElement).value)}
>
<SwitchButton.Option value="login">Log In</SwitchButton.Option>
<SwitchButton.Option value="signup">Sign Up</SwitchButton.Option>
</StyledSwitchButton>
<Content tab={tab} />
</StyledPage>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ import { Template } from './Template.stories'
export const Playground = Template.bind({})

Playground.args = {
leftButton: {
label: 'Left Button Label',
value: 'left',
},
rightButton: {
label: 'Right Button Label',
value: 'right',
},
value: 'right',
name: 'switchButton',
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ import { SwitchButtonField } from '..'

export const Template: StoryFn<
ComponentProps<typeof SwitchButtonField>
> = args => <SwitchButtonField {...args} />
> = args => (
<SwitchButtonField {...args}>
<SwitchButtonField.Option value="left">Left</SwitchButtonField.Option>
<SwitchButtonField.Option value="center">Center</SwitchButtonField.Option>
<SwitchButtonField.Option value="right">Right</SwitchButtonField.Option>
</SwitchButtonField>
)
Loading