Skip to content

Commit

Permalink
feat(toggle-emoji-button): support uncontrolled
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwooseong committed Oct 30, 2024
1 parent 1c44d57 commit 00f80f0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React from 'react'

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

Expand Down Expand Up @@ -26,17 +26,14 @@ const Template: StoryFn<ToggleButtonCompositionType> = ({
variant,
loading,
}) => {
const [value, setValue] = useState('blush')

return (
<Center
width="25vw"
height="15vh"
backgroundColor="bg-lounge"
>
<ToggleEmojiButtonGroup
value={value}
onValueChange={setValue}
defaultValue="blush"
fillDirection={fillDirection}
>
<ToggleEmojiButtonSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,16 @@ export const ToggleEmojiButtonGroup = forwardRef<
HTMLDivElement,
ToggleEmojiButtonGroupProps
>(function ToggleEmojiButtonGroup(
{ fillDirection, value, className, children, style, onValueChange, ...rest },
{
fillDirection,
value,
className,
defaultValue,
children,
style,
onValueChange,
...rest
},
forwardedRef

Check warning on line 160 in packages/bezier-react/src/components/AlphaToggleEmojiButtonGroup/ToggleEmojiButtonGroup.tsx

View check run for this annotation

Codecov / codecov/patch

packages/bezier-react/src/components/AlphaToggleEmojiButtonGroup/ToggleEmojiButtonGroup.tsx#L160

Added line #L160 was not covered by tests
) {
const [ref, setRef] = useState<null | HTMLDivElement>(null)
Expand All @@ -156,6 +165,7 @@ export const ToggleEmojiButtonGroup = forwardRef<
return (

Check warning on line 165 in packages/bezier-react/src/components/AlphaToggleEmojiButtonGroup/ToggleEmojiButtonGroup.tsx

View check run for this annotation

Codecov / codecov/patch

packages/bezier-react/src/components/AlphaToggleEmojiButtonGroup/ToggleEmojiButtonGroup.tsx#L165

Added line #L165 was not covered by tests
<ToggleGroup.Root
type="single"
defaultValue={defaultValue}
onValueChange={onValueChange}
value={value}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ interface ToggleEmojiButtonGroupOwnProps {
* Controlled value of the button item to select.
* should be used with `onValueChange`.
*/
value: string
value?: string
/**
* The value of the button to show as selected when initially rendered.
* Use when you do not need to control the state of the items.
*/
defaultValue?: string
/**
* Event handler called when the value changes.
*/
onValueChange?: (value: string) => void
}

export interface ToggleEmojiButtonGroupProps
extends BezierComponentProps<'div'>,
extends Omit<BezierComponentProps<'div'>, 'defaultValue'>,
ToggleEmojiButtonGroupOwnProps {}

export interface ToggleEmojiButtonSourceProps
Expand Down

0 comments on commit 00f80f0

Please sign in to comment.