-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathstyleguide.config.js
82 lines (78 loc) · 2.57 KB
/
styleguide.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const path = require('path');
const packagejson = require('./package.json');
// Filter props from styleguidist that don't have description in interface or are from react typings
const propFilter = (prop, parent) => {
if (prop.description.length === 0) {
return false;
}
// Remove margin props from props table expect for Block component
if (
['margin', 'mx', 'my', 'mt', 'mr', 'mb', 'ml'].includes(prop.name) &&
parent?.name !== 'Block'
) {
return false;
}
if (prop.parent == null) {
return true;
}
return prop.parent.fileName.indexOf('node_modules/@types/react') < 0;
};
const requireFiles = (axe) => [
...(!!axe
? [path.join(__dirname, '.styleguidist/styleguidist.require.axe.js')]
: []),
path.join(__dirname, '.styleguidist/styleguidist.require.js'),
];
const buildDirectory = (buildType) =>
buildType === 'ASSETS' ? 'tmp' : 'styleguide';
module.exports = {
title: `Suomifi-ui-components ${packagejson.version}`,
components: 'src/core/**/[A-Z]*.tsx',
ignore: ['**/*basestyles.tsx', '**/*baseStyles.tsx', '**/*test.tsx'],
webpackConfig: require('./.styleguidist/webpack.config.js'),
require: requireFiles(!!process.env.AXE),
assetsDir: path.join(__dirname, '.styleguidist/assets'),
resolver: require('react-docgen').resolver.findAllComponentDefinitions,
propsParser: require('react-docgen-typescript').withDefaultConfig({
propFilter,
}).parse,
moduleAliases: {
'suomifi-ui-components': path.resolve(__dirname, 'src'),
'rsg-components/ComponentsList/ComponentsListRenderer': path.resolve(
__dirname,
'node_modules/react-styleguidist/lib/client/rsg-components/ComponentsList/ComponentsListRenderer',
),
},
exampleMode: 'expand',
usageMode: 'expand',
pagePerSection: true,
tocMode: 'collapse',
skipComponentsWithoutExample: false,
getExampleFilename: (componentPath) =>
componentPath.replace(/\.tsx?$/, '.md'),
template: {
head: {
links: [
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600&display=swap',
},
],
},
},
theme: {
fontFamily: {
base: '"Source Sans Pro", sans-serif',
},
},
styleguideDir: buildDirectory(process.env.BUILD_TYPE),
styles: require('./.styleguidist/styleguidist.styles.js'),
sections: require('./.styleguidist/styleguidist.sections.js').sections,
styleguideComponents: {
StyleGuideRenderer: path.join(
__dirname,
'.styleguidist/StyleGuideRenderer',
),
ComponentsList: path.join(__dirname, '.styleguidist/ComponentsList'),
},
};