-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate common files to ts
- Loading branch information
Showing
33 changed files
with
431 additions
and
424 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
import classNames from "classnames"; | ||
import styles from "./Button.module.css"; | ||
|
||
export const BUTTON_VARIANT = { | ||
CONTAINED: "contained", | ||
OUTLINED: "outlined", | ||
} as const; | ||
|
||
export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & { | ||
className?: string; | ||
variant?: typeof BUTTON_VARIANT[keyof typeof BUTTON_VARIANT]; | ||
cancel?: boolean; | ||
type?: "button" | "submit" | "reset"; | ||
children: React.ReactNode; | ||
}; | ||
|
||
const Button = ({ | ||
className, | ||
variant = "contained", | ||
cancel = false, | ||
type, | ||
children, | ||
...props | ||
}: ButtonProps) => { | ||
return ( | ||
<button | ||
className={classNames(className, styles[variant], styles.button, { | ||
[styles.cancel]: cancel, | ||
})} | ||
type={type} | ||
{...props} | ||
> | ||
{children} | ||
</button> | ||
); | ||
}; | ||
|
||
export default Button; |
22 changes: 0 additions & 22 deletions
22
frontend/src/components/@common/Container/Container.stories.js
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
frontend/src/components/@common/Container/Container.stories.tsx
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,24 @@ | ||
import { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
import Container, { CONTAINER_SIZE, ContainerProps } from "./Container"; | ||
|
||
export default { | ||
title: "components/Container", | ||
component: Container, | ||
} as ComponentMeta<typeof Container>; | ||
|
||
const Template: ComponentStory<typeof Container> = (args: ContainerProps) => ( | ||
<Container {...args} /> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
|
||
Default.args = { | ||
children: "내용물", | ||
}; | ||
|
||
export const Narrow = Template.bind({}); | ||
|
||
Narrow.args = { | ||
size: CONTAINER_SIZE.NARROW, | ||
children: "내용물", | ||
}; |
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
14 changes: 0 additions & 14 deletions
14
frontend/src/components/@common/Description/Description.stories.js
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
frontend/src/components/@common/Description/Description.stories.tsx
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,16 @@ | ||
import { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
import Description, { DescriptionProps } from "./Description"; | ||
|
||
export default { | ||
title: "form/Description", | ||
component: Description, | ||
} as ComponentMeta<typeof Description>; | ||
|
||
const Template: ComponentStory<typeof Description> = (args: DescriptionProps) => ( | ||
<Description {...args} /> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
children: "설명입니다!", | ||
}; |
10 changes: 5 additions & 5 deletions
10
...onents/@common/Description/Description.js → ...nents/@common/Description/Description.tsx
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 React from "react"; | ||
import PropTypes from "prop-types"; | ||
import classNames from "classnames"; | ||
import styles from "./Description.module.css"; | ||
|
||
const Description = ({ children, className }) => { | ||
return <div className={classNames(styles.description, className)}>{children}</div>; | ||
export type DescriptionProps = { | ||
className?: string; | ||
children: React.ReactNode; | ||
}; | ||
|
||
Description.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
const Description = ({ className, children }: DescriptionProps) => { | ||
return <div className={classNames(styles.description, className)}>{children}</div>; | ||
}; | ||
|
||
export default Description; |
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
.../@common/IconButton/IconButton.stories.js → ...@common/IconButton/IconButton.stories.tsx
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,18 @@ | ||
import styles from "./IconButton.module.css"; | ||
|
||
export type IconButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & { | ||
type?: "button" | "submit" | "reset"; | ||
className?: string; | ||
src: string; | ||
alt?: string; | ||
}; | ||
|
||
const IconButton = ({ type, className, src, alt, ...props }: IconButtonProps) => { | ||
return ( | ||
<button type={type} className={styles.button} {...props}> | ||
<img src={src} alt={alt} className={className} /> | ||
</button> | ||
); | ||
}; | ||
|
||
export default IconButton; |
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.