-
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 #138 from lunit-io/ds-83-component-prop
[DS-83] Chip component prop 적용 및 Button component prop 개선
- Loading branch information
Showing
7 changed files
with
58 additions
and
26 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
41 changes: 27 additions & 14 deletions
41
packages/design-system/src/components/Button/Button.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,30 +1,43 @@ | ||
import type { ButtonProps as MuiButtonProps } from "@mui/material"; | ||
import type { | ||
ButtonProps as MuiButtonProps, | ||
ButtonTypeMap as MuiButtonTypeMap, | ||
} from "@mui/material"; | ||
import type { OverridableComponent } from "@mui/material/OverridableComponent"; | ||
|
||
/** | ||
* TODO: Omit 을 사용할 경우 component prop 타입 추론이 안되는 이슈 발생 | ||
* https://github.com/lunit-io/design-system/pull/133#discussion_r1354277785 | ||
* */ | ||
type BaseButtonProps<C extends React.ElementType> = Omit< | ||
MuiButtonProps<C, { component?: C }>, | ||
"variant" | ||
> & { icon?: React.ReactNode }; | ||
interface BaseButtonProps extends Omit<MuiButtonProps, "variant"> { | ||
icon?: React.ReactNode; | ||
} | ||
|
||
type ContainedButtonProps<C extends React.ElementType> = BaseButtonProps<C> & { | ||
interface ContainedButtonProps extends BaseButtonProps { | ||
kind?: "contained"; | ||
color?: "primary" | "secondary" | "error"; | ||
}; | ||
} | ||
|
||
type GhostButtonProps<C extends React.ElementType> = BaseButtonProps<C> & { | ||
interface GhostButtonProps extends BaseButtonProps { | ||
kind?: "ghost"; | ||
color?: "primary" | "secondary" | "error"; | ||
}; | ||
} | ||
|
||
type OutlinedButtonProps<C extends React.ElementType> = BaseButtonProps<C> & { | ||
interface OutlinedButtonProps extends BaseButtonProps { | ||
kind?: "outlined"; | ||
color?: "primary" | "secondary"; | ||
} | ||
|
||
export type ButtonProps = | ||
| ContainedButtonProps | ||
| GhostButtonProps | ||
| OutlinedButtonProps; | ||
|
||
export type ButtonTypeMap< | ||
P = {}, | ||
D extends React.ElementType = MuiButtonTypeMap["defaultComponent"] | ||
> = { | ||
props: P & ButtonProps; | ||
defaultComponent: D; | ||
}; | ||
|
||
export type ButtonProps<C extends React.ElementType> = | ||
| ContainedButtonProps<C> | ||
| GhostButtonProps<C> | ||
| OutlinedButtonProps<C>; | ||
export type ButtonType = OverridableComponent<ButtonTypeMap>; |
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
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