-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstyleguide.config.js
88 lines (82 loc) · 2.29 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
83
84
85
86
87
88
const path = require('path');
const { parse, resolver } = require('react-docgen');
const { withDefaultConfig } = require('react-docgen-typescript');
const { createWebpackConfiguration } = require('@tarantool.io/webpack-config');
const tsParser = withDefaultConfig({
savePropValueAsString: true,
}).parse;
const propsParser = function (filePath, source) {
if (filePath.endsWith('.ts') || filePath.endsWith('.tsx')) {
return tsParser(filePath);
}
return parse(source);
};
const webpackConfig = createWebpackConfiguration({
root: __dirname,
entry: path.join(__dirname, 'src', 'index.js'),
lint: true,
emotion: true,
svgSprite: true,
middleware: (cfg) => {
delete cfg.devServer;
return cfg;
},
});
module.exports = {
getComponentPathLine: (componentPath) => {
const exceptions = ['Icon'];
const dir = path.dirname(componentPath);
const fileName = path.basename(componentPath);
const name = fileName === 'index.js' || fileName === 'index.ts' ? dir.slice(dir.lastIndexOf('/') + 1) : fileName;
if (exceptions.includes(name)) return;
return `import { ${name} } from '@tarantool.io/ui-kit';`;
},
ignore: ['src/components/SyntaxHighlight/*'],
sections: [
{
name: 'Intro',
content: './readme.md',
},
{
name: 'Colors',
content: './colors.md',
},
{
name: 'UI Components',
content: './components.md',
components: 'src/components/*/index.{ts,js}',
sectionDepth: 1,
},
{
name: 'Generic styles',
content: 'src/genericStyles/readme.md',
},
{
name: 'GitHub',
href: 'https://github.com/tarantool/front-ui-kit',
external: true,
},
],
template: {
head: {
links: [
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=Source+Code+Pro:wght@400;500&display=swap',
},
],
},
},
moduleAliases: {
'@tarantool.io/ui-kit': path.resolve(__dirname, 'src'),
},
pagePerSection: true,
styleguideDir: 'docs',
title: 'Tarantool UI-Kit',
usageMode: 'expand', // 'hide' | 'collapse' | 'expand'
exampleMode: 'expand', // 'hide' | 'collapse' | 'expand'
version: require('./package').version,
resolver: resolver.findAllComponentDefinitions,
propsParser,
webpackConfig,
};