From a4e7a4005a3131aeb67dd2c9a68f9c9f3122bc96 Mon Sep 17 00:00:00 2001 From: YuHyun Date: Fri, 29 Dec 2023 02:13:57 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20CoachTooltip=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#304] --- .../components/coachmark/CoachTooltip.css.ts | 86 +++++++++++++++++++ .../src/components/coachmark/CoachTooltip.tsx | 73 ++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 packages/frontend/src/components/coachmark/CoachTooltip.css.ts create mode 100644 packages/frontend/src/components/coachmark/CoachTooltip.tsx diff --git a/packages/frontend/src/components/coachmark/CoachTooltip.css.ts b/packages/frontend/src/components/coachmark/CoachTooltip.css.ts new file mode 100644 index 00000000..a248493f --- /dev/null +++ b/packages/frontend/src/components/coachmark/CoachTooltip.css.ts @@ -0,0 +1,86 @@ +import { style, styleVariants } from "@vanilla-extract/css"; + +import color from "../../design-system/tokens/color"; +import typography from "../../design-system/tokens/typography"; +import { + borderRadius, + flexAlignCenter, +} from "../../design-system/tokens/utils.css"; + +export const container = style([ + borderRadius, + { + position: "relative", + width: 398, + padding: 16, + color: color.$scale.grey800, + backgroundColor: color.$semantic.bgWhite, + }, +]); + +export const header = style([flexAlignCenter, { gap: 5, marginBottom: 12 }]); + +export const title = style([typography.$semantic.title3Bold]); + +export const stepProgress = style([ + typography.$semantic.caption2Regular, + { color: color.$scale.grey500 }, +]); + +export const closeButton = style({ + position: "absolute", + top: 13, + right: 3, + border: 0, + color: color.$scale.grey700, + backgroundColor: "transparent", +}); + +export const content = style([ + typography.$semantic.title3Regular, + { height: 53 }, +]); + +export const footer = style([ + flexAlignCenter, + { justifyContent: "space-between" }, +]); + +const actionBaseButton = style([ + typography.$semantic.body2Regular, + { border: 0 }, +]); + +export const actionButtonVariant = styleVariants({ + skip: [ + actionBaseButton, + { + padding: 0, + color: color.$scale.grey600, + backgroundColor: "transparent", + }, + ], + + back: [ + actionBaseButton, + { + width: 67, + marginRight: 8, + borderRadius: 3, + padding: "7px 0", + color: color.$semantic.primary, + backgroundColor: color.$semantic.primaryLow, + }, + ], + + primary: [ + actionBaseButton, + { + width: 67, + borderRadius: 3, + padding: "7px 0", + color: color.$semantic.textWhite, + backgroundColor: color.$semantic.primary, + }, + ], +}); diff --git a/packages/frontend/src/components/coachmark/CoachTooltip.tsx b/packages/frontend/src/components/coachmark/CoachTooltip.tsx new file mode 100644 index 00000000..6939d261 --- /dev/null +++ b/packages/frontend/src/components/coachmark/CoachTooltip.tsx @@ -0,0 +1,73 @@ +import { IoCloseOutline } from "react-icons/io5"; +import { TooltipRenderProps } from "react-joyride"; + +import * as styles from "./CoachTooltip.css"; + +export function CoachTooltip({ + step: { content, showProgress, showSkipButton, title }, + index: stepIndex, + size: stepSize, + isLastStep: lastStep, + continuous, + backProps, + closeProps, + primaryProps, + skipProps, + tooltipProps, +}: TooltipRenderProps) { + const showBackButton = stepIndex > 0; + const showNextButton = continuous && !lastStep; + + return ( +
+
+ {title && {title}} + {showProgress && } + +
+ +
{content}
+ +
+ {showSkipButton && } +
+ {showBackButton && } + {showNextButton && } + {lastStep && } +
+
+
+ ); +} + +function StepProgress({ cur, size }: { cur: number; size: number }) { + return ( + + {cur} / {size} + + ); +} + +function CloseButton(props: TooltipRenderProps["closeProps"]) { + return ( + + ); +} + +type ActionButtonProps = TooltipRenderProps["backProps"] & { + type: "skip" | "back" | "primary"; +}; + +function ActionButton({ type, title, ...props }: ActionButtonProps) { + return ( + + ); +}