Skip to content
Snippets Groups Projects
Commit e676dddf authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette/prefs] Rename « System » theme

parent 16044313
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ import { ipcRenderer } from 'electron'; ...@@ -44,7 +44,7 @@ import { ipcRenderer } from 'electron';
export const THEMES = [ export const THEMES = [
{ id: 'light', label: 'Light' }, { id: 'light', label: 'Light' },
{ id: 'dark', label: 'Dark' }, { id: 'dark', label: 'Dark' },
{ id: 'system', label: 'System' }, { id: 'system', label: 'System Defaults' },
]; ];
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -86,7 +86,7 @@ ipcRenderer.on('dome.ipc.settings.defaults', () => { ...@@ -86,7 +86,7 @@ ipcRenderer.on('dome.ipc.settings.defaults', () => {
export function useThemeColors() { export function useThemeColors() {
const [themeColors] = Settings.useGlobalSettings(ColorTheme); const [themeColors] = Settings.useGlobalSettings(ColorTheme);
const invoke = () => ipcRenderer.invoke('theme-color:which-system'); const invoke = () => ipcRenderer.invoke('theme-color:which-system');
const { result } : { result: 'dark' | 'light' } = usePromise(invoke()); const { result }: { result: 'dark' | 'light' } = usePromise(invoke());
if (themeColors === 'system') if (themeColors === 'system')
return result === 'dark' ? 'dark-code' : 'default'; return result === 'dark' ? 'dark-code' : 'default';
return themeColors === 'dark' ? 'dark-code' : 'default'; return themeColors === 'dark' ? 'dark-code' : 'default';
......
...@@ -39,13 +39,13 @@ import React from 'react'; ...@@ -39,13 +39,13 @@ import React from 'react';
import * as Settings from 'dome/data/settings'; import * as Settings from 'dome/data/settings';
import * as Forms from 'dome/layout/forms'; import * as Forms from 'dome/layout/forms';
import * as P from 'ivette/prefs'; import * as IvettePrefs from 'ivette/prefs';
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- Font Forms // --- Font Forms
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
function ThemeFields(props: P.ThemeProps) { function ThemeFields(props: IvettePrefs.ThemeProps) {
const fontsize = Forms.useValid( const fontsize = Forms.useValid(
Settings.useGlobalSettings(props.fontSize), Settings.useGlobalSettings(props.fontSize),
); );
...@@ -73,12 +73,12 @@ function ThemeFields(props: P.ThemeProps) { ...@@ -73,12 +73,12 @@ function ThemeFields(props: P.ThemeProps) {
} }
function ColorThemeFields() { function ColorThemeFields() {
const [theme, setTheme] = Settings.useGlobalSettings(P.ColorTheme); const [theme, setTheme] = Settings.useGlobalSettings(IvettePrefs.ColorTheme);
const elements = P.THEMES.map(({ id, label }) => { const elements = IvettePrefs.THEMES.map(({ id, label }) => {
return <option value={id} key={id}>{label}</option>; return <option value={id} key={id}>{label}</option>;
}); });
const set = (t: string | undefined) => { const set = (t: string | undefined) => {
if (t) { P.forceThemeUpdate(t); setTheme(t); } if (t) { IvettePrefs.forceThemeUpdate(t); setTheme(t); }
}; };
return ( return (
<Forms.SelectField label={'Color theme'} state={[theme, undefined, set]}> <Forms.SelectField label={'Color theme'} state={[theme, undefined, set]}>
...@@ -91,7 +91,7 @@ function ColorThemeFields() { ...@@ -91,7 +91,7 @@ function ColorThemeFields() {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- Editor Command Forms // --- Editor Command Forms
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
function EditorCommandFields(props: P.EditorCommandProps) { function EditorCommandFields(props: IvettePrefs.EditorCommandProps) {
const cmd = Forms.useDefined(Forms.useValid( const cmd = Forms.useDefined(Forms.useValid(
Settings.useGlobalSettings(props.command), Settings.useGlobalSettings(props.command),
)); ));
...@@ -110,24 +110,24 @@ export default function Preferences() { ...@@ -110,24 +110,24 @@ export default function Preferences() {
return ( return (
<Forms.Page> <Forms.Page>
<Forms.Section label="Theme" unfold> <Forms.Section label="Theme" unfold>
<ColorThemeFields/> <ColorThemeFields />
</Forms.Section> </Forms.Section>
<Forms.Section label="AST View" unfold> <Forms.Section label="AST View" unfold>
<ThemeFields <ThemeFields
target="Internal AST" target="Internal AST"
fontSize={P.AstFontSize} fontSize={IvettePrefs.AstFontSize}
wrapText={P.AstWrapText} wrapText={IvettePrefs.AstWrapText}
/> />
</Forms.Section> </Forms.Section>
<Forms.Section label="Source View" unfold> <Forms.Section label="Source View" unfold>
<ThemeFields <ThemeFields
target="Source Code" target="Source Code"
fontSize={P.SourceFontSize} fontSize={IvettePrefs.SourceFontSize}
wrapText={P.SourceWrapText} wrapText={IvettePrefs.SourceWrapText}
/> />
</Forms.Section> </Forms.Section>
<Forms.Section label="Editor Command" unfold> <Forms.Section label="Editor Command" unfold>
<EditorCommandFields command={P.EditorCommand} /> <EditorCommandFields command={IvettePrefs.EditorCommand} />
</Forms.Section> </Forms.Section>
</Forms.Page> </Forms.Page>
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment