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.

fix(ui): better theme tools (#3070)

Fake-User9501d99de646
diff --git a/js/app/packages/theme/components/ThemeCrud.tsx b/js/app/packages/theme/components/ThemeCrud.tsx
new file mode 100644
index 0000000000..98bfbc65b2
--- /dev/null
+++ b/js/app/packages/theme/components/ThemeCrud.tsx
@@ -0,0 +1,59 @@
+import { deleteTheme, exportTheme } from '../utils/themeUtils';
+import { userThemes } from '../signals/themeSignals';
+import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
+import { createMemo, Show } from 'solid-js';
+import IconClipboard from '@macro-icons/macro-clipboard.svg';
+import IconTrash from '@macro-icons/macro-trash.svg';
+
+interface ThemeCrudProps {
+ themeId: string;
+}
+
+export function ThemeCrud(props: ThemeCrudProps) {
+ const isUserTheme = createMemo(() =>
+ userThemes().some((t) => t.id === props.themeId)
+ );
+
+ const stop = (e: Event) => e.stopPropagation();
+
+ return (
+ <div
+ style="
+ grid-auto-columns: min-content;
+ background-color: var(--b0);
+ grid-auto-flow: column;
+ box-sizing: border-box;
+ align-items: center;
+ direction: rtl;
+ padding: 0 12px;
+ display: grid;
+ height: 100%;
+ gap: 4.5px;
+ "
+ onClick={stop}
+ onPointerDown={stop}
+ >
+ <DeprecatedIconButton
+ tooltip={{label: "Copy To Clipboard"}}
+ onPointerDown={() => exportTheme(props.themeId)}
+ icon={IconClipboard}
+ theme="clear"
+ size="sm"
+ />
+
+ <Show when={isUserTheme()}>
+ <DeprecatedIconButton
+ onPointerDown={() => {
+ deleteTheme(props.themeId);
+ }}
+ tooltip={{label: "Delete Theme"}}
+ icon={IconTrash}
+ theme="clear"
+ size="sm"
+ />
+ </Show>
+ </div>
+ );
+}
+
+export default ThemeCrud;
diff --git a/js/app/packages/theme/components/ThemeEditorAdvanced.tsx b/js/app/packages/theme/components/ThemeEditorAdvanced.tsx
index 5e1a23a47d..24fc1b3db5 100644
--- a/js/app/packages/theme/components/ThemeEditorAdvanced.tsx
+++ b/js/app/packages/theme/components/ThemeEditorAdvanced.tsx
@@ -22,9 +22,7 @@ function setColor(colorValue: ThemeReactiveColor, colorString: string, inputElem
});
inputElement.classList.remove('invalid');
}
- catch(error) {
- console.error(`Error processing color "${colorString}":`, error);
- }
+ catch(error) { console.error(`Error processing color "${colorString}":`, error); }
}
export function ThemeEditorAdvanced(){
@@ -43,7 +41,7 @@ export function ThemeEditorAdvanced(){
<div
style={{
- 'height': isMobile() ? '280px' : '390px',
+ 'height': isMobile() ? '280px' : '390px', /* match themeEditorBasic height */
'font-size': 'var(--text-xs)',
'scrollbar-width': 'none',
'position': 'relative',
@@ -54,13 +52,13 @@ export function ThemeEditorAdvanced(){
>
<div
style="
- overscroll-behavior: none;
- box-sizing: border-box;
- scrollbar-width: none;
- overflow-y: auto;
- height: 100%;
- width: 100%;
- "
+ overscroll-behavior: none;
+ box-sizing: border-box;
+ scrollbar-width: none;
+ overflow-y: auto;
+ height: 100%;
+ width: 100%;
+ "
>
<div
style="
@@ -85,12 +83,8 @@ export function ThemeEditorAdvanced(){
colorValue.h[0](),
displayType()
);
- if (untrack(isSetByInput)) {
- setIsSetByInput(false);
- // console.log('blocked!!!!!!!!!!!!');
- } else {
- setInputValue(newValue);
- }
+ if (untrack(isSetByInput)) { setIsSetByInput(false); /* console.log('blocked!!!'); */ }
+ else { setInputValue(newValue); }
});
return (
@@ -102,44 +96,45 @@ export function ThemeEditorAdvanced(){
>
<div
style="
- grid-template-columns: 140px 1fr 80px;
- background-color: var(--b3);
- align-items: center;
- display: grid;
- height: 41px;
- gap: 1px;
- "
- >
- <div
- style="
- background-color: var(--b0);
- box-sizing: border-box;
+ grid-template-columns: 104px calc(7ch + 40px) 1fr calc(4ch + 40px);
+ background-color: var(--b3);
align-items: center;
- padding: 0 20px;
display: grid;
- height: 100%;
- width: 100%;
+ height: 40px;
+ gap: 1px;
"
+ >
+ <div
+ style="
+ background-color: var(--b0);
+ box-sizing: border-box;
+ align-items: center;
+ padding: 0 20px;
+ display: grid;
+ height: 100%;
+ width: 100%;
+ "
>
<ColorSwatch
color={`oklch(${colorValue.l[0]()} ${colorValue.c[0]()} ${colorValue.h[0]()}deg)`}
- width={'100px'}
+ width={'100%'}
/>
</div>
<div
style="
- background-color: var(--b0);
- box-sizing: border-box;
- align-items: center;
- white-space: nowrap;
- padding: 0 20px;
- display: grid;
- height: 100%;
- width: 100%;
- "
+ background-color: var(--b0);
+ box-sizing: border-box;
+ align-items: center;
+ white-space: nowrap;
+ padding: 0 20px;
+ display: grid;
+ height: 100%;
+ width: 100%;
+ "
>
<input
+ onInput={ (e) => {setColor(colorValue, e.target.value, e.target, setIsSetByInput); }}
style="
color: var(--color-ink-extra-muted);
font-family: var(--font-mono);
@@ -152,29 +147,38 @@ export function ThemeEditorAdvanced(){
"
class="theme-editor-advanced-input"
value={inputValue()}
- onInput={(e) => {
- setColor(
- colorValue,
- e.target.value,
- e.target,
- setIsSetByInput
- );
- }}
type="text"
/>
</div>
<div
style="
- background-color: var(--b0);
- box-sizing: border-box;
- white-space: nowrap;
- align-items: center;
- padding: 0 20px;
- display: grid;
- height: 100%;
- width: 100%;
- "
+ color: var(--color-ink-extra-muted);
+ background-color: var(--b0);
+ box-sizing: border-box;
+ align-items: center;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ padding: 0 20px;
+ overflow: hidden;
+ display: grid;
+ height: 100%;
+ width: 100%;
+ "
+ >
+ {colorValue.description}
+ </div>
+ <div
+ style="
+ background-color: var(--b0);
+ box-sizing: border-box;
+ white-space: nowrap;
+ align-items: center;
+ padding: 0 20px;
+ display: grid;
+ height: 100%;
+ width: 100%;
+ "
>
--{colorKey}
</div>
diff --git a/js/app/packages/theme/components/ThemeList.tsx b/js/app/packages/theme/components/ThemeList.tsx
index c819bf65d7..98e0387e68 100644
--- a/js/app/packages/theme/components/ThemeList.tsx
+++ b/js/app/packages/theme/components/ThemeList.tsx
@@ -2,6 +2,7 @@ import { currentThemeId, isThemeSaved, themes } from '../signals/themeSignals';
import { useAnalytics } from 'app/component/analytics-context';
import { applyTheme } from '../utils/themeUtils';
import { ColorSwatch } from './ColorSwatch';
+import { ThemeCrud } from './ThemeCrud';
import { For } from 'solid-js';
@@ -11,35 +12,15 @@ export function ThemeList() {
return (
<>
<style>{`
- .theme-list-item.current-theme{
+ .theme-list-item-name.current-theme{
transition: none !important;
color: var(--a0) !important;
-
- .theme-list-item-name{
- transition: none !important;
- color: var(--a0) !important;
- }
-
- .theme-color-swatch{
- border-color: var(--a0) !important;
- transition: none !important;
- }
}
@media(hover){
- .theme-list-item:hover{
- transition: none;
- color: var(--a0);
-
- .theme-list-item-name{
- transition: none !important;
- color: var(--a0) !important;
- }
-
- .theme-color-swatch{
- border-color: var(--a0) !important;
- transition: none !important;
- }
+ .theme-list-item-name:hover{
+ transition: none !important;
+ color: var(--a0) !important;
}
}
`}</style>
@@ -68,111 +49,95 @@ export function ThemeList() {
>
<div
style="
- border-bottom: 1px solid var(--b3); /* temp remove when long */
- margin-bottom: -1px; /* temp remove when long */
+ border-bottom: 1px solid var(--b3);
+ background-color: var(--b0);
+ align-items: center;
+ position: absolute;
+ padding: 0 20px;
+ display: flex;
+ height: 42px;
+ width: 100%;
+ z-index: 1;
+ top: 0;
+ left: 0;
+ "
+ >
+ <div
+ style={{
+ 'font-size': '0.875rem',
+ 'font-weight': '600'
+ }}
+ >
+ Theme List
+ </div>
+ </div>
+ <div
+ style="
+ grid-template-columns: min-content 1fr min-content;
background-color: var(--b3);
box-sizing: border-box;
+ grid-auto-rows: 40px;
overflow-x: hidden;
+ padding-top: 40px;
display: grid;
gap: 1px;
"
>
- <div
- style="
- border-bottom: 1px solid var(--b3);
- background-color: var(--b0);
- align-items: center;
- position: absolute;
- padding: 0 20px;
- display: grid;
- height: 42px;
- width: 100%;
- z-index: 1;
- "
- >
- <div
- style={{
- 'font-size': '0.875rem',
- 'font-weight': '600'
- }}
- >
- Theme List
- </div>
- </div>
- <div style="height: 41px;" />
- <For each={themes()}>
- {(theme) => (
- <div
- class={`theme-list-item ${theme.id === currentThemeId() && isThemeSaved() ? 'current-theme' : ''}`}
- onClick={() => {
- analytics.track('theme_changed', {themeId: theme.id})
- applyTheme(theme.id)
- }}
- >
- <div
- style="
-
- grid-template-columns: min-content 1fr;
- background-color: var(--b3);
- align-items: center;
- display: grid;
- height: 41px;
- gap: 1px;
- "
- >
+ <For each={themes()}>
+ {(theme) => (
+ <>
<div
style="
background-color: var(--b0);
box-sizing: border-box;
align-items: center;
padding: 0 20px;
- display: grid;
+ display: flex;
height: 100%;
width: 100%;
+ gap: 5px;
"
>
- <div
- style="
- grid-template-columns: repeat(3, min-content);
- display: grid;
- gap: 5px;
- "
- >
- <ColorSwatch
- color={`oklch(${theme.tokens.a0.l} ${theme.tokens.a0.c} ${theme.tokens.a0.h}deg)`}
- width={'10px'}
- />
- <ColorSwatch
- color={`oklch(${theme.tokens.b0.l} ${theme.tokens.b0.c} ${theme.tokens.b0.h}deg)`}
- width={'10px'}
- />
- <ColorSwatch
- color={`oklch(${theme.tokens.c0.l} ${theme.tokens.c0.c} ${theme.tokens.c0.h}deg)`}
- width={'10px'}
- />
- </div>
+ <ColorSwatch
+ color={`oklch(${theme.tokens.a0.l} ${theme.tokens.a0.c} ${theme.tokens.a0.h}deg)`}
+ width={'10px'}
+ />
+ <ColorSwatch
+ color={`oklch(${theme.tokens.b0.l} ${theme.tokens.b0.c} ${theme.tokens.b0.h}deg)`}
+ width={'10px'}
+ />
+ <ColorSwatch
+ color={`oklch(${theme.tokens.c0.l} ${theme.tokens.c0.c} ${theme.tokens.c0.h}deg)`}
+ width={'10px'}
+ />
</div>
<div
- class="theme-list-item-name"
+ class={`theme-list-item-name ${theme.id === currentThemeId() && isThemeSaved() ? 'current-theme' : ''}`}
+ onClick={() => {
+ analytics.track('theme_changed', {themeId: theme.id})
+ applyTheme(theme.id)
+ }}
style="
transition: color var(--transition);
+ cursor: var(--cursor-pointer);
background-color: var(--b0);
box-sizing: border-box;
white-space: nowrap;
align-items: center;
padding: 0 20px;
- display: grid;
+ display: flex;
height: 100%;
width: 100%;
"
>
{theme.name}
</div>
- </div>
- </div>
- )}
- </For>
+
+ <ThemeCrud themeId={theme.id} />
+ </>
+ )}
+ </For>
</div>
</div>
</div>
diff --git a/js/app/packages/theme/components/ThemeTools.tsx b/js/app/packages/theme/components/ThemeTools.tsx
index 19cb353cf3..08a841b677 100644
--- a/js/app/packages/theme/components/ThemeTools.tsx
+++ b/js/app/packages/theme/components/ThemeTools.tsx
@@ -1,15 +1,12 @@
-import { deleteTheme, exportTheme, importTheme, invertTheme, saveTheme } from '../utils/themeUtils';
-import { currentThemeId, isThemeSaved, themes, userThemes } from '../signals/themeSignals';
+import { currentThemeId, isThemeSaved, themes } from '../signals/themeSignals';
import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
-import { createEffect, createMemo, createSignal, Show } from 'solid-js';
-import { cn } from '@ui/utils/classname';
import IconLightDark from '@macro-icons/macro-light-dark.svg';
-import IconClipboard from '@macro-icons/macro-clipboard.svg';
-import IconImport from '@macro-icons/macro-import.svg';
-import IconTrash from '@macro-icons/macro-trash.svg';
+import { 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 { createMemo, Show } from 'solid-js';
+import { cn } from '@ui/utils/classname';
export function ThemeTools() {
let themeName!: HTMLDivElement;
@@ -22,12 +19,6 @@ export function ThemeTools() {
else{return defaultThemeName}
});
- const [showTrash, setShowTrash] = createSignal<boolean>(true);
- createEffect(() => {
- if(isThemeSaved() && userThemes().some((t) => t.id === currentThemeId())){setShowTrash(true)}
- else{setShowTrash(false)}
- });
-
return (
<div
style={{
@@ -45,18 +36,6 @@ export function ThemeTools() {
>
<div style={{ flex: 1 }}/>
- <Show when={showTrash()}>
- <DeprecatedIconButton
- onPointerDown={() => {
- deleteTheme(currentThemeId());
- }}
- tooltip={{label: "Delete Theme"}}
- icon={IconTrash}
- theme="clear"
- size="sm"
- />
- </Show>
-
<Show when={!isThemeSaved()}>
<DeprecatedIconButton
onPointerDown={() => {
@@ -79,31 +58,13 @@ export function ThemeTools() {
/>
</Show>*/}
- <Show when={isThemeSaved()}>
- <DeprecatedIconButton
- tooltip={{label: "Copy To Clipboard"}}
- onPointerDown={exportTheme}
- icon={IconClipboard}
- theme="clear"
- size="sm"
- />
- </Show>
-
- <DeprecatedIconButton
- tooltip={{label: "Import From Clipboard"}}
- onPointerDown={importTheme}
- icon={IconImport}
- theme="clear"
- size="sm"
- />
-
- <DeprecatedIconButton
- tooltip={{label: "Toggle Light / Dark"}}
- onPointerDown={invertTheme}
- icon={IconLightDark}
+ {/*<DeprecatedIconButton
+ tooltip={{label: "Import From Clipboard"}}
+ onPointerDown={importTheme}
+ icon={IconImport}
theme="clear"
size="sm"
- />
+ />*/}
<DeprecatedIconButton
tooltip={{label: "Randomize Theme"}}
@@ -113,6 +74,14 @@ export function ThemeTools() {
size="sm"
/>
+ <DeprecatedIconButton
+ tooltip={{label: "Toggle Light / Dark"}}
+ onPointerDown={invertTheme}
+ icon={IconLightDark}
+ theme="clear"
+ size="sm"
+ />
+
<div
onKeyDown={(e) => {
if(e.key === 'Enter'){
diff --git a/js/app/packages/theme/signals/themeReactive.ts b/js/app/packages/theme/signals/themeReactive.ts
index 0879488472..0b9ed15254 100644
--- a/js/app/packages/theme/signals/themeReactive.ts
+++ b/js/app/packages/theme/signals/themeReactive.ts
@@ -3,21 +3,21 @@ 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), description: 'accent color'},
+ a1: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'accent color +40°'},
+ a2: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'accent color +80°'},
+ a3: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'accent color +120°'},
+ a4: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'accent color +160°'},
+ b0: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'backaground'},
+ b1: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'background active'},
+ b2: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'background hover'},
+ b3: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'muted edge'},
+ b4: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'edge'},
+ c0: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'text'},
+ c1: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'text muted'},
+ c2: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'text extra muted'},
+ c3: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'text disabled'},
+ c4: {l: createSignal(0), c: createSignal(0), h: createSignal(0), description: 'text placeholder'},
} as const;
const previousTheme: ThemePrevious = {
diff --git a/js/app/packages/theme/types/themeTypes.ts b/js/app/packages/theme/types/themeTypes.ts
index 31d52692e2..590d178204 100644
--- a/js/app/packages/theme/types/themeTypes.ts
+++ b/js/app/packages/theme/types/themeTypes.ts
@@ -1,21 +1,28 @@
import type { Signal } from 'solid-js';
+type ThemeReactiveToken = {
+ l: Signal<number>;
+ c: Signal<number>;
+ h: Signal<number>;
+ description: string;
+};
+
export type ThemeReactive = {
- a0: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- a1: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- a2: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- a3: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- a4: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- b0: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- b1: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- b2: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- b3: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- b4: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- c0: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- c1: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- c2: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- c3: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
- c4: { l: Signal<number>; c: Signal<number>; h: Signal<number> };
+ a0: ThemeReactiveToken;
+ a1: ThemeReactiveToken;
+ a2: ThemeReactiveToken;
+ a3: ThemeReactiveToken;
+ a4: ThemeReactiveToken;
+ b0: ThemeReactiveToken;
+ b1: ThemeReactiveToken;
+ b2: ThemeReactiveToken;
+ b3: ThemeReactiveToken;
+ b4: ThemeReactiveToken;
+ c0: ThemeReactiveToken;
+ c1: ThemeReactiveToken;
+ c2: ThemeReactiveToken;
+ c3: ThemeReactiveToken;
+ c4: ThemeReactiveToken;
};
export type ThemeReactiveColor = ThemeReactive[keyof ThemeReactive];
diff --git a/js/app/packages/theme/utils/themeUtils.ts b/js/app/packages/theme/utils/themeUtils.ts
index f8dfe037a6..5d8c88b395 100644
--- a/js/app/packages/theme/utils/themeUtils.ts
+++ b/js/app/packages/theme/utils/themeUtils.ts
@@ -5,9 +5,9 @@ import { toast } from '@core/component/Toast/Toast';
import { batch, createEffect, on } from 'solid-js';
import { DEFAULT_DARK_THEME } from '../constants';
-export function exportTheme(){
- let id = currentThemeId();
- let theme = JSON.stringify(themes().find((t) => t.id === id));
+export function exportTheme(themeId?: string){
+ const id = themeId ?? currentThemeId();
+ const theme = JSON.stringify(themes().find((t) => t.id === id));
navigator.clipboard.writeText(theme);
}