Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(app): add the quick CSS section and editor commands

Hampus04ad77db8513
diff --git a/fluxer_app/src/features/theme_settings/commands/ThemeSettingsCommands.tsx b/fluxer_app/src/features/theme_settings/commands/ThemeSettingsCommands.tsx
new file mode 100644
index 000000000..9089c7c56
--- /dev/null
+++ b/fluxer_app/src/features/theme_settings/commands/ThemeSettingsCommands.tsx
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import {UserSettingsModal} from '@app/features/app/components/dialogs/LoadableSettingsModals';
+import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
+import * as ThemeProfileCommands from '@app/features/theme/commands/ThemeProfileCommands';
+import ThemeEditTarget from '@app/features/theme/state/ThemeEditTarget';
+import ThemeSettingsState, {QUICK_CSS_EDITOR_FILE} from '@app/features/theme_settings/state/ThemeSettingsState';
+import {quickCssEditorNeedsDesktopUpdate} from '@app/features/theme_settings/utils/QuickCssEditorSupport';
+import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
+import {modal} from '@app/features/ui/commands/ModalCommands';
+import MobileLayout from '@app/features/ui/state/MobileLayout';
+import ModalState from '@app/features/ui/state/Modal';
+import {getElectronAPI} from '@app/features/ui/utils/NativeUtils';
+
+export const QUICK_CSS_EDITOR_WINDOW_KEY = 'fluxer_quick_css_editor';
+
+export function setEditedCustomThemeCss(css: string | null): void {
+ ThemeProfileCommands.setCustomThemeCss(css, ThemeEditTarget.target);
+}
+
+export function canOpenQuickCssEditor(): boolean {
+ return !MobileLayout.enabled && !quickCssEditorNeedsDesktopUpdate();
+}
+
+function focusQuickCssEditor(): void {
+ ThemeSettingsState.editorWindow?.focus();
+ void getElectronAPI()?.popoutFocus?.(QUICK_CSS_EDITOR_WINDOW_KEY);
+}
+
+export function openQuickCssEditor(file: string = QUICK_CSS_EDITOR_FILE): void {
+ if (!canOpenQuickCssEditor()) return;
+ const wasOpen = ThemeSettingsState.editorOpen;
+ ThemeSettingsState.openEditor(file);
+ if (wasOpen) focusQuickCssEditor();
+}
+
+export function focusOrOpenQuickCssEditor(): void {
+ if (!canOpenQuickCssEditor()) return;
+ if (ThemeSettingsState.editorOpen) {
+ focusQuickCssEditor();
+ return;
+ }
+ ThemeSettingsState.openEditor(QUICK_CSS_EDITOR_FILE);
+}
+
+export function openThemesSettings(): void {
+ if (ModalState.hasModalOfModalType('user-settings')) {
+ ComponentBus.dispatch('USER_SETTINGS_TAB_SELECT', {tab: 'themes'});
+ return;
+ }
+ ModalCommands.push(
+ modal(
+ () => (
+ <UserSettingsModal
+ initialTab="themes"
+ data-flx="theme-settings.theme-settings-commands.open-themes-settings.user-settings-modal"
+ />
+ ),
+ 'user-settings',
+ ),
+ );
+}
diff --git a/fluxer_app/src/features/theme_studio/sections/QuickCssEditor.tsx b/fluxer_app/src/features/theme_settings/components/QuickCssEditor.tsx
similarity index 88%
rename from fluxer_app/src/features/theme_studio/sections/QuickCssEditor.tsx
rename to fluxer_app/src/features/theme_settings/components/QuickCssEditor.tsx
index 95b0e5bce..336fb810f 100644
--- a/fluxer_app/src/features/theme_studio/sections/QuickCssEditor.tsx
+++ b/fluxer_app/src/features/theme_settings/components/QuickCssEditor.tsx
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import Accessibility from '@app/features/accessibility/state/Accessibility';
-import {getTokenVariableDefinition, TOKEN_GROUPS} from '@app/features/theme_studio/sections/TokenGroups';
-import type {ThemeStudioBaseTheme} from '@app/features/theme_studio/utils/ThemeStudioPinnedVariables';
+import type {ThemeBaseKind} from '@app/features/theme_settings/utils/ThemeDefaultVariables';
+import {getTokenVariableDefinition, TOKEN_GROUPS} from '@app/features/theme_settings/utils/TokenGroups';
import type {CompletionContext, CompletionResult} from '@codemirror/autocomplete';
import {indentWithTab} from '@codemirror/commands';
import {css, cssLanguage} from '@codemirror/lang-css';
@@ -36,33 +36,33 @@ function themeTokenCompletionSource(context: CompletionContext): CompletionResul
};
}
-function buildEditorTheme(baseTheme: ThemeStudioBaseTheme): Extension {
+function buildEditorTheme(baseTheme: ThemeBaseKind): Extension {
const dark = baseTheme === 'dark';
return EditorView.theme(
{
'&': {
height: '100%',
- color: 'var(--studio-fg-primary)',
- backgroundColor: 'var(--studio-bg-editor)',
+ color: 'var(--text-primary)',
+ backgroundColor: 'var(--background-secondary)',
fontSize: '13px',
},
'.cm-scroller': {
- fontFamily: 'var(--studio-font-mono)',
+ fontFamily: 'var(--font-mono, ui-monospace, monospace)',
lineHeight: '1.6',
padding: '4px 0',
},
'.cm-content': {
- caretColor: 'var(--studio-fg-primary)',
+ caretColor: 'var(--text-primary)',
padding: '8px 0',
},
'.cm-gutters': {
- backgroundColor: 'var(--studio-bg-editor)',
- color: 'var(--studio-fg-muted)',
+ backgroundColor: 'var(--background-secondary)',
+ color: 'var(--text-tertiary)',
border: 'none',
},
'.cm-activeLineGutter': {
backgroundColor: 'transparent',
- color: 'var(--studio-fg-primary)',
+ color: 'var(--text-primary)',
},
'.cm-activeLine': {
backgroundColor: dark ? 'rgba(255, 255, 255, 0.03)' : 'rgba(0, 0, 0, 0.03)',
@@ -74,7 +74,7 @@ function buildEditorTheme(baseTheme: ThemeStudioBaseTheme): Extension {
outline: 'none',
},
'.cm-cursor, .cm-dropCursor': {
- borderLeftColor: 'var(--studio-fg-primary)',
+ borderLeftColor: 'var(--text-primary)',
},
'&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection': {
backgroundColor: dark ? 'rgba(120, 160, 220, 0.28)' : 'rgba(80, 130, 210, 0.22)',
@@ -87,18 +87,18 @@ function buildEditorTheme(baseTheme: ThemeStudioBaseTheme): Extension {
outline: 'none',
},
'.cm-tooltip': {
- backgroundColor: 'var(--studio-bg-elevated)',
- border: '1px solid var(--studio-border)',
+ backgroundColor: 'var(--background-primary)',
+ border: '1px solid var(--background-modifier-accent)',
borderRadius: '6px',
boxShadow: '0 8px 24px rgba(0, 0, 0, 0.28)',
- color: 'var(--studio-fg-primary)',
+ color: 'var(--text-primary)',
},
'.cm-tooltip-autocomplete > ul > li[aria-selected]': {
- backgroundColor: 'var(--studio-accent, rgba(120, 160, 220, 0.3))',
- color: 'var(--studio-fg-on-accent)',
+ backgroundColor: 'var(--brand-primary)',
+ color: 'var(--brand-primary-fill)',
},
'.cm-tooltip-autocomplete > ul > li': {
- fontFamily: 'var(--studio-font-mono)',
+ fontFamily: 'var(--font-mono, ui-monospace, monospace)',
},
},
{dark},
@@ -122,9 +122,9 @@ function buildHighlightStyle(): HighlightStyle {
]);
}
-export interface QuickCssEditorProps {
+interface QuickCssEditorProps {
ariaLabel: string;
- baseTheme: ThemeStudioBaseTheme;
+ baseTheme: ThemeBaseKind;
className?: string;
onChange: (value: string) => void;
readOnly?: boolean;
diff --git a/fluxer_app/src/features/theme_settings/components/QuickCssEditorDiscard.tsx b/fluxer_app/src/features/theme_settings/components/QuickCssEditorDiscard.tsx
new file mode 100644
index 000000000..541f50f72
--- /dev/null
+++ b/fluxer_app/src/features/theme_settings/components/QuickCssEditorDiscard.tsx
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import {ConfirmModal} from '@app/features/app/components/dialogs/ConfirmModal';
+import {CANCEL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
+import ThemeLibrary, {getThemeLabel} from '@app/features/theme/state/ThemeLibrary';
+import ThemeSettingsState from '@app/features/theme_settings/state/ThemeSettingsState';
+import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
+import {modal} from '@app/features/ui/commands/ModalCommands';
+import type {I18n} from '@lingui/core';
+import {msg} from '@lingui/core/macro';
+
+const DISCARD_CHANGES_DESCRIPTOR = msg({
+ message: 'Discard changes to {themeName}?',
+ comment: 'Confirmation title in the quick CSS editor window before leaving a theme with unsaved changes.',
+});
+const DISCARD_DESCRIPTOR = msg({
+ message: 'Discard',
+ comment: 'Confirm button that throws away unsaved changes to a theme in the quick CSS editor window.',
+});
+const UNSAVED_CHANGES_DESCRIPTION_DESCRIPTOR = msg({
+ message: "Your changes to this theme haven't been saved.",
+ comment: 'Confirmation text in the quick CSS editor window before leaving a theme with unsaved changes.',
+});
+export function confirmDiscardThemeChanges(
+ i18n: I18n,
+ portalHost: HTMLElement | null,
+ themeName: string,
+ onDiscard: () => void,
+): void {
+ const render = modal(() => (
+ <ConfirmModal
+ title={i18n._(DISCARD_CHANGES_DESCRIPTOR, {themeName})}
+ description={i18n._(UNSAVED_CHANGES_DESCRIPTION_DESCRIPTOR)}
+ primaryText={i18n._(DISCARD_DESCRIPTOR)}
+ primaryVariant="danger"
+ secondaryText={i18n._(CANCEL_DESCRIPTOR)}
+ onPrimary={onDiscard}
+ data-flx="theme-settings.quick-css-editor-discard.confirm-discard-theme-changes.confirm-modal"
+ />
+ ));
+ if (portalHost) {
+ ModalCommands.pushToPortalHost({modal: render, portalHost});
+ return;
+ }
+ ModalCommands.push(render);
+}
+
+export function requestQuickCssEditorClose(i18n: I18n, close: () => void): void {
+ if (!ThemeSettingsState.editorDirty) {
+ close();
+ return;
+ }
+ const theme = ThemeLibrary.themes.find((candidate) => candidate.id === ThemeSettingsState.editorFile);
+ confirmDiscardThemeChanges(i18n, null, theme ? getThemeLabel(theme) : '', close);
+}
diff --git a/fluxer_app/src/features/theme_settings/components/QuickCssSection.tsx b/fluxer_app/src/features/theme_settings/components/QuickCssSection.tsx
new file mode 100644
index 000000000..6f1ab3fe1
--- /dev/null
+++ b/fluxer_app/src/features/theme_settings/components/QuickCssSection.tsx
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import Accessibility from '@app/features/accessibility/state/Accessibility';
+import {ConfirmModal} from '@app/features/app/components/dialogs/ConfirmModal';
+import {SettingsSection} from '@app/features/app/components/dialogs/shared/SettingsSection';
+import {CANCEL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
+import {remFromPx} from '@app/features/theme/layout/RemFromPx';
+import ThemeEditTarget from '@app/features/theme/state/ThemeEditTarget';
+import ThemeProfile from '@app/features/theme/state/ThemeProfile';
+import * as ThemeSettingsCommands from '@app/features/theme_settings/commands/ThemeSettingsCommands';
+import styles from '@app/features/theme_settings/ThemesTab.module.css';
+import {quickCssEditorNeedsDesktopUpdate} from '@app/features/theme_settings/utils/QuickCssEditorSupport';
+import {
+ OPEN_QUICK_CSS_EDITOR_DESCRIPTOR,
+ SYNC_CUSTOM_CSS_ACROSS_DEVICES_DESCRIPTOR,
+} from '@app/features/theme_settings/utils/ThemeSettingsMessageDescriptors';
+import {Button} from '@app/features/ui/button/Button';
+import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
+import {modal} from '@app/features/ui/commands/ModalCommands';
+import {Switch} from '@app/features/ui/components/form/FormSwitch';
+import MobileLayout from '@app/features/ui/state/MobileLayout';
+import {QUICK_CSS_SECTION_DESCRIPTOR} from '@app/features/user/components/settings_utils/section_registry/ThemesSections';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {FileCssIcon} from '@phosphor-icons/react';
+import {observer} from 'mobx-react-lite';
+import type React from 'react';
+
+const QUICK_CSS_DESCRIPTION_DESCRIPTOR = msg({
+ message:
+ "Write your own CSS to change anything in the app. The editor opens in its own window that your CSS doesn't change, so you can always fix CSS that breaks the app.",
+ comment: 'Description of the "Quick CSS" section in Settings > Themes.',
+});
+const QUICK_CSS_SIZE_DESCRIPTOR = msg({
+ message: '{lines, plural, one {# line} other {# lines}} of quick CSS.',
+ comment: 'Shown in the "Quick CSS" section in Settings > Themes. How long the quick CSS of the edited theme is.',
+});
+const QUICK_CSS_EMPTY_DESCRIPTOR = msg({
+ message: "You haven't written any quick CSS yet.",
+ comment: 'Shown in the "Quick CSS" section in Settings > Themes when the edited theme has no quick CSS.',
+});
+const OPEN_ON_A_COMPUTER_DESCRIPTOR = msg({
+ message: 'Open this page on a computer to edit quick CSS.',
+ comment: 'Shown in the "Quick CSS" section in Settings > Themes on phones, where the editor window is not available.',
+});
+const UPDATE_DESKTOP_APP_DESCRIPTOR = msg({
+ message: 'Update the desktop app to edit quick CSS.',
+ comment:
+ 'Shown under the disabled "Open quick CSS editor" button in Settings > Themes when the desktop app is too old to open the editor window.',
+});
+const SYNC_CUSTOM_CSS_ACROSS_DEVICES_DESCRIPTION_DESCRIPTOR = msg({
+ message: 'Only the CSS text is synced. Uploaded assets and local file references stay on this device.',
+ comment: 'Description of the "Sync custom CSS across devices" switch in Settings > Themes.',
+});
+const SYNC_CUSTOM_CSS_DESCRIPTOR = msg({
+ message: 'Sync custom CSS?',
+ comment: 'Confirmation title before turning on custom CSS sync in Settings > Themes.',
+});
+const SYNC_CUSTOM_CSS_CONFIRM_DESCRIPTION_DESCRIPTOR = msg({
+ message:
+ 'Only the CSS text is synced across devices. Uploaded assets, desktop file references, fonts, and media stay on this device.',
+ comment: 'Confirmation text before turning on custom CSS sync in Settings > Themes.',
+});
+const SYNC_CSS_TEXT_DESCRIPTOR = msg({
+ message: 'Sync CSS text',
+ comment: 'Confirm button that turns on custom CSS sync in Settings > Themes.',
+});
+
+function countLines(css: string | null): number {
+ if (!css || css.trim().length === 0) return 0;
+ return css.split('\n').length;
+}
+
+export const QuickCssSection: React.FC = observer(() => {
+ const {i18n} = useLingui();
+ const target = ThemeEditTarget.target;
+ const lines = countLines(ThemeProfile.customThemeCssFor(target));
+ const needsDesktopUpdate = quickCssEditorNeedsDesktopUpdate();
+ const handleSyncChange = (value: boolean) => {
+ if (!value) {
+ Accessibility.updateSettings({customThemeCssSyncAcrossDevices: false});
+ return;
+ }
+ ModalCommands.push(
+ modal(() => (
+ <ConfirmModal
+ title={i18n._(SYNC_CUSTOM_CSS_DESCRIPTOR)}
+ description={i18n._(SYNC_CUSTOM_CSS_CONFIRM_DESCRIPTION_DESCRIPTOR)}
+ primaryText={i18n._(SYNC_CSS_TEXT_DESCRIPTOR)}
+ secondaryText={i18n._(CANCEL_DESCRIPTOR)}
+ onPrimary={() => Accessibility.updateSettings({customThemeCssSyncAcrossDevices: true})}
+ data-flx="theme-settings.quick-css-section.handle-sync-change.confirm-modal"
+ />
+ )),
+ );
+ };
+ return (
+ <SettingsSection
+ id="quick-css"
+ title={i18n._(QUICK_CSS_SECTION_DESCRIPTOR)}
+ description={i18n._(QUICK_CSS_DESCRIPTION_DESCRIPTOR)}
+ data-flx="theme-settings.quick-css-section.quick-css"
+ >
+ <div className={styles.stack} data-flx="theme-settings.quick-css-section.stack">
+ <p className={styles.note} data-flx="theme-settings.quick-css-section.note">
+ {lines > 0 ? i18n._(QUICK_CSS_SIZE_DESCRIPTOR, {lines}) : i18n._(QUICK_CSS_EMPTY_DESCRIPTOR)}
+ </p>
+ {MobileLayout.enabled ? (
+ <p className={styles.note} data-flx="theme-settings.quick-css-section.note--2">
+ {i18n._(OPEN_ON_A_COMPUTER_DESCRIPTOR)}
+ </p>
+ ) : (
+ <>
+ <div data-flx="theme-settings.quick-css-section.div">
+ <Button
+ fitContent
+ disabled={needsDesktopUpdate}
+ leftIcon={
+ <FileCssIcon size={remFromPx(18)} data-flx="theme-settings.quick-css-section.file-css-icon" />
+ }
+ onClick={() => ThemeSettingsCommands.openQuickCssEditor()}
+ data-flx="theme-settings.quick-css-section.button.open-quick-css-editor"
+ >
+ {i18n._(OPEN_QUICK_CSS_EDITOR_DESCRIPTOR)}
+ </Button>
+ </div>
+ {needsDesktopUpdate ? (
+ <p className={styles.note} data-flx="theme-settings.quick-css-section.update-desktop-app">
+ {i18n._(UPDATE_DESKTOP_APP_DESCRIPTOR)}
+ </p>
+ ) : null}
+ </>
+ )}
+ </div>
+ {target === 'account' ? (
+ <Switch
+ label={i18n._(SYNC_CUSTOM_CSS_ACROSS_DEVICES_DESCRIPTOR)}
+ description={i18n._(SYNC_CUSTOM_CSS_ACROSS_DEVICES_DESCRIPTION_DESCRIPTOR)}
+ value={Accessibility.customThemeCssSyncAcrossDevices}
+ onChange={handleSyncChange}
+ data-flx="theme-settings.quick-css-section.switch.sync-change"
+ />
+ ) : null}
+ </SettingsSection>
+ );
+});
diff --git a/fluxer_app/src/features/theme_settings/utils/CssSyntaxErrors.ts b/fluxer_app/src/features/theme_settings/utils/CssSyntaxErrors.ts
new file mode 100644
index 000000000..4c27290d5
--- /dev/null
+++ b/fluxer_app/src/features/theme_settings/utils/CssSyntaxErrors.ts
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import {cssLanguage} from '@codemirror/lang-css';
+
+export function findFirstCssSyntaxErrorLine(css: string): number | null {
+ let errorOffset: number | null = null;
+ cssLanguage.parser.parse(css).iterate({
+ enter: (node) => {
+ if (errorOffset !== null) return false;
+ if (node.type.isError) {
+ errorOffset = node.from;
+ return false;
+ }
+ return undefined;
+ },
+ });
+ if (errorOffset === null) return null;
+ return css.slice(0, errorOffset).split('\n').length;
+}
diff --git a/fluxer_app/src/features/theme_settings/utils/QuickCssEditorSupport.ts b/fluxer_app/src/features/theme_settings/utils/QuickCssEditorSupport.ts
new file mode 100644
index 000000000..61223320c
--- /dev/null
+++ b/fluxer_app/src/features/theme_settings/utils/QuickCssEditorSupport.ts
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import {getElectronAPI, isDesktop} from '@app/features/ui/utils/NativeUtils';
+
+export function quickCssEditorNeedsDesktopUpdate(): boolean {
+ return isDesktop() && getElectronAPI()?.cssEditorWindow !== true;
+}
diff --git a/fluxer_app/src/features/theme_studio/sections/TokenGroups.ts b/fluxer_app/src/features/theme_settings/utils/TokenGroups.ts
similarity index 58%
rename from fluxer_app/src/features/theme_studio/sections/TokenGroups.ts
rename to fluxer_app/src/features/theme_settings/utils/TokenGroups.ts
index ec37d3c85..5086dd31f 100644
--- a/fluxer_app/src/features/theme_studio/sections/TokenGroups.ts
+++ b/fluxer_app/src/features/theme_settings/utils/TokenGroups.ts
@@ -41,83 +41,96 @@ const GROUP_ORDER: ReadonlyArray<string> = [
const GROUP_LABEL_DESCRIPTORS: Readonly<Record<string, MessageDescriptor | undefined>> = {
typography: msg({
message: 'Typography',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for font and text-sizing tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for font and text-sizing tokens.',
}),
surfaces: msg({
message: 'Surfaces',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for background surface tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for background surface tokens.',
}),
text: msg({
message: 'Text',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for text color tokens.',
+ comment: 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for text color tokens.',
}),
brand: msg({
message: 'Brand & accents',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for brand and accent color tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for brand and accent color tokens.',
}),
status: msg({
message: 'Status indicators',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for presence and status color tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for presence and status color tokens.',
}),
buttons: msg({
message: 'Buttons',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for button color tokens.',
+ comment: 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for button color tokens.',
}),
borders: msg({
message: 'Borders & focus',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for border and focus ring tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for border and focus ring tokens.',
}),
alerts: msg({
message: 'Alerts & callouts',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for alert and callout tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for alert and callout tokens.',
}),
markup: msg({
message: 'Markup & mentions',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for markdown and mention tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for markdown and mention tokens.',
}),
code: msg({
message: 'Code & terminal',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for code block and terminal tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for code block and terminal tokens.',
}),
tables: msg({
message: 'Tables',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for table tokens.',
+ comment: 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for table tokens.',
}),
messages: msg({
message: 'Messages',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for chat message tokens.',
+ comment: 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for chat message tokens.',
}),
forms: msg({
message: 'Forms',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for form input tokens.',
+ comment: 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for form input tokens.',
}),
layout: msg({
message: 'Layout',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for spacing and sizing tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for spacing and sizing tokens.',
}),
scrolling: msg({
message: 'Scrolling',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for scrollbar tokens.',
+ comment: 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for scrollbar tokens.',
}),
motion: msg({
message: 'Motion',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for animation and transition tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for animation and transition tokens.',
}),
layering: msg({
message: 'Layering',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for stacking order tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for stacking order tokens.',
}),
media: msg({
message: 'Media',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for image and video tokens.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for image and video tokens.',
}),
emoji: msg({
message: 'Emoji',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for emoji tokens.',
+ comment: 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for emoji tokens.',
}),
other: msg({
message: 'Other',
- comment: 'Collapsible group heading in the Theme Studio tokens list, for tokens that fit no other group.',
+ comment:
+ 'Collapsible group heading in the "Colors and fonts" list in Settings > Themes, for tokens that fit no other group.',
}),
};
@@ -154,14 +167,13 @@ function buildGroups(): ReadonlyArray<TokenGroupDefinition> {
}
export const TOKEN_GROUPS: ReadonlyArray<TokenGroupDefinition> = buildGroups();
-export const DEFAULT_EXPANDED_GROUP_IDS: ReadonlyArray<string> = ['surfaces', 'text', 'brand', 'messages'];
function assertTokenGroupsCoverConstants(): void {
const grouped = new Set<string>();
for (const group of TOKEN_GROUPS) {
for (const variable of group.variables) {
if (grouped.has(variable)) {
- throw new Error(`Token Studio: variable ${variable} is assigned to more than one group`);
+ throw new Error(`Theme tokens: variable ${variable} is assigned to more than one group`);
}
grouped.add(variable);
}
@@ -169,12 +181,12 @@ function assertTokenGroupsCoverConstants(): void {
const expected = new Set<string>(THEME_VARIABLE_NAMES);
for (const variable of expected) {
if (!grouped.has(variable)) {
- throw new Error(`Token Studio: variable ${variable} is missing from TokenGroups`);
+ throw new Error(`Theme tokens: variable ${variable} is missing from TokenGroups`);
}
}
for (const variable of grouped) {
if (!expected.has(variable)) {
- throw new Error(`Token Studio: variable ${variable} is not present in theme constants`);
+ throw new Error(`Theme tokens: variable ${variable} is not present in theme constants`);
}
}
}
@@ -183,7 +195,7 @@ if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {
try {
assertTokenGroupsCoverConstants();
} catch (error) {
- console.error('[ThemeStudio] TokenGroups taxonomy mismatch:', error);
+ console.error('[ThemeSettings] TokenGroups taxonomy mismatch:', error);
}
}