Skip to content
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 ToggleEmojiButtonGroup and ToggleEmojiButtonSource component #2301

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2f04466
feat(toggle-emoji-button-group): add component
yangwooseong Jun 18, 2024
c215c60
feat(toggle-emoji-button-group): add export
yangwooseong Jun 18, 2024
9fa434f
feat(toggle-emoji-button-group): add storybook
yangwooseong Jun 18, 2024
7d91e92
feat(toggle-emoji-button-group): add spinner
yangwooseong Jun 18, 2024
5d7775e
docs(toggle-emoji-button-group): add jsdoc
yangwooseong Jun 18, 2024
3e577cf
feat(toggle-emoji-button): calculate button size by js and add resize…
yangwooseong Jun 19, 2024
9899b03
chore(toggle-emoji-button): stylelint
yangwooseong Jun 21, 2024
394b649
feat(toggle-emoji-button): remove magic number and assign as css var
yangwooseong Jun 21, 2024
344b004
refactor(toggle-emoji-button): split context
yangwooseong Jun 21, 2024
5392f33
refactor(toggle-emoji-button): split resize hook
yangwooseong Jun 21, 2024
659c590
chore(toggle-emoji-button): reorder export, set fillDirection to hori…
yangwooseong Jun 21, 2024
e52d5b9
chore(changeset): add
yangwooseong Jun 21, 2024
20c98bb
feat(toggle-emoji-button): fix emoji sie of content to 30
yangwooseong Jun 21, 2024
9ecd6e3
refactor(toggle-emoji-button): refer to emoji size as css variabe
yangwooseong Jun 21, 2024
2b92d46
feat(toggle-emoji-button): rename AlphaSpinner to AlphaLoader
yangwooseong Oct 29, 2024
20dbb2a
feat(toggle-emoji-button): replace content props with name props
yangwooseong Oct 29, 2024
4e115ba
feat(toggle-emoji-button): only allow single type
yangwooseong Oct 30, 2024
fc971b7
chore(toggle-emoji-button): rm new line, add figma link
yangwooseong Oct 30, 2024
e493b5a
feat(toggle-emoji-button): support uncontrolled
yangwooseong Oct 30, 2024
2f1e503
feat(toggle-emoji-button): rm redundant div
yangwooseong Nov 6, 2024
d7967fe
refactor(toggle-emoji-button): remove context, set css variable in co…
yangwooseong Nov 6, 2024
d4fb032
refactor(toggle-emoji-button): rename variable
yangwooseong Nov 6, 2024
c815a3b
refactor(toggle-emoji-button): give default value to button size
yangwooseong Nov 6, 2024
32c77b8
feat(toggle-emoji-button): remove loader
yangwooseong Nov 6, 2024
cfbe5e7
refactor(toggle-emoji-button): remove type assertion with dir
yangwooseong Nov 6, 2024
c2fae95
fix(toggle-emoji-button): resolve typecheck failed
yangwooseong Nov 6, 2024
f7a9162
refactor(toggle-emoji-button): rename variables
yangwooseong Nov 6, 2024
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
5 changes: 5 additions & 0 deletions .changeset/wild-ducks-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@channel.io/bezier-react': patch
---

Add `ToggleEmojiButtonGroup` and `ToggleEmojiButtonSource` component.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const Primary = {
args: {
text: 'Invite',
selected: false,
loading: false,
prefixContent: GiftIcon,
suffixContent: ArrowRightIcon,
size: 'm',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
@use '../../styles/mixins/dimension';
@use 'sass:map';

@import '../Icon/Icon.module';

.Button {
position: relative;

Expand Down Expand Up @@ -89,25 +84,6 @@
display: flex;
align-items: center;
justify-content: center;

&:where(.loading) {
visibility: hidden;
}
}

& :where(.ButtonLoader) {
position: absolute;
inset: 0;

display: flex;
align-items: center;
justify-content: center;

&:where(.size-s) {
& :is(.Loader) {
@include dimension.square(#{map.get($size-map, 's')}px);
}
}
}

/* NOTE: this fixes container width when bold toggles */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { isBezierIcon } from '@channel.io/bezier-icons'
import * as TogglePrimitive from '@radix-ui/react-toggle'
import classNames from 'classnames'

import { AlphaLoader } from '~/src/components/AlphaLoader'
import { useToggleButtonContext } from '~/src/components/AlphaToggleButton/ToggleButtonContext'
import { BaseButton } from '~/src/components/BaseButton'
import { Icon, type IconSize } from '~/src/components/Icon'
Expand Down Expand Up @@ -45,7 +44,6 @@ export const ToggleButton = forwardRef<HTMLButtonElement, ToggleButtonProps>(
shape: shapeProps,
size = 'm',
className,
loading,
onSelectedChange,
...rest
},
Expand All @@ -72,12 +70,7 @@ export const ToggleButton = forwardRef<HTMLButtonElement, ToggleButtonProps>(
className
)}
>
<div
className={classNames(
styles.ButtonContent,
loading && styles.loading
)}
>
<div className={classNames(styles.ButtonContent)}>
<SideContent
size={ICON_SIZE}
content={prefixContent}
Expand All @@ -98,22 +91,6 @@ export const ToggleButton = forwardRef<HTMLButtonElement, ToggleButtonProps>(
content={suffixContent}
/>
</div>

{loading && (
<div
className={classNames(
styles.ButtonLoader,
// NOTE: Loader size is the same as icon size
styles[`size-${ICON_SIZE}`]
)}
>
<AlphaLoader
size="s"
className={styles.Loader}
variant="secondary"
/>
</div>
)}
</Comp>
</TogglePrimitive.Root>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ interface ToggleButtonOwnProps {
*/
text: string

/**
* If `loading` is true, spinner will be shown, replacing the content.
* @default false
*/
loading?: boolean

/**
* Props that shows whether the button is selected.
* @default false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react'

import type { Meta, StoryFn, StoryObj } from '@storybook/react'

import { Center } from '~/src/components/Center'

import {
ToggleEmojiButtonGroup,
ToggleEmojiButtonSource,
} from './ToggleEmojiButtonGroup'
import type {
ToggleEmojiButtonGroupProps,
ToggleEmojiButtonSourceProps,
} from './ToggleEmojiButtonGroup.types'

const meta: Meta<typeof ToggleEmojiButtonGroup> = {
component: ToggleEmojiButtonGroup,
}
export default meta

type ToggleButtonCompositionType = ToggleEmojiButtonGroupProps &
Pick<ToggleEmojiButtonSourceProps, 'variant'>

const Template: StoryFn<ToggleButtonCompositionType> = ({
fillDirection,
variant,
}) => {
return (
<Center
width="25vw"
height="15vh"
backgroundColor="bg-lounge"
>
<ToggleEmojiButtonGroup
defaultValue="blush"
fillDirection={fillDirection}
>
<ToggleEmojiButtonSource
variant={variant}
value="blush"
name="blush"
/>
<ToggleEmojiButtonSource
variant={variant}
value="grinning"
name="grinning"
/>
</ToggleEmojiButtonGroup>
</Center>
)
}

export const Primary = {
render: Template,

args: {
fillDirection: 'horizontal',
variant: 'primary',
},
parameters: {
design: {
type: 'link',
url: 'https://www.figma.com/design/fPXP9zfjZU9NyARnhTWL6o/Input?node-id=425-281&t=ktusTVyr8cD3cTlt-1',
},
},
} satisfies StoryObj<ToggleButtonCompositionType>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@use '../../styles/mixins/dimension';

.ToggleEmojiButtonGroup {
display: flex;
gap: var(--b-toggle-emoji-button-group-gap);
align-items: center;
justify-content: center;

/* stylelint-disable-next-line selector-class-pattern */
&:where(.fillDirection-horizontal) {
width: 100%;

& :where(.ToggleEmojiButtonSource) {
flex-grow: 1;
}
}

/* stylelint-disable-next-line selector-class-pattern */
&:where(.fillDirection-all) {
width: 100%;
height: 100%;

& :is(.ToggleEmojiButtonSource) {
max-width: 160px;
max-height: 160px;
}
}
}

.ToggleEmojiButtonSource {
position: relative;

display: flex;
align-items: center;
justify-content: center;

padding: 12px;

border-radius: var(--radius-12);

&:where(.size-m) {
@include dimension.square(var(--b-toggle-emoji-button-size));
}

&:where(.variant-primary) {
background-color: var(--alpha-color-bg-grey-lightest);
box-shadow: var(--alpha-shadow-input-default);

&:where(&:hover) {
background-color: var(--alpha-color-bg-grey-lighter);
}

&:where([data-state='on']) {
background-color: var(--alpha-color-bg-blue-lightest);
box-shadow: 0 0 0 1px var(--alpha-color-primary-bg-normal) inset;
}
}

&:where(.variant-secondary) {
background-color: var(--alpha-color-bg-black-lightest);

&:where(&:hover) {
background-color: var(--alpha-color-bg-black-lighter);
}

&:where([data-state='on']) {
background-color: var(--alpha-color-primary-bg-lighter);
}
}

& :where(.ButtonContent) {
display: flex;
align-items: center;
justify-content: center;
}
}
Loading
Loading