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 / Shared / lib / vibe-globals.js

vibe-globals.js in Extendify 3.2.1, at src/Shared/lib/vibe-globals.js

55 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {
2 applyOwnedSection,
3 collectOwnedPaths,
4 } from '@shared/lib/owned-globals';
5
6 const ownedSettings = ['layout', 'typography', 'custom'];
7 // Per-leaf, so clearing a heading size leaves fontFamily to the fonts layer.
8 // WordPress reads duotone per block name, never per variation, so blocks is owned here.
9 const ownedStyles = ['typography', 'elements', 'blocks'];
10
11 // The fonts and palette layers own these; a declaring payload is ignored.
12 const isExcludedPath = (section, path) => {
13 if (path[path.length - 1] === 'fontFamily') return true;
14 if (section !== 'settings') return false;
15 if (path[0] === 'color') return true;
16 return path[0] === 'typography' && path[1] === 'fontFamilies';
17 };
18
19 export const ownedSettingPaths = (vibes) =>
20 collectOwnedPaths({
21 payloads: vibes,
22 section: 'settings',
23 roots: ownedSettings,
24 exclude: isExcludedPath,
25 });
26
27 export const ownedStylePaths = (vibes) =>
28 collectOwnedPaths({
29 payloads: vibes,
30 section: 'styles',
31 roots: ownedStyles,
32 exclude: isExcludedPath,
33 });
34
35 export const applyVibeGlobals = ({ currentSettings, vibeSettings, vibes }) =>
36 applyOwnedSection(currentSettings, vibeSettings, ownedSettingPaths(vibes));
37
38 export const applyVibeStyles = ({ currentStyles, vibeStyles, vibes }) =>
39 applyOwnedSection(currentStyles, vibeStyles, ownedStylePaths(vibes));
40
41 // A fonts or colors write may not move vibe-owned leaves.
42 export const preserveVibeSettings = ({
43 mergedSettings,
44 currentSettings,
45 vibes,
46 }) =>
47 applyOwnedSection(mergedSettings, currentSettings, ownedSettingPaths(vibes));
48
49 export const preserveVibeStyles = ({ mergedStyles, currentStyles, vibes }) =>
50 applyOwnedSection(mergedStyles, currentStyles, ownedStylePaths(vibes));
51
52 // natural-1 is what the theme ships, so writing it would only restate the theme.
53 export const vibeGlobalsEntry = (vibes, selectedVibe) =>
54 selectedVibe === 'natural-1' ? undefined : vibes?.[selectedVibe];
55