Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional CSS Variables and multi-theme ability #2981

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7639c0c
Make bulma themeable with full backward compatibility :sparkles:
Tofandel Jun 5, 2020
cc6d912
Improve build script
Tofandel Jun 5, 2020
ce6db01
Improved build script and made the doc use the themeable file to test it
Tofandel Jun 5, 2020
8050b9e
Add error message on build script usage
Tofandel Jun 5, 2020
9d9c016
Greatly improved build script (postcss and minification included, the…
Tofandel Jun 5, 2020
8c70297
Forgotten replacements and add variable-list to gitignore
Tofandel Jun 5, 2020
3c4e158
Get rid of unnecessary tmp var file
Tofandel Jun 6, 2020
b18cf6f
Fixed hsla ajdust formula
Tofandel Jun 6, 2020
713e0a4
Fix variable registration
Tofandel Jun 6, 2020
a6f5084
First fully working preview of new themeable logic
Tofandel Jun 10, 2020
a240a0d
Small cleanup
Tofandel Jun 10, 2020
b549c16
Cleanup
Tofandel Jun 10, 2020
f73170f
Fix source map generation
Tofandel Jun 10, 2020
d840682
Fix tree shaking of unused variables and add shortening ability
Tofandel Jun 10, 2020
282d9da
Added theming mixins and modified the build process accordingly
Tofandel Jun 11, 2020
fcab881
Made the docs themeable and added watcher and options to build script
Tofandel Jun 11, 2020
0551e4e
Fix watcher
Tofandel Jun 11, 2020
7133118
Add dark mode for doc
Tofandel Jun 12, 2020
4f9ad38
Merge remote-tracking branch 'remotes/upstream/master'
Tofandel Jun 12, 2020
db8841d
Fix themeable generation
Tofandel Jun 12, 2020
5539f80
Fixed compressed theme generation
Tofandel Jun 12, 2020
c7b4868
Added theme switcher to doc
Tofandel Jun 13, 2020
cecf80a
Rebuild files
Tofandel Jun 13, 2020
af793d0
Update changelog
Tofandel Jun 13, 2020
9a31b65
Added doc for themes
Tofandel Jun 13, 2020
f3b8a7d
Added doc for themes
Tofandel Jun 13, 2020
0646a3a
Fix rtl with border radius
Tofandel Jun 13, 2020
25c61d4
Postcss-var-optimize
Tofandel Jun 14, 2020
91448df
Created and added a postcss plugin to optimize the css variables and …
Tofandel Jun 14, 2020
ade0fd1
Update docs and fix missing trailing slash in all path
Tofandel Jun 14, 2020
b6f589a
Remove deprecation
Tofandel Jun 14, 2020
b8fef46
Return value in register for maximum BC
Tofandel Jun 14, 2020
6904dd9
Added migrating a theme section
Tofandel Jun 14, 2020
d2c7e64
Fix typo
Tofandel Jun 14, 2020
dd79846
Update doc
Tofandel Jun 14, 2020
af41c9f
Remove themeable.css and cleanup build script
Tofandel Jun 15, 2020
abc8672
Cleanup npm scripts
Tofandel Jun 15, 2020
8f0ad68
Fix comment lint
Tofandel Aug 1, 2020
ac76b1d
Fix comment lint
Tofandel Aug 1, 2020
fbfe632
Lint comments
Tofandel Aug 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env node

const path = require('path')

const {sassToString, ensureDirectoryExistence, renderSassSync, writeOutput, partition, watch, unwatch} = require("./utils");

let args = process.argv.slice(2);


let options;

[options, args] = partition(args, (arg) => {
return arg.charAt(0) === '-'
})

if (args.length < 2) {
console.error("Usage:" + process.argv[0] + process.argv[1] + " input.sass ouput.css [--themeable [--full]]")
}

const input = args[0];

if (path.parse(input).ext !== ".sass" && path.parse(input).ext !== ".scss") {
console.error("The input file must be a sass or scss file")
return;
}

const outInfo = path.parse(args[1])

const output = path.resolve(process.cwd(), outInfo.dir + path.sep + outInfo.name);

const shouldWatch = options.indexOf("--watch") >= 0

const build = async () => {
ensureDirectoryExistence(output)

if (options.indexOf('--themeable') < 0) {
//No variables build
const render = renderSassSync(input, output, false);
//Output the non themeable generated css
await writeOutput(output, render)
return render
} else {
const defaultVars = {};
const modifiedVars = {};

let data = '$themeable: "any";'

let render = renderSassSync(input, output, false, data, {
'_vRegister($name, $value)': function (name, value) {
const val = sassToString(value);
name = name.getValue();
if (!(name in defaultVars) || defaultVars[name] === val) {
defaultVars[name] = val;
} else {
// If variable is registered again with a different value, it was modified
modifiedVars[name] = val;
}
return value;
},
});

if (options.indexOf('--full') >= 0) {
await writeOutput(output, render)
} else {
//Default compressed
data = '$themeable: true;\n' +
'$css_vars: (' + Object.keys(modifiedVars).map((v) => '"' + v + '"').join(', ') + ');';
render = renderSassSync(input, output, false, data)
await writeOutput(output, render)
}
return render;
}
}

build().then(render => {

if (shouldWatch) {
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const watcher = async (file) => {
console.log("\nFile " + file + " has been touched, recompiling\n")
unwatch()
try {
render = await build()
} catch (e) {
console.error(e)
}
watch(render, watcher)

rl.question('Continuing watcher, press enter to exit: ', (answer) => {
rl.close();
unwatch();
});
}
watch(render, watcher)
rl.question('Started watcher, press enter to exit', (answer) => {
rl.close();
unwatch();
});
}
});
1 change: 1 addition & 0 deletions bulma.sass
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
@import "sass/components/_all"
@import "sass/grid/_all"
@import "sass/layout/_all"
@import "sass/themeable/_all"
Loading