cascading-color-systems
Advanced tools
Comparing version 0.1.0-beta.15 to 0.1.0-beta.16
55
dist.js
@@ -20,3 +20,2 @@ (function (global, factory) { | ||
_exports.default = _default; | ||
function _default() { | ||
@@ -30,4 +29,5 @@ // root elements | ||
const modeAuto = document.querySelector('[data-ccs-input="auto-mode"]'); | ||
const unsetBtn = document.querySelector('[data-ccs-input="unset"]'); // controls | ||
const unsetBtn = document.querySelector('[data-ccs-input="unset"]'); | ||
// controls | ||
const controls = { | ||
@@ -40,3 +40,2 @@ theme: document.querySelector('[data-ccs-input~="theme"]'), | ||
}; | ||
const showUnsetBtn = (show = true) => { | ||
@@ -46,9 +45,10 @@ if (unsetBtn) { | ||
} | ||
}; // attributes | ||
}; | ||
// attributes | ||
const attrs = { | ||
theme: "data-ccs-theme" | ||
}; // properties | ||
}; | ||
// properties | ||
const props = { | ||
@@ -60,4 +60,5 @@ hue: "--ccs-prime--user", | ||
mode: "--ccs-mode--user" | ||
}; // local storage | ||
}; | ||
// local storage | ||
const store = { | ||
@@ -70,4 +71,5 @@ theme: "ccsTheme", | ||
contrast: "ccsContrast" | ||
}; // set a value | ||
}; | ||
// set a value | ||
const setValue = (type, to, toStore = true) => { | ||
@@ -80,3 +82,2 @@ if (to) { | ||
} | ||
if (toStore && store[type]) { | ||
@@ -88,3 +89,2 @@ localStorage.setItem(store[type], to); | ||
}; | ||
const clearProps = (sub = null) => Object.keys(props).forEach(prop => { | ||
@@ -95,3 +95,2 @@ if (!sub || sub.includes(prop)) { | ||
}); | ||
const clearStore = (sub = null) => Object.keys(store).forEach(type => { | ||
@@ -102,7 +101,5 @@ if (!sub || sub.includes(type)) { | ||
}); | ||
const resetControls = (sub = null) => Object.keys(controls).forEach(type => { | ||
if (!sub || sub.includes(type)) { | ||
const el = controls[type]; | ||
if (el) { | ||
@@ -113,8 +110,5 @@ el.value = el.getAttribute("data-default"); | ||
}); | ||
const subTheme = ["hue", "sat", "light", "contrast"]; | ||
const setSelection = (type, selection) => { | ||
const unsetTheme = controls.theme && controls.theme.dataset.ccsInput && controls.theme.dataset.ccsInput.includes("unset-values"); | ||
if (type === "theme" && unsetTheme) { | ||
@@ -125,7 +119,6 @@ clearProps(subTheme); | ||
} | ||
setValue(type, selection); | ||
}; // clear all settings on reset | ||
}; | ||
// clear all settings on reset | ||
const unset = () => { | ||
@@ -135,3 +128,2 @@ if (controls.theme) { | ||
} | ||
clearStore(); | ||
@@ -141,11 +133,9 @@ clearProps(); | ||
showUnsetBtn(false); | ||
if (modeAuto) { | ||
modeAuto.checked = true; | ||
} | ||
}; // modes | ||
}; | ||
// modes | ||
const getMode = () => parseInt(getComputedStyle(root).getPropertyValue("--ccs-mode").trim(), 10); | ||
const changeMode = scheme => { | ||
@@ -158,3 +148,2 @@ const schemeDict = { | ||
const setting = schemeDict[scheme]; | ||
if (setting) { | ||
@@ -168,3 +157,2 @@ setValue("mode", setting); | ||
}; | ||
const toggleMode = () => { | ||
@@ -178,9 +166,8 @@ const modeDict = { | ||
const modeBtn = modeDict[mode * -1]; | ||
if (modeBtn) { | ||
modeBtn.checked = true; | ||
} | ||
}; // initialize everything | ||
}; | ||
// initialize everything | ||
const initMenu = () => { | ||
@@ -191,6 +178,4 @@ if (themeMenu) { | ||
}; | ||
const initMode = () => { | ||
let to = localStorage.getItem(store.mode); | ||
if (to) { | ||
@@ -203,3 +188,2 @@ const modeDict = { | ||
setValue("mode", to); | ||
if (modeBtn) { | ||
@@ -212,7 +196,5 @@ modeBtn.checked = true; | ||
}; | ||
const initValue = type => { | ||
controls[type].setAttribute("data-default", controls[type].value); | ||
const to = localStorage.getItem(store[type]); | ||
if (to) { | ||
@@ -224,9 +206,8 @@ setValue(type, to, false); | ||
}; | ||
/* init defaults */ | ||
window.onload = initMenu(); | ||
window.onload = initMode(); | ||
/* attach event listeners */ | ||
invertBtn && invertBtn.addEventListener("click", toggleMode); | ||
@@ -233,0 +214,0 @@ modeLight && modeLight.addEventListener("change", () => changeMode("light")); |
{ | ||
"name": "cascading-color-systems", | ||
"version": "0.1.0-beta.15", | ||
"version": "0.1.0-beta.16", | ||
"description": "generate dynamic color palettes with custom properties", | ||
@@ -19,16 +19,10 @@ "title": "Cascading Colors", | ||
"devDependencies": { | ||
"@babel/cli": "^7.12.1", | ||
"@babel/core": "^7.12.3", | ||
"@babel/plugin-transform-modules-umd": "^7.12.1", | ||
"@babel/cli": "^7.19.3", | ||
"@babel/core": "^7.20.5", | ||
"@babel/plugin-transform-modules-umd": "^7.18.6", | ||
"cssremedy": "^0.1.0-beta.2", | ||
"sass": "^1.27.0", | ||
"sassdoc": "^2.7.3", | ||
"sassdoc-theme-herman": "^3.2.0" | ||
"sass": "^1.56.2", | ||
"sassdoc": "^2.7.4", | ||
"sassdoc-theme-herman": "^5.0.0" | ||
}, | ||
"resolutions": { | ||
"marked": "^0.7.0", | ||
"sassdoc-theme-herman/nunjucks/chokidar": ">=3.0.0", | ||
"sassdoc-theme-herman/nunjucks/yargs": "^13.2", | ||
"sassdoc-theme-herman/typogr/mkdirp": "^0.5.5" | ||
}, | ||
"scripts": { | ||
@@ -50,5 +44,4 @@ "build-sass": "sass sass/_output.scss css/ccs.css", | ||
"index.js", | ||
"dist.js", | ||
"docs/" | ||
"dist.js" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
59248
24
553