Skip to content

Commit

Permalink
feat: Coachmark 컴포넌트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
YuHyun-P committed Dec 29, 2023
1 parent 635adcd commit 8bde8f7
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
64 changes: 64 additions & 0 deletions packages/frontend/src/components/coachmark/Coachmark.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import ReactJoyride, { Props } from "react-joyride";

import color from "../../design-system/tokens/color";
import { coachmarkZIndex } from "../../design-system/tokens/utils.css";
import useMount from "../../hooks/useMount";

import { CoachTooltip } from "./CoachTooltip";

export type CoachmarkProps = { steps: Props["steps"] } & Partial<
Pick<
Props,
"steps" | "continuous" | "showProgress" | "showSkipButton" | "callback"
>
>;

export function Coachmark({
steps,
continuous,
showProgress,
showSkipButton,
callback,
}: CoachmarkProps) {
const { mounted } = useMount();

if (!mounted) return null;
return (
<ReactJoyride
steps={steps}
continuous={continuous}
showProgress={showProgress}
showSkipButton={showSkipButton}
locale={LOCALE}
styles={STYLES}
tooltipComponent={CoachTooltip}
spotlightPadding={0}
floaterProps={FLOATER_PROPS}
callback={callback}
/>
);
}

const LOCALE: Props["locale"] = {
back: "이전",
next: "다음",
close: "닫기",
last: "종료",
skip: "건너뛰기",
};

const STYLES: Props["styles"] = {
options: {
overlayColor: "rgba(0, 0, 0, 0.2)",
primaryColor: color.$semantic.primary,
zIndex: coachmarkZIndex,
},
};

const FLOATER_PROPS: Props["floaterProps"] = {
offset: 25,
styles: {
arrow: { length: 15, spread: 18 },
floater: { filter: "none" },
},
};
1 change: 1 addition & 0 deletions packages/frontend/src/components/coachmark/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { type CoachmarkProps, Coachmark } from "./Coachmark";

0 comments on commit 8bde8f7

Please sign in to comment.