This repository has been archived by the owner on Oct 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
styleguide.config.js
86 lines (80 loc) · 2.41 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
const path = require('path');
const camelCase = require('lodash').camelCase;
const fs = require('fs');
const MiniHtmlWebpackPlugin = require('mini-html-webpack-plugin');
const { generateCSSReferences, generateJSReferences } = MiniHtmlWebpackPlugin;
const dir = path.join(__dirname, 'src');
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
module.exports = {
title: 'Nordnet UI Kit',
styleguideDir: path.join(__dirname, 'documentation/dist'),
skipComponentsWithoutExample: true,
template: ({ css, js, title, publicPath }) =>
`<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>${title}</title>
${generateCSSReferences(css, publicPath)}
<link href="https://fonts.googleapis.com/css?family=Bitter:400,700|Open+Sans:300,400,600,700,800" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
</head>
<body>
<div id="rsg-root"></div>
${generateJSReferences(js, publicPath)}
</body>
</html>
`,
sections: [
{
name: 'Components',
components: () => {
const componentPath = `${dir}/components`;
const folders = fs.readdirSync(componentPath);
return folders
.filter(c => fs.statSync(path.join(componentPath, c)).isDirectory()) // Filter out directories
.map(folder => `${dir}/components/${folder}/${folder}.jsx`);
},
},
{
name: 'Theme',
components: './documentation/theme/*.jsx',
},
],
getComponentPathLine(componentPath) {
if (componentPath.indexOf('documentation') !== -1) {
return '';
}
const fileName = path.basename(componentPath, '.jsx');
const componentName = capitalize(camelCase(fileName));
return `import { ${componentName} } from 'nordnet-ui-kit';`;
},
getExampleFilename(componentPath) {
return componentPath.replace(/\.jsx?$/, '.md');
},
styleguideComponents: {
Wrapper: path.join(__dirname, 'documentation', 'wrapper.jsx'),
},
moduleAliases: {
'nordnet-ui-kit': path.resolve(__dirname, 'src'),
},
webpackConfig: {
module: {
rules: [
{
test: /.jsx?$/,
use: 'babel-loader',
exclude: /node_modules/,
},
],
},
devServer: {
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
},
};