Load the Material colour scheme directly from the source YAML, rather than hardcoding it into Stylus format

This commit is contained in:
Danielle McLean 2017-10-27 11:33:01 +11:00
parent 9d91cec6f9
commit 0419a844ce
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
8 changed files with 45 additions and 20 deletions

View file

@ -192,7 +192,7 @@ STATICFILES_FINDERS = (
)
COMPRESS_PRECOMPILERS = (
('text/stylus', os.path.join(BASE_DIR, 'node_modules', '.bin', 'stylus') + ' {infile} -o {outfile}'),
('text/stylus', './node_modules/.bin/stylus {infile} -u ./lemoncurry/static/lemoncurry/css/theme -o {outfile}'),
)
MEDIA_URL = STATIC_URL + 'media/'

@ -0,0 +1 @@
Subproject commit cbbc47444208fb8f28dbc48ea986c9dc81843e9a

View file

@ -1,17 +0,0 @@
// Source: https://github.com/ntpeters/base16-materialtheme-scheme/blob/cbbc474/material-darker.yaml
$base00 = #212121
$base01 = #303030
$base02 = #353535
$base03 = #4A4A4A
$base04 = #B2CCD6
$base05 = #EEFFFF
$base06 = #EEFFFF
$base07 = #FFFFFF
$base08 = #F07178
$base09 = #F78C6C
$base0A = #FFCB6B
$base0B = #C3E88D
$base0C = #89DDFF
$base0D = #82AAFF
$base0E = #C792EA
$base0F = #FF5370

View file

@ -1,5 +1,3 @@
@import 'base16-material-darker'
html
background-color $base01

View file

@ -0,0 +1,18 @@
const {join} = require('path');
const {readFileSync} = require('fs');
const stylus = require('stylus');
const {safeLoad} = require('js-yaml');
const themePath = join(__dirname, '..', '..', 'base16-materialtheme-scheme', 'material-darker.yaml');
module.exports = function() {
const theme = safeLoad(readFileSync(themePath, 'utf8'));
return function(style) {
for (let i = 0; i < 16; i++) {
const key = 'base0' + i.toString(16).toUpperCase();
style.define('$' + key, new stylus.nodes.Literal('#' + theme[key]));
}
};
};