@gtkx/css 0.1.45 → 0.1.47
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/README.md +1 -1
- package/dist/cache.d.ts +4 -0
- package/dist/cache.js +4 -0
- package/dist/css.d.ts +40 -0
- package/dist/css.js +40 -0
- package/dist/style-sheet.d.ts +6 -0
- package/dist/style-sheet.js +6 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ export const App = () => {
|
|
|
68
68
|
defaultHeight={300}
|
|
69
69
|
onCloseRequest={quit}
|
|
70
70
|
>
|
|
71
|
-
<Box orientation={Orientation.VERTICAL} spacing={12}
|
|
71
|
+
<Box orientation={Orientation.VERTICAL} spacing={12} marginStart={20} marginEnd={20} marginTop={20} marginBottom={20}>
|
|
72
72
|
<Label.Root label={`Count: ${count}`} />
|
|
73
73
|
<Button
|
|
74
74
|
label="Increment"
|
package/dist/cache.d.ts
CHANGED
package/dist/cache.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import createCache from "@emotion/cache";
|
|
2
2
|
import { StyleSheet } from "./style-sheet.js";
|
|
3
3
|
let gtkCache = null;
|
|
4
|
+
/**
|
|
5
|
+
* Creates and returns a singleton Emotion cache configured for GTK.
|
|
6
|
+
* Uses StyleSheet to inject styles into GTK's CssProvider.
|
|
7
|
+
*/
|
|
4
8
|
export const getGtkCache = () => {
|
|
5
9
|
if (!gtkCache) {
|
|
6
10
|
const sheet = new StyleSheet({ key: "gtkx" });
|
package/dist/css.d.ts
CHANGED
|
@@ -2,7 +2,47 @@ import type { CSSInterpolation } from "@emotion/serialize";
|
|
|
2
2
|
type CSSClassName = string & {
|
|
3
3
|
__brand: "css";
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Creates a CSS class from styles and injects them into GTK.
|
|
7
|
+
* Works like Emotion's css function but outputs to GTK's CssProvider.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const buttonStyle = css`
|
|
12
|
+
* background: @theme_bg_color;
|
|
13
|
+
* padding: 12px;
|
|
14
|
+
* border-radius: 6px;
|
|
15
|
+
* `;
|
|
16
|
+
*
|
|
17
|
+
* <Button cssClasses={[buttonStyle]}>Styled Button</Button>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
5
20
|
export declare const css: (...args: CSSInterpolation[]) => CSSClassName;
|
|
21
|
+
/**
|
|
22
|
+
* Merges multiple class names, filtering out falsy values.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* const combined = cx(baseStyle, isActive && activeStyle, 'manual-class');
|
|
27
|
+
* <Button cssClasses={[combined]}>Button</Button>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
6
30
|
export declare const cx: (...classNames: (string | boolean | undefined | null)[]) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Injects global CSS styles.
|
|
33
|
+
* Note: In GTK, these styles apply to all widgets on the display.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* injectGlobal`
|
|
38
|
+
* window {
|
|
39
|
+
* background: @theme_bg_color;
|
|
40
|
+
* }
|
|
41
|
+
* button {
|
|
42
|
+
* border-radius: 6px;
|
|
43
|
+
* }
|
|
44
|
+
* `;
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
7
47
|
export declare const injectGlobal: (...args: CSSInterpolation[]) => void;
|
|
8
48
|
export {};
|
package/dist/css.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { serializeStyles } from "@emotion/serialize";
|
|
2
2
|
import { getGtkCache } from "./cache.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a CSS class from styles and injects them into GTK.
|
|
5
|
+
* Works like Emotion's css function but outputs to GTK's CssProvider.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const buttonStyle = css`
|
|
10
|
+
* background: @theme_bg_color;
|
|
11
|
+
* padding: 12px;
|
|
12
|
+
* border-radius: 6px;
|
|
13
|
+
* `;
|
|
14
|
+
*
|
|
15
|
+
* <Button cssClasses={[buttonStyle]}>Styled Button</Button>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
3
18
|
export const css = (...args) => {
|
|
4
19
|
const cache = getGtkCache();
|
|
5
20
|
const serialized = serializeStyles(args, cache.registered);
|
|
@@ -11,7 +26,32 @@ export const css = (...args) => {
|
|
|
11
26
|
}
|
|
12
27
|
return className;
|
|
13
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Merges multiple class names, filtering out falsy values.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const combined = cx(baseStyle, isActive && activeStyle, 'manual-class');
|
|
35
|
+
* <Button cssClasses={[combined]}>Button</Button>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
14
38
|
export const cx = (...classNames) => classNames.filter((cn) => typeof cn === "string" && cn.length > 0).join(" ");
|
|
39
|
+
/**
|
|
40
|
+
* Injects global CSS styles.
|
|
41
|
+
* Note: In GTK, these styles apply to all widgets on the display.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* injectGlobal`
|
|
46
|
+
* window {
|
|
47
|
+
* background: @theme_bg_color;
|
|
48
|
+
* }
|
|
49
|
+
* button {
|
|
50
|
+
* border-radius: 6px;
|
|
51
|
+
* }
|
|
52
|
+
* `;
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
15
55
|
export const injectGlobal = (...args) => {
|
|
16
56
|
const cache = getGtkCache();
|
|
17
57
|
const serialized = serializeStyles(args, cache.registered);
|
package/dist/style-sheet.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ type StyleSheetOptions = {
|
|
|
5
5
|
speedy?: boolean;
|
|
6
6
|
prepend?: boolean;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Custom StyleSheet implementation for Emotion that outputs to GTK's CssProvider.
|
|
10
|
+
* Implements Emotion's StyleSheet interface to enable CSS-in-JS with GTK widgets.
|
|
11
|
+
*
|
|
12
|
+
* Rules are queued until GTK is initialized, then applied automatically.
|
|
13
|
+
*/
|
|
8
14
|
export declare class StyleSheet {
|
|
9
15
|
key: string;
|
|
10
16
|
private rules;
|
package/dist/style-sheet.js
CHANGED
|
@@ -12,6 +12,12 @@ const flushPendingStyles = () => {
|
|
|
12
12
|
pendingSheets.length = 0;
|
|
13
13
|
};
|
|
14
14
|
events.once("start", flushPendingStyles);
|
|
15
|
+
/**
|
|
16
|
+
* Custom StyleSheet implementation for Emotion that outputs to GTK's CssProvider.
|
|
17
|
+
* Implements Emotion's StyleSheet interface to enable CSS-in-JS with GTK widgets.
|
|
18
|
+
*
|
|
19
|
+
* Rules are queued until GTK is initialized, then applied automatically.
|
|
20
|
+
*/
|
|
15
21
|
export class StyleSheet {
|
|
16
22
|
key;
|
|
17
23
|
rules = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/css",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"description": "Emotion-style CSS-in-JS for GTKX applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@emotion/cache": "11.14.0",
|
|
37
37
|
"@emotion/serialize": "1.3.3",
|
|
38
|
-
"@gtkx/ffi": "0.1.
|
|
38
|
+
"@gtkx/ffi": "0.1.47"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -b && cp ../../README.md .",
|