Browse Source

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

tags/v1.4.0
Danielle McLean 1 year ago
parent
commit
0419a844ce
Signed by: Danielle McLean <dani@00dani.me> GPG Key ID: 5A5D2D1AFF12EEC5

+ 3
- 0
.gitmodules View File

@@ -0,0 +1,3 @@
1
+[submodule "lemoncurry/static/base16-materialtheme-scheme"]
2
+	path = lemoncurry/static/base16-materialtheme-scheme
3
+	url = git://github.com/ntpeters/base16-materialtheme-scheme.git

+ 1
- 1
lemoncurry/settings/base.py View File

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

+ 1
- 0
lemoncurry/static/base16-materialtheme-scheme

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

+ 0
- 17
lemoncurry/static/lemoncurry/css/base16-material-darker.styl View File

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

+ 0
- 2
lemoncurry/static/lemoncurry/css/layout.styl View File

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

+ 18
- 0
lemoncurry/static/lemoncurry/css/theme.js View File

@@ -0,0 +1,18 @@
1
+const {join} = require('path');
2
+const {readFileSync} = require('fs');
3
+
4
+const stylus = require('stylus');
5
+const {safeLoad} = require('js-yaml');
6
+
7
+const themePath = join(__dirname, '..', '..', 'base16-materialtheme-scheme', 'material-darker.yaml');
8
+
9
+module.exports = function() {
10
+	const theme = safeLoad(readFileSync(themePath, 'utf8'));
11
+	return function(style) {
12
+		for (let i = 0; i < 16; i++) {
13
+			const key = 'base0' + i.toString(16).toUpperCase();
14
+
15
+			style.define('$' + key, new stylus.nodes.Literal('#' + theme[key]));
16
+		}
17
+	};
18
+};

+ 1
- 0
package.json View File

@@ -4,6 +4,7 @@
4 4
 	"repository": "https://gitlab.com/00dani/lemoncurry",
5 5
 	"license": "MIT",
6 6
 	"devDependencies": {
7
+		"js-yaml": "^3.10.0",
7 8
 		"stylus": "^0.54.5"
8 9
 	},
9 10
 	"dependencies": {

+ 21
- 0
yarn.lock View File

@@ -6,6 +6,12 @@ amdefine@>=0.0.4:
6 6
   version "1.0.1"
7 7
   resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
8 8
 
9
+argparse@^1.0.7:
10
+  version "1.0.9"
11
+  resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86"
12
+  dependencies:
13
+    sprintf-js "~1.0.2"
14
+
9 15
 balanced-match@^1.0.0:
10 16
   version "1.0.0"
11 17
   resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
@@ -31,6 +37,10 @@ debug@*:
31 37
   dependencies:
32 38
     ms "2.0.0"
33 39
 
40
+esprima@^4.0.0:
41
+  version "4.0.0"
42
+  resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"
43
+
34 44
 fs.realpath@^1.0.0:
35 45
   version "1.0.0"
36 46
   resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -57,6 +67,13 @@ inherits@2:
57 67
   version "2.0.3"
58 68
   resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
59 69
 
70
+js-yaml@^3.10.0:
71
+  version "3.10.0"
72
+  resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc"
73
+  dependencies:
74
+    argparse "^1.0.7"
75
+    esprima "^4.0.0"
76
+
60 77
 minimatch@^3.0.2:
61 78
   version "3.0.4"
62 79
   resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
@@ -101,6 +118,10 @@ source-map@0.1.x:
101 118
   dependencies:
102 119
     amdefine ">=0.0.4"
103 120
 
121
+sprintf-js@~1.0.2:
122
+  version "1.0.3"
123
+  resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
124
+
104 125
 stylus@^0.54.5:
105 126
   version "0.54.5"
106 127
   resolved "https://registry.yarnpkg.com/stylus/-/stylus-0.54.5.tgz#42b9560931ca7090ce8515a798ba9e6aa3d6dc79"

Loading…
Cancel
Save