-
Notifications
You must be signed in to change notification settings - Fork 46
/
copystyles.js
66 lines (56 loc) · 2.68 KB
/
copystyles.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
/**
* Node script to copy over CSS from <root>/button.css into ./src/Button.svelte
*/
const fs = require('fs');
/**
* Buttons
*/
let css = fs.readFileSync('../agnosticui-css/button.css', 'utf8');
const vue = fs.readFileSync('./src/stories/Button.vue', 'utf8');
const styleRegex = /<style module>([\s\S]*?)<\/style>/;
let withSynchronizedStyles = vue.replace(styleRegex, `<style module>\n${css}\n</style>`);
fs.writeFileSync('./src/stories/Button.vue', withSynchronizedStyles, 'utf8');
/**
* Button Groups
*/
css = fs.readFileSync('../agnosticui-css/button-group.css', 'utf8');
const vueButtonGroup = fs.readFileSync('./src/stories/ButtonGroup.vue', 'utf8');
const vueBtnGroupsSynchronizedStyles = vueButtonGroup.replace(styleRegex, `<style module>\n${css}\n</style>`);
fs.writeFileSync('./src/stories/ButtonGroup.vue', vueBtnGroupsSynchronizedStyles, 'utf8');
/**
* Progress
*/
css = fs.readFileSync('../agnosticui-css/progress.css', 'utf8');
const progressVue = fs.readFileSync('./src/stories/Progress.vue', 'utf8');
const progressSynchronized = progressVue.replace(styleRegex, `<style module>\n${css}\n</style>`);
fs.writeFileSync('./src/stories/Progress.vue', progressSynchronized, 'utf8');
/**
* Cards
*/
css = fs.readFileSync('../agnosticui-css/card.css', 'utf8');
const cardVue = fs.readFileSync('./src/stories/Card.vue', 'utf8');
const cardSynchronized = cardVue.replace(styleRegex, `<style module>\n${css}\n</style>`);
fs.writeFileSync('./src/stories/Card.vue', cardSynchronized, 'utf8');
/**
* Header
*/
css = fs.readFileSync('../agnosticui-css/header.css', 'utf8');
const headerVue = fs.readFileSync('./src/stories/Header.vue', 'utf8');
const headerSynchronized = headerVue.replace(styleRegex, `<style module>\n${css}\n</style>`);
fs.writeFileSync('./src/stories/Header.vue', headerSynchronized, 'utf8');
/**
* Header Navigation & Header Nav Item
*/
css = fs.readFileSync('../agnosticui-css/headernav.css', 'utf8');
const headerNavVue = fs.readFileSync('./src/stories/HeaderNav.vue', 'utf8');
const headerNavSynchronized = headerNavVue.replace(styleRegex, `<style module>\n${css}\n</style>`);
fs.writeFileSync('./src/stories/HeaderNav.vue', headerNavSynchronized, 'utf8');
css = fs.readFileSync('../agnosticui-css/headernavitem.css', 'utf8');
const headerNavItemVue = fs.readFileSync('./src/stories/HeaderNavItem.vue', 'utf8');
const headerNavItemSynchronized = headerNavItemVue.replace(styleRegex, `<style module>\n${css}\n</style>`);
fs.writeFileSync('./src/stories/HeaderNavItem.vue', headerNavItemSynchronized, 'utf8');
/**
* FlexGrid
*/
css = fs.readFileSync('../agnosticui-css/flexboxgrid-custom.css', 'utf8');
fs.writeFileSync('./src/stories/FlexGrid/FlexBoxGrid2Custom.module.css', css, 'utf8');