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

Add $darken_ Utility Functions for Darkening Palette Colors #728

Merged
merged 10 commits into from
Aug 21, 2024
5 changes: 5 additions & 0 deletions lib/KThemePlugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isNuxtServerSideRendering } from '../lib/utils';
import computedClass from './styles/computedClass';
import { darken1, darken2, darken3 } from './styles/darkenColors.js';

import KBreadcrumbs from './KBreadcrumbs';
import KButton from './buttons-and-links/KButton';
Expand Down Expand Up @@ -115,6 +116,10 @@ export default function KThemePlugin(Vue) {
Vue.prototype.$themePalette = themePalette();
Vue.prototype.$computedClass = computedClass;

Vue.prototype.$darken1 = darken1;
Vue.prototype.$darken2 = darken2;
Vue.prototype.$darken3 = darken3;

// globally-accessible components
Vue.component('KButton', KButton);
Vue.component('KButtonGroup', KButtonGroup);
Expand Down
19 changes: 19 additions & 0 deletions lib/styles/darkenColors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Color from 'color';
MisRob marked this conversation as resolved.
Show resolved Hide resolved

export function darken1(color) {
return Color(color)
.darken(0.15)
.hex();
}

export function darken2(color) {
return Color(color)
.darken(0.3)
.hex();
}

export function darken3(color) {
return Color(color)
.darken(0.45)
.hex();
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@vue/composition-api": "1.7.2",
"aphrodite": "https://github.com/learningequality/aphrodite/",
"autosize": "3.0.21",
"color": "3.2.1",
shivam-daksh marked this conversation as resolved.
Show resolved Hide resolved
"css-element-queries": "1.2.0",
"date-fns": "1.30.1",
"frame-throttle": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4021,7 +4021,7 @@ color-string@^1.6.0:
color-name "^1.0.0"
simple-swizzle "^0.2.2"

color@^3.0.0:
color@3.2.1, color@^3.0.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164"
integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==
Expand Down
Loading