From b2469c03bd4bdb29c5e80752f812203a6755c159 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 4 Jun 2021 17:30:16 -0300 Subject: move around a bunch of utility functions --- src/util/colors.js | 28 ---------------------------- src/util/link.js | 9 ++++++++- 2 files changed, 8 insertions(+), 29 deletions(-) (limited to 'src/util') diff --git a/src/util/colors.js b/src/util/colors.js index 01c55024..3a7ce8f3 100644 --- a/src/util/colors.js +++ b/src/util/colors.js @@ -19,31 +19,3 @@ export function getColors(primary) { return {primary, dim, bg}; } - -export function getLinkThemeString(color) { - if (!color) return ''; - - const { primary, dim } = getColors(color); - return `--primary-color: ${primary}; --dim-color: ${dim}`; -} - -export function getThemeString(color, additionalVariables = []) { - if (!color) return ''; - - const { primary, dim, bg } = getColors(color); - - const variables = [ - `--primary-color: ${primary}`, - `--dim-color: ${dim}`, - `--bg-color: ${bg}`, - ...additionalVariables - ].filter(Boolean); - - if (!variables.length) return ''; - - return ( - `:root {\n` + - variables.map(line => ` ` + line + ';\n').join('') + - `}` - ); -} diff --git a/src/util/link.js b/src/util/link.js index 107b35ff..7ed5fd8e 100644 --- a/src/util/link.js +++ b/src/util/link.js @@ -10,7 +10,14 @@ // gener8ting just a8out any link on the site. import * as html from './html.js' -import { getLinkThemeString } from './colors.js' +import { getColors } from './colors.js' + +export function getLinkThemeString(color) { + if (!color) return ''; + + const { primary, dim } = getColors(color); + return `--primary-color: ${primary}; --dim-color: ${dim}`; +} const linkHelper = (hrefFn, {color = true, attr = null} = {}) => (thing, { -- cgit 1.3.0-6-gf8a5