-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add AlphaButton
component
#2182
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
99d5483
feat(alpha-button): add types
yangwooseong bfe1c7c
feat(alpha-button): define style by color, variant, size
yangwooseong e36c619
feat(alpha-button): add icon
yangwooseong 5d42643
feat(alpha-button): add color for icon and text
yangwooseong 8f9fbc6
feat(alpha-button): add spinner
yangwooseong 3bf4d31
feat(alpha-button): fix ButtonContent gap to ButtonText padding, add …
yangwooseong ca0eeff
feat(alpha-=button): add typography
yangwooseong 7f4ad74
feat(alpha-button): apply color to spinner as well
yangwooseong d387ea7
feat(alpha-button): apply active, hover style
yangwooseong 1bf926d
feat(alpha-button): export Button
yangwooseong cdb8bfd
feat(alpha-button): add simple storybook
yangwooseong 29280e0
chore(changeset): add
yangwooseong a7a63d8
refactor(alpha-button): move type props into rest
yangwooseong a2ddbcb
feat(button,alpha-button): change focus-visible style
yangwooseong 5d95d90
chore(changeset): add
yangwooseong 787c722
feat(alpha-button): rm floating from variant props, etc
yangwooseong 3c94977
feat(alpha-button): resolve typecheck, lint error and rename type
yangwooseong 43e6a3c
chore(alpha-button): add comment
yangwooseong 484529a
feat(alpha-button): add missed transition property
yangwooseong a918a38
fix(alpha-button): fix typo in transition property
yangwooseong 958f7c2
refactor(alpha-button): rm for loop, instead overide previously defin…
yangwooseong 316a018
refactor(alpha-button): cover `disabled` in rest props
yangwooseong f61f019
feat(alpha-button): fix bg color of secondary, rm redundant :not sele…
yangwooseong 96933f4
refactor(alpha-button): add &: to nested selector for consistence
yangwooseong f58e049
feat(alpha-button): make text props required
yangwooseong 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@channel.io/bezier-react": patch | ||
--- | ||
|
||
Change outline color of primary and blue `Button` component when focused. |
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,5 @@ | ||
--- | ||
"@channel.io/bezier-react": patch | ||
--- | ||
|
||
Add `AlphaButton` component. |
29 changes: 29 additions & 0 deletions
29
packages/bezier-react/src/components/AlphaButton/AlphaButton.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,29 @@ | ||
import { ArrowRightIcon, PlusIcon } from '@channel.io/bezier-icons' | ||
import { type Meta, type StoryObj } from '@storybook/react' | ||
|
||
import { | ||
AlphaButton, | ||
type AlphaButtonProps, | ||
} from '~/src/components/AlphaButton' | ||
|
||
const meta: Meta<typeof AlphaButton> = { | ||
component: AlphaButton, | ||
argTypes: { | ||
onClick: { action: 'onClick' }, | ||
}, | ||
} | ||
export default meta | ||
|
||
export const Playground: StoryObj<AlphaButtonProps> = { | ||
args: { | ||
text: 'Invite', | ||
disabled: false, | ||
active: false, | ||
loading: false, | ||
prefixIcon: PlusIcon, | ||
suffixIcon: ArrowRightIcon, | ||
size: 'm', | ||
variant: 'primary', | ||
color: 'blue', | ||
}, | ||
} |
267 changes: 267 additions & 0 deletions
267
packages/bezier-react/src/components/AlphaButton/Button.module.scss
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,267 @@ | ||
$chromatic-colors: 'blue', 'red', 'green', 'cobalt', 'orange', 'pink', 'purple'; | ||
|
||
.Button { | ||
position: relative; | ||
box-sizing: border-box; | ||
transition: background-color var(--transition-s); | ||
|
||
/* dimension */ | ||
&:where(.size-xs) { | ||
height: 20px; | ||
padding: 0 4px; | ||
|
||
& :where(.ButtonText) { | ||
padding: 0 3px; | ||
} | ||
} | ||
|
||
&:where(.size-s) { | ||
height: 24px; | ||
padding: 0 6px; | ||
|
||
& :where(.ButtonText) { | ||
padding: 0 3px; | ||
} | ||
|
||
& :where(.ButtonContent) { | ||
gap: 1px; | ||
} | ||
} | ||
|
||
&:where(.size-m) { | ||
height: 36px; | ||
padding: 0 10px; | ||
|
||
& :where(.ButtonText) { | ||
padding: 0 4px; | ||
} | ||
} | ||
|
||
&:where(.size-l) { | ||
height: 44px; | ||
padding: 0 14px; | ||
|
||
& :where(.ButtonText) { | ||
padding: 0 6px; | ||
} | ||
} | ||
|
||
&:where(.size-xl) { | ||
height: 54px; | ||
padding: 0 18px; | ||
|
||
& :where(.ButtonText) { | ||
padding: 0 6px; | ||
} | ||
} | ||
|
||
/* background-color */ | ||
&:where(.variant-primary) { | ||
$background-color-by-color: ( | ||
blue: var(--alpha-color-primary-bg-normal), | ||
cobalt: var(--alpha-color-accent-bg-normal), | ||
red: var(--alpha-color-critical-bg-normal), | ||
orange: var(--alpha-color-warning-bg-normal), | ||
green: var(--alpha-color-success-bg-normal), | ||
pink: var(--alpha-color-bg-pink-normal), | ||
purple: var(--alpha-color-bg-purple-normal), | ||
dark-grey: var(--alpha-color-bg-grey-darkest), | ||
light-grey: var(--alpha-color-bg-black-dark), | ||
); | ||
|
||
@each $color, $background-color in $background-color-by-color { | ||
&:where(.color-#{$color}) { | ||
background-color: $background-color; | ||
} | ||
} | ||
} | ||
|
||
&:where(.variant-secondary) { | ||
$background-color-by-color: ( | ||
blue: var(--alpha-color-primary-bg-lightest), | ||
cobalt: var(--alpha-color-accent-bg-lightest), | ||
red: var(--alpha-color-critical-bg-lightest), | ||
orange: var(--alpha-color-warning-bg-lightest), | ||
green: var(--alpha-color-success-bg-lightest), | ||
pink: var(--alpha-color-bg-pink-lightest), | ||
purple: var(--alpha-color-bg-purple-lightest), | ||
dark-grey: var(--alpha-color-bg-black-lighter), | ||
light-grey: var(--alpha-color-bg-black-lighter), | ||
); | ||
|
||
@each $color, $background-color in $background-color-by-color { | ||
&:where(.color-#{$color}) { | ||
background-color: $background-color; | ||
} | ||
} | ||
} | ||
|
||
&:where(.variant-tertiary) { | ||
background-color: initial; | ||
} | ||
|
||
/* color */ | ||
/* stylelint-disable-next-line no-duplicate-selectors */ | ||
&:where(.variant-primary) { | ||
color: var(--alpha-color-fg-absolute-white-dark); | ||
|
||
&:where(.color-dark-grey) { | ||
color: var(--alpha-color-fg-white-normal); | ||
} | ||
|
||
&:where(.color-light-grey) { | ||
color: var(--alpha-color-fg-absolute-white-normal); | ||
} | ||
} | ||
|
||
&:where(.variant-secondary, .variant-tertiary) { | ||
$color-map: ( | ||
blue: var(--alpha-color-primary-fg-normal), | ||
cobalt: var(--alpha-color-accent-fg-normal), | ||
red: var(--alpha-color-critical-fg-normal), | ||
orange: var(--alpha-color-warning-fg-normal), | ||
green: var(--alpha-color-success-fg-normal), | ||
pink: var(--alpha-color-fg-pink-normal), | ||
purple: var(--alpha-color-fg-purple-normal), | ||
dark-grey: var(--alpha-color-fg-black-darkest), | ||
light-grey: var(--alpha-color-fg-black-darker), | ||
); | ||
|
||
@each $button-color, $color in $color-map { | ||
&:where(.color-#{$button-color}) { | ||
color: $color; | ||
} | ||
} | ||
|
||
&:where(.color-dark-grey) { | ||
& :where(.ButtonIcon) { | ||
color: var(--alpha-color-fg-black-darker); | ||
} | ||
} | ||
|
||
&:where(.color-light-grey) { | ||
& :where(.ButtonIcon) { | ||
color: var(--alpha-color-fg-black-dark); | ||
} | ||
} | ||
} | ||
|
||
&:where(.variant-tertiary.color-white) { | ||
& :where(.ButtonIcon) { | ||
color: var(--alpha-color-fg-absolute-white-light); | ||
} | ||
|
||
& :where(.ButtonText) { | ||
color: var(--alpha-color-fg-absolute-white-normal); | ||
} | ||
} | ||
|
||
/* border-radius */ | ||
&:where(.variant-primary, .variant-secondary, .variant-tertiary) { | ||
$border-radius-by-size: ( | ||
xs: var(--alpha-dimension-6), | ||
s: var(--alpha-dimension-7), | ||
m: var(--alpha-dimension-10), | ||
l: var(--alpha-dimension-12), | ||
xl: var(--alpha-dimension-14), | ||
); | ||
|
||
@each $size, $border-radius in $border-radius-by-size { | ||
&:where(.size-#{$size}) { | ||
border-radius: $border-radius; | ||
} | ||
} | ||
} | ||
|
||
/* TODO: use v2 token when design is specified */ | ||
|
||
/* visual effect on interaction */ | ||
&:where(.active, :hover):where(:not(:disabled)) { | ||
&:where(.variant-primary) { | ||
@each $color in $chromatic-colors { | ||
&:where(.color-#{$color}) { | ||
background-color: var(--bgtxt-#{$color}-dark); | ||
} | ||
} | ||
|
||
&:where(.color-dark-grey) { | ||
background-color: var(--bg-grey-darkest); | ||
} | ||
|
||
&:where(.color-light-grey) { | ||
background-color: var(--bg-black-darker); | ||
} | ||
} | ||
|
||
&:where(.variant-secondary) { | ||
@each $color in $chromatic-colors { | ||
&:where(.color-#{$color}) { | ||
background-color: var(--bgtxt-#{$color}-lighter); | ||
} | ||
} | ||
|
||
&:where(.color-dark-grey, .color-light-grey) { | ||
background-color: var(--bg-black-light); | ||
} | ||
} | ||
|
||
&:where(.variant-tertiary) { | ||
@each $color in $chromatic-colors { | ||
&:where(.color-#{$color}) { | ||
background-color: var(--bgtxt-#{$color}-lightest); | ||
} | ||
} | ||
|
||
&:where(.color-dark-grey, .color-light-grey, .color-white) { | ||
background-color: var(--bg-black-lighter); | ||
} | ||
} | ||
|
||
&:where(.color-dark-grey):where(.variant-secondary, .variant-tertiary) { | ||
& :is(.ButtonIcon, .ButtonLoader) { | ||
color: var(--txt-black-darkest); | ||
} | ||
} | ||
|
||
&:where(.color-light-grey):where(.variant-secondary, .variant-tertiary) { | ||
& :is(.ButtonIcon, .ButtonLoader) { | ||
color: var(--txt-black-darker); | ||
} | ||
} | ||
|
||
&:where(.color-white.variant-tertiary) { | ||
& :where(.ButtonIcon) { | ||
color: var(--alpha-color-fg-absolute-white-normal); | ||
} | ||
} | ||
} | ||
|
||
&:where(.variant-primary.color-blue:focus-visible) { | ||
outline: 3px solid var(--bgtxt-blue-light); | ||
} | ||
|
||
&:disabled { | ||
cursor: not-allowed; | ||
opacity: var(--alpha-opacity-disabled); | ||
} | ||
|
||
/* internal components */ | ||
.ButtonContent { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
&:where(.loading) { | ||
visibility: hidden; | ||
} | ||
} | ||
|
||
.ButtonLoader { | ||
position: absolute; | ||
inset: 0; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
} |
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.
👍