@gtk-js/theme-fluent 0.0.2
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/CHANGELOG.md +15 -0
- package/build.ts +104 -0
- package/dist/dark_circular_default.css +8117 -0
- package/dist/dark_circular_round.css +8172 -0
- package/dist/dark_square_default.css +8119 -0
- package/dist/dark_square_round.css +8174 -0
- package/dist/index.ts +8 -0
- package/dist/light_circular_default.css +8113 -0
- package/dist/light_circular_round.css +8168 -0
- package/dist/light_square_default.css +8115 -0
- package/dist/light_square_round.css +8170 -0
- package/package.json +18 -0
- package/src/index.ts +73 -0
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gtk-js/theme-fluent",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.0.2",
|
|
7
|
+
"main": "src/index.ts",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@gtk-js/gtk-css": "0.1.1"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./src/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "bun build.ts"
|
|
16
|
+
},
|
|
17
|
+
"type": "module"
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { GtkTheme, resolveColorScheme } from "@gtk-js/gtk-css";
|
|
2
|
+
import dark_circular_default from "../dist/dark_circular_default.css" with { type: "text" };
|
|
3
|
+
import dark_circular_round from "../dist/dark_circular_round.css" with { type: "text" };
|
|
4
|
+
import dark_square_default from "../dist/dark_square_default.css" with { type: "text" };
|
|
5
|
+
import dark_square_round from "../dist/dark_square_round.css" with { type: "text" };
|
|
6
|
+
import light_circular_default from "../dist/light_circular_default.css" with { type: "text" };
|
|
7
|
+
import light_circular_round from "../dist/light_circular_round.css" with { type: "text" };
|
|
8
|
+
import light_square_default from "../dist/light_square_default.css" with { type: "text" };
|
|
9
|
+
import light_square_round from "../dist/light_square_round.css" with { type: "text" };
|
|
10
|
+
|
|
11
|
+
const CSS_MAP = {
|
|
12
|
+
light_circular_default,
|
|
13
|
+
light_circular_round,
|
|
14
|
+
light_square_default,
|
|
15
|
+
light_square_round,
|
|
16
|
+
dark_circular_default,
|
|
17
|
+
dark_circular_round,
|
|
18
|
+
dark_square_default,
|
|
19
|
+
dark_square_round,
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The Fluent theme — a Fluent Design / Windows-style GTK theme.
|
|
24
|
+
*
|
|
25
|
+
* Supports runtime accent color and light/dark/auto color scheme.
|
|
26
|
+
* Window button style and corner style are selected at construction time,
|
|
27
|
+
* picking from pre-compiled CSS variants.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Default (auto color scheme, square buttons, Fluent blue accent):
|
|
31
|
+
* const theme = new FluentTheme();
|
|
32
|
+
*
|
|
33
|
+
* // Forced dark with circular buttons, rounded corners, custom accent:
|
|
34
|
+
* const theme = new FluentTheme({ colorScheme: "dark", titlebutton: "circular", window: "round", accentColor: "#e66100" });
|
|
35
|
+
*
|
|
36
|
+
* // Immutable — create a new instance when settings change:
|
|
37
|
+
* const theme = useMemo(() => new FluentTheme({ colorScheme, accentColor }), [colorScheme, accentColor]);
|
|
38
|
+
* <GtkProvider theme={theme} />
|
|
39
|
+
*/
|
|
40
|
+
export class FluentTheme extends GtkTheme {
|
|
41
|
+
readonly colorScheme: "light" | "dark" | "auto";
|
|
42
|
+
/** Window button style. "square" is the native Fluent/Windows look. */
|
|
43
|
+
readonly titlebutton: "circular" | "square";
|
|
44
|
+
/** Corner style. "round" increases corner radii throughout. */
|
|
45
|
+
readonly window: "default" | "round";
|
|
46
|
+
/** Accent color as a CSS color string. Defaults to Fluent blue (#1A73E8). */
|
|
47
|
+
readonly accentColor: string;
|
|
48
|
+
|
|
49
|
+
constructor({
|
|
50
|
+
colorScheme = "auto",
|
|
51
|
+
titlebutton = "square",
|
|
52
|
+
window = "default",
|
|
53
|
+
accentColor = "#1A73E8",
|
|
54
|
+
}: {
|
|
55
|
+
colorScheme?: "light" | "dark" | "auto";
|
|
56
|
+
titlebutton?: "circular" | "square";
|
|
57
|
+
window?: "default" | "round";
|
|
58
|
+
accentColor?: string;
|
|
59
|
+
} = {}) {
|
|
60
|
+
super();
|
|
61
|
+
this.colorScheme = colorScheme;
|
|
62
|
+
this.titlebutton = titlebutton;
|
|
63
|
+
this.window = window;
|
|
64
|
+
this.accentColor = accentColor;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getCSS() {
|
|
68
|
+
const scheme = resolveColorScheme(this.colorScheme);
|
|
69
|
+
const key = `${scheme}_${this.titlebutton}_${this.window}` as keyof typeof CSS_MAP;
|
|
70
|
+
const base = CSS_MAP[key];
|
|
71
|
+
return base + `\n[data-gtk-provider] { --fluent-accent: ${this.accentColor}; }\n`;
|
|
72
|
+
}
|
|
73
|
+
}
|