mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 20:19:13 +00:00
* Exclude Create link from sidebar, for reals this time * Fix bug * Very rough prototype of look & feel * a11y * Clean up data files * Automatically generate theme metadata * Read look & feel params straight from theme * First stab at dimensionality icons * Fix rounding 0 bug * Add border width slider * [Image-comparer] Expose wrapper as part * [Comparer] `pointer-events: none` while dragging * Dark mode slider * Adjust increments and ranges for look + feel sliders * Fix preview * Fix bug where dark mode was not inverted * Ability to select panel from URL * Create mixin for Vue form controls and use it in `<swatch-select>` * Prototype of slider min/max icon buttons * Nx tooltip * Icons * Prevent failed request * info-tip: Support passing text as prop * Clearable * [Brutalist] Match `--wa-shadow-offset-x-scale` to `--wa-shadow-offset-y-scale` * Add 'Blocky' dimension (derived from Awesome theme) * Only show Reset button when `clearable` is set * Remove `clearable` from Look & Feel sliders * Add tooltips to min/max buttons * Remove superfluous `aria-label` * Do not assume that all hyphens in URLs mean nesting, make it explicit * Formatting * Fix bug where styles were not applied on page load * Update Subtle dimension to maximize compatibility * `<wa-scoped>`: Do not allow non-template children * Workaround for card not updating * Update Glossy dimension to maximize compatibility * Sync scrolling between regular and inverted preview * Fix bug * Make changing the base theme reset customizations * Fix palette page * Remove cancel button from editable text * Don't error in theme pages * Update Playful dimension to maximize compatibility * Rename 'Look and Feel' to 'Elements' for better parallel structure * Hide dimensionality controls * Make back icon motion more subtle * Expand spacing slider bounds * Add `tabindex="-1"` where missing in theme showcase * Remove extraneous gap from theme headers * fix edit button bug * rename comparer => comparison; fix aria-controls * Always save theme name on blur * Add changelog for themer and new patterns category --------- Co-authored-by: lindsaym-fa <dev@lindsaym.design> Co-authored-by: Cory LaViska <cory@abeautifulsite.net>
119 lines
3.0 KiB
JavaScript
119 lines
3.0 KiB
JavaScript
import { deepEach, isPlainObject } from '../scripts/util/deep.js';
|
|
|
|
/**
|
|
* Data related to themes, theme remixing
|
|
* Must work in both browser and Node.js
|
|
*/
|
|
export const cdnUrl = globalThis.document ? document.documentElement.dataset.cdnUrl : '/dist/';
|
|
|
|
// This should eventually replace all uses of `urls` and `themeParams`
|
|
export const themeConfig = {
|
|
base: { url: id => `styles/themes/${id}.css`, default: 'default' },
|
|
colors: {
|
|
url: id => `styles/themes/${id}/color.css`,
|
|
docs: '/docs/themes/',
|
|
icon: 'palette',
|
|
default() {
|
|
return this.base;
|
|
},
|
|
},
|
|
palette: {
|
|
url: id => `styles/color/${id}.css`,
|
|
docs: '/docs/palette/',
|
|
icon: 'swatchbook',
|
|
default(baseTheme) {
|
|
return baseTheme?.palette;
|
|
},
|
|
},
|
|
brand: {
|
|
url: id => `styles/brand/${id}.css`,
|
|
icon: 'droplet',
|
|
default(baseTheme) {
|
|
return baseTheme?.brand;
|
|
},
|
|
},
|
|
typography: {
|
|
url: id => `styles/themes/${id}/typography.css`,
|
|
docs: '/docs/themes/',
|
|
icon: 'font-case',
|
|
default() {
|
|
return this.base;
|
|
},
|
|
},
|
|
icon: {
|
|
library: {
|
|
cssProperty: '--wa-icon-library',
|
|
default: 'default',
|
|
},
|
|
family: {
|
|
cssProperty: '--wa-icon-family',
|
|
default(baseTheme) {
|
|
return baseTheme?.icon?.family ?? 'classic';
|
|
},
|
|
},
|
|
style: {
|
|
cssProperty: '--wa-icon-variant',
|
|
default(baseTheme) {
|
|
return baseTheme?.icon?.style ?? 'solid';
|
|
},
|
|
},
|
|
},
|
|
rounding: {
|
|
cssProperty: '--wa-border-radius-scale',
|
|
default(baseTheme) {
|
|
return baseTheme?.rounding ?? 1;
|
|
},
|
|
},
|
|
spacing: {
|
|
cssProperty: '--wa-space-scale',
|
|
default(baseTheme) {
|
|
return baseTheme?.spacing ?? 1;
|
|
},
|
|
},
|
|
borderWidth: {
|
|
cssProperty: '--wa-border-width-scale',
|
|
default(baseTheme) {
|
|
return baseTheme?.borderWidth ?? 1;
|
|
},
|
|
},
|
|
dimensionality: {
|
|
url: id => `styles/themes/${id}/dimension.css`,
|
|
docs: '/docs/themes/',
|
|
icon: 'cube',
|
|
default() {
|
|
return this.base;
|
|
},
|
|
},
|
|
};
|
|
|
|
export function getPath(key) {
|
|
if (key.startsWith('icon-')) {
|
|
// TODO detect what the nested prefixes are from theme config metadata
|
|
return ['icon', ...key.slice(5)];
|
|
}
|
|
}
|
|
|
|
// Shallow remixing params in correct order
|
|
// base must be first. brand needs to come after palette, which needs to come after colors.
|
|
export const themeParams = Object.keys(themeConfig).filter(aspect => themeConfig[aspect].url);
|
|
|
|
export const urls = themeParams.reduce((acc, aspect) => {
|
|
acc[aspect] = themeConfig[aspect].url;
|
|
return acc;
|
|
}, {});
|
|
|
|
export const themeDefaults = { ...themeConfig };
|
|
|
|
deepEach(themeDefaults, (value, key, parent, path) => {
|
|
if (isPlainObject(value)) {
|
|
// Replace w/ default value or shallow clone
|
|
return value.default ?? { ...value };
|
|
}
|
|
});
|
|
|
|
export const selectors = {
|
|
palette: id =>
|
|
[':where(:root)', ':host', ":where([class^='wa-theme-'], [class*=' wa-theme-'])", `.wa-palette-${id}`].join(',\n'),
|
|
theme: id => [':where(:root)', ':host', `.wa-theme-${id}`].join(',\n'),
|
|
};
|