-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from lunit-io/ds-91-use-small-size
[DS-91] medium size 대신 small size 사용
- Loading branch information
Showing
4 changed files
with
49 additions
and
30 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 |
---|---|---|
@@ -1,18 +1,37 @@ | ||
import React from 'react' | ||
import { CommonToggle, CommonIndeterminateToggle } from './Toggle.styled' | ||
import type { ToggleProps } from './Toggle.types' | ||
|
||
import React from "react"; | ||
import { CommonToggle, CommonIndeterminateToggle } from "./Toggle.styled"; | ||
import type { ToggleProps } from "./Toggle.types"; | ||
|
||
const Toggle = (props: ToggleProps) => { | ||
const { size = "medium", indeterminate = false, disableRipple, ...switchProps } = props | ||
const { | ||
size = "small", | ||
indeterminate = false, | ||
disableRipple, | ||
...switchProps | ||
} = props; | ||
|
||
if (indeterminate) { | ||
const { checked: _, ...restProps } = switchProps; | ||
// can't use checked props with indeterminate | ||
return <CommonIndeterminateToggle toggleSize={size} checked focusRipple={false} disableRipple={disableRipple} {...restProps} /> | ||
return ( | ||
<CommonIndeterminateToggle | ||
toggleSize={size} | ||
checked | ||
focusRipple={false} | ||
disableRipple={disableRipple} | ||
{...restProps} | ||
/> | ||
); | ||
} | ||
|
||
return <CommonToggle toggleSize={size} focusRipple={false} disableRipple={disableRipple} {...switchProps}/> | ||
} | ||
return ( | ||
<CommonToggle | ||
toggleSize={size} | ||
focusRipple={false} | ||
disableRipple={disableRipple} | ||
{...switchProps} | ||
/> | ||
); | ||
}; | ||
|
||
export default Toggle | ||
export default Toggle; |
16 changes: 8 additions & 8 deletions
16
packages/design-system/src/components/Toggle/Toggle.types.ts
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,14 +1,14 @@ | ||
import type { SwitchProps } from "@mui/material" | ||
import type { SwitchProps } from "@mui/material"; | ||
|
||
export interface ToggleProps extends Omit<SwitchProps, "size" > { | ||
export interface ToggleProps extends Omit<SwitchProps, "size"> { | ||
/** | ||
* The size of the component. | ||
* @default medium | ||
* @default small | ||
*/ | ||
size?: 'medium' | 'large' | ||
size?: "small" | "large"; | ||
/** | ||
* If `true`, the component has consistent 'checked' value and change shape. | ||
* @default false | ||
*/ | ||
indeterminate?: boolean | ||
* If `true`, the component has consistent 'checked' value and change shape. | ||
* @default false | ||
*/ | ||
indeterminate?: boolean; | ||
} |
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