Files: 58ab0241031aa549a35cce1e678c27065ae66221 / styles / index.js
888 bytesRaw
1 | const path = require('path') |
2 | const fs = require('fs') |
3 | const compile = require('micro-css') |
4 | |
5 | const vendorPaths = [require.resolve('flatpickr/dist/flatpickr.css')] |
6 | const vendorCss = vendorPaths.map((vendorPath) => fs.readFileSync(vendorPath, 'utf8')) |
7 | |
8 | const theme = (themeName) => { |
9 | const themePath = path.join(__dirname, themeName) |
10 | const basePath = path.join(__dirname, 'base') |
11 | const dirs = [basePath, themePath] |
12 | |
13 | const mcss = [] |
14 | const css = [...vendorCss] |
15 | |
16 | dirs.forEach(dir => { |
17 | fs.readdirSync(dir).forEach(file => { |
18 | if (/\.mcss$/i.test(file)) { |
19 | mcss.push(fs.readFileSync(path.resolve(dir, file), 'utf8')) |
20 | } |
21 | if (/\.css$/i.test(file)) { |
22 | css.push(fs.readFileSync(path.resolve(dir, file), 'utf8')) |
23 | } |
24 | }) |
25 | }) |
26 | |
27 | return compile(mcss.join('\n')) + css.join('\n') |
28 | } |
29 | |
30 | module.exports = { |
31 | light: theme('light'), |
32 | dark: theme('dark') |
33 | } |
34 |
Built with git-ssb-web