-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#304]
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import ReactJoyride, { type Props as JoyrideProps } 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 = Partial< | ||
Omit< | ||
JoyrideProps, | ||
| "locale" | ||
| "styles" | ||
| "tooltipComponent" | ||
| "spotlightPadding" | ||
| "floaterProps" | ||
> | ||
>; | ||
|
||
export function Coachmark(props: CoachmarkProps) { | ||
const { mounted } = useMount(); | ||
|
||
if (!mounted) return null; | ||
return ( | ||
<ReactJoyride | ||
{...props} | ||
locale={LOCALE} | ||
styles={STYLES} | ||
tooltipComponent={CoachTooltip} | ||
spotlightPadding={0} | ||
floaterProps={FLOATER_PROPS} | ||
/> | ||
); | ||
} | ||
|
||
type RequiredJoyrideProps = Required<JoyrideProps>; | ||
|
||
const LOCALE: RequiredJoyrideProps["locale"] = { | ||
back: "이전", | ||
next: "다음", | ||
close: "닫기", | ||
last: "종료", | ||
skip: "건너뛰기", | ||
}; | ||
|
||
const STYLES: RequiredJoyrideProps["styles"] = { | ||
options: { | ||
overlayColor: "rgba(0, 0, 0, 0.2)", | ||
primaryColor: color.$semantic.primary, | ||
zIndex: coachmarkZIndex, | ||
}, | ||
}; | ||
|
||
const FLOATER_PROPS: RequiredJoyrideProps["floaterProps"] = { | ||
offset: 25, | ||
styles: { | ||
arrow: { length: 15, spread: 18 }, | ||
floater: { filter: "none" }, | ||
}, | ||
}; |
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 @@ | ||
export { type CoachmarkProps, Coachmark } from "./Coachmark"; |