From c3610bbe0f63835a4e3bccba97d03c31aeb62990 Mon Sep 17 00:00:00 2001 From: sohee Date: Wed, 24 Apr 2024 19:52:21 +0900 Subject: [PATCH] feat: Fonts storybook --- apps/docs/src/index.css | 65 +++++++++++++++++------- apps/docs/src/stories/Colors.stories.tsx | 2 +- apps/docs/src/stories/Fonts.stories.tsx | 57 +++++++++++++++++++++ 3 files changed, 104 insertions(+), 20 deletions(-) create mode 100644 apps/docs/src/stories/Fonts.stories.tsx diff --git a/apps/docs/src/index.css b/apps/docs/src/index.css index c0e710b..4e11abb 100644 --- a/apps/docs/src/index.css +++ b/apps/docs/src/index.css @@ -2,46 +2,41 @@ box-sizing: border-box; padding: 0; margin: 0; - font-family: 'SUIT', sans-serif; + font-family: "SUIT", sans-serif; font-style: normal; } body { - background-color: rgb(0,0,0) + background-color: rgb(0, 0, 0); } @font-face { - font-family: 'SUIT'; - src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Light.woff2') - format('woff2'); + font-family: "SUIT"; + src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Light.woff2") format("woff2"); font-weight: 300; font-style: normal; } @font-face { - font-family: 'SUIT'; - src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Regular.woff2') - format('woff2'); + font-family: "SUIT"; + src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; } @font-face { - font-family: 'SUIT'; - src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Medium.woff2') - format('woff2'); + font-family: "SUIT"; + src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; } @font-face { - font-family: 'SUIT'; - src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-SemiBold.woff2') - format('woff2'); + font-family: "SUIT"; + src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; } @font-face { - font-family: 'SUIT'; - src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Bold.woff2') - format('woff2'); + font-family: "SUIT"; + src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; } @@ -58,7 +53,7 @@ body { flex-direction: column; gap: 16px; color: white; - font-family: 'SUIT', sans-serif; + font-family: "SUIT", sans-serif; h4 { font-size: 28px; @@ -101,4 +96,36 @@ body { height: 80px; } } -} \ No newline at end of file +} + +.fonts-wrap { + padding: 20px; + color: white; + display: flex; + flex-direction: column; + gap: 20px; + width: 1000px; +} + +.fonts-group { + border: 1px solid #3f3f47; + padding: 15px 20px; + border-radius: 10px; + + & > p:first-of-type { + font-size: 20px; + font-weight: 700; + margin-bottom: 16px; + } + & > div { + margin-bottom: 16px; + + p { + color: #c3c3c6; + font-size: 16px; + } + span { + color: #808087; + } + } +} diff --git a/apps/docs/src/stories/Colors.stories.tsx b/apps/docs/src/stories/Colors.stories.tsx index 0990324..c0b8c2b 100644 --- a/apps/docs/src/stories/Colors.stories.tsx +++ b/apps/docs/src/stories/Colors.stories.tsx @@ -17,7 +17,7 @@ export const Default = { }); return
-

* 마우스 오버시 이름과 코드가 뜹니다 *

+

* 마우스 오버시 이름과 코드가 뜹니다 *

Main Color

diff --git a/apps/docs/src/stories/Fonts.stories.tsx b/apps/docs/src/stories/Fonts.stories.tsx new file mode 100644 index 0000000..105a410 --- /dev/null +++ b/apps/docs/src/stories/Fonts.stories.tsx @@ -0,0 +1,57 @@ +import { fontsObject } from '@sopt-makers/fonts'; +import { ChangeEvent, useState } from 'react'; +import { TextField } from '@sopt-makers/ui'; + +export default { + title: 'fonts/Fonts' +} + +type FontName = keyof typeof fontsObject; + +const useInput = (defaultValue: string) => { + const [input, setInput] = useState(defaultValue); + + const handleInputChange = (e: ChangeEvent) => { + setInput(e.target.value); + } + + return [input, handleInputChange] as const; +} + +export const Default = () => { + const [text, handleTextChange] = useInput('SOPT에 없던 새로운 가치를 프로덕트를 통해 만들어 갑니다.'); + + const getFontColor = (fontType: string) => { + switch (fontType) { + case 'HEADING': + return '#FFC234'; + case 'TITLE': + return '#16BF81'; + case 'BODY': + return '#F77234'; + case 'LABEL': + return '#346FFA'; + } + } + + return
+

* 공통 스타일 - fontFamily : SUIT / fontStyle : normal *

+ value={text} onChange={handleTextChange} placeholder="예시 문장을 입력해주세요" /> + + {Object.keys(fontsObject).map((fontName) => { + const fontObject = fontsObject[fontName as FontName]; + + return
+

{fontName}

+
+

fontWeight : {fontObject.fontWeight}

+

fontSize : {fontObject.fontSize}

+

lineHeight : {fontObject.lineHeight}

+

letterSpacing : {fontObject.letterSpacing}

+
+

{text}

+
+ } + )} +
+} \ No newline at end of file