@gtk-js/theme-adwaita 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 +22 -0
- package/dist/auto.css +7357 -0
- package/dist/dark.css +7186 -0
- package/dist/light.css +7130 -0
- package/package.json +18 -0
- package/src/index.ts +48 -0
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gtk-js/theme-adwaita",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.0.2",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "src/index.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.ts"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "bun build.ts"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@gtk-js/gtk-css": "0.1.1"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GtkTheme } from "@gtk-js/gtk-css";
|
|
2
|
+
import autoCSS from "../dist/auto.css" with { type: "text" };
|
|
3
|
+
import darkCSS from "../dist/dark.css" with { type: "text" };
|
|
4
|
+
import lightCSS from "../dist/light.css" with { type: "text" };
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Adwaita theme — the default GNOME/libadwaita theme.
|
|
8
|
+
*
|
|
9
|
+
* Supports free-pick accent color and light/dark/auto color scheme.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Default (auto color scheme, GNOME blue accent):
|
|
13
|
+
* const theme = new AdwaitaTheme();
|
|
14
|
+
*
|
|
15
|
+
* // Forced dark with custom accent:
|
|
16
|
+
* const theme = new AdwaitaTheme({ colorScheme: "dark", accentColor: "#e66100" });
|
|
17
|
+
*
|
|
18
|
+
* // Immutable — create a new instance when settings change:
|
|
19
|
+
* const theme = useMemo(() => new AdwaitaTheme({ colorScheme, accentColor }), [colorScheme, accentColor]);
|
|
20
|
+
* <GtkProvider theme={theme} />
|
|
21
|
+
*/
|
|
22
|
+
export class AdwaitaTheme extends GtkTheme {
|
|
23
|
+
readonly colorScheme: "light" | "dark" | "auto";
|
|
24
|
+
readonly accentColor: string;
|
|
25
|
+
|
|
26
|
+
constructor({
|
|
27
|
+
colorScheme = "auto",
|
|
28
|
+
accentColor = "#3584e4",
|
|
29
|
+
}: {
|
|
30
|
+
colorScheme?: "light" | "dark" | "auto";
|
|
31
|
+
accentColor?: string;
|
|
32
|
+
} = {}) {
|
|
33
|
+
super();
|
|
34
|
+
this.colorScheme = colorScheme;
|
|
35
|
+
this.accentColor = accentColor;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getCSS() {
|
|
39
|
+
const base =
|
|
40
|
+
this.colorScheme === "dark" ? darkCSS : this.colorScheme === "light" ? lightCSS : autoCSS;
|
|
41
|
+
|
|
42
|
+
// Append accent override on top of the default baked into the CSS
|
|
43
|
+
return (
|
|
44
|
+
base +
|
|
45
|
+
`\n[data-gtk-provider] { --accent-bg-color: ${this.accentColor}; --accent-fg-color: white; }\n`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|