-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
UI: Improved Button and IconButton #24266
Merged
Merged
Changes from 42 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
e760142
Add the new IconButton
cdedreuille 1f2fe6b
Replace IconButton
cdedreuille e3c3e59
Merge branch 'v8' into icon-button
cdedreuille 8b6b89b
Merge branch 'v8' into icon-button
cdedreuille 9e5ee81
Make IconButton works with text for backward compatibility
cdedreuille f6f7e26
Remove the old IconButton
cdedreuille 930d1e2
Update separator
cdedreuille 9b12740
Merge branch 'release-8-0' into icon-button
cdedreuille 926da91
Fix icons in panel not showing correctly
cdedreuille c207df0
Merge branch 'release-8-0' into icon-button
cdedreuille 4cd425c
Update all props on IconButton
cdedreuille 2c49acc
Merge branch 'release-8-0' into icon-button
cdedreuille c9a9f06
Fix missing IconButton
cdedreuille 4b1e76e
Make icon prop optional
cdedreuille ae268a5
Update IconButton.tsx
cdedreuille 4ac1af7
Revert "Fix missing IconButton"
cdedreuille 26383b5
Revert
cdedreuille 893d7e7
Fix some issues
cdedreuille 84480a3
Update IconButton.stories.tsx
cdedreuille e7a67d1
Improved structure
cdedreuille 8ca9be8
Merge branch 'release-8-0' into icon-button
cdedreuille 493cb3e
Improve Button
cdedreuille c67cfd4
Replace IconButton with new Button component
cdedreuille 21796c2
Update eject.tsx
cdedreuille 698727a
Cleanup
cdedreuille 95808a3
Update Button.tsx
cdedreuille e8b7934
Fix issues
cdedreuille fd77578
Fix animation on svg
cdedreuille 2c820ac
Fix name
cdedreuille cf89b4f
Fixed. I used Stack and Row
cdedreuille 3f8ec42
Removed string
cdedreuille 1dd8cc2
Update Button.tsx
cdedreuille b24e5c4
Update Button.tsx
cdedreuille 213faad
use 'a' if we are using isLink
cdedreuille dd8d9e2
Fixes
cdedreuille 1da9c7c
Merge branch 'release-8-0' into icon-button
cdedreuille 76c5601
Add migration + deprecated warnings
cdedreuille 83147eb
Add isLink story
cdedreuille 18e6465
Improve deprecated warning
cdedreuille 2003a4b
Improve Button docs
cdedreuille 602ecd7
Improve docs
cdedreuille fe09c25
Merge branch 'release-8-0' into icon-button
cdedreuille 3de2756
Improved migration notes
cdedreuille acbbd3b
Fixed spelling mistake
cdedreuille 64ba705
Update Button.tsx
cdedreuille aecc130
Cleaning
cdedreuille 0d56d6e
Merge branch 'release-8-0' into icon-button
cdedreuille b30db0e
Fix button shrinking
cdedreuille 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 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 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 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
90 changes: 90 additions & 0 deletions
90
code/ui/components/src/components/Button/Button.deprecated.stories.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import React from 'react'; | ||
import { Button } from './Button'; | ||
import { Icons } from '../icon/icon'; | ||
import { Form } from '../form'; | ||
|
||
const meta: Meta<typeof Button> = { | ||
title: 'Button/Deprecated', | ||
component: Button, | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Button>; | ||
|
||
export const Default = { args: { children: 'Default' } }; | ||
|
||
export const FormButton: Story = { | ||
render: (args) => <Form.Button {...args} />, | ||
args: { children: 'Form.Button' }, | ||
}; | ||
|
||
export const Primary: Story = { args: { primary: true, children: 'Primary' } }; | ||
export const Secondary: Story = { args: { secondary: true, children: 'Secondary' } }; | ||
export const Tertiary: Story = { args: { tertiary: true, children: 'Tertiary' } }; | ||
export const Gray: Story = { args: { gray: true, children: 'Gray' } }; | ||
|
||
export const Outline: Story = { args: { outline: true, children: 'Outline' } }; | ||
export const OutlinePrimary: Story = { | ||
args: { outline: true, primary: true, children: 'Outline Primary' }, | ||
}; | ||
export const OutlineSecondary: Story = { | ||
args: { outline: true, secondary: true, children: 'Outline Secondary' }, | ||
}; | ||
export const OutlineTertiary: Story = { | ||
args: { outline: true, tertiary: true, children: 'Outline Tertiary' }, | ||
}; | ||
|
||
export const Disabled: Story = { args: { disabled: true, children: 'Disabled' } }; | ||
export const DisabledPrimary: Story = { | ||
args: { disabled: true, primary: true, children: 'Disabled Priary' }, | ||
}; | ||
export const DisabledSecondary: Story = { | ||
args: { disabled: true, secondary: true, children: 'Disabled Secondary' }, | ||
}; | ||
export const DisabledTertiary: Story = { | ||
args: { disabled: true, tertiary: true, children: 'Disabled Tertiary' }, | ||
}; | ||
export const DisabledGray: Story = { | ||
args: { disabled: true, gray: true, children: 'Disabled Gray' }, | ||
}; | ||
|
||
export const Small: Story = { args: { small: true, children: 'Small' } }; | ||
export const SmallPrimary: Story = { | ||
args: { small: true, primary: true, children: 'Small Priary' }, | ||
}; | ||
export const SmallSecondary: Story = { | ||
args: { small: true, secondary: true, children: 'Small Secondary' }, | ||
}; | ||
export const SmallTertiary: Story = { | ||
args: { small: true, tertiary: true, children: 'Small Tertiary' }, | ||
}; | ||
export const SmallGray: Story = { | ||
args: { small: true, gray: true, children: 'Small Gray' }, | ||
}; | ||
|
||
export const IsLink: Story = { | ||
args: { isLink: true, children: 'Button as a link' }, | ||
}; | ||
|
||
export const IconPrimary: Story = { | ||
args: { | ||
primary: true, | ||
containsIcon: true, | ||
title: 'link', | ||
children: <Icons icon="link" />, | ||
}, | ||
}; | ||
export const IconOutline: Story = { | ||
args: { outline: true, containsIcon: true, title: 'link', children: <Icons icon="link" /> }, | ||
}; | ||
export const IconOutlineSmall: Story = { | ||
args: { | ||
outline: true, | ||
containsIcon: true, | ||
small: true, | ||
title: 'link', | ||
children: <Icons icon="link" />, | ||
}, | ||
}; |
219 changes: 161 additions & 58 deletions
219
code/ui/components/src/components/Button/Button.stories.tsx
This file contains 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 |
---|---|---|
@@ -1,82 +1,185 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import type { ReactNode } from 'react'; | ||
import React from 'react'; | ||
import type { Args } from '@storybook/types'; | ||
|
||
import { Button } from './Button'; | ||
import { Icons } from '../icon/icon'; | ||
import { Form } from '../form/index'; | ||
|
||
export default { | ||
const meta = { | ||
title: 'Button', | ||
component: Button, | ||
}; | ||
args: { children: 'Button' }, | ||
} satisfies Meta<typeof Button>; | ||
|
||
export const Default = { args: { children: 'Default' } }; | ||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const FormButton = { | ||
render: (args: Args) => <Form.Button {...args} />, | ||
args: { children: 'Form.Button' }, | ||
}; | ||
const Stack = ({ children }: { children: ReactNode }) => ( | ||
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>{children}</div> | ||
); | ||
|
||
export const Primary = { args: { primary: true, children: 'Primary' } }; | ||
export const Secondary = { args: { secondary: true, children: 'Secondary' } }; | ||
export const Tertiary = { args: { tertiary: true, children: 'Tertiary' } }; | ||
export const Gray = { args: { gray: true, children: 'Gray' } }; | ||
const Row = ({ children }: { children: ReactNode }) => ( | ||
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>{children}</div> | ||
); | ||
|
||
export const Outline = { args: { outline: true, children: 'Outline' } }; | ||
export const OutlinePrimary = { | ||
args: { outline: true, primary: true, children: 'Outline Primary' }, | ||
}; | ||
export const OutlineSecondary = { | ||
args: { outline: true, secondary: true, children: 'Outline Secondary' }, | ||
}; | ||
export const OutlineTertiary = { | ||
args: { outline: true, tertiary: true, children: 'Outline Tertiary' }, | ||
}; | ||
export const Base: Story = {}; | ||
|
||
export const Disabled = { args: { disabled: true, children: 'Disabled' } }; | ||
export const DisabledPrimary = { | ||
args: { disabled: true, primary: true, children: 'Disabled Priary' }, | ||
}; | ||
export const DisabledSecondary = { | ||
args: { disabled: true, secondary: true, children: 'Disabled Secondary' }, | ||
}; | ||
export const DisabledTertiary = { | ||
args: { disabled: true, tertiary: true, children: 'Disabled Tertiary' }, | ||
}; | ||
export const DisabledGray = { | ||
args: { disabled: true, gray: true, children: 'Disabled Gray' }, | ||
export const Variants: Story = { | ||
cdedreuille marked this conversation as resolved.
Show resolved
Hide resolved
|
||
render: (args) => ( | ||
<Stack> | ||
<Row> | ||
<Button variant="solid" {...args}> | ||
Solid | ||
</Button> | ||
<Button variant="outline" {...args}> | ||
Outline | ||
</Button> | ||
<Button variant="ghost" {...args}> | ||
Ghost | ||
</Button> | ||
</Row> | ||
<Row> | ||
<Button variant="solid" {...args}> | ||
<Icons icon="facehappy" /> Solid | ||
</Button> | ||
<Button variant="outline" {...args}> | ||
<Icons icon="facehappy" /> Outline | ||
</Button> | ||
<Button variant="ghost" {...args}> | ||
<Icons icon="facehappy" /> Ghost | ||
</Button> | ||
</Row> | ||
<Row> | ||
<Button variant="solid" padding="small" {...args}> | ||
<Icons icon="facehappy" /> | ||
</Button> | ||
<Button variant="outline" padding="small" {...args}> | ||
<Icons icon="facehappy" /> | ||
</Button> | ||
<Button variant="ghost" padding="small" {...args}> | ||
<Icons icon="facehappy" /> | ||
</Button> | ||
</Row> | ||
</Stack> | ||
), | ||
}; | ||
|
||
export const Small = { args: { small: true, children: 'Small' } }; | ||
export const SmallPrimary = { | ||
args: { small: true, primary: true, children: 'Small Priary' }, | ||
export const Active: Story = { | ||
args: { | ||
active: true, | ||
children: ( | ||
<> | ||
<Icons icon="facehappy" /> | ||
Button | ||
</> | ||
), | ||
}, | ||
render: (args) => ( | ||
<Row> | ||
<Button variant="solid" {...args} /> | ||
<Button variant="outline" {...args} /> | ||
<Button variant="ghost" {...args} /> | ||
</Row> | ||
), | ||
}; | ||
export const SmallSecondary = { | ||
args: { small: true, secondary: true, children: 'Small Secondary' }, | ||
|
||
export const WithIcon: Story = { | ||
args: { | ||
children: ( | ||
<> | ||
<Icons icon="facehappy" /> | ||
Button | ||
</> | ||
), | ||
}, | ||
render: (args) => ( | ||
<Row> | ||
<Button variant="solid" {...args} /> | ||
<Button variant="outline" {...args} /> | ||
<Button variant="ghost" {...args} /> | ||
</Row> | ||
), | ||
}; | ||
export const SmallTertiary = { | ||
args: { small: true, tertiary: true, children: 'Small Tertiary' }, | ||
|
||
export const IconOnly: Story = { | ||
args: { | ||
children: <Icons icon="facehappy" />, | ||
padding: 'small', | ||
}, | ||
render: (args) => ( | ||
<Row> | ||
<Button variant="solid" {...args} /> | ||
<Button variant="outline" {...args} /> | ||
<Button variant="ghost" {...args} /> | ||
</Row> | ||
), | ||
}; | ||
export const SmallGray = { | ||
args: { small: true, gray: true, children: 'Small Gray' }, | ||
|
||
export const Sizes: Story = { | ||
render: () => ( | ||
<Row> | ||
<Button size="small">Small Button</Button> | ||
<Button size="medium">Medium Button</Button> | ||
</Row> | ||
), | ||
}; | ||
|
||
export const IconPrimary = { | ||
export const Disabled: Story = { | ||
args: { | ||
primary: true, | ||
containsIcon: true, | ||
title: 'link', | ||
children: <Icons icon="link" />, | ||
disabled: true, | ||
children: 'Disabled Button', | ||
}, | ||
}; | ||
export const IconOutline = { | ||
args: { outline: true, containsIcon: true, title: 'link', children: <Icons icon="link" /> }, | ||
|
||
export const WithHref: Story = { | ||
render: () => ( | ||
<Row> | ||
<Button onClick={() => console.log('Hello')}>I am a button using onClick</Button> | ||
<Button asChild> | ||
<a href="https://storybook.js.org/">I am an anchor using Href</a> | ||
</Button> | ||
</Row> | ||
), | ||
}; | ||
export const IconOutlineSmall = { | ||
|
||
export const Animated: Story = { | ||
args: { | ||
outline: true, | ||
containsIcon: true, | ||
small: true, | ||
title: 'link', | ||
children: <Icons icon="link" />, | ||
variant: 'outline', | ||
}, | ||
render: (args) => ( | ||
<Stack> | ||
<Row> | ||
<Button animation="glow" {...args}> | ||
Button | ||
</Button> | ||
<Button animation="jiggle" {...args}> | ||
Button | ||
</Button> | ||
<Button animation="rotate360" {...args}> | ||
Button | ||
</Button> | ||
</Row> | ||
<Row> | ||
<Button animation="glow" {...args}> | ||
<Icons icon="facehappy" /> Button | ||
</Button> | ||
<Button animation="jiggle" {...args}> | ||
<Icons icon="facehappy" /> Button | ||
</Button> | ||
<Button animation="rotate360" {...args}> | ||
<Icons icon="facehappy" /> Button | ||
</Button> | ||
</Row> | ||
<Row> | ||
<Button animation="glow" padding="small" {...args}> | ||
<Icons icon="facehappy" /> | ||
</Button> | ||
<Button animation="jiggle" padding="small" {...args}> | ||
<Icons icon="facehappy" /> | ||
</Button> | ||
<Button animation="rotate360" padding="small" {...args}> | ||
<Icons icon="facehappy" /> | ||
</Button> | ||
</Row> | ||
</Stack> | ||
), | ||
}; |
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.
We need to:
We don't need to specify stuff that we "might remove" in the future, it doesn't help the user and just creates uncertainty.
In reality this is mostly an accessible version of what's written in the source code and the types, but we can't expect users to read those at all. Consider that users will see the warning in the console with a link to this section, they'll need a way forward here to resolve the warning.
Here's a proposal:
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 just pushed an update with some new notes and clear descriptions of what props are deprecated and what is the alternative.