Skip to content

Commit 6f59131

Browse files
joshuaellisjhoward1994madhurisandbhor
authored
docs: remove website & enhance storybook (#1697)
Co-authored-by: Jamie Howard <[email protected]> Co-authored-by: Madhuri Sandbhor <[email protected]>
1 parent 9fdfdde commit 6f59131

File tree

137 files changed

+15334
-6359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+15334
-6359
lines changed

.changeset/calm-pets-live.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': minor
3+
---
4+
5+
feat: typography now extends Box

.yarn/patches/@storybook-blocks-npm-7.6.17-481e2fff02.patch

Lines changed: 14118 additions & 0 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ making a pull request that may not align with the project roadmap.
1313

1414
**Before submitting your pull request** make sure the following requirements are fulfilled:
1515

16-
- Fork the repository and create your new branch from `main`.
16+
- Fork the repository and create your new branch from `develop`.
1717
- Run `yarn` in the root of the repository.
1818
- If you've fixed a bug or added code that should be tested, please make sure to add tests
1919
- Ensure the following test suites are passing:
@@ -46,18 +46,6 @@ yarn develop
4646

4747
Storybook will be running on `localhost:6006` for you to test your changes to components or their documentation.
4848

49-
### 4. Start the website for documentation changes (optional)
50-
51-
Start the DS website to test your changes on the design-system website, not all changes would require this step.
52-
53-
```bash
54-
cd website
55-
yarn
56-
yarn dev
57-
```
58-
59-
**Awesome! You are now able to contribute to Strapi Design System.**
60-
6149
---
6250

6351
## Git Conventions
@@ -109,7 +97,7 @@ Use `kebab-case` to name your branches: `prefix/branch-name-something`
10997

11098
- `fix`: When fixing an issue: `fix/some-bug`
11199
- `chore`: When doing some cleanup, working on tooling, some refactoring: `chore/update-dependencies`
112-
- `doc`: When writing documentation: `doc/documentation-subject`
100+
- `docs`: When writing documentation: `doc/documentation-subject`
113101
- `feature`: When you are working on a feature. Start by creating a `feature/name-of-feature` branch & create tasks branches with the feature name as prefix:
114102
- `feature/i18n` is the main feature branch
115103
- `i18n/init-plugin` is a task for this feature
@@ -118,7 +106,7 @@ The most important thing to remember is to make your intention explicit. Try to
118106

119107
## Pull Requests
120108

121-
New pull requests should be done either against `main` or against the related feature branch (see [Git Conventions](#branches)). You can reference the Jira task ID in the Pull Request description.
109+
New pull requests should be done either against `develop` or against the related feature branch (see [Git Conventions](#branches)). You can reference the Jira task ID in the Pull Request description.
122110

123111
If your pull request is against `main` don't forget to add it to the relevant milestone. If you are not sure which one to select, use the one for the next release.
124112

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</a>
55
</p>
66
<p align="center">
7-
<a style='margin-right:10px' href="https://design-system.strapi.io/">Documentation</a>|<a style='margin-left:10px' href="https://design-system-git-main-strapijs.vercel.app/">Try components</a></p>
7+
<a href="https://v2.design-system.strapi.io/">Documentation</a>
88
<br />
99

1010
[![Version](https://img.shields.io/npm/v/@strapi/design-system?style=flat&colorA=4945ff&colorB=4945ff)](https://www.npmjs.com/package/@strapi/design-system)

docs/.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
**/node_modules/**
21
storybook-static

docs/.eslintrc

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
{
22
"root": true,
33
"extends": ["@strapi/eslint-config/front/typescript"],
4-
"parserOptions": {
5-
"project": ["./tsconfig.eslint.json"]
6-
},
7-
"settings": {
8-
"import/resolver": {
9-
"typescript": {
10-
"project": "./tsconfig.eslint.json"
11-
}
12-
}
13-
},
14-
"ignorePatterns": ["**/*.mdx/*.{ts,tsx}"],
154
"overrides": [
165
{
176
"files": ["*.stories.tsx"],
@@ -23,21 +12,19 @@
2312
"error",
2413
{
2514
"selector": "ImportDeclaration[source.value='react'][specifiers.0.type='ImportDefaultSpecifier']",
26-
"message": "Default React import not allowed"
27-
}
28-
]
29-
}
15+
"message": "Default React import not allowed",
16+
},
17+
],
18+
},
3019
},
3120
{
3221
"files": ["*.mdx"],
3322
"extends": ["plugin:mdx/recommended"],
3423
"rules": {
24+
"react/jsx-no-undef": "off",
3525
"import/namespace": "off",
36-
"@typescript-eslint/no-unused-vars": "error"
37-
}
38-
}
26+
"@typescript-eslint/no-unused-vars": "error",
27+
},
28+
},
3929
],
40-
"rules": {
41-
"import/no-unresolved": "off"
42-
}
4330
}

docs/.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "all",
4+
"singleQuote": true,
5+
"printWidth": 120,
6+
"tabWidth": 2,
7+
"proseWrap": "always"
8+
}

docs/.storybook/main.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,39 @@ const config: StorybookConfig = {
2121
if (config.mode !== 'production') {
2222
config.optimizeDeps = {
2323
...config.optimizeDeps,
24-
exclude: ['@strapi/ui-primtivies', '@strapi/design-system', '@strapi/icons'],
24+
include: [
25+
...(config.optimizeDeps?.include ?? []),
26+
'react',
27+
`react/jsx-runtime`,
28+
'react-dom/client',
29+
'styled-components',
30+
],
31+
exclude: [
32+
...(config.optimizeDeps?.exclude ?? []),
33+
'@strapi/ui-primitives',
34+
'@strapi/design-system',
35+
'@strapi/icons',
36+
],
2537
};
2638

2739
if (!config.resolve) {
2840
config.resolve = {};
2941
}
3042

43+
config.resolve.dedupe = [
44+
...(config.resolve?.dedupe ?? []),
45+
'react',
46+
'react-dom',
47+
'react-router-dom',
48+
'styled-components',
49+
];
50+
3151
config.resolve.alias = {
3252
...config.resolve?.alias,
3353
'@strapi/ui-primitives': resolve(__dirname, '..', '..', 'packages', 'primitives', 'src'),
3454
'@strapi/design-system': resolve(__dirname, '..', '..', 'packages', 'strapi-design-system', 'src'),
3555
'@strapi/icons': resolve(__dirname, '..', '..', 'packages', 'strapi-icons', 'src'),
56+
'styled-components': resolve(__dirname, '..', '..', 'node_modules', 'styled-components'),
3657
};
3758
}
3859

docs/.storybook/manager.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/.storybook/preview-head.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
<style>
22
body {
3+
margin: 0;
34
padding: 0 !important;
5+
-webkit-font-smoothing: antialiased;
6+
-moz-osx-font-smoothing: grayscale;
7+
height: 100vh;
8+
overflow: auto;
49
}
510

6-
#storybook-root:not([hidden='true']) {
7-
display: flex;
8-
justify-content: stretch;
9-
align-items: stretch;
11+
#storybook-root {
1012
height: 100%;
1113
}
14+
15+
.sbdocs.sbdocs-content > .sb-unstyled {
16+
height: 100%;
17+
}
18+
19+
.sbdocs.sbdocs-wrapper {
20+
padding: 0;
21+
}
22+
23+
.sbdocs.sbdocs-content {
24+
max-width: unset;
25+
}
1226
</style>

docs/.storybook/preview.tsx

Lines changed: 118 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,136 @@ import { Preview } from '@storybook/react';
33
import { useDarkMode } from 'storybook-dark-mode';
44
import { parse } from 'qs';
55

6-
import { VisuallyHidden, DesignSystemProvider, Box, darkTheme, lightTheme } from '@strapi/design-system';
6+
import { DesignSystemProvider, Box, darkTheme, lightTheme, type BoxProps } from '@strapi/design-system';
77

8-
import { createCustomTheme } from './utils/createCustomTheme';
8+
import { DocsContainer, Unstyled } from '@storybook/blocks';
9+
import styled, { DefaultTheme } from 'styled-components';
10+
import { MARKDOWN_OVERRIDES, Markdown } from '../components/Markdown';
11+
12+
const createCustomTheme = (theme: DefaultTheme, base: 'light' | 'dark' = 'light') => {
13+
return {
14+
base,
15+
brandTitle: 'Strapi Design System',
16+
brandUrl: 'https://strapi.io/',
17+
brandImage: base === 'light' ? '/site/logo.svg' : '/site/logo_dark.svg',
18+
19+
//
20+
colorPrimary: theme.colors.primary600,
21+
colorSecondary: theme.colors.secondary600,
22+
23+
// UI
24+
appBg: theme.colors.neutral100,
25+
appContentBg: theme.colors.neutral0,
26+
appPreviewBg: theme.colors.neutral0,
27+
appBorderColor: theme.colors.neutral200,
28+
29+
// Text colors
30+
textColor: theme.colors.neutral800,
31+
textInverseColor: theme.colors.neutral800,
32+
33+
// Toolbar default and active colors
34+
barTextColor: theme.colors.neutral800,
35+
barSelectedColor: theme.colors.primary600,
36+
barHoverColor: theme.colors.primary600,
37+
barBg: theme.colors.neutral0,
38+
39+
// Form colors
40+
inputBg: theme.colors.neutral0,
41+
inputBorder: theme.colors.neutral800,
42+
inputTextColor: theme.colors.neutral800,
43+
};
44+
};
45+
46+
const themeQueryURL = parse(document.location.search).theme;
47+
48+
const Theme = ({ children, ...props }: BoxProps) => {
49+
const isDarkAddon = useDarkMode();
50+
const [isDark, setIsDark] = React.useState(themeQueryURL || isDarkAddon);
51+
52+
React.useEffect(() => {
53+
if (!themeQueryURL && isDarkAddon !== isDark) {
54+
setIsDark(isDarkAddon);
55+
}
56+
}, [isDarkAddon, isDark]);
57+
58+
return (
59+
<DesignSystemProvider locale="en" theme={isDark ? darkTheme : lightTheme}>
60+
<Main as="main" background="neutral0" padding="4rem" paddingBottom="8rem" height="100%">
61+
<Box maxWidth="84rem" margin="auto" height="100%" {...props}>
62+
{children}
63+
</Box>
64+
</Main>
65+
</DesignSystemProvider>
66+
);
67+
};
68+
69+
const Main = styled(Box)`
70+
.sbdocs-preview {
71+
border: solid 1px ${(props) => props.theme.colors.neutral200};
72+
73+
.docs-story > div {
74+
background: ${(props) => props.theme.colors.neutral0};
75+
}
76+
}
77+
78+
.docblock-argstable {
79+
border: solid 1px ${(props) => props.theme.colors.neutral200};
80+
81+
table > tbody {
82+
border: solid 1px ${(props) => props.theme.colors.neutral200} !important;
83+
}
84+
}
85+
86+
.docblock-argstable tr th {
87+
color: ${(props) => props.theme.colors.neutral800};
88+
}
89+
90+
.docblock-argstable tr td {
91+
color: ${(props) => props.theme.colors.neutral800} !important;
92+
background-color: ${(props) => props.theme.colors.neutral0} !important;
93+
border-inline: unset !important;
94+
border-block: unset !important;
95+
border-top: solid 1px ${(props) => props.theme.colors.neutral200} !important;
96+
}
97+
98+
.docblock-code-toggle {
99+
cursor: pointer;
100+
border: 1px solid ${(props) => props.theme.colors.neutral200};
101+
background: ${(props) => props.theme.colors.neutral150};
102+
color: ${(props) => props.theme.colors.neutral800};
103+
}
104+
105+
.docblock-code-toggle:hover {
106+
background-color: ${(props) => props.theme.colors.neutral100};
107+
}
108+
`;
9109

10110
const preview: Preview = {
11111
decorators: [
12112
(Story) => (
13113
<Theme>
14-
<main>
15-
<VisuallyHidden>
16-
{/* Necessary in order to prevent axe core from providing errors on main / heading */}
17-
<h1>Storybook story</h1>
18-
</VisuallyHidden>
19-
<Box height="100%" padding={2}>
20-
<Story />
21-
</Box>
22-
</main>
114+
<Story />
23115
</Theme>
24116
),
25117
],
26118
parameters: {
119+
docs: {
120+
container: ({ children, ...props }: { children: any; context: any }) => (
121+
<DocsContainer {...props}>
122+
<Unstyled>
123+
<Theme>{children}</Theme>
124+
</Unstyled>
125+
</DocsContainer>
126+
),
127+
components: MARKDOWN_OVERRIDES,
128+
},
27129
options: {
28130
storySort: {
29131
order: [
132+
'Getting Started',
133+
['Welcome', 'Contributing', 'Changelog', 'Migration Guides', ['V1 to V2']],
30134
'Foundations',
31-
['Overview', 'Icons', ['Overview', '*']],
135+
['Accessibility', 'Color', 'Grid', 'Icons', ['Overview', '*'], 'Typography'],
32136
'Primitives',
33137
['Overview', '*'],
34138
'Inputs',
@@ -38,38 +142,13 @@ const preview: Preview = {
38142
],
39143
},
40144
},
41-
actions: { argTypesRegex: '^on[A-Z].*' },
42-
controls: {
43-
expanded: true,
44-
},
45145
darkMode: {
46146
// Override the default dark theme
47-
dark: createCustomTheme({ theme: darkTheme, asStorybookTheme: false }),
147+
dark: createCustomTheme(darkTheme, 'dark'),
48148
// Override the default light theme
49-
light: createCustomTheme({ theme: lightTheme, asStorybookTheme: false }),
149+
light: createCustomTheme(lightTheme),
50150
},
51151
},
52152
};
53153

54-
const themeQueryURL = parse(document.location.search).theme;
55-
56-
const Theme = ({ children }: { children: React.ReactNode }) => {
57-
const isDarkAddon = useDarkMode();
58-
const [isDark, setIsDark] = React.useState(themeQueryURL || isDarkAddon);
59-
60-
React.useEffect(() => {
61-
if (!themeQueryURL && isDarkAddon !== isDark) {
62-
setIsDark(isDarkAddon);
63-
}
64-
}, [isDarkAddon, isDark]);
65-
66-
return (
67-
<DesignSystemProvider locale="en" theme={isDark ? darkTheme : lightTheme}>
68-
<Box flex="1 0 100%" padding={2} background="neutral0">
69-
{children}
70-
</Box>
71-
</DesignSystemProvider>
72-
);
73-
};
74-
75154
export default preview;

0 commit comments

Comments
 (0)