@radheim/theme 0.0.0-stage → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tui/color.d.ts +8 -0
- package/dist/tui/color.js +67 -0
- package/dist/tui/expand.d.ts +4 -0
- package/dist/tui/expand.js +95 -0
- package/dist/tui/index.d.ts +9 -0
- package/dist/tui/index.js +8 -0
- package/dist/tui/resolve.d.ts +3362 -0
- package/dist/tui/resolve.js +265 -0
- package/dist/tui/schema.d.ts +4963 -0
- package/dist/tui/schema.js +240 -0
- package/dist/tui/select.d.ts +8 -0
- package/dist/tui/select.js +18 -0
- package/dist/tui/syntax.d.ts +3 -0
- package/dist/tui/syntax.js +78 -0
- package/dist/tui/types.d.ts +96 -0
- package/dist/tui/types.js +1 -0
- package/dist/tui/v1-migrate-new-designs.d.ts +3 -0
- package/dist/tui/v1-migrate-new-designs.js +353 -0
- package/dist/tui/v1-migrate.d.ts +30 -0
- package/dist/tui/v1-migrate.js +476 -0
- package/dist/tui/v1.d.ts +74 -0
- package/dist/tui/v1.js +1 -0
- package/package.json +43 -4
- package/README.md +0 -3
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export const HueStep = Schema.Literals([100, 200, 300, 400, 500, 600, 700, 800, 900]);
|
|
3
|
+
export const ActionVariant = Schema.Literals(["primary", "secondary", "destructive"]);
|
|
4
|
+
export const ActionState = Schema.Literals(["disabled", "pressed", "focused", "selected", "hovered"]);
|
|
5
|
+
export const SurfaceName = Schema.Literals(["dialog", "dialog.footer"]);
|
|
6
|
+
export const FormfieldState = ActionState;
|
|
7
|
+
export const FeedbackKind = Schema.Literals(["error", "warning", "success", "info"]);
|
|
8
|
+
const Mode = Schema.Literals(["light", "dark"]);
|
|
9
|
+
const HexColor = Schema.String.check(Schema.isPattern(/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i));
|
|
10
|
+
const ColorValue = Schema.Union([
|
|
11
|
+
HexColor,
|
|
12
|
+
Schema.Literal("transparent"),
|
|
13
|
+
Schema.TemplateLiteral(["$", Schema.NonEmptyString]),
|
|
14
|
+
]);
|
|
15
|
+
export const HueName = Schema.NonEmptyString;
|
|
16
|
+
export const CategoricalDefinition = Schema.Array(HueName).check(Schema.isMinLength(1));
|
|
17
|
+
const HueColorValue = Schema.Union([
|
|
18
|
+
HexColor,
|
|
19
|
+
Schema.String.check(Schema.isPattern(/^\$hue\..+\.(?:100|200|300|400|500|600|700|800|900)$/)),
|
|
20
|
+
]);
|
|
21
|
+
const HueScaleDefinition = Schema.Record(HueStep, HexColor);
|
|
22
|
+
const HueValueDefinition = Schema.Union([
|
|
23
|
+
Schema.String.check(Schema.isPattern(/^\$hue\..+$/)),
|
|
24
|
+
HueScaleDefinition,
|
|
25
|
+
]);
|
|
26
|
+
const HueRecord = Schema.Record(HueName, HueValueDefinition);
|
|
27
|
+
const HueDefinition = HueRecord.check(Schema.makeFilter((hues) => {
|
|
28
|
+
const missing = ["accent", "interactive", "neutral"].filter((name) => hues[name] === undefined);
|
|
29
|
+
return missing.length ? `Missing required semantic hues: ${missing.join(", ")}` : undefined;
|
|
30
|
+
}));
|
|
31
|
+
const StatefulColorDefinition = Schema.Struct({
|
|
32
|
+
base: Schema.optional(ColorValue),
|
|
33
|
+
$hovered: Schema.optional(ColorValue),
|
|
34
|
+
$focused: Schema.optional(ColorValue),
|
|
35
|
+
$pressed: Schema.optional(ColorValue),
|
|
36
|
+
$selected: Schema.optional(ColorValue),
|
|
37
|
+
$disabled: Schema.optional(ColorValue),
|
|
38
|
+
});
|
|
39
|
+
const ActionColorDefinition = Schema.Struct({
|
|
40
|
+
primary: Schema.optional(StatefulColorDefinition),
|
|
41
|
+
secondary: Schema.optional(StatefulColorDefinition),
|
|
42
|
+
destructive: Schema.optional(StatefulColorDefinition),
|
|
43
|
+
});
|
|
44
|
+
const TextFeedbackDefinition = Schema.Struct({
|
|
45
|
+
base: Schema.optional(ColorValue),
|
|
46
|
+
muted: Schema.optional(ColorValue),
|
|
47
|
+
});
|
|
48
|
+
const BackgroundFeedbackDefinition = Schema.Struct({
|
|
49
|
+
base: Schema.optional(ColorValue),
|
|
50
|
+
});
|
|
51
|
+
const TextDefinition = Schema.Struct({
|
|
52
|
+
base: Schema.optional(ColorValue),
|
|
53
|
+
muted: Schema.optional(ColorValue),
|
|
54
|
+
faint: Schema.optional(ColorValue),
|
|
55
|
+
selection: Schema.optional(ColorValue),
|
|
56
|
+
action: Schema.optional(ActionColorDefinition),
|
|
57
|
+
formfield: Schema.optional(StatefulColorDefinition),
|
|
58
|
+
feedback: Schema.optional(Schema.Struct({
|
|
59
|
+
error: Schema.optional(TextFeedbackDefinition),
|
|
60
|
+
warning: Schema.optional(TextFeedbackDefinition),
|
|
61
|
+
success: Schema.optional(TextFeedbackDefinition),
|
|
62
|
+
info: Schema.optional(TextFeedbackDefinition),
|
|
63
|
+
})),
|
|
64
|
+
});
|
|
65
|
+
const BackgroundDefinition = Schema.Struct({
|
|
66
|
+
base: Schema.optional(ColorValue),
|
|
67
|
+
selection: Schema.optional(ColorValue),
|
|
68
|
+
raised: Schema.optional(Schema.Struct({
|
|
69
|
+
base: Schema.optional(ColorValue),
|
|
70
|
+
high: Schema.optional(ColorValue),
|
|
71
|
+
max: Schema.optional(ColorValue),
|
|
72
|
+
})),
|
|
73
|
+
action: Schema.optional(ActionColorDefinition),
|
|
74
|
+
formfield: Schema.optional(StatefulColorDefinition),
|
|
75
|
+
feedback: Schema.optional(Schema.Struct({
|
|
76
|
+
error: Schema.optional(BackgroundFeedbackDefinition),
|
|
77
|
+
warning: Schema.optional(BackgroundFeedbackDefinition),
|
|
78
|
+
success: Schema.optional(BackgroundFeedbackDefinition),
|
|
79
|
+
info: Schema.optional(BackgroundFeedbackDefinition),
|
|
80
|
+
})),
|
|
81
|
+
});
|
|
82
|
+
export const SyntaxToken = Schema.Literals([
|
|
83
|
+
"comment",
|
|
84
|
+
"keyword",
|
|
85
|
+
"function",
|
|
86
|
+
"variable",
|
|
87
|
+
"string",
|
|
88
|
+
"number",
|
|
89
|
+
"type",
|
|
90
|
+
"operator",
|
|
91
|
+
"punctuation",
|
|
92
|
+
]);
|
|
93
|
+
export const SyntaxDefinition = Schema.Record(SyntaxToken, Schema.optionalKey(HueColorValue));
|
|
94
|
+
export const MarkdownToken = Schema.Literals([
|
|
95
|
+
"text",
|
|
96
|
+
"heading",
|
|
97
|
+
"link",
|
|
98
|
+
"linkText",
|
|
99
|
+
"code",
|
|
100
|
+
"blockQuote",
|
|
101
|
+
"emphasis",
|
|
102
|
+
"strong",
|
|
103
|
+
"horizontalRule",
|
|
104
|
+
"listItem",
|
|
105
|
+
"listEnumeration",
|
|
106
|
+
"image",
|
|
107
|
+
"imageText",
|
|
108
|
+
"codeBlock",
|
|
109
|
+
]);
|
|
110
|
+
export const MarkdownDefinition = Schema.Record(MarkdownToken, Schema.optionalKey(HueColorValue));
|
|
111
|
+
const DiffDefinition = Schema.Struct({
|
|
112
|
+
text: Schema.optional(Schema.Struct({
|
|
113
|
+
added: Schema.optional(ColorValue),
|
|
114
|
+
removed: Schema.optional(ColorValue),
|
|
115
|
+
context: Schema.optional(ColorValue),
|
|
116
|
+
hunkHeader: Schema.optional(ColorValue),
|
|
117
|
+
})),
|
|
118
|
+
background: Schema.optional(Schema.Struct({
|
|
119
|
+
added: Schema.optional(ColorValue),
|
|
120
|
+
removed: Schema.optional(ColorValue),
|
|
121
|
+
context: Schema.optional(ColorValue),
|
|
122
|
+
})),
|
|
123
|
+
highlight: Schema.optional(Schema.Struct({ added: Schema.optional(ColorValue), removed: Schema.optional(ColorValue) })),
|
|
124
|
+
lineNumber: Schema.optional(Schema.Struct({
|
|
125
|
+
text: Schema.optional(ColorValue),
|
|
126
|
+
background: Schema.optional(Schema.Struct({ added: Schema.optional(ColorValue), removed: Schema.optional(ColorValue) })),
|
|
127
|
+
})),
|
|
128
|
+
});
|
|
129
|
+
// Find-in-session matches. Optional in every theme: unset colors fall back to raised and focused tokens.
|
|
130
|
+
const FindDefinition = Schema.Struct({
|
|
131
|
+
text: Schema.optional(Schema.Struct({ current: Schema.optional(ColorValue) })),
|
|
132
|
+
background: Schema.optional(Schema.Struct({ match: Schema.optional(ColorValue), current: Schema.optional(ColorValue) })),
|
|
133
|
+
});
|
|
134
|
+
const ThemeTokensDefinition = Schema.Struct({
|
|
135
|
+
text: Schema.optional(TextDefinition),
|
|
136
|
+
background: Schema.optional(BackgroundDefinition),
|
|
137
|
+
border: Schema.optional(Schema.Struct({ base: Schema.optional(ColorValue) })),
|
|
138
|
+
scrollbar: Schema.optional(Schema.Struct({ base: Schema.optional(ColorValue) })),
|
|
139
|
+
diff: Schema.optional(DiffDefinition),
|
|
140
|
+
find: Schema.optional(FindDefinition),
|
|
141
|
+
syntax: Schema.optional(SyntaxDefinition),
|
|
142
|
+
markdown: Schema.optional(MarkdownDefinition),
|
|
143
|
+
});
|
|
144
|
+
const DialogTokensDefinition = Schema.Struct({
|
|
145
|
+
...ThemeTokensDefinition.fields,
|
|
146
|
+
"@footer": Schema.optional(ThemeTokensDefinition),
|
|
147
|
+
});
|
|
148
|
+
const CompleteStatefulColorDefinition = Schema.Struct({
|
|
149
|
+
base: ColorValue,
|
|
150
|
+
$hovered: Schema.optional(ColorValue),
|
|
151
|
+
$focused: Schema.optional(ColorValue),
|
|
152
|
+
$pressed: Schema.optional(ColorValue),
|
|
153
|
+
$selected: Schema.optional(ColorValue),
|
|
154
|
+
$disabled: Schema.optional(ColorValue),
|
|
155
|
+
});
|
|
156
|
+
const CompleteActionColorDefinition = Schema.Struct({
|
|
157
|
+
primary: CompleteStatefulColorDefinition,
|
|
158
|
+
secondary: CompleteStatefulColorDefinition,
|
|
159
|
+
destructive: CompleteStatefulColorDefinition,
|
|
160
|
+
});
|
|
161
|
+
const CompleteTextFeedbackDefinition = Schema.Struct({ base: ColorValue, muted: Schema.optional(ColorValue) });
|
|
162
|
+
const CompleteBackgroundFeedbackDefinition = Schema.Struct({ base: ColorValue });
|
|
163
|
+
const CompleteThemeTokensDefinition = Schema.Struct({
|
|
164
|
+
text: Schema.Struct({
|
|
165
|
+
base: ColorValue,
|
|
166
|
+
muted: ColorValue,
|
|
167
|
+
faint: Schema.optional(ColorValue),
|
|
168
|
+
selection: Schema.optional(ColorValue),
|
|
169
|
+
action: CompleteActionColorDefinition,
|
|
170
|
+
formfield: CompleteStatefulColorDefinition,
|
|
171
|
+
feedback: Schema.Struct({
|
|
172
|
+
error: CompleteTextFeedbackDefinition,
|
|
173
|
+
warning: CompleteTextFeedbackDefinition,
|
|
174
|
+
success: CompleteTextFeedbackDefinition,
|
|
175
|
+
info: CompleteTextFeedbackDefinition,
|
|
176
|
+
}),
|
|
177
|
+
}),
|
|
178
|
+
background: Schema.Struct({
|
|
179
|
+
base: ColorValue,
|
|
180
|
+
selection: Schema.optional(ColorValue),
|
|
181
|
+
raised: Schema.Struct({ base: ColorValue, high: ColorValue, max: ColorValue }),
|
|
182
|
+
action: CompleteActionColorDefinition,
|
|
183
|
+
formfield: CompleteStatefulColorDefinition,
|
|
184
|
+
feedback: Schema.Struct({
|
|
185
|
+
error: CompleteBackgroundFeedbackDefinition,
|
|
186
|
+
warning: CompleteBackgroundFeedbackDefinition,
|
|
187
|
+
success: CompleteBackgroundFeedbackDefinition,
|
|
188
|
+
info: CompleteBackgroundFeedbackDefinition,
|
|
189
|
+
}),
|
|
190
|
+
}),
|
|
191
|
+
border: Schema.Struct({ base: ColorValue }),
|
|
192
|
+
scrollbar: Schema.Struct({ base: ColorValue }),
|
|
193
|
+
diff: Schema.Struct({
|
|
194
|
+
text: Schema.Struct({ added: ColorValue, removed: ColorValue, context: ColorValue, hunkHeader: ColorValue }),
|
|
195
|
+
background: Schema.Struct({ added: ColorValue, removed: ColorValue, context: ColorValue }),
|
|
196
|
+
highlight: Schema.Struct({ added: ColorValue, removed: ColorValue }),
|
|
197
|
+
lineNumber: Schema.Struct({
|
|
198
|
+
text: ColorValue,
|
|
199
|
+
background: Schema.Struct({ added: ColorValue, removed: ColorValue }),
|
|
200
|
+
}),
|
|
201
|
+
}),
|
|
202
|
+
find: Schema.optional(FindDefinition),
|
|
203
|
+
syntax: Schema.Record(SyntaxToken, HueColorValue),
|
|
204
|
+
markdown: Schema.Record(MarkdownToken, HueColorValue),
|
|
205
|
+
});
|
|
206
|
+
const ThemeDefinitionFields = Schema.Struct({
|
|
207
|
+
hue: HueDefinition,
|
|
208
|
+
categorical: CategoricalDefinition,
|
|
209
|
+
...CompleteThemeTokensDefinition.fields,
|
|
210
|
+
"@dialog": Schema.optional(DialogTokensDefinition),
|
|
211
|
+
});
|
|
212
|
+
export const ThemeDefinition = ThemeDefinitionFields;
|
|
213
|
+
export const BaseThemeDefinition = Schema.Struct({
|
|
214
|
+
categorical: CategoricalDefinition,
|
|
215
|
+
...CompleteThemeTokensDefinition.fields,
|
|
216
|
+
"@dialog": Schema.optional(DialogTokensDefinition),
|
|
217
|
+
});
|
|
218
|
+
export const ModeDefinition = Schema.Struct({
|
|
219
|
+
hue: HueDefinition,
|
|
220
|
+
categorical: Schema.optional(CategoricalDefinition),
|
|
221
|
+
...ThemeTokensDefinition.fields,
|
|
222
|
+
"@dialog": Schema.optional(DialogTokensDefinition),
|
|
223
|
+
});
|
|
224
|
+
const FileMetadata = {
|
|
225
|
+
$schema: Schema.optional(Schema.String),
|
|
226
|
+
};
|
|
227
|
+
export const ThemeDocument = Schema.Union([
|
|
228
|
+
Schema.Struct({
|
|
229
|
+
...FileMetadata,
|
|
230
|
+
base: BaseThemeDefinition,
|
|
231
|
+
light: ModeDefinition,
|
|
232
|
+
dark: Schema.optional(ModeDefinition),
|
|
233
|
+
}),
|
|
234
|
+
Schema.Struct({
|
|
235
|
+
...FileMetadata,
|
|
236
|
+
base: BaseThemeDefinition,
|
|
237
|
+
light: Schema.optional(ModeDefinition),
|
|
238
|
+
dark: ModeDefinition,
|
|
239
|
+
}),
|
|
240
|
+
]);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Mode, ThemeDefinition, ThemeDocument } from "./index.js";
|
|
2
|
+
export declare function selectTheme(document: ThemeDocument, mode?: Mode): ThemeDefinition;
|
|
3
|
+
export declare function selectThemeMode(document: ThemeDocument, mode?: Mode): {
|
|
4
|
+
theme: ThemeDefinition;
|
|
5
|
+
mode: Mode;
|
|
6
|
+
};
|
|
7
|
+
export declare function themeModes(document: ThemeDocument): readonly Mode[];
|
|
8
|
+
export declare function supportsThemeMode(document: ThemeDocument, mode: Mode): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { mergeTheme } from "./expand.js";
|
|
2
|
+
export function selectTheme(document, mode) {
|
|
3
|
+
return selectThemeMode(document, mode).theme;
|
|
4
|
+
}
|
|
5
|
+
export function selectThemeMode(document, mode = "light") {
|
|
6
|
+
const modes = themeModes(document);
|
|
7
|
+
const selectedMode = modes.includes(mode) ? mode : modes[0];
|
|
8
|
+
const selected = document[selectedMode];
|
|
9
|
+
if (!selected)
|
|
10
|
+
throw new Error("Theme must provide at least one mode");
|
|
11
|
+
return { theme: mergeTheme(document.base, selected), mode: selectedMode };
|
|
12
|
+
}
|
|
13
|
+
export function themeModes(document) {
|
|
14
|
+
return ["light", "dark"].filter((mode) => document[mode] !== undefined);
|
|
15
|
+
}
|
|
16
|
+
export function supportsThemeMode(document, mode) {
|
|
17
|
+
return themeModes(document).includes(mode);
|
|
18
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { SyntaxStyle } from "@opentui/core";
|
|
2
|
+
export function generateSyntax(theme, owner) {
|
|
3
|
+
const step = 200;
|
|
4
|
+
const syntax = theme.syntax;
|
|
5
|
+
const markdown = theme.markdown;
|
|
6
|
+
const feedback = theme.text.feedback;
|
|
7
|
+
const rules = [
|
|
8
|
+
rule(["default"], theme.text.base),
|
|
9
|
+
rule(["prompt"], theme.hue.accent[step]),
|
|
10
|
+
rule(["extmark.file"], feedback.warning.base, { bold: true }),
|
|
11
|
+
rule(["extmark.agent"], theme.categorical[0][step], { bold: true }),
|
|
12
|
+
rule(["extmark.skill"], (theme.categorical[1] ?? theme.categorical[0])[step], { bold: true }),
|
|
13
|
+
rule(["extmark.paste"],
|
|
14
|
+
// The page color: dark in dark mode, light in light mode. A transparent page (the system theme) falls back to the selected-row text.
|
|
15
|
+
theme.background.base.a === 1 ? theme.background.base : theme.text.action.primary.focused, {
|
|
16
|
+
background: feedback.warning.base,
|
|
17
|
+
bold: true,
|
|
18
|
+
}),
|
|
19
|
+
rule(["comment", "comment.documentation"], syntax.comment, { italic: true }),
|
|
20
|
+
rule(["string", "symbol", "character.special", "character"], syntax.string),
|
|
21
|
+
rule(["number", "boolean", "constant", "float"], syntax.number),
|
|
22
|
+
rule(["keyword.return", "keyword.conditional", "keyword.repeat", "keyword.coroutine"], syntax.keyword, {
|
|
23
|
+
italic: true,
|
|
24
|
+
}),
|
|
25
|
+
rule(["keyword.type"], syntax.type, { bold: true, italic: true }),
|
|
26
|
+
rule(["keyword.function", "function.method"], syntax.function),
|
|
27
|
+
rule(["keyword"], syntax.keyword, { italic: true }),
|
|
28
|
+
rule(["keyword.import", "string.escape", "string.regexp", "tag.attribute", "keyword.export"], syntax.keyword),
|
|
29
|
+
rule(["operator", "keyword.operator", "punctuation.delimiter", "keyword.conditional.ternary"], syntax.operator),
|
|
30
|
+
rule(["variable", "variable.parameter", "function.method.call", "function.call", "property", "parameter", "field"], syntax.variable),
|
|
31
|
+
rule(["variable.member", "function", "constructor"], syntax.function),
|
|
32
|
+
rule(["type", "module", "class", "namespace"], syntax.type),
|
|
33
|
+
rule(["type.definition"], syntax.type, { bold: true }),
|
|
34
|
+
rule(["punctuation", "punctuation.bracket"], syntax.punctuation),
|
|
35
|
+
rule(["variable.builtin", "type.builtin", "function.builtin", "module.builtin", "constant.builtin", "variable.super"], feedback.error.base),
|
|
36
|
+
rule(["keyword.directive", "keyword.modifier", "keyword.exception"], syntax.keyword, { italic: true }),
|
|
37
|
+
rule(["punctuation.special", "tag.delimiter"], syntax.operator),
|
|
38
|
+
rule([
|
|
39
|
+
"markup.heading",
|
|
40
|
+
"markup.heading.2",
|
|
41
|
+
"markup.heading.3",
|
|
42
|
+
"markup.heading.4",
|
|
43
|
+
"markup.heading.5",
|
|
44
|
+
"markup.heading.6",
|
|
45
|
+
], markdown.heading, { bold: true }),
|
|
46
|
+
rule(["markup.heading.1"], markdown.heading, { bold: true, underline: true }),
|
|
47
|
+
rule(["markup.bold", "markup.strong"], markdown.strong, { bold: true }),
|
|
48
|
+
rule(["markup.italic"], markdown.emphasis, { italic: true }),
|
|
49
|
+
rule(["markup.list"], markdown.listItem),
|
|
50
|
+
rule(["markup.quote"], markdown.blockQuote, { italic: true }),
|
|
51
|
+
rule(["markup.raw", "markup.raw.block"], markdown.code),
|
|
52
|
+
rule(["markup.raw.inline"], markdown.code, { background: theme.background.base }),
|
|
53
|
+
rule(["markup.link", "markup.link.url", "string.special", "string.special.url"], markdown.link, {
|
|
54
|
+
underline: true,
|
|
55
|
+
}),
|
|
56
|
+
rule(["markup.link.label"], markdown.linkText, { underline: true }),
|
|
57
|
+
rule(["label"], markdown.linkText),
|
|
58
|
+
rule(["spell", "nospell"], theme.text.base),
|
|
59
|
+
rule(["markup.underline"], theme.text.base, { underline: true }),
|
|
60
|
+
rule(["comment.error"], feedback.error.base, { italic: true, bold: true }),
|
|
61
|
+
rule(["comment.warning"], feedback.warning.base, { italic: true, bold: true }),
|
|
62
|
+
rule(["comment.todo", "comment.note"], feedback.info.base, { italic: true, bold: true }),
|
|
63
|
+
rule(["attribute", "annotation"], feedback.warning.base),
|
|
64
|
+
rule(["tag"], feedback.error.base),
|
|
65
|
+
rule(["markup.strikethrough", "markup.list.unchecked", "debug"], theme.text.muted),
|
|
66
|
+
rule(["markup.list.checked"], feedback.success.base),
|
|
67
|
+
rule(["diff.plus"], theme.diff.text.added, { background: theme.diff.background.added }),
|
|
68
|
+
rule(["diff.minus"], theme.diff.text.removed, { background: theme.diff.background.removed }),
|
|
69
|
+
rule(["diff.delta"], theme.diff.text.context, { background: theme.diff.background.context }),
|
|
70
|
+
rule(["error"], feedback.error.base, { bold: true }),
|
|
71
|
+
rule(["warning"], feedback.warning.base, { bold: true }),
|
|
72
|
+
rule(["info"], feedback.info.base),
|
|
73
|
+
];
|
|
74
|
+
return SyntaxStyle.fromTheme(rules, owner);
|
|
75
|
+
}
|
|
76
|
+
function rule(scope, foreground, style = {}) {
|
|
77
|
+
return { scope, style: { foreground, ...style } };
|
|
78
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { RGBA } from "@opentui/core";
|
|
2
|
+
import type { ActionState, ActionVariant, FeedbackKind, HueStep, MarkdownToken, SemanticHue, SurfaceName, SyntaxToken } from "./schema.js";
|
|
3
|
+
export type ResolvedActionState = "base" | ActionState;
|
|
4
|
+
export type ResolvedFormfieldState = ResolvedActionState;
|
|
5
|
+
export type HueScale = Readonly<Record<HueStep, RGBA>>;
|
|
6
|
+
export type Hue = Readonly<Record<SemanticHue, HueScale>>;
|
|
7
|
+
export type HueSource = Readonly<{
|
|
8
|
+
hue: string;
|
|
9
|
+
step: HueStep;
|
|
10
|
+
}>;
|
|
11
|
+
export type Categorical = readonly HueScale[];
|
|
12
|
+
export type ActionStates = Readonly<Partial<Record<ActionState, boolean>>>;
|
|
13
|
+
export type StatefulColor = Readonly<Record<ResolvedActionState, RGBA>> & {
|
|
14
|
+
readonly state: (states: ActionStates) => RGBA;
|
|
15
|
+
};
|
|
16
|
+
export type FormfieldColor = StatefulColor;
|
|
17
|
+
export type ResolvedThemeTokens = {
|
|
18
|
+
readonly hue: Hue;
|
|
19
|
+
readonly categorical: Categorical;
|
|
20
|
+
readonly source: (color: RGBA) => HueSource | undefined;
|
|
21
|
+
readonly increase: (color: RGBA, amount?: number) => RGBA;
|
|
22
|
+
readonly decrease: (color: RGBA, amount?: number) => RGBA;
|
|
23
|
+
readonly text: {
|
|
24
|
+
readonly base: RGBA;
|
|
25
|
+
readonly muted: RGBA;
|
|
26
|
+
readonly faint: RGBA;
|
|
27
|
+
/** Text inside a mouse or keyboard text selection. */
|
|
28
|
+
readonly selection: RGBA;
|
|
29
|
+
readonly action: Readonly<Record<ActionVariant, StatefulColor>>;
|
|
30
|
+
readonly formfield: FormfieldColor;
|
|
31
|
+
readonly feedback: Readonly<Record<FeedbackKind, {
|
|
32
|
+
readonly base: RGBA;
|
|
33
|
+
readonly muted: RGBA;
|
|
34
|
+
}>>;
|
|
35
|
+
};
|
|
36
|
+
readonly background: {
|
|
37
|
+
readonly base: RGBA;
|
|
38
|
+
/** The highlight behind a mouse or keyboard text selection. */
|
|
39
|
+
readonly selection: RGBA;
|
|
40
|
+
readonly raised: {
|
|
41
|
+
readonly base: RGBA;
|
|
42
|
+
readonly high: RGBA;
|
|
43
|
+
readonly max: RGBA;
|
|
44
|
+
};
|
|
45
|
+
readonly action: Readonly<Record<ActionVariant, StatefulColor>>;
|
|
46
|
+
readonly formfield: FormfieldColor;
|
|
47
|
+
readonly feedback: Readonly<Record<FeedbackKind, {
|
|
48
|
+
readonly base: RGBA;
|
|
49
|
+
}>>;
|
|
50
|
+
};
|
|
51
|
+
readonly border: {
|
|
52
|
+
readonly base: RGBA;
|
|
53
|
+
};
|
|
54
|
+
readonly scrollbar: {
|
|
55
|
+
readonly base: RGBA;
|
|
56
|
+
};
|
|
57
|
+
readonly diff: {
|
|
58
|
+
readonly text: {
|
|
59
|
+
readonly added: RGBA;
|
|
60
|
+
readonly removed: RGBA;
|
|
61
|
+
readonly context: RGBA;
|
|
62
|
+
readonly hunkHeader: RGBA;
|
|
63
|
+
};
|
|
64
|
+
readonly background: {
|
|
65
|
+
readonly added: RGBA;
|
|
66
|
+
readonly removed: RGBA;
|
|
67
|
+
readonly context: RGBA;
|
|
68
|
+
};
|
|
69
|
+
readonly highlight: {
|
|
70
|
+
readonly added: RGBA;
|
|
71
|
+
readonly removed: RGBA;
|
|
72
|
+
};
|
|
73
|
+
readonly lineNumber: {
|
|
74
|
+
readonly text: RGBA;
|
|
75
|
+
readonly background: {
|
|
76
|
+
readonly added: RGBA;
|
|
77
|
+
readonly removed: RGBA;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
readonly find: {
|
|
82
|
+
readonly text: {
|
|
83
|
+
readonly current: RGBA;
|
|
84
|
+
};
|
|
85
|
+
readonly background: {
|
|
86
|
+
readonly match: RGBA;
|
|
87
|
+
readonly current: RGBA;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
readonly syntax: Readonly<Record<SyntaxToken, RGBA>>;
|
|
91
|
+
readonly markdown: Readonly<Record<MarkdownToken, RGBA>>;
|
|
92
|
+
};
|
|
93
|
+
export type ResolvedTheme = ResolvedThemeTokens & {
|
|
94
|
+
/** The same theme re-resolved on a raised surface. Absolute: every view's surfaces are the base theme's. */
|
|
95
|
+
readonly surface: (name: SurfaceName) => ResolvedTheme;
|
|
96
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|