-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update switch, action chip, control chip
- Loading branch information
Showing
75 changed files
with
1,662 additions
and
741 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
```tsx copy filename="action-chip.tsx" | ||
import { Slot } from "@radix-ui/react-slot"; | ||
import { actionChip, type ActionChipVariantProps } from "@seed-design/recipe/actionChip"; | ||
import clsx from "clsx"; | ||
import * as React from "react"; | ||
|
||
import "@seed-design/stylesheet/actionChip.css"; | ||
|
||
export interface ActionChipProps | ||
extends React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
ActionChipVariantProps { | ||
prefixIcon?: React.ReactNode; | ||
|
||
suffixIcon?: React.ReactNode; | ||
} | ||
|
||
export const ActionChip = React.forwardRef<HTMLButtonElement, ActionChipProps>( | ||
( | ||
{ | ||
className, | ||
size = "medium", | ||
layout = "withText", | ||
children, | ||
prefixIcon, | ||
suffixIcon, | ||
...otherProps | ||
}, | ||
ref, | ||
) => { | ||
const classNames = actionChip({ size, layout }); | ||
return ( | ||
<button ref={ref} className={clsx(classNames.root, className)} {...otherProps}> | ||
{prefixIcon && <Slot className={classNames.prefix}>{prefixIcon}</Slot>} | ||
{layout === "withText" ? ( | ||
<span className={classNames.label}>{children}</span> | ||
) : ( | ||
<Slot className={classNames.icon}>{children}</Slot> | ||
)} | ||
{suffixIcon && <Slot className={classNames.suffix}>{suffixIcon}</Slot>} | ||
</button> | ||
); | ||
}, | ||
); | ||
ActionChip.displayName = "ActionChip"; | ||
|
||
``` |
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,62 @@ | ||
```tsx copy filename="control-chip.tsx" | ||
import { Slot } from "@radix-ui/react-slot"; | ||
import { controlChip, type ControlChipVariantProps } from "@seed-design/recipe/controlChip"; | ||
import clsx from "clsx"; | ||
import * as React from "react"; | ||
|
||
import "@seed-design/stylesheet/controlChip.css"; | ||
import { UseCheckboxProps, useCheckbox } from "@seed-design/react-checkbox"; | ||
import { visuallyHidden } from "../util/visuallyHidden"; | ||
|
||
export interface ControlChipToggleProps | ||
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">, | ||
UseCheckboxProps, | ||
ControlChipVariantProps { | ||
prefixIcon?: React.ReactNode; | ||
|
||
suffixIcon?: React.ReactNode; | ||
} | ||
|
||
const ControlChipToggle = React.forwardRef<HTMLInputElement, ControlChipToggleProps>( | ||
( | ||
{ | ||
className, | ||
size = "medium", | ||
layout = "withText", | ||
children, | ||
prefixIcon, | ||
suffixIcon, | ||
...otherProps | ||
}, | ||
ref, | ||
) => { | ||
const classNames = controlChip({ size, layout }); | ||
const { rootProps, hiddenInputProps, restProps } = useCheckbox(otherProps); | ||
return ( | ||
<label {...rootProps} className={clsx(classNames.root, className)}> | ||
{prefixIcon && <Slot className={classNames.prefix}>{prefixIcon}</Slot>} | ||
{layout === "withText" ? ( | ||
<span className={classNames.label}>{children}</span> | ||
) : ( | ||
<Slot className={classNames.icon}>{children}</Slot> | ||
)} | ||
{suffixIcon && <Slot className={classNames.suffix}>{suffixIcon}</Slot>} | ||
<input ref={ref} {...hiddenInputProps} {...restProps} style={visuallyHidden} /> | ||
</label> | ||
); | ||
}, | ||
); | ||
ControlChipToggle.displayName = "ControlChip.Toggle"; | ||
|
||
export const ControlChip = Object.assign( | ||
() => { | ||
console.warn( | ||
"ControlChip is a base component and should not be rendered. Use ControlChip.Toggle or ControlChip.Radio instead.", | ||
); | ||
}, | ||
{ | ||
Toggle: ControlChipToggle, | ||
}, | ||
); | ||
|
||
``` |
13 changes: 13 additions & 0 deletions
13
component-docs/public/__mdx__/react/action-chip-icon-only.mdx
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,13 @@ | ||
```tsx copy | ||
import IconAddFill from "@seed-design/icon/IconAddFill"; | ||
import { ActionChip } from "seed-design/ui/action-chip"; | ||
|
||
export default function ActionChipIconOnly() { | ||
return ( | ||
<ActionChip layout="iconOnly"> | ||
<IconAddFill /> | ||
</ActionChip> | ||
); | ||
} | ||
|
||
``` |
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,8 @@ | ||
```tsx copy | ||
import { ActionChip } from "seed-design/ui/action-chip"; | ||
|
||
export default function ActionChipMedium() { | ||
return <ActionChip size="medium">라벨</ActionChip>; | ||
} | ||
|
||
``` |
9 changes: 9 additions & 0 deletions
9
component-docs/public/__mdx__/react/action-chip-prefix-icon.mdx
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,9 @@ | ||
```tsx copy | ||
import IconAddFill from "@seed-design/icon/IconAddFill"; | ||
import { ActionChip } from "seed-design/ui/action-chip"; | ||
|
||
export default function ActionChipPrefixIcon() { | ||
return <ActionChip prefixIcon={<IconAddFill />}>라벨</ActionChip>; | ||
} | ||
|
||
``` |
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,8 @@ | ||
```tsx copy | ||
import { ActionChip } from "seed-design/ui/action-chip"; | ||
|
||
export default function ActionChipPreview() { | ||
return <ActionChip>라벨</ActionChip>; | ||
} | ||
|
||
``` |
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,8 @@ | ||
```tsx copy | ||
import { ActionChip } from "seed-design/ui/action-chip"; | ||
|
||
export default function ActionChipSmall() { | ||
return <ActionChip size="small">라벨</ActionChip>; | ||
} | ||
|
||
``` |
13 changes: 13 additions & 0 deletions
13
component-docs/public/__mdx__/react/control-chip-icon-only.mdx
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,13 @@ | ||
```tsx copy | ||
import IconAddFill from "@seed-design/icon/IconAddFill"; | ||
import { ControlChip } from "seed-design/ui/control-chip"; | ||
|
||
export default function ControlChipIconOnly() { | ||
return ( | ||
<ControlChip.Toggle layout="iconOnly"> | ||
<IconAddFill /> | ||
</ControlChip.Toggle> | ||
); | ||
} | ||
|
||
``` |
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,8 @@ | ||
```tsx copy | ||
import { ControlChip } from "seed-design/ui/control-chip"; | ||
|
||
export default function ActionChipMedium() { | ||
return <ControlChip.Toggle size="medium">라벨</ControlChip.Toggle>; | ||
} | ||
|
||
``` |
9 changes: 9 additions & 0 deletions
9
component-docs/public/__mdx__/react/control-chip-prefix-icon.mdx
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,9 @@ | ||
```tsx copy | ||
import IconAddFill from "@seed-design/icon/IconAddFill"; | ||
import { ControlChip } from "seed-design/ui/control-chip"; | ||
|
||
export default function ControlChipPrefixIcon() { | ||
return <ControlChip.Toggle prefixIcon={<IconAddFill />}>라벨</ControlChip.Toggle>; | ||
} | ||
|
||
``` |
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,8 @@ | ||
```tsx copy | ||
import { ControlChip } from "seed-design/ui/control-chip"; | ||
|
||
export default function ControlChipPreview() { | ||
return <ControlChip.Toggle>라벨</ControlChip.Toggle>; | ||
} | ||
|
||
``` |
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,8 @@ | ||
```tsx copy | ||
import { ControlChip } from "seed-design/ui/control-chip"; | ||
|
||
export default function ActionChipSmall() { | ||
return <ControlChip.Toggle size="small">라벨</ControlChip.Toggle>; | ||
} | ||
|
||
``` |
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
Oops, something went wrong.