logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: 9ec61d0f0a26369196d9e9b4ac62f4a5b3c38ce1
parent 1af8ca29f33a43f72175f4b17a2447149694a7d8
Author: Henry Jameson <me@hjkos.com>
Date:   Fri,  9 Feb 2024 19:37:22 +0200

comments and cleanup

Diffstat:

Msrc/components/button.style.js9++++++---
Msrc/services/theme_data/theme_data_3.service.js19+++++++++++--------
2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/components/button.style.js b/src/components/button.style.js @@ -21,17 +21,20 @@ const hoverGlow = { } export default { - name: 'Button', - selector: '.button', + name: 'Button', // Name of the component + selector: '.button', // CSS selector/prefix + // States, system witll calculate ALL possible combinations of those and append a "normal" to them + standalone "normal" state states: { + // normal: state is implicitly added disabled: ':disabled', toggled: '.toggled', pressed: ':active', hover: ':hover', focused: ':focus-within' }, + // Variants are mutually exclusive, which saves on computation time variants: { - normal: '-default', + normal: '-default', // you can override normal variant danger: '.danger', unstyled: '-unstyled' }, diff --git a/src/services/theme_data/theme_data_3.service.js b/src/services/theme_data/theme_data_3.service.js @@ -20,6 +20,8 @@ import Text from 'src/components/text.style.js' import Link from 'src/components/link.style.js' import Icon from 'src/components/icon.style.js' +const DEBUG = false + export const DEFAULT_SHADOWS = { panel: [{ x: 1, @@ -150,11 +152,11 @@ const combinationsMatch = (criteria, subject, strict) => { if (criteria.variant !== subject.variant) return false } - const subjectStatesSet = new Set(subject.state) - const criteriaStatesSet = new Set(criteria.state) - // Subject states > 1 essentially means state is "normal" and therefore matches - if (subjectStatesSet.size > 1 || strict) { + if (subject.state.length > 1 || strict) { + const subjectStatesSet = new Set(subject.state) + const criteriaStatesSet = new Set(criteria.state) + const setsAreEqual = [...criteriaStatesSet].every(state => subjectStatesSet.has(state)) && [...subjectStatesSet].every(state => criteriaStatesSet.has(state)) @@ -448,6 +450,7 @@ export const init = (extraRuleset, palette) => { computed[lowerLevelSelector].virtualDirectivesRaw = virtualDirectivesRaw // Debug: lets you see what it think background color should be + if (!DEBUG) return const directives = { textColor, @@ -456,9 +459,10 @@ export const init = (extraRuleset, palette) => { } addRule({ - parent, + selector, virtual: true, component: component.name, + parent, ...combination, directives, virtualDirectives, @@ -503,6 +507,7 @@ export const init = (extraRuleset, palette) => { computed[selector].background = { ...rgb, a: computedDirectives.opacity ?? 1 } addRule({ + selector, component: component.name, ...combination, parent, @@ -531,9 +536,7 @@ export const init = (extraRuleset, palette) => { return { raw: rules, css: rules.map(rule => { - if (rule.virtual) return '' - - let selector = ruleToSelector(rule).replace(/\/\*.*\*\//g, '') + let selector = rule.selector if (!selector) { selector = 'body' }