Skip to content

Commit

Permalink
feat(docs): story 기본 폰트를 지정해요
Browse files Browse the repository at this point in the history
  • Loading branch information
te6-in committed Nov 20, 2024
1 parent 01fe3ca commit 87521fb
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions docs/stories/components/decorator.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
import type { Decorator } from "@storybook/react";
import type { DetailedHTMLProps, HtmlHTMLAttributes } from "react";

const STORY_LIGHT_THEME = "Light Theme";
const STORY_DARK_THEME = "Dark Theme";

const FONT_SCALING = "Font Scaling";

const DEFAULT_PROPERTIES: DetailedHTMLProps<
HtmlHTMLAttributes<HTMLHtmlElement>,
HTMLHtmlElement
> & {
[key: string]: unknown;
} = {
lang: "ko",
"data-seed-scale-letter-spacing": "ios",
style: {
display: "flex",
flexDirection: "column",
padding: "0 20px",
fontFamily: `-apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`,
},
};

export const SeedThemeDecorator: Decorator = (Story, ctx) => {
if (ctx.name === STORY_LIGHT_THEME) {
return (
<html
lang="ko"
data-seed="light-only"
data-seed-scale-color="light"
data-seed-scale-letter-spacing="ios"
style={{ display: "flex", flexDirection: "column", padding: "0 20px" }}
>
<html {...DEFAULT_PROPERTIES} data-seed="light-only" data-seed-scale-color="light">
<Story />
</html>
);
}

if (ctx.name === STORY_DARK_THEME) {
return (
<html
lang="ko"
data-seed="dark-only"
data-seed-scale-color="dark"
data-seed-scale-letter-spacing="ios"
style={{ display: "flex", flexDirection: "column", padding: "0 20px" }}
>
<html {...DEFAULT_PROPERTIES} data-seed="dark-only" data-seed-scale-color="dark">
<Story />
</html>
);
Expand All @@ -49,29 +54,18 @@ export const SeedThemeDecorator: Decorator = (Story, ctx) => {

return (
<html
lang="ko"
{...DEFAULT_PROPERTIES}
data-seed="light-only"
data-seed-scale-color="light"
data-seed-scale-letter-spacing="ios"
style={{
display: "flex",
flexDirection: "column",
padding: "0 20px",
fontSize: fontScaleMap[fontScale],
}}
style={{ ...DEFAULT_PROPERTIES.style, fontSize: fontScaleMap[fontScale] }}
>
<Story />
</html>
);
}

return (
<html
lang="ko"
data-seed="light-only"
data-seed-scale-color="light"
data-seed-scale-letter-spacing="ios"
>
<html {...DEFAULT_PROPERTIES} data-seed="light-only" data-seed-scale-color="light">
<Story />
</html>
);
Expand Down

0 comments on commit 87521fb

Please sign in to comment.