-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(card): creating a card #16
Merged
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fb84c0b
feat(card): created a hotelfeaturedcard Component
sgd122 b3ccd9a
feat(image): 이미지 loading, error 이미지 size 조정
sgd122 e4f2438
feat(card): created a HotelFeaturedCard Component
sgd122 a5ff9aa
feat(card): careated a PriceCard Component
sgd122 317235c
feat(card): created a HotelCard Component
sgd122 596968f
feat(card): updated a card component (type, typography...)
sgd122 137596c
feat(card): created a MainReviewCard Component
sgd122 812df9f
feat(card): created a HotelTitleCard Component
sgd122 2ecdf6a
feat(card): updated a HotelTitleCard Component
sgd122 9eb9b7e
feat(card): created a HotelReviewCard Component
sgd122 85cfdb2
feat(card): created a CouponCard Component
sgd122 6c2ffaf
feat(card): init a OptionCard Component
sgd122 0b30cdd
feat(card): add a OptionCard Component
sgd122 df46bd7
feat(card): add a StatusCard Component
sgd122 8f03ef6
feat(card): add a TimeLineBanner Component
sgd122 b6fbd17
feat(card): add a SkeletonTimeLineBanner Component
sgd122 7d73561
feat(card): updated a OptionCard Props description
sgd122 297f979
feat(card): 카드 컴포넌트 스타일링 수정
sgd122 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
58 changes: 58 additions & 0 deletions
58
packages/travelmakers-design-core/src/components/Card/CouponCard/CouponCard.style.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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { createStyles } from "@travelmakers-design-v2/styles"; | ||
import { Props } from "./CouponCard"; | ||
|
||
export default createStyles((theme, { type }: Pick<Props, "type">) => { | ||
const getBackgroundColor = () => { | ||
return { | ||
week: { | ||
backgroundColor: theme.colors.secondary, | ||
}, | ||
month: { | ||
backgroundColor: theme.colors.secondary20, | ||
}, | ||
all: { | ||
backgroundColor: theme.colors.primary, | ||
}, | ||
}; | ||
}; | ||
|
||
return { | ||
container: { | ||
width: "296px", | ||
height: "142px", | ||
backgroundColor: theme.colors.primary99, | ||
borderRadius: theme.radius.radius20, | ||
display: "flex", | ||
}, | ||
leftBox: { | ||
...getBackgroundColor()[type], | ||
width: "80px", | ||
display: "flex", | ||
flexDirection: "column", | ||
padding: theme.spacing.spacing10, | ||
borderRadius: `${theme.radius.radius20} 0 0 ${theme.radius.radius20}`, | ||
}, | ||
rightBox: { | ||
width: "100%", | ||
padding: theme.spacing.spacing20, | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: theme.spacing.spacing5, | ||
}, | ||
discountBox: { | ||
display: "flex", | ||
flexDirection: "row", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
}, | ||
checkBox: { | ||
backgroundColor: theme.colors.primaryContainer, | ||
borderRadius: theme.radius.radius100, | ||
width: 16, | ||
height: 16, | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
}, | ||
}; | ||
}); |
143 changes: 143 additions & 0 deletions
143
packages/travelmakers-design-core/src/components/Card/CouponCard/CouponCard.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,143 @@ | ||
import { PolymorphicRef, useTmTheme } from "@travelmakers-design-v2/styles"; | ||
import { forwardRef, PropsWithChildren } from "react"; | ||
import { View } from "../../View"; | ||
import useStyles from "./CouponCard.style"; | ||
import { CouponCardProps, CouponCardComponent } from "./CouponCard.type"; | ||
import { Typography } from "../../Typography"; | ||
import { Icon } from "../../Icon"; | ||
|
||
export interface Props { | ||
/** CouponCard의 Type을 설정합니다. */ | ||
type: "week" | "month" | "all"; | ||
|
||
/** CouponCard의 상태를 설정합니다. */ | ||
state: "default" | "applied" | "checked"; | ||
|
||
/** CouponCard의 day를 설정합니다. */ | ||
day: number; | ||
|
||
/** CouponCard의 타이틀을 설정합니다. */ | ||
title: string; | ||
|
||
/** CouponCard의 서브 타이틀을 설정합니다. */ | ||
subTitle: string; | ||
|
||
/** CouponCard의 적용상품 설정합니다. */ | ||
item?: string; | ||
|
||
/** CouponCard의 잔여수량을 설정합니다. */ | ||
remainingQuantity?: number; | ||
|
||
/** CouponCard의 내용을 설정합니다. */ | ||
content: string; | ||
} | ||
|
||
export const CouponCard: CouponCardComponent & { | ||
displayName?: string; | ||
} = forwardRef( | ||
<C extends React.ElementType = "div">( | ||
{ | ||
type, | ||
state, | ||
day, | ||
title, | ||
subTitle, | ||
item, | ||
remainingQuantity, | ||
content, | ||
className, | ||
...props | ||
}: PropsWithChildren<CouponCardProps<C>>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P4: children을 사용하지 않으니 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
ref: PolymorphicRef<C> | ||
) => { | ||
const { classes, cx } = useStyles({ type }); | ||
const theme = useTmTheme(); | ||
const DAY_TYPE = { | ||
week: "Week", | ||
month: "Month", | ||
all: "All", | ||
}; | ||
|
||
const getItemText = ( | ||
item: Props["item"], | ||
remainingQuantity: Props["remainingQuantity"] | ||
) => { | ||
const firstText = item ?? "전체"; | ||
const secondText = ` | 잔여 ${remainingQuantity}개`; | ||
if (remainingQuantity) { | ||
return `${firstText} ${secondText}`; | ||
} else { | ||
return firstText; | ||
} | ||
}; | ||
|
||
const getStateIcon = (state: Props["state"]) => { | ||
switch (state) { | ||
case "applied": | ||
return ( | ||
<Typography level="body3" color="primary3"> | ||
적용중 | ||
</Typography> | ||
); | ||
|
||
case "checked": | ||
return ( | ||
<div className={classes.checkBox}> | ||
<Icon | ||
src="IcCheck" | ||
width={12} | ||
height={12} | ||
color={theme.colors.white} | ||
/> | ||
</div> | ||
); | ||
|
||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
return ( | ||
<View<React.ElementType> | ||
component={"div"} | ||
ref={ref} | ||
className={cx(className, classes.container)} | ||
{...props} | ||
> | ||
<div className={classes.leftBox}> | ||
<Typography level="display2" color={"white"}> | ||
{day} | ||
</Typography> | ||
<Typography family="Noto Serif KR" level="body1" color={"white"}> | ||
{DAY_TYPE[type]} | ||
</Typography> | ||
</div> | ||
<div className={classes.rightBox}> | ||
<div className={classes.discountBox}> | ||
<div> | ||
<Typography level="display6" color="secondary"> | ||
{title} | ||
</Typography> | ||
</div> | ||
<div>{getStateIcon(state)}</div> | ||
</div> | ||
<Typography level="body3" color="primary"> | ||
{subTitle} | ||
</Typography> | ||
<Typography level="caption" color="errorInteract"> | ||
{getItemText(item, remainingQuantity)} | ||
</Typography> | ||
<Typography | ||
level="caption" | ||
color="primary3" | ||
style={{ whiteSpace: "pre-line" }} | ||
> | ||
{content} | ||
</Typography> | ||
</div> | ||
</View> | ||
); | ||
} | ||
); | ||
|
||
CouponCard.displayName = "CouponCard"; |
20 changes: 20 additions & 0 deletions
20
packages/travelmakers-design-core/src/components/Card/CouponCard/CouponCard.type.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
ClassNames, | ||
PolymorphicComponentProps, | ||
TmComponentProps, | ||
} from "@travelmakers-design-v2/styles"; | ||
import { Props } from "./CouponCard"; | ||
import useStyles from "./CouponCard.style"; | ||
|
||
type CouponCardStylesNames = ClassNames<typeof useStyles>; | ||
|
||
interface SharedCouponCardProps | ||
extends Props, | ||
TmComponentProps<CouponCardStylesNames> {} | ||
|
||
export type CouponCardProps<C extends React.ElementType> = | ||
PolymorphicComponentProps<C, SharedCouponCardProps>; | ||
|
||
export type CouponCardComponent = <C extends React.ElementType = "div">( | ||
props: CouponCardProps<C> | ||
) => React.ReactElement; |
2 changes: 2 additions & 0 deletions
2
packages/travelmakers-design-core/src/components/Card/CouponCard/index.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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { CouponCard } from "./CouponCard"; | ||
export type { CouponCardProps } from "./CouponCard.type"; |
86 changes: 86 additions & 0 deletions
86
...es/travelmakers-design-core/src/components/Card/CouponCard/stories/CouponCard.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,86 @@ | ||
import { Meta } from "@storybook/react"; | ||
import { CouponCard } from "../CouponCard"; | ||
|
||
export default { | ||
title: "@travelmakers-design-v2/core/General/Card/CouponCard", | ||
component: CouponCard, | ||
argTypes: { | ||
type: { | ||
defaultValue: "week", | ||
description: "CouponCard의 Type을 설정합니다.", | ||
options: ["week", "month", "all"], | ||
control: { type: "inline-radio" }, | ||
}, | ||
state: { | ||
defaultValue: "default", | ||
description: "CouponCard의 상태를 설정합니다.", | ||
options: ["default", "applied", "checked"], | ||
control: { type: "inline-radio" }, | ||
}, | ||
day: { | ||
defaultValue: 1, | ||
description: "CouponCard의 day를 설정합니다.", | ||
table: { | ||
type: { | ||
summary: "number", | ||
}, | ||
}, | ||
control: { type: "number" }, | ||
}, | ||
title: { | ||
defaultValue: "00%", | ||
description: "CouponCard의 타이틀을 설정합니다.", | ||
table: { | ||
type: { | ||
summary: "string", | ||
}, | ||
}, | ||
control: { type: "text" }, | ||
}, | ||
subTitle: { | ||
defaultValue: "호텔에삶 특별 혜택", | ||
description: "CouponCard의 서브 타이틀을 설정합니다.", | ||
table: { | ||
type: { | ||
summary: "string", | ||
}, | ||
}, | ||
control: { type: "text" }, | ||
}, | ||
item: { | ||
defaultValue: "적용 상품", | ||
description: "CouponCard의 적용상품 설정합니다.", | ||
table: { | ||
type: { | ||
summary: "string", | ||
}, | ||
}, | ||
control: { type: "text" }, | ||
}, | ||
remainingQuantity: { | ||
defaultValue: 5, | ||
description: "CouponCard의 잔여수량을 설정합니다.", | ||
table: { | ||
type: { | ||
summary: "number", | ||
}, | ||
}, | ||
control: { type: "number" }, | ||
}, | ||
content: { | ||
defaultValue: | ||
"*쿠폰 사용 안내 문구\n *쿠폰 사용 안내 문구 안내 문구\n *쿠폰사용안내 문구 안내 문구", | ||
description: "CouponCard의 내용을 설정합니다.", | ||
table: { | ||
type: { | ||
summary: "string", | ||
}, | ||
}, | ||
control: { type: "text" }, | ||
}, | ||
}, | ||
} as Meta; | ||
|
||
export const Default = (props) => { | ||
return <CouponCard {...props} />; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P4: container에 borderRadius가 적용되어있어서
overflow: hidden
을 추가하고 leftBox의 borderRadius는 제거해줘도 될 것 같습니다!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 백그라운드영역자체는 직사각형으로 자리가 잡혀있어서 hidden으로 영역제거가 되지 않는것 같습니다 ㅠ
해당 부분은 유지해두겠슴돠 :)