Skip to content

Commit

Permalink
fix: markdown story styling (#1536)
Browse files Browse the repository at this point in the history
* fix: markdown story styling

* refactor(docs): dry markdown wrapping components and shink document styling

* refactor(docs): dry docs stories more
  • Loading branch information
jinlee93 authored Mar 10, 2023
1 parent 4598445 commit 89eba6b
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 195 deletions.
58 changes: 0 additions & 58 deletions .storybook/components/Docs/Documents.stories.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { StoryObj } from '@storybook/react';
import React from 'react';
import GettingStartedDocs from '../../../../docs/GETTING_STARTED.md';
import { markdownStorybookOptions } from '../MarkdownWrapper';
export default {
title: 'Getting Started',
component: GettingStartedDocs,
...markdownStorybookOptions,
};

export const GettingStarted: StoryObj = {
render: () => <GettingStartedDocs />,
};
38 changes: 38 additions & 0 deletions .storybook/components/Docs/Guildelines/Documents.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { StoryObj } from '@storybook/react';
import React from 'react';
import Code from '../../../../docs/CODE_GUIDELINES.md';
import ComponentDocs from '../../../../docs/COMPONENTS.md';
import IconDocs from '../../../../docs/ICONS.md';
import LayoutDocs from '../../../../docs/LAYOUT.md';
import TokenDocs from '../../../../docs/TOKENS.md';
import TypographyDocs from '../../../../docs/TYPOGRAPHY.md';
import { markdownStorybookOptions } from '../MarkdownWrapper';

export default {
title: 'Documentation/Guidelines',
...markdownStorybookOptions,
};

export const CodeGuidelines: StoryObj = {
render: () => <Code />,
};

export const Components: StoryObj = {
render: () => <ComponentDocs />,
};

export const Icons: StoryObj = {
render: () => <IconDocs />,
};

export const Layout: StoryObj = {
render: () => <LayoutDocs />,
};

export const Tokens: StoryObj = {
render: () => <TokenDocs />,
};

export const Typography: StoryObj = {
render: () => <TypographyDocs />,
};
105 changes: 105 additions & 0 deletions .storybook/components/Docs/MarkdownWrapper.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
.markdown {
body {
margin: 8px;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: bold;
}
h1 {
font-size: 2em;
margin-block-start: 0.67em;
margin-block-end: 0.67em;
}
h2 {
font-size: 1.5em;
margin-block-start: 0.83em;
margin-block-end: 0.83em;
}
h3 {
font-size: 1.17em;
margin-block-start: 1em;
margin-block-end: 1em;
}
h4 {
margin-block-start: 1.33em;
margin-block-end: 1.33em;
}
h5 {
font-size: 0.83em;
margin-block-start: 1.67em;
margin-block-end: 1.67em;
}
h6 {
font-size: 0.67em;
margin-block-start: 2.33em;
margin-block-end: 2.33em;
}
a {
color: -webkit-link;
text-decoration: underline;
}
hr {
margin-block-start: 0.5em;
margin-block-end: 0.5em;
margin-inline-start: auto;
margin-inline-end: auto;
}
dl,
p {
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}
dd {
margin-inline-start: 40px;
}
pre {
margin: 1em 0px;
}
fieldset {
margin-inline-start: 2px;
margin-inline-end: 2px;
padding-block-start: 0.35em;
padding-inline-start: 0.75em;
padding-inline-end: 0.75em;
padding-block-end: 0.625em;
}
legend {
padding-inline-start: 2px;
padding-inline-end: 2px;
}
ol,
ul {
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
padding-inline-start: 40px;
}
ol {
list-style-type: decimal;
}
ul {
list-style-type: disc;
}
ul ul,
ol ul {
list-style-type: circle;
}
ol ul,
ul ol,
ol ol,
ul ul {
margin-block-start: 0px;
margin-block-end: 0px;
}
textarea {
resize: auto;
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
import type { Story } from '@storybook/react';
import type { ReactNode } from 'react';
import React, { useEffect } from 'react';
// @ts-expect-error prism.js must be in JS
import Prism from './prism';
import { LayoutContainer } from '../../../src/components/LayoutContainer/LayoutContainer';
import { LayoutLinelengthContainer } from '../../../src/components/LayoutLinelengthContainer/LayoutLinelengthContainer';
import './prism.css';
import styles from './MarkdownWrapper.module.css';

export interface Props {
type MarkdownWrapperProps = {
/**
* Child node(s) that can be nested inside component
*/
children?: ReactNode;
}
children: ReactNode;
};

export const Documentation: React.FC<Props> = ({ children }) => {
export const MarkdownWrapper = ({ children }: MarkdownWrapperProps) => {
useEffect(() => {
Prism.highlightAll();
}, []);
return (
<LayoutContainer>
<LayoutContainer className={styles['markdown']}>
<LayoutLinelengthContainer>{children}</LayoutLinelengthContainer>
</LayoutContainer>
);
};

export const markdownStorybookOptions = {
parameters: {
chromatic: { disableSnapshot: true },
axe: {
skip: true,
},
},
decorators: [
(Story: Story) => (
<MarkdownWrapper>
<Story />
</MarkdownWrapper>
),
],
};
14 changes: 14 additions & 0 deletions .storybook/components/Docs/Recipes/Recipes.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { StoryObj } from '@storybook/react';
import React from 'react';
import RecipesDocs from '../../../../docs/RECIPES.md';
import { markdownStorybookOptions } from '../MarkdownWrapper';

export default {
title: 'Documentation/Recipes',
component: RecipesDocs,
...markdownStorybookOptions,
};

export const Recipes: StoryObj = {
render: () => <RecipesDocs />,
};
14 changes: 14 additions & 0 deletions .storybook/components/Docs/Theming/Theming.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { StoryObj } from '@storybook/react';
import React from 'react';
import ThemingDocs from '../../../../docs/THEMING.md';
import { markdownStorybookOptions } from '../MarkdownWrapper';

export default {
title: 'Documentation/Theming',
component: ThemingDocs,
...markdownStorybookOptions,
};

export const Theming: StoryObj = {
render: () => <ThemingDocs />,
};
23 changes: 0 additions & 23 deletions .storybook/components/GettingStarted/GettingStarted.stories.tsx

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions .storybook/components/Recipes/Recipes.stories.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions .storybook/components/Recipes/RecipesDocumentation.tsx

This file was deleted.

Loading

0 comments on commit 89eba6b

Please sign in to comment.