This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstyleguide.config.js
83 lines (76 loc) · 2.8 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
const path = require('path');
const fs = require('fs');
function brc(name) {
return path.resolve(__dirname, `node_modules/buildo-react-components/src/${name}/${name}.tsx`);
}
const brcComponents = fs.readdirSync(path.resolve(__dirname, 'node_modules/buildo-react-components/src'))
.filter(c => [
'index.ts',
'utils',
'KitchenSink',
'InputChildren',
'Scroll',
'TransitionWrapper'
].indexOf(c) === -1)
.map(brc);
module.exports = {
// build
serverPort: 8080,
styleguideDir: 'docs', // target of the `build` task
require: [
// "global" setup + sass imports
path.resolve(__dirname, 'styleguide/setup.ts')
],
styleguideComponents: {
Logo: path.resolve(__dirname, 'styleguide/components/Logo.tsx'),
StyleGuide: path.join(__dirname, 'styleguide/components/StyleGuide.tsx')
},
compilerConfig: {
objectAssign: 'Object.assign',
transforms: { dangerousTaggedTemplateString: true }
},
// content
title: '@buildo/react-components',
template: {
head: {
raw: `
<meta charset="utf-8">
<title>@buildo/react-components</title>
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://i.icomoon.io/public/5ba04e2a5e/Showroom/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
`
}
},
propsParser: require('react-docgen-typescript').parse, // detect docs using TS information
sections: [
{
name: 'Getting started',
content: 'sections/GettingStarted.md'
},
{
name: 'Components',
components: brcComponents.concat([
path.resolve(__dirname, 'node_modules/react-autosize-textarea/src/TextareaAutosize.tsx'),
path.resolve(__dirname, 'node_modules/react-cookie-banner/src/CookieBanner.tsx'),
path.resolve(__dirname, 'node_modules/react-flexview/src/FlexView.tsx')
]).sort((a, b) => a.split('/').slice(-1)[0].toLowerCase() > b.split('/').slice(-1)[0].toLowerCase() ? 1 : -1),
}
],
getComponentPathLine(componentPath) {
const name = path.basename(componentPath, '.tsx');
switch (name) {
case 'TextareaAutosize': return `import TextareaAutosize from "react-autosize-textarea"`;
case 'CookieBanner': return `import CookieBanner from "react-cookie-banner"`;
case 'FlexView': return `import FlexView from "react-flexview"`;
default: return `import ${name} from "buildo-react-components/lib/${name}";`;
}
},
getExampleFilename(componentPath) {
if (componentPath.includes('buildo-react-components')) {
return componentPath.split('/').slice(0, -1).concat('Examples.md').join('/');
} else {
return componentPath.split('/').slice(0, -2).concat(['examples', 'Examples.md']).join('/');
}
}
};