-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDS-1644' of github.com:coingaming/moon-light into MDS-…
…1644
- Loading branch information
Showing
6 changed files
with
211 additions
and
1 deletion.
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,5 @@ | ||
--- | ||
"docs": minor | ||
--- | ||
|
||
feat: add Typography documentation [MDS-1642] |
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,20 @@ | ||
import type { Preview } from "@storybook/react"; | ||
import "../app/globals.css"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
options: { | ||
storySort: { | ||
order: ["Typography", "Components"], | ||
}, | ||
}, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
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,43 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { captionsSizes } from "./constants"; | ||
|
||
type Size = { size: string }; | ||
|
||
const meta: Meta<Size> = { | ||
title: "Typography/Caption", | ||
tags: ["autodocs"], | ||
argTypes: { | ||
size: { | ||
table: { | ||
type: { | ||
summary: captionsSizes.join(" | "), | ||
}, | ||
}, | ||
description: | ||
"By default, there are just two caption sizes with different letter-spacing, and are defined with text-moon-XX-caption class names. You also need to make them uppercase.", | ||
control: { | ||
type: "select", | ||
}, | ||
options: captionsSizes, | ||
}, | ||
}, | ||
render: ({ size }: Size) => { | ||
const match = size.match(/-(\d+)-/); | ||
const sizeValue = match ? Number(match[1]) : null; | ||
return ( | ||
<span className={`text-moon-${sizeValue}-caption uppercase`}> | ||
Size {sizeValue} | ||
</span> | ||
); | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<Size>; | ||
|
||
export const Caption: Story = { | ||
args: { | ||
size: "text-moon-9-caption", | ||
}, | ||
}; |
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,77 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { COLORS, FONT_WEIGHTS, TEXT_DECORATIONS } from "./constants"; | ||
|
||
const colorsValues = COLORS.map((color) => `text-${color}`); | ||
type Color = (typeof colorsValues)[number]; | ||
type FontWeightType = (typeof FONT_WEIGHTS)[number]; | ||
type TextDecorationType = (typeof TEXT_DECORATIONS)[number]; | ||
|
||
type CustomType = { | ||
weight: FontWeightType; | ||
color: Color; | ||
textDecoration: TextDecorationType; | ||
}; | ||
|
||
const meta: Meta<CustomType> = { | ||
title: "Typography/Custom", | ||
tags: ["autodocs"], | ||
argTypes: { | ||
color: { | ||
description: "Class name to set color", | ||
control: { | ||
type: "select", | ||
}, | ||
options: colorsValues, | ||
table: { | ||
type: { | ||
summary: colorsValues.join(" | "), | ||
}, | ||
}, | ||
}, | ||
weight: { | ||
description: "Class name to set font-weight", | ||
control: { | ||
type: "select", | ||
}, | ||
options: FONT_WEIGHTS, | ||
table: { | ||
type: { | ||
summary: FONT_WEIGHTS.join(" | "), | ||
}, | ||
}, | ||
}, | ||
textDecoration: { | ||
description: "Class name to set text-decoration", | ||
control: { | ||
type: "select", | ||
}, | ||
options: TEXT_DECORATIONS, | ||
table: { | ||
type: { | ||
summary: TEXT_DECORATIONS.join(" | "), | ||
}, | ||
}, | ||
}, | ||
}, | ||
render: ({ color, textDecoration, weight }: CustomType) => { | ||
return ( | ||
<div className="grid grid-flow-col"> | ||
<p className={color}>Color: {color}</p> | ||
<p className={weight}>Font-weight: {weight}</p> | ||
<p className={textDecoration}>Text-transform: {textDecoration}</p> | ||
</div> | ||
); | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<CustomType>; | ||
|
||
export const Custom: Story = { | ||
args: { | ||
color: "text-piccolo", | ||
weight: "font-medium", | ||
textDecoration: "underline", | ||
}, | ||
}; |
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,42 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { textSizes } from "./constants"; | ||
|
||
type SizeType = { | ||
size: string; | ||
}; | ||
|
||
const meta: Meta<SizeType> = { | ||
title: "Typography/Size", | ||
tags: ["autodocs"], | ||
argTypes: { | ||
size: { | ||
description: | ||
"To change font size, use one of the predefined class names such as text-moon-XX. Those class names include a combination of font-size, line-height, and letter-spacing properties where applicable.", | ||
control: { | ||
type: "select", | ||
}, | ||
table: { | ||
type: { | ||
summary: textSizes.join(" | "), | ||
}, | ||
}, | ||
options: textSizes, | ||
}, | ||
}, | ||
render: ({ size }: { size: string }) => { | ||
const match = size.match(/-(\d+)$/); | ||
const sizeValue = match ? Number(match[1]) : null; | ||
|
||
return <p className={size}>Size {sizeValue}</p>; | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<SizeType>; | ||
|
||
export const Size: Story = { | ||
args: { | ||
size: "text-moon-20", | ||
}, | ||
}; |
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