Skip to content

Commit 9098f53

Browse files
committed
initial pass at settings, not current saved
1 parent 3539137 commit 9098f53

11 files changed

Lines changed: 1955 additions & 1379 deletions

File tree

apps/client/app.config.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ export const appConfig = {
4949
local: string
5050
src: string
5151
}[],
52+
// themes to load into the editor via shiki
53+
themes: [
54+
{ name: "Code Glue Light", theme: codeGlueLight },
55+
{ name: "Vitesse Dark", theme: "vitesse-dark" },
56+
{ name: "Vitesse Light", theme: "vitesse-light" },
57+
] satisfies {
58+
name: string
59+
theme: ThemeInput | "none" | StringLiteralUnion<BundledTheme, string>
60+
}[],
5261
editor: {
5362
tabSize: 2,
5463
printWidth: 80,
5564
defaultFontSize: 14,
5665
defaultFontWidth: 100,
5766
defaultFontWeight: 260,
5867
defaultFont: "Monaspace Argon",
59-
// themes to load into the editor via shiki
60-
themes: [
61-
{ name: "Code Glue Light", theme: codeGlueLight },
62-
{ name: "Vitesse Dark", theme: "vitesse-dark" },
63-
{ name: "Vitesse Light", theme: "vitesse-light" },
64-
] satisfies {
65-
name: string
66-
theme: ThemeInput | "none" | StringLiteralUnion<BundledTheme, string>
67-
}[],
6868
// languages that need to support the above themes
6969
languages: ["typescript", "javascript"] satisfies (
7070
| LanguageInput
@@ -74,7 +74,9 @@ export const appConfig = {
7474
},
7575
logs: {
7676
defaultFontSize: 14,
77-
font: "Monaspace Krypton",
77+
defaultFontWidth: 100,
78+
defaultFontWeight: 260,
79+
defaultFont: "Monaspace Krypton",
7880
},
7981
queries: {
8082
settings: parseAsBoolean.withDefault(false),

apps/client/src/components/Editor/index.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { type Monaco, Editor as MonacoEditor } from "@monaco-editor/react"
22
import React from "react"
3+
import { useSnapshot } from "valtio/react"
34

45
import { appConfig } from "@/config"
5-
import { codeGlueLight } from "@/design/editorThemes"
66
import { useCurrentAutomation } from "@/hooks/useAutomation"
77
import { store } from "@/store"
8+
import { getUserSettingOrDefault, settingsStore } from "@/store/settings"
89

910
import type { editor } from "monaco-editor"
1011

@@ -16,6 +17,13 @@ export const Editor: React.FC = () => {
1617
useCurrentAutomation()
1718
const path = automationId ? `/automations/${automationId}.ts` : undefined
1819

20+
const snap = useSnapshot(settingsStore)
21+
const theme = getUserSettingOrDefault(snap, "editor.theme")
22+
const typeface = getUserSettingOrDefault(snap, "editor.typeface")
23+
const fontSize = getUserSettingOrDefault(snap, "editor.fontSize")
24+
const fontWidth = getUserSettingOrDefault(snap, "editor.fontWidth")
25+
const fontWeight = getUserSettingOrDefault(snap, "editor.fontWeight")
26+
1927
/**
2028
* Support for automation draft saving with debounce
2129
*/
@@ -74,7 +82,7 @@ export const Editor: React.FC = () => {
7482
<MonacoEditor
7583
{...{
7684
language: "typescript",
77-
theme: codeGlueLight.name,
85+
theme,
7886
defaultValue: automationSnapshot.body,
7987
beforeMount: handleEditorBeforeMount,
8088
onChange: handleEditorChange,
@@ -86,12 +94,11 @@ export const Editor: React.FC = () => {
8694
minimap: { enabled: false },
8795
tabSize: appConfig.editor.tabSize,
8896
rulers: [appConfig.editor.printWidth],
89-
fontSize: appConfig.editor.defaultFontSize,
90-
fontFamily: appConfig.editor.font,
91-
fontWeight: "260",
97+
fontSize,
98+
fontFamily: typeface,
9299
fontLigatures:
93100
"'calt', 'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'ss07', 'ss08', 'ss09', 'ss10', 'liga'",
94-
fontVariations: true,
101+
fontVariations: `'wght' ${fontWeight}, 'wdth' ${fontWidth}`,
95102
allowVariableFonts: true,
96103
automaticLayout: true,
97104
occurrencesHighlight: "off",

apps/client/src/components/Editor/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ configureMonacoPrettier(monaco, {
6767

6868
// Create the language highlighter, add themes and languages in appConfig
6969
const highlighter = await createHighlighter({
70-
themes: appConfig.editor.themes,
70+
themes: appConfig.themes.map((t) => t.theme),
7171
langs: appConfig.editor.languages,
7272
})
7373

apps/client/src/components/Logs.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { useCallback, useEffect, useRef } from "react"
1+
import { useEffect } from "react"
2+
import { useSnapshot } from "valtio/react"
23

34
import { ScrollView, type ScrollViewRef, Text } from "@code-glue/paradigm"
45
import { formatAutomationContext } from "@code-glue/server/utils/helpers/format.mts"
@@ -7,8 +8,8 @@ import {
78
type LogLine,
89
useAutomationLogs,
910
} from "@/hooks/useAutomationLogs"
10-
import { appConfig } from "../../app.config"
11-
import { useAutomation } from "../hooks/useAutomation"
11+
import { useAutomation } from "@/hooks/useAutomation"
12+
import { getUserSettingOrDefault, settingsStore } from "@/store/settings"
1213

1314
import type React from "react"
1415

@@ -43,6 +44,11 @@ export const Logs = ({
4344
ref,
4445
}: LogsProps) => {
4546
const { automationSnapshot: automation } = useAutomation(automationId)
47+
const snap = useSnapshot(settingsStore)
48+
const typeface = getUserSettingOrDefault(snap, "console.typeface")
49+
const fontSize = getUserSettingOrDefault(snap, "console.fontSize")
50+
const fontWidth = getUserSettingOrDefault(snap, "console.fontWidth")
51+
const fontWeight = getUserSettingOrDefault(snap, "console.fontWeight")
4652

4753
const loggerContext = automationId
4854
? formatAutomationContext(automation.title)
@@ -82,7 +88,8 @@ export const Logs = ({
8288
<Text
8389
style={Text.style.footnote}
8490
key={logKey(log)}
85-
_style={{ fontFamily: appConfig.logs.font }}
91+
// biome-ignore lint/suspicious/noExplicitAny: runtime values, not Tamagui tokens
92+
_style={{ fontFamily: typeface, fontSize, fontWeight, fontStretch: `${fontWidth}%` } as any}
8693
color={log.isHistorical ? "$colorDisabled" : "$color"}
8794
>
8895
<Text

apps/client/src/design/editorThemes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const codeGlueLight = {
3535
"editorSuggestWidget.highlightForeground": "#3f8ffa",
3636
"editorSuggestWidget.selectedBackground": "#3f8ffa",
3737
"editorSuggestWidget.border": "#c0c0c0",
38-
"editorRuler.foreground": "#ececec",
38+
"editorRuler.foreground": "#d0d0d0",
3939
},
4040
settings: [
4141
{

apps/client/src/pages/Frame/Frame.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useSnapshot } from "valtio/react"
44
import { Center, Layout, ParadigmProvider, Text } from "@code-glue/paradigm"
55
import { glueDesignConfig } from "@/design/design.config"
66
import { store } from "@/store"
7+
import { settingsStore } from "@/store/settings"
78
import { Content } from "./Content"
89
import { Nav } from "./Nav"
910

@@ -12,6 +13,7 @@ export const Frame = () => {
1213
isReady: storeIsReady,
1314
apiStatus: { typesReady },
1415
} = useSnapshot(store)
16+
const { appTheme } = useSnapshot(settingsStore)
1517

1618
const [fontsLoaded, setFontsLoaded] = useState(false)
1719

@@ -25,7 +27,10 @@ export const Frame = () => {
2527
fontsLoaded && storeIsReady && (typesReady || store.serverError)
2628

2729
return (
28-
<ParadigmProvider config={glueDesignConfig}>
30+
<ParadigmProvider
31+
config={glueDesignConfig}
32+
{...(appTheme !== undefined ? { theme: appTheme } : {})}
33+
>
2934
{!appReady ? (
3035
<Center fillContainer>
3136
<Text>Loading...</Text>

0 commit comments

Comments
 (0)