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 / Notifications / colors.js

colors.js in Extendify 3.2.1, at src/Notifications/colors.js

53 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // `--ext-*` resolves once at the scope root, so setting it here reaches nothing.
2 const BAR_SURFACE = {
3 main: '--color-design-main',
4 text: '--color-design-text',
5 };
6
7 // No partner color behind the card, so it has no `--color-*` alias to set.
8 const CARD_SURFACE = {
9 main: '--ext-notification-card-main',
10 text: '--ext-notification-card-text',
11 };
12
13 const buttonMap = (main, text) => ({
14 'button-main': main,
15 'button-text': text,
16 'button-hover-main': '--ext-notification-button-hover-main',
17 'button-hover-text': '--ext-notification-button-hover-text',
18 });
19
20 const BANNER_BUTTON = buttonMap('--color-banner-main', '--color-banner-text');
21 const DESIGN_BUTTON = buttonMap('--color-design-main', '--color-design-text');
22
23 const variablesFrom = (map, colors) =>
24 Object.fromEntries(
25 Object.entries(colors)
26 .filter(([key, value]) => map[key] && typeof value === 'string')
27 .map(([key, value]) => [map[key], value]),
28 );
29
30 export const colorsOf = (notification) => notification?.colors ?? {};
31
32 export const barVariables = (colors) => variablesFrom(BAR_SURFACE, colors);
33
34 export const cardVariables = (colors) => variablesFrom(CARD_SURFACE, colors);
35
36 export const bannerButtonVariables = (colors) =>
37 variablesFrom(BANNER_BUTTON, colors);
38
39 export const designButtonVariables = (colors) =>
40 variablesFrom(DESIGN_BUTTON, colors);
41
42 export const buttonHoverClasses = (colors) => ({
43 'hover:bg-[var(--ext-notification-button-hover-main)]': Boolean(
44 colors['button-hover-main'],
45 ),
46 'hover:text-[var(--ext-notification-button-hover-text)]': Boolean(
47 colors['button-hover-text'],
48 ),
49 // A supplied hover color has to land exactly, not dimmed.
50 'hover:opacity-90':
51 !colors['button-hover-main'] && !colors['button-hover-text'],
52 });
53