Skip to content

Commit

Permalink
feat: CoachTooltip 컴포넌트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
YuHyun-P committed Dec 28, 2023
1 parent 49ce030 commit a4e7a40
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 0 deletions.
86 changes: 86 additions & 0 deletions packages/frontend/src/components/coachmark/CoachTooltip.css.ts
Original file line number Diff line number Diff line change
@@ -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,
},
],
});
73 changes: 73 additions & 0 deletions packages/frontend/src/components/coachmark/CoachTooltip.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div {...tooltipProps} className={styles.container}>
<div className={styles.header}>
{title && <strong className={styles.title}>{title}</strong>}
{showProgress && <StepProgress cur={stepIndex + 1} size={stepSize} />}
<CloseButton {...closeProps} />
</div>

<div className={styles.content}>{content}</div>

<div className={styles.footer}>
{showSkipButton && <ActionButton type="skip" {...skipProps} />}
<div>
{showBackButton && <ActionButton type="back" {...backProps} />}
{showNextButton && <ActionButton type="primary" {...primaryProps} />}
{lastStep && <ActionButton type="primary" {...primaryProps} />}
</div>
</div>
</div>
);
}

function StepProgress({ cur, size }: { cur: number; size: number }) {
return (
<span className={styles.stepProgress}>
{cur} / {size}
</span>
);
}

function CloseButton(props: TooltipRenderProps["closeProps"]) {
return (
<button type="button" {...props} className={styles.closeButton}>
<IoCloseOutline size={27} />
</button>
);
}

type ActionButtonProps = TooltipRenderProps["backProps"] & {
type: "skip" | "back" | "primary";
};

function ActionButton({ type, title, ...props }: ActionButtonProps) {
return (
<button
type="button"
{...props}
className={styles.actionButtonVariant[type]}
>
{title}
</button>
);
}

0 comments on commit a4e7a40

Please sign in to comment.