PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / AutoLaunch / functions / design.js

design.js in Extendify 3.2.1, at src/AutoLaunch/functions/design.js

34 lines 1013 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {
2 BG_SOURCE_ATTR,
3 DESIGN_ROOT_ATTR,
4 } from '@auto-launch/functions/tokens';
5
6 // A design may carry a variable this build predates; anything else is not ours.
7 const DESIGN_VAR = /^--ext-(ui|tpl)-[a-z0-9-]+$/;
8
9 let logo;
10
11 // The design is read once before the first paint, so the parts read it from here.
12 export const chooseLogo = (source) => {
13 logo = source;
14 };
15
16 export const activeLogo = () => logo;
17
18 export const designRoot = () => document.querySelector(`[${DESIGN_ROOT_ATTR}]`);
19
20 export const applyBgSource = (node, source) => {
21 if (source) node.setAttribute(BG_SOURCE_ATTR, source);
22 else node.removeAttribute(BG_SOURCE_ATTR);
23 };
24
25 // Never on :root, or everything outside the flow is repainted with it.
26 export const applyDesign = (node, design) => {
27 if (!node || !design) return;
28 for (const [name, value] of Object.entries(design.vars ?? {})) {
29 if (DESIGN_VAR.test(name)) node.style.setProperty(name, value);
30 }
31 node.setAttribute(DESIGN_ROOT_ATTR, '');
32 applyBgSource(node, design.shader);
33 };
34