Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Russell/biome is bad sometimes (#149)

Fake-Userf46ed017132e
diff --git a/js/app/biome.jsonc b/js/app/biome.jsonc
index c9c3b278f1..9ad33eb0d4 100644
--- a/js/app/biome.jsonc
+++ b/js/app/biome.jsonc
@@ -123,6 +123,19 @@
"javascript": {
"globals": ["Bun"]
}
+ },
+ {
+ "includes": ["packages/block-theme/**"],
+ "formatter": {
+ "enabled": false
+ },
+ "assist": {
+ "actions": {
+ "source": {
+ "organizeImports": "off"
+ }
+ }
+ }
}
]
}
diff --git a/js/app/packages/block-theme/components/ThemeEditorAdvanced.tsx b/js/app/packages/block-theme/components/ThemeEditorAdvanced.tsx
index 5ae4b8b3a1..753a6a511c 100644
--- a/js/app/packages/block-theme/components/ThemeEditorAdvanced.tsx
+++ b/js/app/packages/block-theme/components/ThemeEditorAdvanced.tsx
@@ -1,32 +1,15 @@
+import { batch, createEffect, createSignal, For, type Setter, untrack } from 'solid-js';
import { SegmentedControl } from '@core/component/FormControls/SegmentControls';
-import {
- batch,
- createEffect,
- createSignal,
- For,
- type Setter,
- untrack,
-} from 'solid-js';
-import { themeReactive } from '../signals/themeReactive';
-import type { ThemeReactiveColor } from '../types/themeTypes';
import { convertOklchTo, getOklch, validateColor } from '../utils/colorUtil';
+import type { ThemeReactiveColor } from '../types/themeTypes';
+import { themeReactive } from '../signals/themeReactive';
import { ColorSwatch } from './ColorSwatch';
const formatArray = ['hex', 'rgb', 'hsl', 'oklch'];
const [displayType, setDisplayType] = createSignal(formatArray[0]);
-function setColor(
- colorValue: ThemeReactiveColor,
- colorString: string,
- inputElement: HTMLInputElement,
- setIsSetByInput: Setter<boolean>
-) {
- if (
- !colorString ||
- colorString.trim() === '' ||
- colorString.length < 6 ||
- !validateColor(colorString)
- ) {
+function setColor(colorValue: ThemeReactiveColor, colorString: string, inputElement: HTMLInputElement, setIsSetByInput: Setter<boolean>){
+ if(!colorString || colorString.trim() === '' || colorString.length < 6 || !validateColor(colorString)){
inputElement.classList.add('invalid');
return;
}
@@ -39,12 +22,13 @@ function setColor(
colorValue.h[1](oklch.h ? oklch.h : 0);
});
inputElement.classList.remove('invalid');
- } catch (error) {
+ }
+ catch(error) {
console.error(`Error processing color "${colorString}":`, error);
}
}
-export function ThemeEditorAdvanced() {
+export function ThemeEditorAdvanced(){
return (
<>
<style>{`
diff --git a/js/app/packages/block-theme/components/ThemeEditorBasic.tsx b/js/app/packages/block-theme/components/ThemeEditorBasic.tsx
index 8a10653453..164e8464ab 100644
--- a/js/app/packages/block-theme/components/ThemeEditorBasic.tsx
+++ b/js/app/packages/block-theme/components/ThemeEditorBasic.tsx
@@ -1,10 +1,4 @@
-import {
- batch,
- createEffect,
- createSignal,
- onCleanup,
- onMount,
-} from 'solid-js';
+import { batch, createEffect, createSignal, onCleanup, onMount } from 'solid-js';
import { themeReactive } from '../signals/themeReactive';
function setLightness(lightness: number) {
@@ -24,17 +18,15 @@ function setChroma(chroma: number, saturation: number) {
themeReactive.a2.c[1](chroma);
themeReactive.a3.c[1](chroma);
themeReactive.a4.c[1](chroma);
-
- //parseFloat(sliderSaturationRef.value)
setSaturation(saturation);
});
}
function setHue(hue: number) {
batch(() => {
- themeReactive.a0.h[1](hue);
- themeReactive.a1.h[1](hue + 40);
- themeReactive.a2.h[1](hue + 80);
+ themeReactive.a0.h[1](hue );
+ themeReactive.a1.h[1](hue + 40);
+ themeReactive.a2.h[1](hue + 80);
themeReactive.a3.h[1](hue + 120);
themeReactive.a4.h[1](hue + 160);
@@ -72,31 +64,11 @@ function setSaturation(saturation: number) {
let q = 8;
function sigmoid(x: number, b: number): number {
- return (
- -(
- (1 / (1 + Math.exp(b * (x - 0.5))) - 0.5) *
- (0.5 / (1 / (1 + Math.exp(q / 2)) - 0.5))
- ) + 0.5
- );
+ return (-((1 / (1 + Math.exp(b * (x - 0.5))) - 0.5) * (0.5 / (1 / (1 + Math.exp(q / 2)) - 0.5))) + 0.5);
}
function getContrastFromY(y: number): number {
- return (
- (-2 *
- Math.log(
- 1 / (-(y - 0.5) / (0.5 / (1 / (1 + Math.exp(q / 2)) - 0.5)) + 0.5) - 1
- ) -
- (-2 *
- Math.log(
- 1 / (-(y - 0.5) / (0.5 / (1 / (1 + Math.exp(q / 2)) - 0.5)) + 0.5) - 1
- ) <
- 0
- ? -1
- : 1)) /
- (q - 1) /
- 2 +
- 0.5
- );
+ return ((-2 * Math.log(1 / (-(y - 0.5) / (0.5 / (1 / (1 + Math.exp(q / 2)) - 0.5)) + 0.5) - 1) - (-2 * Math.log(1 / (-(y - 0.5) / (0.5 / (1 / (1 + Math.exp(q / 2)) - 0.5)) + 0.5) - 1) < 0 ? -1 : 1)) / (q - 1) / 2 + 0.5);
}
function setContrast(contrast: number) {
@@ -119,7 +91,7 @@ function setContrast(contrast: number) {
});
}
-export function randomizeTheme() {
+export function randomizeTheme(){
batch(() => {
const randLightness = Math.random();
const randHue = Math.random();
@@ -136,7 +108,7 @@ export function randomizeTheme() {
});
}
-export function ThemeEditorBasic() {
+export function ThemeEditorBasic(){
const [canvasThumbDrag, setCanvasThumbDrag] = createSignal(false);
let sliderSaturationRef!: HTMLInputElement;
@@ -148,13 +120,9 @@ export function ThemeEditorBasic() {
let gl: WebGL2RenderingContext;
let program: WebGLProgram;
- function setupWebGL() {
- const context = canvasRef.getContext('webgl2', {
- colorSpace: 'display-p3',
- });
- if (!context || !(context instanceof WebGL2RenderingContext)) {
- throw new Error('WebGL2 not supported');
- }
+ function setupWebGL(){
+ const context = canvasRef.getContext('webgl2', {colorSpace: 'display-p3'});
+ if(!context || !(context instanceof WebGL2RenderingContext)){throw new Error('WebGL2 not supported')}
gl = context;
gl.viewport(0, 0, canvasRef.width, canvasRef.height);
program = gl.createProgram()!;
@@ -231,7 +199,7 @@ export function ThemeEditorBasic() {
chromaLocation = gl.getUniformLocation(program, 'chroma')!;
}
- function setCanvasColor(e: PointerEvent) {
+ function setCanvasColor(e: PointerEvent){
const rect = canvasContainerRef.getBoundingClientRect();
const x =
Math.min(Math.max(e.clientX - rect.left, 0), rect.width) / rect.width;
@@ -243,33 +211,33 @@ export function ThemeEditorBasic() {
});
}
- function handleCanvasPointerDown(e: PointerEvent) {
+ function handleCanvasPointerDown(e: PointerEvent){
setCanvasThumbDrag(true);
setCanvasColor(e);
}
- function handlePointerMove(e: PointerEvent) {
- if (canvasThumbDrag()) {
+ function handlePointerMove(e: PointerEvent){
+ if(canvasThumbDrag()){
setCanvasColor(e);
}
}
- function handlePointerUp() {
+ function handlePointerUp(){
setCanvasThumbDrag(false);
}
- function handleChromaChange(e: Event) {
+ function handleChromaChange(e: Event){
setChroma(
parseFloat((e.target as HTMLInputElement).value),
parseFloat(sliderSaturationRef.value)
);
}
- function handleSaturationChange(e: Event) {
+ function handleSaturationChange(e: Event){
setSaturation(parseFloat((e.target as HTMLInputElement).value));
}
- function handleContrastChange(e: Event) {
+ function handleContrastChange(e: Event){
setContrast(parseFloat((e.target as HTMLInputElement).value));
}
@@ -286,10 +254,8 @@ export function ThemeEditorBasic() {
canvasThumbRef.style.top = `${(1 - themeReactive.a0.l[0]()) * 100}%`;
});
- document.addEventListener('pointermove', handlePointerMove, {
- passive: true,
- });
- document.addEventListener('pointerup', handlePointerUp, { passive: true });
+ document.addEventListener('pointermove', handlePointerMove, {passive: true});
+ document.addEventListener('pointerup', handlePointerUp, {passive: true});
});
onCleanup(() => {
@@ -325,91 +291,91 @@ export function ThemeEditorBasic() {
onPointerDown={handleCanvasPointerDown}
ref={canvasContainerRef}
style="
- border: 1px solid var(--b4);
- position: relative;
- height: 250px;
- width: 100%;
- "
+ border: 1px solid var(--b4);
+ position: relative;
+ height: 250px;
+ width: 100%;
+ "
>
<canvas
ref={canvasRef}
style="
- touch-action: none;
- user-select: none;
- display: block;
- height: 100%;
- width: 100%;
- "
+ touch-action: none;
+ user-select: none;
+ display: block;
+ height: 100%;
+ width: 100%;
+ "
/>
<div
ref={canvasThumbRef}
style="
- transform: translate(-50%, -50%);
- background-color: var(--a0);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- position: absolute;
- height: 18px;
- width: 18px;
- "
+ transform: translate(-50%, -50%);
+ background-color: var(--a0);
+ border: 1px solid var(--b4);
+ box-sizing: border-box;
+ position: absolute;
+ height: 18px;
+ width: 18px;
+ "
/>
</div>
<div
style="
- grid-template-columns: 11ch 1fr;
- height: min-content;
- display: grid;
- width: 100%;
- gap: 20px 10px;
- "
+ grid-template-columns: 11ch 1fr;
+ height: min-content;
+ display: grid;
+ width: 100%;
+ gap: 20px 10px;
+ "
>
<div style="position: relative;">
<div
style="
- transform: translateY(-50%);
- position: absolute;
- top: 50%;
- left: 0;
- "
+ transform: translateY(-50%);
+ position: absolute;
+ top: 50%;
+ left: 0;
+ "
>
chroma:
</div>
</div>
<div
style="
- box-sizing: border-box;
- position: relative;
- height: 10px;
- width: 100%;
- "
+ box-sizing: border-box;
+ position: relative;
+ height: 10px;
+ width: 100%;
+ "
>
<div
style="
- background: linear-gradient(to right, oklch(from var(--a0) l 0.0 h), oklch(from var(--a0) l 0.37 h));
- transform: translate(-50%, -50%);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- position: absolute;
- height: 10px;
- width: 100%;
- left: 50%;
- top: 50%;
- "
+ background: linear-gradient(to right, oklch(from var(--a0) l 0.0 h), oklch(from var(--a0) l 0.37 h));
+ transform: translate(-50%, -50%);
+ border: 1px solid var(--b4);
+ box-sizing: border-box;
+ position: absolute;
+ height: 10px;
+ width: 100%;
+ left: 50%;
+ top: 50%;
+ "
/>
<div
style={{
- left: `${themeReactive.a0.c[0]() * (100 / 0.37)}%`,
- transform: 'translate(-50%, -50%)',
+ 'left': `${themeReactive.a0.c[0]() * (100 / 0.37)}%`,
+ 'transform': 'translate(-50%, -50%)',
'background-color': 'var(--a0)',
- border: '1px solid var(--b4)',
+ 'border': '1px solid var(--b4)',
'box-sizing': 'border-box',
'border-radius': '0px',
- position: 'absolute',
- height: '18px',
- width: '18px',
- top: '50%',
+ 'position': 'absolute',
+ 'height': '18px',
+ 'width': '18px',
+ 'top': '50%',
}}
/>
@@ -420,20 +386,20 @@ export function ThemeEditorBasic() {
}}
class="theme-editor-basdic-slider"
style="
- -webkit-appearance: none;
- width: calc(100% + 18px);
- box-sizing: border-box;
- border-radius: 0px;
- position: absolute;
- background: #0000;
- appearance: none;
- cursor: pointer;
- outline: none;
- height: 100%;
- left: -9px;
- margin: 0;
- top: 0;
- "
+ -webkit-appearance: none;
+ width: calc(100% + 18px);
+ box-sizing: border-box;
+ border-radius: 0px;
+ position: absolute;
+ background: #0000;
+ appearance: none;
+ cursor: pointer;
+ outline: none;
+ height: 100%;
+ left: -9px;
+ margin: 0;
+ top: 0;
+ "
step="0.001"
type="range"
max="0.37"
@@ -444,38 +410,38 @@ export function ThemeEditorBasic() {
<div style="position: relative;">
<div
style="
- transform: translateY(-50%);
- position: absolute;
- top: 50%;
- left: 0;
- "
+ transform: translateY(-50%);
+ position: absolute;
+ top: 50%;
+ left: 0;
+ "
>
saturation:
</div>
</div>
<div
style="
- box-sizing: border-box;
- position: relative;
- height: 10px;
- width: 100%;
- "
+ box-sizing: border-box;
+ position: relative;
+ height: 10px;
+ width: 100%;
+ "
>
<div
style="
- grid-template-columns: 50fr 40.5fr 32fr 24.5fr 18fr 12.5fr 8fr 5fr 2fr 0.5fr;
- transform: translate(-50%, -50%);
- background-color: var(--b4);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- position: absolute;
- display: grid;
- height: 10px;
- width: 100%;
- left: 50%;
- top: 50%;
- gap: 1px;
- "
+ grid-template-columns: 50fr 40.5fr 32fr 24.5fr 18fr 12.5fr 8fr 5fr 2fr 0.5fr;
+ transform: translate(-50%, -50%);
+ background-color: var(--b4);
+ border: 1px solid var(--b4);
+ box-sizing: border-box;
+ position: absolute;
+ display: grid;
+ height: 10px;
+ width: 100%;
+ left: 50%;
+ top: 50%;
+ gap: 1px;
+ "
>
<div style="background-color: var(--b0); height: 100%; width: 100%;" />
<div style="background-color: var(--b0); height: 100%; width: 100%;" />
@@ -491,16 +457,16 @@ export function ThemeEditorBasic() {
<div
style={{
- left: `${(themeReactive.b0.c[0]() / (themeReactive.a0.c[0]() * 0.8) / 0.37) * 100}%`,
- transform: 'translate(-50%, -50%)',
+ 'left': `${(themeReactive.b0.c[0]() / (themeReactive.a0.c[0]() * 0.8) / 0.37) * 100}%`,
+ 'transform': 'translate(-50%, -50%)',
'background-color': 'var(--b0)',
- border: '1px solid var(--b4)',
+ 'border': '1px solid var(--b4)',
'box-sizing': 'border-box',
'border-radius': '0px',
- position: 'absolute',
- height: '18px',
- width: '18px',
- top: '50%',
+ 'position': 'absolute',
+ 'height': '18px',
+ 'width': '18px',
+ 'top': '50%',
}}
/>
@@ -510,20 +476,20 @@ export function ThemeEditorBasic() {
}}
class="theme-editor-basdic-slider"
style="
- -webkit-appearance: none;
- width: calc(100% + 18px);
- box-sizing: border-box;
- border-radius: 0px;
- position: absolute;
- background: #0000;
- appearance: none;
- cursor: pointer;
- outline: none;
- height: 100%;
- left: -9px;
- margin: 0;
- top: 0;
- "
+ -webkit-appearance: none;
+ width: calc(100% + 18px);
+ box-sizing: border-box;
+ border-radius: 0px;
+ position: absolute;
+ background: #0000;
+ appearance: none;
+ cursor: pointer;
+ outline: none;
+ height: 100%;
+ left: -9px;
+ margin: 0;
+ top: 0;
+ "
ref={sliderSaturationRef}
step="0.001"
type="range"
@@ -536,38 +502,38 @@ export function ThemeEditorBasic() {
<div style="position: relative;">
<div
style="
- transform: translateY(-50%);
- position: absolute;
- top: 50%;
- left: 0;
- "
+ transform: translateY(-50%);
+ position: absolute;
+ top: 50%;
+ left: 0;
+ "
>
contrast:
</div>
</div>
<div
style="
- box-sizing: border-box;
- position: relative;
- height: 10px;
- width: 100%;
- "
+ box-sizing: border-box;
+ position: relative;
+ height: 10px;
+ width: 100%;
+ "
>
<div
style="
- grid-template-columns: 0.5fr 2fr 5fr 8fr 12.5fr 18fr 50fr 50fr 18fr 12.5fr 8fr 5fr 2fr 0.5fr;
- transform: translate(-50%, -50%);
- background-color: var(--b4);
- border: 1px solid var(--b4);
- box-sizing: border-box;
- position: absolute;
- display: grid;
- height: 10px;
- width: 100%;
- left: 50%;
- top: 50%;
- gap: 1px;
- "
+ grid-template-columns: 0.5fr 2fr 5fr 8fr 12.5fr 18fr 50fr 50fr 18fr 12.5fr 8fr 5fr 2fr 0.5fr;
+ transform: translate(-50%, -50%);
+ background-color: var(--b4);
+ border: 1px solid var(--b4);
+ box-sizing: border-box;
+ position: absolute;
+ display: grid;
+ height: 10px;
+ width: 100%;
+ left: 50%;
+ top: 50%;
+ gap: 1px;
+ "
>
<div style="background-color: var(--b0); height: 100%; width: 100%;" />
<div style="background-color: var(--b0); height: 100%; width: 100%;" />
@@ -587,16 +553,16 @@ export function ThemeEditorBasic() {
<div
style={{
- left: `${getContrastFromY(themeReactive.b0.l[0]()) * 100}%`,
- transform: 'translate(-50%, -50%)',
+ 'left': `${getContrastFromY(themeReactive.b0.l[0]()) * 100}%`,
+ 'transform': 'translate(-50%, -50%)',
'background-color': 'var(--b0)',
- border: '1px solid var(--b4)',
+ 'border': '1px solid var(--b4)',
'box-sizing': 'border-box',
'border-radius': '0px',
- position: 'absolute',
- height: '18px',
- width: '18px',
- top: '50%',
+ 'position': 'absolute',
+ 'height': '18px',
+ 'width': '18px',
+ 'top': '50%',
}}
/>
@@ -606,20 +572,20 @@ export function ThemeEditorBasic() {
}}
class="theme-editor-basdic-slider"
style="
- -webkit-appearance: none;
- width: calc(100% + 18px);
- box-sizing: border-box;
- border-radius: 0px;
- position: absolute;
- background: #0000;
- appearance: none;
- cursor: pointer;
- outline: none;
- height: 100%;
- left: -9px;
- margin: 0;
- top: 0;
- "
+ -webkit-appearance: none;
+ width: calc(100% + 18px);
+ box-sizing: border-box;
+ border-radius: 0px;
+ position: absolute;
+ background: #0000;
+ appearance: none;
+ cursor: pointer;
+ outline: none;
+ height: 100%;
+ left: -9px;
+ margin: 0;
+ top: 0;
+ "
ref={sliderContrastRef}
type="range"
step="0.001"
diff --git a/js/app/packages/block-theme/components/ThemeList.tsx b/js/app/packages/block-theme/components/ThemeList.tsx
index d4dc5d0f9e..056f8865aa 100644
--- a/js/app/packages/block-theme/components/ThemeList.tsx
+++ b/js/app/packages/block-theme/components/ThemeList.tsx
@@ -52,31 +52,29 @@ export function ThemeList() {
<div
style="
- font-family: var(--font-mono);
- border: 1px solid var(--b4);
- overscoll-behavior: none;
- scrollbar-width: none;
- overflow-y: scroll;
- font-size: 14px;
- "
+ font-family: var(--font-mono);
+ border: 1px solid var(--b4);
+ overscoll-behavior: none;
+ scrollbar-width: none;
+ overflow-y: scroll;
+ font-size: 14px;
+ "
>
<div
style="
- background-color: var(--b4);
- overscroll-behavior: none;
- box-sizing: border-box;
- overflow-x: hidden;
- display: grid;
- gap: 1px;
- "
+ background-color: var(--b4);
+ overscroll-behavior: none;
+ box-sizing: border-box;
+ overflow-x: hidden;
+ display: grid;
+ gap: 1px;
+ "
>
<For each={themes()}>
{(theme) => (
<div
class={`theme-list-item ${theme.id === currentThemeId() && isThemeSaved() ? 'current-theme' : ''}`}
- onPointerDown={() => {
- applyTheme(theme.id);
- }}
+ onPointerDown={() => {applyTheme(theme.id)}}
style="
grid-template-columns: min-content 1fr min-content;
background-color: var(--b0);
@@ -95,27 +93,27 @@ export function ThemeList() {
"
>
<ColorSwatch
- width={'10px'}
color={`oklch(${theme.tokens.a0.l} ${theme.tokens.a0.c} ${theme.tokens.a0.h}deg)`}
+ width={'10px'}
/>
<ColorSwatch
- width={'10px'}
color={`oklch(${theme.tokens.b0.l} ${theme.tokens.b0.c} ${theme.tokens.b0.h}deg)`}
+ width={'10px'}
/>
<ColorSwatch
- width={'10px'}
color={`oklch(${theme.tokens.c0.l} ${theme.tokens.c0.c} ${theme.tokens.c0.h}deg)`}
+ width={'10px'}
/>
</div>
<hr
style="
- border: none;
- transition: border-color var(--transition);
- border-top: 1px dashed var(--b4);
- box-sizing: border-box;
- width: 100%;
- "
+ border: none;
+ transition: border-color var(--transition);
+ border-top: 1px dashed var(--b4);
+ box-sizing: border-box;
+ width: 100%;
+ "
/>
<div
@@ -123,7 +121,7 @@ export function ThemeList() {
style="
transition: color var(--transition);
white-space: nowrap;
- "
+ "
>
{theme.name}
</div>
diff --git a/js/app/packages/block-theme/components/ThemeTools.tsx b/js/app/packages/block-theme/components/ThemeTools.tsx
index c5019fca79..b505399fcb 100644
--- a/js/app/packages/block-theme/components/ThemeTools.tsx
+++ b/js/app/packages/block-theme/components/ThemeTools.tsx
@@ -1,59 +1,39 @@
-import { IconButton } from '@core/component/IconButton';
-import { DEV_MODE_ENV } from '@core/constant/featureFlags';
-import IconClipboard from '@macro-icons/macro-clipboard.svg';
-import IconDice from '@macro-icons/macro-dice.svg';
+import { deleteTheme, exportTheme, invertTheme, saveTheme } from '../utils/themeUtils';
+import { currentThemeId, isThemeSaved, themes } from '../signals/themeSignals';
+import { createEffect, createMemo, createSignal, Show } from 'solid-js';
import IconLightDark from '@macro-icons/macro-light-dark.svg';
-import IconSave from '@macro-icons/macro-save.svg';
+import IconClipboard from '@macro-icons/macro-clipboard.svg';
+import { DEV_MODE_ENV } from '@core/constant/featureFlags';
+import { IconButton } from '@core/component/IconButton';
// import IconFigma from '@macro-icons/macro-figma.svg';
import IconTrash from '@macro-icons/macro-trash.svg';
-import { createEffect, createMemo, createSignal, Show } from 'solid-js';
-import { DEFAULT_THEMES } from '../constants';
-import { currentThemeId, isThemeSaved, themes } from '../signals/themeSignals';
-import {
- deleteTheme,
- exportTheme,
- invertTheme,
- saveTheme,
-} from '../utils/themeUtils';
import { randomizeTheme } from './ThemeEditorBasic';
+import IconDice from '@macro-icons/macro-dice.svg';
+import IconSave from '@macro-icons/macro-save.svg';
// import { copyTokens } from './ComputeTokens';
+import { DEFAULT_THEMES } from '../constants';
export function ThemeTools() {
let themeName!: HTMLDivElement;
const currentThemeName = createMemo(() => {
const theme = themes().find((theme) => theme.id === currentThemeId());
- if (isThemeSaved()) {
- return theme?.name;
- } else {
- return 'Theme Name';
- }
+ if(isThemeSaved()){return theme?.name}
+ else{return 'Theme Name'}
});
const [showTrash, setShowTrash] = createSignal<boolean>(true);
createEffect(() => {
- if (
- isThemeSaved() &&
- !DEFAULT_THEMES.find((t) => t.id === currentThemeId())
- ) {
- setShowTrash(true);
- } else {
- setShowTrash(false);
- }
+ if(isThemeSaved() && !DEFAULT_THEMES.find((t) => t.id === currentThemeId())){setShowTrash(true)}
+ else{setShowTrash(false)}
});
const [columnCount, setColumnCount] = createSignal(0);
createEffect(() => {
let count = 3;
- if (!isThemeSaved()) {
- count++;
- }
- if (DEV_MODE_ENV) {
- count++;
- }
- if (showTrash()) {
- count++;
- }
+ if(!isThemeSaved()){count++}
+ if(DEV_MODE_ENV){count++}
+ if(showTrash()){count++}
setColumnCount(count);
});
@@ -61,17 +41,17 @@ export function ThemeTools() {
<div
style={{
'grid-template-columns': `min-content 1fr repeat(${columnCount()}, min-content)`,
- padding: '0 12px 0 20px' /* (41 - 32) / 2 */,
- gap: '4.5px' /* (41 - 32) / 2 */,
+ 'padding': '0 12px 0 20px' /* (41 - 32) / 2 */,
+ 'gap': '4.5px' /* (41 - 32) / 2 */,
'font-family': 'var( --font-mono)',
- border: '1px solid var(--b4)',
+ 'border': '1px solid var(--b4)',
'scrollbar-width': 'none',
'align-items': 'center',
- overflow: 'hidden',
+ 'overflow': 'hidden',
'font-size': '14px',
- display: 'grid',
- height: '43px',
- width: '100%',
+ 'display': 'grid',
+ 'height': '43px',
+ 'width': '100%',
}}
>
<div ref={themeName} contentEditable style="white-space: nowrap;">
@@ -80,11 +60,11 @@ export function ThemeTools() {
<hr
style="
- border: none;
- border-top: 1px dashed var(--b4);
- box-sizing: border-box;
- width: 100%;
- "
+ border: none;
+ border-top: 1px dashed var(--b4);
+ box-sizing: border-box;
+ width: 100%;
+ "
/>
<Show when={showTrash()}>
diff --git a/js/app/packages/block-theme/signals/themeReactive.ts b/js/app/packages/block-theme/signals/themeReactive.ts
index beca3f9644..64d99ab3f8 100644
--- a/js/app/packages/block-theme/signals/themeReactive.ts
+++ b/js/app/packages/block-theme/signals/themeReactive.ts
@@ -1,41 +1,41 @@
-import { createEffect, createSignal, on } from 'solid-js';
import type { ThemePrevious, ThemeReactive } from '../types/themeTypes';
-import { setIsThemeSaved, setThemeUpdate, themeUpdate } from './themeSignals';
+import { setIsThemeSaved, setThemeUpdate } from './themeSignals';
+import { createEffect, createSignal, on } from 'solid-js';
export const themeReactive: ThemeReactive = {
- a0: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- a1: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- a2: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- a3: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- a4: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- b0: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- b1: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- b2: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- b3: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- b4: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- c0: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- c1: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- c2: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- c3: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
- c4: { l: createSignal(0), c: createSignal(0), h: createSignal(0) },
+ a0: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ a1: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ a2: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ a3: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ a4: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ b0: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ b1: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ b2: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ b3: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ b4: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ c0: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ c1: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ c2: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ c3: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
+ c4: {l: createSignal(0), c: createSignal(0), h: createSignal(0)},
};
const previousTheme: ThemePrevious = {
- a0: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- a1: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- a2: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- a3: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- a4: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- b0: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- b1: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- b2: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- b3: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- b4: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- c0: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- c1: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- c2: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- c3: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
- c4: { l: Number.NaN, c: Number.NaN, h: Number.NaN },
+ a0: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ a1: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ a2: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ a3: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ a4: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ b0: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ b1: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ b2: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ b3: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ b4: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ c0: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ c1: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ c2: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ c3: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
+ c4: {l: Number.NaN, c: Number.NaN, h: Number.NaN},
};
let transitionState = false;
@@ -51,51 +51,21 @@ function jamTransition(): void {
}
}
const ALL_THEME_SIGNALS = [
- themeReactive.a0.l[0],
- themeReactive.a0.c[0],
- themeReactive.a0.h[0],
- themeReactive.a1.l[0],
- themeReactive.a1.c[0],
- themeReactive.a1.h[0],
- themeReactive.a2.l[0],
- themeReactive.a2.c[0],
- themeReactive.a2.h[0],
- themeReactive.a3.l[0],
- themeReactive.a3.c[0],
- themeReactive.a3.h[0],
- themeReactive.a4.l[0],
- themeReactive.a4.c[0],
- themeReactive.a4.h[0],
- themeReactive.b0.l[0],
- themeReactive.b0.c[0],
- themeReactive.b0.h[0],
- themeReactive.b1.l[0],
- themeReactive.b1.c[0],
- themeReactive.b1.h[0],
- themeReactive.b2.l[0],
- themeReactive.b2.c[0],
- themeReactive.b2.h[0],
- themeReactive.b3.l[0],
- themeReactive.b3.c[0],
- themeReactive.b3.h[0],
- themeReactive.b4.l[0],
- themeReactive.b4.c[0],
- themeReactive.b4.h[0],
- themeReactive.c0.l[0],
- themeReactive.c0.h[0],
- themeReactive.c0.c[0],
- themeReactive.c1.l[0],
- themeReactive.c1.c[0],
- themeReactive.c1.h[0],
- themeReactive.c2.l[0],
- themeReactive.c2.c[0],
- themeReactive.c2.h[0],
- themeReactive.c3.l[0],
- themeReactive.c3.c[0],
- themeReactive.c3.h[0],
- themeReactive.c4.l[0],
- themeReactive.c4.c[0],
- themeReactive.c4.h[0],
+ themeReactive.a0.l[0], themeReactive.a0.c[0], themeReactive.a0.h[0],
+ themeReactive.a1.l[0], themeReactive.a1.c[0], themeReactive.a1.h[0],
+ themeReactive.a2.l[0], themeReactive.a2.c[0], themeReactive.a2.h[0],
+ themeReactive.a3.l[0], themeReactive.a3.c[0], themeReactive.a3.h[0],
+ themeReactive.a4.l[0], themeReactive.a4.c[0], themeReactive.a4.h[0],
+ themeReactive.b0.l[0], themeReactive.b0.c[0], themeReactive.b0.h[0],
+ themeReactive.b1.l[0], themeReactive.b1.c[0], themeReactive.b1.h[0],
+ themeReactive.b2.l[0], themeReactive.b2.c[0], themeReactive.b2.h[0],
+ themeReactive.b3.l[0], themeReactive.b3.c[0], themeReactive.b3.h[0],
+ themeReactive.b4.l[0], themeReactive.b4.c[0], themeReactive.b4.h[0],
+ themeReactive.c0.l[0], themeReactive.c0.h[0], themeReactive.c0.c[0],
+ themeReactive.c1.l[0], themeReactive.c1.c[0], themeReactive.c1.h[0],
+ themeReactive.c2.l[0], themeReactive.c2.c[0], themeReactive.c2.h[0],
+ themeReactive.c3.l[0], themeReactive.c3.c[0], themeReactive.c3.h[0],
+ themeReactive.c4.l[0], themeReactive.c4.c[0], themeReactive.c4.h[0],
];
createEffect(
@@ -104,323 +74,53 @@ createEffect(
() => {
jamTransition();
- if (themeReactive.a0.l[0]() !== previousTheme.a0.l) {
- document.documentElement.style.setProperty(
- '--a0l',
- `${themeReactive.a0.l[0]()}`
- );
- previousTheme.a0.l = themeReactive.a0.l[0]();
- }
- if (themeReactive.a0.c[0]() !== previousTheme.a0.c) {
- document.documentElement.style.setProperty(
- '--a0c',
- `${themeReactive.a0.c[0]()}`
- );
- previousTheme.a0.c = themeReactive.a0.c[0]();
- }
- if (themeReactive.a0.h[0]() !== previousTheme.a0.h) {
- document.documentElement.style.setProperty(
- '--a0h',
- `${themeReactive.a0.h[0]()}deg`
- );
- previousTheme.a0.h = themeReactive.a0.h[0]();
- }
- if (themeReactive.a1.l[0]() !== previousTheme.a1.l) {
- document.documentElement.style.setProperty(
- '--a1l',
- `${themeReactive.a1.l[0]()}`
- );
- previousTheme.a1.l = themeReactive.a1.l[0]();
- }
- if (themeReactive.a1.c[0]() !== previousTheme.a1.c) {
- document.documentElement.style.setProperty(
- '--a1c',
- `${themeReactive.a1.c[0]()}`
- );
- previousTheme.a1.c = themeReactive.a1.c[0]();
- }
- if (themeReactive.a1.h[0]() !== previousTheme.a1.h) {
- document.documentElement.style.setProperty(
- '--a1h',
- `${themeReactive.a1.h[0]()}deg`
- );
- previousTheme.a1.h = themeReactive.a1.h[0]();
- }
- if (themeReactive.a2.l[0]() !== previousTheme.a2.l) {
- document.documentElement.style.setProperty(
- '--a2l',
- `${themeReactive.a2.l[0]()}`
- );
- previousTheme.a2.l = themeReactive.a2.l[0]();
- }
- if (themeReactive.a2.c[0]() !== previousTheme.a2.c) {
- document.documentElement.style.setProperty(
- '--a2c',
- `${themeReactive.a2.c[0]()}`
- );
- previousTheme.a2.c = themeReactive.a2.c[0]();
- }
- if (themeReactive.a2.h[0]() !== previousTheme.a2.h) {
- document.documentElement.style.setProperty(
- '--a2h',
- `${themeReactive.a2.h[0]()}deg`
- );
- previousTheme.a2.h = themeReactive.a2.h[0]();
- }
- if (themeReactive.a3.l[0]() !== previousTheme.a3.l) {
- document.documentElement.style.setProperty(
- '--a3l',
- `${themeReactive.a3.l[0]()}`
- );
- previousTheme.a3.l = themeReactive.a3.l[0]();
- }
- if (themeReactive.a3.c[0]() !== previousTheme.a3.c) {
- document.documentElement.style.setProperty(
- '--a3c',
- `${themeReactive.a3.c[0]()}`
- );
- previousTheme.a3.c = themeReactive.a3.c[0]();
- }
- if (themeReactive.a3.h[0]() !== previousTheme.a3.h) {
- document.documentElement.style.setProperty(
- '--a3h',
- `${themeReactive.a3.h[0]()}deg`
- );
- previousTheme.a3.h = themeReactive.a3.h[0]();
- }
- if (themeReactive.a4.l[0]() !== previousTheme.a4.l) {
- document.documentElement.style.setProperty(
- '--a4l',
- `${themeReactive.a4.l[0]()}`
- );
- previousTheme.a4.l = themeReactive.a4.l[0]();
- }
- if (themeReactive.a4.c[0]() !== previousTheme.a4.c) {
- document.documentElement.style.setProperty(
- '--a4c',
- `${themeReactive.a4.c[0]()}`
- );
- previousTheme.a4.c = themeReactive.a4.c[0]();
- }
- if (themeReactive.a4.h[0]() !== previousTheme.a4.h) {
- document.documentElement.style.setProperty(
- '--a4h',
- `${themeReactive.a4.h[0]()}deg`
- );
- previousTheme.a4.h = themeReactive.a4.h[0]();
- }
- if (themeReactive.b0.l[0]() !== previousTheme.b0.l) {
- document.documentElement.style.setProperty(
- '--b0l',
- `${themeReactive.b0.l[0]()}`
- );
- previousTheme.b0.l = themeReactive.b0.l[0]();
- }
- if (themeReactive.b0.c[0]() !== previousTheme.b0.c) {
- document.documentElement.style.setProperty(
- '--b0c',
- `${themeReactive.b0.c[0]()}`
- );
- previousTheme.b0.c = themeReactive.b0.c[0]();
- }
- if (themeReactive.b0.h[0]() !== previousTheme.b0.h) {
- document.documentElement.style.setProperty(
- '--b0h',
- `${themeReactive.b0.h[0]()}deg`
- );
- previousTheme.b0.h = themeReactive.b0.h[0]();
- }
- if (themeReactive.b1.l[0]() !== previousTheme.b1.l) {
- document.documentElement.style.setProperty(
- '--b1l',
- `${themeReactive.b1.l[0]()}`
- );
- previousTheme.b1.l = themeReactive.b1.l[0]();
- }
- if (themeReactive.b1.c[0]() !== previousTheme.b1.c) {
- document.documentElement.style.setProperty(
- '--b1c',
- `${themeReactive.b1.c[0]()}`
- );
- previousTheme.b1.c = themeReactive.b1.c[0]();
- }
- if (themeReactive.b1.h[0]() !== previousTheme.b1.h) {
- document.documentElement.style.setProperty(
- '--b1h',
- `${themeReactive.b1.h[0]()}deg`
- );
- previousTheme.b1.h = themeReactive.b1.h[0]();
- }
- if (themeReactive.b2.l[0]() !== previousTheme.b2.l) {
- document.documentElement.style.setProperty(
- '--b2l',
- `${themeReactive.b2.l[0]()}`
- );
- previousTheme.b2.l = themeReactive.b2.l[0]();
- }
- if (themeReactive.b2.c[0]() !== previousTheme.b2.c) {
- document.documentElement.style.setProperty(
- '--b2c',
- `${themeReactive.b2.c[0]()}`
- );
- previousTheme.b2.c = themeReactive.b2.c[0]();
- }
- if (themeReactive.b2.h[0]() !== previousTheme.b2.h) {
- document.documentElement.style.setProperty(
- '--b2h',
- `${themeReactive.b2.h[0]()}deg`
- );
- previousTheme.b2.h = themeReactive.b2.h[0]();
- }
- if (themeReactive.b3.l[0]() !== previousTheme.b3.l) {
- document.documentElement.style.setProperty(
- '--b3l',
- `${themeReactive.b3.l[0]()}`
- );
- previousTheme.b3.l = themeReactive.b3.l[0]();
- }
- if (themeReactive.b3.c[0]() !== previousTheme.b3.c) {
- document.documentElement.style.setProperty(
- '--b3c',
- `${themeReactive.b3.c[0]()}`
- );
- previousTheme.b3.c = themeReactive.b3.c[0]();
- }
- if (themeReactive.b3.h[0]() !== previousTheme.b3.h) {
- document.documentElement.style.setProperty(
- '--b3h',
- `${themeReactive.b3.h[0]()}deg`
- );
- previousTheme.b3.h = themeReactive.b3.h[0]();
- }
- if (themeReactive.b4.l[0]() !== previousTheme.b4.l) {
- document.documentElement.style.setProperty(
- '--b4l',
- `${themeReactive.b4.l[0]()}`
- );
- previousTheme.b4.l = themeReactive.b4.l[0]();
- }
- if (themeReactive.b4.c[0]() !== previousTheme.b4.c) {
- document.documentElement.style.setProperty(
- '--b4c',
- `${themeReactive.b4.c[0]()}`
- );
- previousTheme.b4.c = themeReactive.b4.c[0]();
- }
- if (themeReactive.b4.h[0]() !== previousTheme.b4.h) {
- document.documentElement.style.setProperty(
- '--b4h',
- `${themeReactive.b4.h[0]()}deg`
- );
- previousTheme.b4.h = themeReactive.b4.h[0]();
- }
- if (themeReactive.c0.l[0]() !== previousTheme.c0.l) {
- document.documentElement.style.setProperty(
- '--c0l',
- `${themeReactive.c0.l[0]()}`
- );
- previousTheme.c0.l = themeReactive.c0.l[0]();
- }
- if (themeReactive.c0.c[0]() !== previousTheme.c0.c) {
- document.documentElement.style.setProperty(
- '--c0c',
- `${themeReactive.c0.c[0]()}`
- );
- previousTheme.c0.c = themeReactive.c0.c[0]();
- }
- if (themeReactive.c0.h[0]() !== previousTheme.c0.h) {
- document.documentElement.style.setProperty(
- '--c0h',
- `${themeReactive.c0.h[0]()}deg`
- );
- previousTheme.c0.h = themeReactive.c0.h[0]();
- }
- if (themeReactive.c1.l[0]() !== previousTheme.c1.l) {
- document.documentElement.style.setProperty(
- '--c1l',
- `${themeReactive.c1.l[0]()}`
- );
- previousTheme.c1.l = themeReactive.c1.l[0]();
- }
- if (themeReactive.c1.c[0]() !== previousTheme.c1.c) {
- document.documentElement.style.setProperty(
- '--c1c',
- `${themeReactive.c1.c[0]()}`
- );
- previousTheme.c1.c = themeReactive.c1.c[0]();
- }
- if (themeReactive.c1.h[0]() !== previousTheme.c1.h) {
- document.documentElement.style.setProperty(
- '--c1h',
- `${themeReactive.c1.h[0]()}deg`
- );
- previousTheme.c1.h = themeReactive.c1.h[0]();
- }
- if (themeReactive.c2.l[0]() !== previousTheme.c2.l) {
- document.documentElement.style.setProperty(
- '--c2l',
- `${themeReactive.c2.l[0]()}`
- );
- previousTheme.c2.l = themeReactive.c2.l[0]();
- }
- if (themeReactive.c2.c[0]() !== previousTheme.c2.c) {
- document.documentElement.style.setProperty(
- '--c2c',
- `${themeReactive.c2.c[0]()}`
- );
- previousTheme.c2.c = themeReactive.c2.c[0]();
- }
- if (themeReactive.c2.h[0]() !== previousTheme.c2.h) {
- document.documentElement.style.setProperty(
- '--c2h',
- `${themeReactive.c2.h[0]()}deg`
- );
- previousTheme.c2.h = themeReactive.c2.h[0]();
- }
- if (themeReactive.c3.l[0]() !== previousTheme.c3.l) {
- document.documentElement.style.setProperty(
- '--c3l',
- `${themeReactive.c3.l[0]()}`
- );
- previousTheme.c3.l = themeReactive.c3.l[0]();
- }
- if (themeReactive.c3.c[0]() !== previousTheme.c3.c) {
- document.documentElement.style.setProperty(
- '--c3c',
- `${themeReactive.c3.c[0]()}`
- );
- previousTheme.c3.c = themeReactive.c3.c[0]();
- }
- if (themeReactive.c3.h[0]() !== previousTheme.c3.h) {
- document.documentElement.style.setProperty(
- '--c3h',
- `${themeReactive.c3.h[0]()}deg`
- );
- previousTheme.c3.h = themeReactive.c3.h[0]();
- }
- if (themeReactive.c4.l[0]() !== previousTheme.c4.l) {
- document.documentElement.style.setProperty(
- '--c4l',
- `${themeReactive.c4.l[0]()}`
- );
- previousTheme.c4.l = themeReactive.c4.l[0]();
- }
- if (themeReactive.c4.c[0]() !== previousTheme.c4.c) {
- document.documentElement.style.setProperty(
- '--c4c',
- `${themeReactive.c4.c[0]()}`
- );
- previousTheme.c4.c = themeReactive.c4.c[0]();
- }
- if (themeReactive.c4.h[0]() !== previousTheme.c4.h) {
- document.documentElement.style.setProperty(
- '--c4h',
- `${themeReactive.c4.h[0]()}deg`
- );
- previousTheme.c4.h = themeReactive.c4.h[0]();
- }
+ if(themeReactive.a0.l[0]() !== previousTheme.a0.l){document.documentElement.style.setProperty( '--a0l', `${themeReactive.a0.l[0]()}` ); previousTheme.a0.l = themeReactive.a0.l[0]()}
+ if(themeReactive.a0.c[0]() !== previousTheme.a0.c){document.documentElement.style.setProperty( '--a0c', `${themeReactive.a0.c[0]()}` ); previousTheme.a0.c = themeReactive.a0.c[0]()}
+ if(themeReactive.a0.h[0]() !== previousTheme.a0.h){document.documentElement.style.setProperty( '--a0h', `${themeReactive.a0.h[0]()}deg` ); previousTheme.a0.h = themeReactive.a0.h[0]()}
+ if(themeReactive.a1.l[0]() !== previousTheme.a1.l){document.documentElement.style.setProperty( '--a1l', `${themeReactive.a1.l[0]()}` ); previousTheme.a1.l = themeReactive.a1.l[0]()}
+ if(themeReactive.a1.c[0]() !== previousTheme.a1.c){document.documentElement.style.setProperty( '--a1c', `${themeReactive.a1.c[0]()}` ); previousTheme.a1.c = themeReactive.a1.c[0]()}
+ if(themeReactive.a1.h[0]() !== previousTheme.a1.h){document.documentElement.style.setProperty( '--a1h', `${themeReactive.a1.h[0]()}deg` ); previousTheme.a1.h = themeReactive.a1.h[0]()}
+ if(themeReactive.a2.l[0]() !== previousTheme.a2.l){document.documentElement.style.setProperty( '--a2l', `${themeReactive.a2.l[0]()}` ); previousTheme.a2.l = themeReactive.a2.l[0]()}
+ if(themeReactive.a2.c[0]() !== previousTheme.a2.c){document.documentElement.style.setProperty( '--a2c', `${themeReactive.a2.c[0]()}` ); previousTheme.a2.c = themeReactive.a2.c[0]()}
+ if(themeReactive.a2.h[0]() !== previousTheme.a2.h){document.documentElement.style.setProperty( '--a2h', `${themeReactive.a2.h[0]()}deg` ); previousTheme.a2.h = themeReactive.a2.h[0]()}
+ if(themeReactive.a3.l[0]() !== previousTheme.a3.l){document.documentElement.style.setProperty( '--a3l', `${themeReactive.a3.l[0]()}` ); previousTheme.a3.l = themeReactive.a3.l[0]()}
+ if(themeReactive.a3.c[0]() !== previousTheme.a3.c){document.documentElement.style.setProperty( '--a3c', `${themeReactive.a3.c[0]()}` ); previousTheme.a3.c = themeReactive.a3.c[0]()}
+ if(themeReactive.a3.h[0]() !== previousTheme.a3.h){document.documentElement.style.setProperty( '--a3h', `${themeReactive.a3.h[0]()}deg` ); previousTheme.a3.h = themeReactive.a3.h[0]()}
+ if(themeReactive.a4.l[0]() !== previousTheme.a4.l){document.documentElement.style.setProperty( '--a4l', `${themeReactive.a4.l[0]()}` ); previousTheme.a4.l = themeReactive.a4.l[0]()}
+ if(themeReactive.a4.c[0]() !== previousTheme.a4.c){document.documentElement.style.setProperty( '--a4c', `${themeReactive.a4.c[0]()}` ); previousTheme.a4.c = themeReactive.a4.c[0]()}
+ if(themeReactive.a4.h[0]() !== previousTheme.a4.h){document.documentElement.style.setProperty( '--a4h', `${themeReactive.a4.h[0]()}deg` ); previousTheme.a4.h = themeReactive.a4.h[0]()}
+ if(themeReactive.b0.l[0]() !== previousTheme.b0.l){document.documentElement.style.setProperty( '--b0l', `${themeReactive.b0.l[0]()}` ); previousTheme.b0.l = themeReactive.b0.l[0]()}
+ if(themeReactive.b0.c[0]() !== previousTheme.b0.c){document.documentElement.style.setProperty( '--b0c', `${themeReactive.b0.c[0]()}` ); previousTheme.b0.c = themeReactive.b0.c[0]()}
+ if(themeReactive.b0.h[0]() !== previousTheme.b0.h){document.documentElement.style.setProperty( '--b0h', `${themeReactive.b0.h[0]()}deg` ); previousTheme.b0.h = themeReactive.b0.h[0]()}
+ if(themeReactive.b1.l[0]() !== previousTheme.b1.l){document.documentElement.style.setProperty( '--b1l', `${themeReactive.b1.l[0]()}` ); previousTheme.b1.l = themeReactive.b1.l[0]()}
+ if(themeReactive.b1.c[0]() !== previousTheme.b1.c){document.documentElement.style.setProperty( '--b1c', `${themeReactive.b1.c[0]()}` ); previousTheme.b1.c = themeReactive.b1.c[0]()}
+ if(themeReactive.b1.h[0]() !== previousTheme.b1.h){document.documentElement.style.setProperty( '--b1h', `${themeReactive.b1.h[0]()}deg` ); previousTheme.b1.h = themeReactive.b1.h[0]()}
+ if(themeReactive.b2.l[0]() !== previousTheme.b2.l){document.documentElement.style.setProperty( '--b2l', `${themeReactive.b2.l[0]()}` ); previousTheme.b2.l = themeReactive.b2.l[0]()}
+ if(themeReactive.b2.c[0]() !== previousTheme.b2.c){document.documentElement.style.setProperty( '--b2c', `${themeReactive.b2.c[0]()}` ); previousTheme.b2.c = themeReactive.b2.c[0]()}
+ if(themeReactive.b2.h[0]() !== previousTheme.b2.h){document.documentElement.style.setProperty( '--b2h', `${themeReactive.b2.h[0]()}deg` ); previousTheme.b2.h = themeReactive.b2.h[0]()}
+ if(themeReactive.b3.l[0]() !== previousTheme.b3.l){document.documentElement.style.setProperty( '--b3l', `${themeReactive.b3.l[0]()}` ); previousTheme.b3.l = themeReactive.b3.l[0]()}
+ if(themeReactive.b3.c[0]() !== previousTheme.b3.c){document.documentElement.style.setProperty( '--b3c', `${themeReactive.b3.c[0]()}` ); previousTheme.b3.c = themeReactive.b3.c[0]()}
+ if(themeReactive.b3.h[0]() !== previousTheme.b3.h){document.documentElement.style.setProperty( '--b3h', `${themeReactive.b3.h[0]()}deg` ); previousTheme.b3.h = themeReactive.b3.h[0]()}
+ if(themeReactive.b4.l[0]() !== previousTheme.b4.l){document.documentElement.style.setProperty( '--b4l', `${themeReactive.b4.l[0]()}` ); previousTheme.b4.l = themeReactive.b4.l[0]()}
+ if(themeReactive.b4.c[0]() !== previousTheme.b4.c){document.documentElement.style.setProperty( '--b4c', `${themeReactive.b4.c[0]()}` ); previousTheme.b4.c = themeReactive.b4.c[0]()}
+ if(themeReactive.b4.h[0]() !== previousTheme.b4.h){document.documentElement.style.setProperty( '--b4h', `${themeReactive.b4.h[0]()}deg` ); previousTheme.b4.h = themeReactive.b4.h[0]()}
+ if(themeReactive.c0.l[0]() !== previousTheme.c0.l){document.documentElement.style.setProperty( '--c0l', `${themeReactive.c0.l[0]()}` ); previousTheme.c0.l = themeReactive.c0.l[0]()}
+ if(themeReactive.c0.c[0]() !== previousTheme.c0.c){document.documentElement.style.setProperty( '--c0c', `${themeReactive.c0.c[0]()}` ); previousTheme.c0.c = themeReactive.c0.c[0]()}
+ if(themeReactive.c0.h[0]() !== previousTheme.c0.h){document.documentElement.style.setProperty( '--c0h', `${themeReactive.c0.h[0]()}deg` ); previousTheme.c0.h = themeReactive.c0.h[0]()}
+ if(themeReactive.c1.l[0]() !== previousTheme.c1.l){document.documentElement.style.setProperty( '--c1l', `${themeReactive.c1.l[0]()}` ); previousTheme.c1.l = themeReactive.c1.l[0]()}
+ if(themeReactive.c1.c[0]() !== previousTheme.c1.c){document.documentElement.style.setProperty( '--c1c', `${themeReactive.c1.c[0]()}` ); previousTheme.c1.c = themeReactive.c1.c[0]()}
+ if(themeReactive.c1.h[0]() !== previousTheme.c1.h){document.documentElement.style.setProperty( '--c1h', `${themeReactive.c1.h[0]()}deg` ); previousTheme.c1.h = themeReactive.c1.h[0]()}
+ if(themeReactive.c2.l[0]() !== previousTheme.c2.l){document.documentElement.style.setProperty( '--c2l', `${themeReactive.c2.l[0]()}` ); previousTheme.c2.l = themeReactive.c2.l[0]()}
+ if(themeReactive.c2.c[0]() !== previousTheme.c2.c){document.documentElement.style.setProperty( '--c2c', `${themeReactive.c2.c[0]()}` ); previousTheme.c2.c = themeReactive.c2.c[0]()}
+ if(themeReactive.c2.h[0]() !== previousTheme.c2.h){document.documentElement.style.setProperty( '--c2h', `${themeReactive.c2.h[0]()}deg` ); previousTheme.c2.h = themeReactive.c2.h[0]()}
+ if(themeReactive.c3.l[0]() !== previousTheme.c3.l){document.documentElement.style.setProperty( '--c3l', `${themeReactive.c3.l[0]()}` ); previousTheme.c3.l = themeReactive.c3.l[0]()}
+ if(themeReactive.c3.c[0]() !== previousTheme.c3.c){document.documentElement.style.setProperty( '--c3c', `${themeReactive.c3.c[0]()}` ); previousTheme.c3.c = themeReactive.c3.c[0]()}
+ if(themeReactive.c3.h[0]() !== previousTheme.c3.h){document.documentElement.style.setProperty( '--c3h', `${themeReactive.c3.h[0]()}deg` ); previousTheme.c3.h = themeReactive.c3.h[0]()}
+ if(themeReactive.c4.l[0]() !== previousTheme.c4.l){document.documentElement.style.setProperty( '--c4l', `${themeReactive.c4.l[0]()}` ); previousTheme.c4.l = themeReactive.c4.l[0]()}
+ if(themeReactive.c4.c[0]() !== previousTheme.c4.c){document.documentElement.style.setProperty( '--c4c', `${themeReactive.c4.c[0]()}` ); previousTheme.c4.c = themeReactive.c4.c[0]()}
+ if(themeReactive.c4.h[0]() !== previousTheme.c4.h){document.documentElement.style.setProperty( '--c4h', `${themeReactive.c4.h[0]()}deg` ); previousTheme.c4.h = themeReactive.c4.h[0]()}
- setThemeUpdate(themeUpdate() * -1);
+ setThemeUpdate();
setIsThemeSaved(false);
},
{ defer: true }
diff --git a/js/app/packages/block-theme/signals/themeSignals.ts b/js/app/packages/block-theme/signals/themeSignals.ts
index 16eb03f5e1..fa72f807b1 100644
--- a/js/app/packages/block-theme/signals/themeSignals.ts
+++ b/js/app/packages/block-theme/signals/themeSignals.ts
@@ -10,72 +10,59 @@ import { convertThemev0v1 } from '../utils/themeMigrations';
export const [isThemeSaved, setIsThemeSaved] = createSignal<boolean>(true);
-export const [themeUpdate, setThemeUpdate] = createSignal<number>(1);
+export const [themeUpdate, setThemeUpdate] = createSignal<undefined>(undefined, {equals: () => false});
export const [htmlColor, setHtmlColor] = makePersisted(
createSignal({ color: '' }),
- { name: 'html-color-theme' }
+ {name: 'html-color-theme'}
);
export const [userThemes, setUserThemes] = makePersisted(
createSignal<ThemeV1[]>([]),
- { name: 'macro-user-themes' }
+ {name: 'macro-user-themes'}
);
setUserThemes(
userThemes().map((theme) => {
- if (!theme.version) {
- return convertThemev0v1(theme as unknown as ThemeV0);
- } else {
- return theme;
- }
+ if(!theme.version){return convertThemev0v1(theme as unknown as ThemeV0)}
+ else{return theme}
})
);
let convertedDefaultThemes = DEFAULT_THEMES.map((theme) => {
- if (!theme.version) {
- return convertThemev0v1(theme as unknown as ThemeV0);
- } else {
- return theme;
- }
+ if(!theme.version){return convertThemev0v1(theme as unknown as ThemeV0)}
+ else{return theme}
});
export const [currentThemeId, setCurrentThemeId_] = makePersisted(
createSignal<string>(DEFAULT_DARK_THEME),
- { name: 'macro-selected-theme' }
+ {name: 'macro-selected-theme'}
);
// If theme should match system, when we set current theme, we also set the corresponding mode's theme
// This avoids the issue where a user sets a theme, and then refreshes, and gets reverted to their preferred mode's theme.
-export const setCurrentThemeId = (
- ...args: Parameters<typeof setCurrentThemeId_>
-) => {
+export const setCurrentThemeId = ( ...args: Parameters<typeof setCurrentThemeId_> ) => {
setCurrentThemeId_(...args);
- if (themeShouldMatchSystem()) {
- systemMode() === 'dark'
- ? setDarkModeTheme(...args)
- : setLightModeTheme(...args);
+ if(themeShouldMatchSystem()){
+ systemMode() === 'dark' ? setDarkModeTheme(...args) : setLightModeTheme(...args);
}
};
-export const themes = createMemo(() => [
- ...convertedDefaultThemes,
- ...userThemes(),
-]);
+export const themes = createMemo(() => [...convertedDefaultThemes, ...userThemes()]);
export const [lightModeTheme, setLightModeTheme] = makePersisted(
createSignal<string>(DEFAULT_LIGHT_THEME),
- { name: 'macro-light-mode-theme' }
+ {name: 'macro-light-mode-theme'}
);
export const [darkModeTheme, setDarkModeTheme] = makePersisted(
createSignal<string>(DEFAULT_DARK_THEME),
- { name: 'macro-dark-mode-theme' }
+ {name: 'macro-dark-mode-theme'}
);
-export const [themeShouldMatchSystem, setThemeShouldMatchSystem] =
- makePersisted(createSignal<boolean>(true), {
- name: 'macro-theme-should-match-system',
- });
+export const [themeShouldMatchSystem, setThemeShouldMatchSystem] = makePersisted(
+ createSignal<boolean>(true),
+ {name: 'macro-theme-should-match-system'}
+);
export const [systemMode, setSystemMode] = createSignal<'dark' | 'light'>(
window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
@@ -88,67 +75,35 @@ darkModeQuery.addEventListener('change', (e: MediaQueryListEvent) => {
export const [monochromeIcons, setMonochromeIcons] = makePersisted(
createSignal<boolean>(false),
- { name: 'enable-monochrome-icons' }
+ {name: 'enable-monochrome-icons'}
);
createEffect(() => {
- if (monochromeIcons()) {
+ if(monochromeIcons()){
document.documentElement.style.setProperty('--theme-contact', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-canvas', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-folder', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-image', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-write', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-video', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-html', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-note', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-code', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-chat', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-pdf', 'var(--c0)');
- document.documentElement.style.setProperty('--theme-rss', 'var(--c0)');
- } else {
- document.documentElement.style.setProperty(
- '--theme-folder',
- 'oklch(var(--a0l) var(--a0c) 240)'
- );
- document.documentElement.style.setProperty(
- '--theme-canvas',
- 'oklch(var(--a0l) var(--a0c) 60)'
- );
- document.documentElement.style.setProperty(
- '--theme-write',
- 'oklch(var(--a0l) var(--a0c) 260)'
- );
- document.documentElement.style.setProperty(
- '--theme-video',
- 'oklch(var(--a0l) var(--a0c) 277)'
- );
- document.documentElement.style.setProperty(
- '--theme-note',
- 'oklch(var(--a0l) var(--a0c) 293)'
- );
- document.documentElement.style.setProperty(
- '--theme-code',
- 'oklch(var(--a0l) var(--a0c) 162)'
- );
- document.documentElement.style.setProperty(
- '--theme-chat',
- 'oklch(var(--a0l) var(--a0c) 220)'
- );
- document.documentElement.style.setProperty(
- '--theme-image',
- 'oklch(var(--a0l) var(--a0c) 95)'
- );
- document.documentElement.style.setProperty(
- '--theme-html',
- 'oklch(var(--a0l) var(--a0c) 47)'
- );
- document.documentElement.style.setProperty(
- '--theme-rss',
- 'oklch(var(--a0l) var(--a0c) 260)'
- );
- document.documentElement.style.setProperty(
- '--theme-pdf',
- 'oklch(var(--a0l) var(--a0c) 25)'
- );
+ document.documentElement.style.setProperty('--theme-canvas' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-folder' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-image' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-write' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-video' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-html' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-note' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-code' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-chat' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-pdf' , 'var(--c0)');
+ document.documentElement.style.setProperty('--theme-rss' , 'var(--c0)');
+ }
+ else{
+ document.documentElement.style.setProperty( '--theme-folder', 'oklch(var(--a0l) var(--a0c) 240)');
+ document.documentElement.style.setProperty( '--theme-canvas', 'oklch(var(--a0l) var(--a0c) 60)');
+ document.documentElement.style.setProperty( '--theme-write' , 'oklch(var(--a0l) var(--a0c) 260)');
+ document.documentElement.style.setProperty( '--theme-video' , 'oklch(var(--a0l) var(--a0c) 277)');
+ document.documentElement.style.setProperty( '--theme-note' , 'oklch(var(--a0l) var(--a0c) 293)');
+ document.documentElement.style.setProperty( '--theme-code' , 'oklch(var(--a0l) var(--a0c) 162)');
+ document.documentElement.style.setProperty( '--theme-chat' , 'oklch(var(--a0l) var(--a0c) 220)');
+ document.documentElement.style.setProperty( '--theme-image' , 'oklch(var(--a0l) var(--a0c) 95)');
+ document.documentElement.style.setProperty( '--theme-html' , 'oklch(var(--a0l) var(--a0c) 47)');
+ document.documentElement.style.setProperty( '--theme-rss' , 'oklch(var(--a0l) var(--a0c) 260)');
+ document.documentElement.style.setProperty( '--theme-pdf' , 'oklch(var(--a0l) var(--a0c) 25)');
}
});
diff --git a/js/app/packages/block-theme/utils/colorUtil.ts b/js/app/packages/block-theme/utils/colorUtil.ts
index 407d52df7e..a3106fa1f7 100644
--- a/js/app/packages/block-theme/utils/colorUtil.ts
+++ b/js/app/packages/block-theme/utils/colorUtil.ts
@@ -22,11 +22,11 @@ import Color from 'colorjs.io';
// return color.toString({ format: 'hex' }).substring(0, 7);
// }
-export function validateColor(color: string): boolean {
+export function validateColor(color: string): boolean{
return CSS.supports('color', color);
}
-export function getOklch(cssColor: string) {
+export function getOklch(cssColor: string){
const color = new Color(cssColor);
const convert = color.to('oklch');
@@ -38,9 +38,9 @@ export function getOklch(cssColor: string) {
return returnColor;
}
-export function convertOklchTo(l: number, c: number, h: number, type: string) {
+export function convertOklchTo(l: number, c: number, h: number, type: string){
// console.log(`oklch values: L=${l}, C=${c}, H=${h} | type: ${type}`);
- try {
+ try{
const lightness = Math.max(0, Math.min(1, l));
const chroma = Math.max(0, c < 1e-10 ? 0 : c);
const hue = h;
@@ -48,20 +48,15 @@ export function convertOklchTo(l: number, c: number, h: number, type: string) {
const color = new Color('oklch', [lightness, chroma, hue]);
switch (type) {
- case 'hex':
- return color.to('srgb').toString({ format: 'hex', precision: 4 });
- case 'rgb':
- return color.to('srgb').toString({ format: 'rgb', precision: 4 });
- case 'oklab':
- return color.to('oklab').toString({ precision: 4 });
- case 'hsl':
- return color.to('hsl').toString({ precision: 4 });
- case 'oklch':
- return color.toString({ precision: 4 });
- default:
- return color.to('srgb').toString({ format: 'hex' });
+ case 'hex' : return color.to('srgb' ).toString({ precision: 4, format: 'hex'});
+ case 'rgb' : return color.to('srgb' ).toString({ precision: 4, format: 'rgb'});
+ case 'oklab': return color.to('oklab').toString({ precision: 4 });
+ case 'hsl' : return color.to('hsl' ).toString({ precision: 4 });
+ case 'oklch': return color.toString({ precision: 4 });
+ default: return color.to('srgb').toString({ format: 'hex' });
}
- } catch (error) {
+ }
+ catch(error){
console.error(error);
return '#000000';
}
diff --git a/js/app/packages/block-theme/utils/themeMigrations.ts b/js/app/packages/block-theme/utils/themeMigrations.ts
index c69152e6dc..7cc2164391 100644
--- a/js/app/packages/block-theme/utils/themeMigrations.ts
+++ b/js/app/packages/block-theme/utils/themeMigrations.ts
@@ -6,81 +6,21 @@ export function convertThemev0v1(theme: ThemeV0): ThemeV1 {
name: theme.name,
version: 1,
tokens: {
- a0: {
- l: theme.specification['--accent-l'],
- c: theme.specification['--accent-c'],
- h: (theme.specification['--accent-h'] + 30) % 360,
- },
- a1: {
- l: theme.specification['--accent-l'],
- c: theme.specification['--accent-c'],
- h: (theme.specification['--accent-h'] + 30) % 360,
- },
- a2: {
- l: theme.specification['--accent-l'],
- c: theme.specification['--accent-c'],
- h: (theme.specification['--accent-h'] + 30) % 360,
- },
- a3: {
- l: theme.specification['--accent-l'],
- c: theme.specification['--accent-c'],
- h: (theme.specification['--accent-h'] + 30) % 360,
- },
- a4: {
- l: theme.specification['--accent-l'],
- c: theme.specification['--accent-c'],
- h: (theme.specification['--accent-h'] + 30) % 360,
- },
- b0: {
- l: theme.specification['--surface-l'],
- c: theme.specification['--surface-c'],
- h: theme.specification['--surface-h'],
- },
- b1: {
- l: theme.specification['--surface-l-1'],
- c: theme.specification['--surface-c'],
- h: theme.specification['--surface-h'],
- },
- b2: {
- l: theme.specification['--surface-l-2'],
- c: theme.specification['--surface-c'],
- h: theme.specification['--surface-h'],
- },
- b3: {
- l: theme.specification['--surface-l-3'],
- c: theme.specification['--surface-c'],
- h: theme.specification['--surface-h'],
- },
- b4: {
- l: theme.specification['--surface-l-4'],
- c: theme.specification['--surface-c'],
- h: theme.specification['--surface-h'],
- },
- c0: {
- l: theme.specification['--contrast-l'],
- c: theme.specification['--contrast-c'],
- h: theme.specification['--contrast-h'],
- },
- c1: {
- l: theme.specification['--contrast-l-1'],
- c: theme.specification['--contrast-c'],
- h: theme.specification['--contrast-h'],
- },
- c2: {
- l: theme.specification['--contrast-l-2'],
- c: theme.specification['--contrast-c'],
- h: theme.specification['--contrast-h'],
- },
- c3: {
- l: theme.specification['--contrast-l-3'],
- c: theme.specification['--contrast-c'],
- h: theme.specification['--contrast-h'],
- },
- c4: {
- l: theme.specification['--contrast-l-4'],
- c: theme.specification['--contrast-c'],
- h: theme.specification['--contrast-h'],
- },
+ a0: { l: theme.specification['--accent-l' ], c: theme.specification['--accent-c' ], h: (theme.specification['--accent-h' ] + 30) % 360},
+ a1: { l: theme.specification['--accent-l' ], c: theme.specification['--accent-c' ], h: (theme.specification['--accent-h' ] + 30) % 360},
+ a2: { l: theme.specification['--accent-l' ], c: theme.specification['--accent-c' ], h: (theme.specification['--accent-h' ] + 30) % 360},
+ a3: { l: theme.specification['--accent-l' ], c: theme.specification['--accent-c' ], h: (theme.specification['--accent-h' ] + 30) % 360},
+ a4: { l: theme.specification['--accent-l' ], c: theme.specification['--accent-c' ], h: (theme.specification['--accent-h' ] + 30) % 360},
+ b0: { l: theme.specification['--surface-l' ], c: theme.specification['--surface-c' ], h: theme.specification['--surface-h' ] },
+ b1: { l: theme.specification['--surface-l-1' ], c: theme.specification['--surface-c' ], h: theme.specification['--surface-h' ] },
+ b2: { l: theme.specification['--surface-l-2' ], c: theme.specification['--surface-c' ], h: theme.specification['--surface-h' ] },
+ b3: { l: theme.specification['--surface-l-3' ], c: theme.specification['--surface-c' ], h: theme.specification['--surface-h' ] },
+ b4: { l: theme.specification['--surface-l-4' ], c: theme.specification['--surface-c' ], h: theme.specification['--surface-h' ] },
+ c0: { l: theme.specification['--contrast-l' ], c: theme.specification['--contrast-c'], h: theme.specification['--contrast-h'] },
+ c1: { l: theme.specification['--contrast-l-1'], c: theme.specification['--contrast-c'], h: theme.specification['--contrast-h'] },
+ c2: { l: theme.specification['--contrast-l-2'], c: theme.specification['--contrast-c'], h: theme.specification['--contrast-h'] },
+ c3: { l: theme.specification['--contrast-l-3'], c: theme.specification['--contrast-c'], h: theme.specification['--contrast-h'] },
+ c4: { l: theme.specification['--contrast-l-4'], c: theme.specification['--contrast-c'], h: theme.specification['--contrast-h'] },
},
};
}
diff --git a/js/app/packages/block-theme/utils/themeUtils.ts b/js/app/packages/block-theme/utils/themeUtils.ts
index 05452e64ed..0905e0e182 100644
--- a/js/app/packages/block-theme/utils/themeUtils.ts
+++ b/js/app/packages/block-theme/utils/themeUtils.ts
@@ -1,37 +1,23 @@
+import { currentThemeId, darkModeTheme, lightModeTheme, setCurrentThemeId, setHtmlColor, setIsThemeSaved, setUserThemes, systemMode, themeShouldMatchSystem, themes, userThemes} from '../signals/themeSignals';
+import type { ThemeV1, ThemeV1Tokens } from '../types/themeTypes';
+import { themeReactive } from '../signals/themeReactive';
import { toast } from '@core/component/Toast/Toast';
import { batch, createEffect, on } from 'solid-js';
import { DEFAULT_DARK_THEME } from '../constants';
-import { themeReactive } from '../signals/themeReactive';
-import {
- currentThemeId,
- darkModeTheme,
- lightModeTheme,
- setCurrentThemeId,
- setHtmlColor,
- setIsThemeSaved,
- setUserThemes,
- systemMode,
- themeShouldMatchSystem,
- themes,
- userThemes,
-} from '../signals/themeSignals';
-import type { ThemeV1, ThemeV1Tokens } from '../types/themeTypes';
-export function exportTheme() {
+export function exportTheme(){
let id = currentThemeId();
let theme = JSON.stringify(themes().find((t) => t.id === id));
navigator.clipboard.writeText(theme);
}
-export function systemThemeEffect() {
+export function systemThemeEffect(){
createEffect(
on(
[themeShouldMatchSystem, systemMode, darkModeTheme, lightModeTheme],
() => {
- if (themeShouldMatchSystem()) {
- applyTheme(
- systemMode() === 'dark' ? darkModeTheme() : lightModeTheme()
- );
+ if(themeShouldMatchSystem()){
+ applyTheme(systemMode() === 'dark' ? darkModeTheme() : lightModeTheme());
}
},
{ defer: true }
@@ -39,35 +25,29 @@ export function systemThemeEffect() {
);
}
-export function applyTheme(id: string): void {
+export function applyTheme(id: string): void{
let theme = themes().find((t) => t.id === id);
- if (!theme) {
+ if(!theme){
console.error(`theme not found: ${id}`);
theme = themes().find((t) => t.id === DEFAULT_DARK_THEME)!;
}
setCurrentThemeId(theme.id);
batch(() => {
- (Object.keys(theme!.tokens) as Array<keyof ThemeV1Tokens>).forEach(
- (tokenKey) => {
- (
- Object.keys(theme!.tokens[tokenKey]) as Array<'l' | 'c' | 'h'>
- ).forEach((prop) => {
+ (Object.keys(theme!.tokens) as Array<keyof ThemeV1Tokens>).forEach((tokenKey) => {
+ (Object.keys(theme!.tokens[tokenKey]) as Array<'l' | 'c' | 'h'>).forEach((prop) => {
themeReactive[tokenKey][prop][1](theme!.tokens[tokenKey][prop]);
});
}
);
- queueMicrotask(() => {
- /* scuffed af */
+ queueMicrotask(() => {/* scuffed af */
setIsThemeSaved(true);
- setHtmlColor({
- color: `oklch(${themeReactive.b0.l[0]()} ${themeReactive.b0.c[0]()} ${themeReactive.b0.h[0]()}deg)`,
- });
+ setHtmlColor({color: `oklch(${themeReactive.b0.l[0]()} ${themeReactive.b0.c[0]()} ${themeReactive.b0.h[0]()}deg)`});
});
});
}
-export function invertTheme(): void {
+export function invertTheme(): void{
batch(() => {
themeReactive.b0.l[1](1 - themeReactive.b0.l[0]());
themeReactive.b2.l[1](1 - themeReactive.b2.l[0]());
@@ -82,88 +62,28 @@ export function invertTheme(): void {
});
}
-function getCurrentTokens(): ThemeV1Tokens {
+function getCurrentTokens(): ThemeV1Tokens{
const themeTokens: ThemeV1Tokens = {
- a0: {
- l: themeReactive.a0.l[0](),
- c: themeReactive.a0.c[0](),
- h: themeReactive.a0.h[0](),
- },
- a1: {
- l: themeReactive.a1.l[0](),
- c: themeReactive.a1.c[0](),
- h: themeReactive.a1.h[0](),
- },
- a2: {
- l: themeReactive.a2.l[0](),
- c: themeReactive.a2.c[0](),
- h: themeReactive.a2.h[0](),
- },
- a3: {
- l: themeReactive.a3.l[0](),
- c: themeReactive.a3.c[0](),
- h: themeReactive.a3.h[0](),
- },
- a4: {
- l: themeReactive.a4.l[0](),
- c: themeReactive.a4.c[0](),
- h: themeReactive.a4.h[0](),
- },
- b0: {
- l: themeReactive.b0.l[0](),
- c: themeReactive.b0.c[0](),
- h: themeReactive.b0.h[0](),
- },
- b1: {
- l: themeReactive.b1.l[0](),
- c: themeReactive.b1.c[0](),
- h: themeReactive.b1.h[0](),
- },
- b2: {
- l: themeReactive.b2.l[0](),
- c: themeReactive.b2.c[0](),
- h: themeReactive.b2.h[0](),
- },
- b3: {
- l: themeReactive.b3.l[0](),
- c: themeReactive.b3.c[0](),
- h: themeReactive.b3.h[0](),
- },
- b4: {
- l: themeReactive.b4.l[0](),
- c: themeReactive.b4.c[0](),
- h: themeReactive.b4.h[0](),
- },
- c0: {
- l: themeReactive.c0.l[0](),
- c: themeReactive.c0.c[0](),
- h: themeReactive.c0.h[0](),
- },
- c1: {
- l: themeReactive.c1.l[0](),
- c: themeReactive.c1.c[0](),
- h: themeReactive.c1.h[0](),
- },
- c2: {
- l: themeReactive.c2.l[0](),
- c: themeReactive.c2.c[0](),
- h: themeReactive.c2.h[0](),
- },
- c3: {
- l: themeReactive.c3.l[0](),
- c: themeReactive.c3.c[0](),
- h: themeReactive.c3.h[0](),
- },
- c4: {
- l: themeReactive.c4.l[0](),
- c: themeReactive.c4.c[0](),
- h: themeReactive.c4.h[0](),
- },
+ a0: { l: themeReactive.a0.l[0](), c: themeReactive.a0.c[0](), h: themeReactive.a0.h[0]()},
+ a1: { l: themeReactive.a1.l[0](), c: themeReactive.a1.c[0](), h: themeReactive.a1.h[0]()},
+ a2: { l: themeReactive.a2.l[0](), c: themeReactive.a2.c[0](), h: themeReactive.a2.h[0]()},
+ a3: { l: themeReactive.a3.l[0](), c: themeReactive.a3.c[0](), h: themeReactive.a3.h[0]()},
+ a4: { l: themeReactive.a4.l[0](), c: themeReactive.a4.c[0](), h: themeReactive.a4.h[0]()},
+ b0: { l: themeReactive.b0.l[0](), c: themeReactive.b0.c[0](), h: themeReactive.b0.h[0]()},
+ b1: { l: themeReactive.b1.l[0](), c: themeReactive.b1.c[0](), h: themeReactive.b1.h[0]()},
+ b2: { l: themeReactive.b2.l[0](), c: themeReactive.b2.c[0](), h: themeReactive.b2.h[0]()},
+ b3: { l: themeReactive.b3.l[0](), c: themeReactive.b3.c[0](), h: themeReactive.b3.h[0]()},
+ b4: { l: themeReactive.b4.l[0](), c: themeReactive.b4.c[0](), h: themeReactive.b4.h[0]()},
+ c0: { l: themeReactive.c0.l[0](), c: themeReactive.c0.c[0](), h: themeReactive.c0.h[0]()},
+ c1: { l: themeReactive.c1.l[0](), c: themeReactive.c1.c[0](), h: themeReactive.c1.h[0]()},
+ c2: { l: themeReactive.c2.l[0](), c: themeReactive.c2.c[0](), h: themeReactive.c2.h[0]()},
+ c3: { l: themeReactive.c3.l[0](), c: themeReactive.c3.c[0](), h: themeReactive.c3.h[0]()},
+ c4: { l: themeReactive.c4.l[0](), c: themeReactive.c4.c[0](), h: themeReactive.c4.h[0]()},
};
return themeTokens;
}
-export function saveTheme(name: string): void {
+export function saveTheme(name: string): void{
const id = crypto.randomUUID();
const tokens = getCurrentTokens();
const newTheme: ThemeV1 = {
@@ -177,7 +97,7 @@ export function saveTheme(name: string): void {
setIsThemeSaved(true);
}
-export function deleteTheme(id: string): void {
+export function deleteTheme(id: string): void{
setUserThemes(userThemes().filter((theme) => theme.id !== id));
setIsThemeSaved(false);
setCurrentThemeId('');
@@ -186,13 +106,10 @@ export function deleteTheme(id: string): void {
/** Checks if the theme contrast is too low, and if so, applies a readable theme. This is to prevent malicious actors sending "Theme Viruses" which make a user's theme unusable. */
export function ensureMinimalThemeContrast() {
const spec = themes().find((t) => t.id === currentThemeId())?.tokens;
- if (!spec) return;
- // Check if the contrast is too low, so that users can't get stuck with an unreadable theme
+ if(!spec){return}// Check if the contrast is too low, so that users can't get stuck with an unreadable theme
const lowContrastTheme = Math.abs(spec.c0.l - spec.b0.l) < 0.2;
- if (lowContrastTheme) {
+ if(lowContrastTheme){
applyTheme(DEFAULT_DARK_THEME);
- toast.alert(
- 'Tried to load a theme with low contrast, applying a readable theme.'
- );
+ toast.alert('Tried to load a theme with low contrast, applying a readable theme.');
}
}