Files: 612509945be4d8cb719d3b0a5a0390a0ddbcf911 / styles / index.js
917 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 | dracula: theme('dracula') |
34 | } |
35 |
Built with git-ssb-web