@open-grid/theme 0.1.0
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/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/index.css +102 -0
- package/dist/tokens.d.ts +44 -0
- package/dist/tokens.js +67 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Open Grid contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @open-grid/theme
|
|
2
|
+
|
|
3
|
+
CSS variables and base theme for Open Grid.
|
|
4
|
+
|
|
5
|
+
Use this package when applying the default Open Grid styling tokens to a styled UI package.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @open-grid/theme
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import "@open-grid/theme/css";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Import the theme before a framework UI package's CSS. Override the exposed `--og-*` custom properties on the styled `.og-grid` root to integrate Open Grid with an existing design system. The semantic `[data-open-grid]` scroller inherits those values, so toolbar controls and grid content use one token set.
|
|
20
|
+
|
|
21
|
+
## Typed Tokens
|
|
22
|
+
|
|
23
|
+
Use the optional `@open-grid/theme/tokens` entry point when product code owns theme values. It rejects unknown or empty token values at runtime and keeps CSS custom-property names out of application code:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createOpenGridThemeStyle } from "@open-grid/theme/tokens";
|
|
27
|
+
|
|
28
|
+
const lightGridTheme = createOpenGridThemeStyle({
|
|
29
|
+
accent: "#155eef",
|
|
30
|
+
focus: "#0e9384",
|
|
31
|
+
surfaceSelected: "#eff4ff",
|
|
32
|
+
rowHeight: "36px",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Pass the result to React's or Vue's grid-root `style` prop. React applications should cast the framework-neutral object to `CSSProperties`; Vue accepts it directly. Svelte's `style` prop is string-only, so use `createOpenGridThemeCssText`:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { createOpenGridThemeCssText } from "@open-grid/theme/tokens";
|
|
40
|
+
|
|
41
|
+
const darkGridTheme = createOpenGridThemeCssText({
|
|
42
|
+
accent: "#84adff",
|
|
43
|
+
focus: "#5fe9d0",
|
|
44
|
+
surfaceSelected: "#102a56",
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Define separate light and dark token sets when colors need different contrast. Apply the selected values to the styled grid root while keeping `data-og-theme` on the grid or product ancestor for the remaining bundled defaults. Use product CSS such as `.billing-workspace .og-grid { --og-accent: ...; }` when themes are static.
|
|
49
|
+
|
|
50
|
+
## Customize
|
|
51
|
+
|
|
52
|
+
Apply CSS overrides to the styled grid root:
|
|
53
|
+
|
|
54
|
+
```css
|
|
55
|
+
.billing-workspace .og-grid {
|
|
56
|
+
--og-font-family: Inter, sans-serif;
|
|
57
|
+
--og-accent: #7c3aed;
|
|
58
|
+
--og-focus: #0f766e;
|
|
59
|
+
--og-surface-selected: #f1edff;
|
|
60
|
+
--og-row-height: 36px;
|
|
61
|
+
--og-header-height: 40px;
|
|
62
|
+
--og-radius-lg: 4px;
|
|
63
|
+
--og-shadow-md: 0 12px 28px rgb(16 24 40 / 18%);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The contract includes semantic surface, border, text, accent, danger, sizing, radius, shadow, and motion tokens. Existing base tokens such as `--og-surface`, `--og-border-color`, `--og-text`, and `--og-accent` remain supported; newer tokens let product themes distinguish raised, subtle, hover, selected, strong-border, and status states without overriding internal selectors.
|
|
68
|
+
|
|
69
|
+
## Dark Theme
|
|
70
|
+
|
|
71
|
+
Set `data-og-theme="dark"` on the grid or an ancestor. Dark tokens apply to the marked element itself and to styled or semantic grid descendants, including controls that are siblings of the semantic `[data-open-grid]` scroller. The bundled values remain fully overridable:
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<section data-og-theme="dark">
|
|
75
|
+
<div data-open-grid><!-- framework DataGrid output --></div>
|
|
76
|
+
</section>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The theme sets `color-scheme` for native controls but does not define the surrounding application shell. Product applications remain responsible for applying matching page, toolbar, and panel colors and for choosing or persisting the active theme. A standalone unstyled `[data-open-grid]` still receives the base theme directly; inside a styled `.og-grid`, it inherits root overrides instead of redeclaring defaults.
|
|
80
|
+
|
|
81
|
+
See the [project README](https://github.com/Goatshave/open-grid#readme) for framework UI installation and examples.
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
:where(.og-grid, [data-open-grid]:not(.og-grid [data-open-grid])) {
|
|
2
|
+
color-scheme: light;
|
|
3
|
+
--og-font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
4
|
+
--og-font-size: 13px;
|
|
5
|
+
--og-font-weight-medium: 500;
|
|
6
|
+
--og-font-weight-semibold: 600;
|
|
7
|
+
--og-border-color: #d8dee8;
|
|
8
|
+
--og-border: var(--og-border-color);
|
|
9
|
+
--og-border-subtle: #e9edf3;
|
|
10
|
+
--og-border-strong: #bcc6d4;
|
|
11
|
+
--og-surface: #ffffff;
|
|
12
|
+
--og-surface-raised: #ffffff;
|
|
13
|
+
--og-surface-muted: #f6f8fb;
|
|
14
|
+
--og-surface-subtle: #fbfcfe;
|
|
15
|
+
--og-surface-hover: #edf3ff;
|
|
16
|
+
--og-surface-selected: #e8f0ff;
|
|
17
|
+
--og-text: #172033;
|
|
18
|
+
--og-text-muted: #5f6b7f;
|
|
19
|
+
--og-text-subtle: #7f8a9d;
|
|
20
|
+
--og-accent: #2563eb;
|
|
21
|
+
--og-accent-hover: #1d4ed8;
|
|
22
|
+
--og-accent-soft: #e8f0ff;
|
|
23
|
+
--og-focus: #0f766e;
|
|
24
|
+
--og-danger: #c4322b;
|
|
25
|
+
--og-danger-soft: #fff1f0;
|
|
26
|
+
--og-row-height: 40px;
|
|
27
|
+
--og-header-height: 42px;
|
|
28
|
+
--og-control-height: 34px;
|
|
29
|
+
--og-radius-sm: 4px;
|
|
30
|
+
--og-radius: 6px;
|
|
31
|
+
--og-radius-lg: 8px;
|
|
32
|
+
--og-shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
|
|
33
|
+
--og-shadow-md: 0 10px 28px rgb(16 24 40 / 14%);
|
|
34
|
+
--og-shadow-pinned-left: 8px 0 14px -12px rgb(16 24 40 / 52%);
|
|
35
|
+
--og-shadow-pinned-right: -8px 0 14px -12px rgb(16 24 40 / 52%);
|
|
36
|
+
--og-transition: 140ms ease;
|
|
37
|
+
color: var(--og-text);
|
|
38
|
+
background: var(--og-surface);
|
|
39
|
+
font-family: var(--og-font-family);
|
|
40
|
+
font-size: var(--og-font-size);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:where(
|
|
44
|
+
[data-og-theme="dark"],
|
|
45
|
+
.og-grid[data-og-theme="dark"],
|
|
46
|
+
[data-open-grid][data-og-theme="dark"],
|
|
47
|
+
[data-og-theme="dark"] .og-grid,
|
|
48
|
+
[data-og-theme="dark"] [data-open-grid]:not(.og-grid [data-open-grid])
|
|
49
|
+
) {
|
|
50
|
+
color-scheme: dark;
|
|
51
|
+
--og-border-color: #354052;
|
|
52
|
+
--og-border-subtle: #2b3443;
|
|
53
|
+
--og-border-strong: #58657a;
|
|
54
|
+
--og-surface: #171c25;
|
|
55
|
+
--og-surface-raised: #202733;
|
|
56
|
+
--og-surface-muted: #242c39;
|
|
57
|
+
--og-surface-subtle: #1b222d;
|
|
58
|
+
--og-surface-hover: #293a5a;
|
|
59
|
+
--og-surface-selected: #223b68;
|
|
60
|
+
--og-text: #edf1f7;
|
|
61
|
+
--og-text-muted: #aab4c3;
|
|
62
|
+
--og-text-subtle: #8793a5;
|
|
63
|
+
--og-accent: #79a8ff;
|
|
64
|
+
--og-accent-hover: #9bbdff;
|
|
65
|
+
--og-accent-soft: #243b66;
|
|
66
|
+
--og-focus: #5eead4;
|
|
67
|
+
--og-danger: #ff8a80;
|
|
68
|
+
--og-danger-soft: #482925;
|
|
69
|
+
--og-shadow-sm: 0 1px 2px rgb(0 0 0 / 24%);
|
|
70
|
+
--og-shadow-md: 0 14px 34px rgb(0 0 0 / 34%);
|
|
71
|
+
--og-shadow-pinned-left: 8px 0 14px -12px rgb(0 0 0 / 82%);
|
|
72
|
+
--og-shadow-pinned-right: -8px 0 14px -12px rgb(0 0 0 / 82%);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:where([data-open-grid] [role="row"]) {
|
|
76
|
+
min-height: var(--og-row-height);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
:where([data-open-grid] [role="columnheader"]) {
|
|
80
|
+
min-height: var(--og-header-height);
|
|
81
|
+
color: var(--og-text-muted);
|
|
82
|
+
background: var(--og-surface-muted);
|
|
83
|
+
border-bottom: 1px solid var(--og-border-color);
|
|
84
|
+
font-weight: var(--og-font-weight-semibold);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:where([data-open-grid] [role="gridcell"]) {
|
|
88
|
+
border-bottom: 1px solid var(--og-border-subtle);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:where([data-open-grid] [role="gridcell"]:focus-visible),
|
|
92
|
+
:where([data-open-grid] [role="columnheader"]:focus-visible) {
|
|
93
|
+
outline: 2px solid var(--og-focus);
|
|
94
|
+
outline-offset: -2px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
:where([data-open-grid] [data-pinned="left"]),
|
|
98
|
+
:where([data-open-grid] [data-pinned="right"]) {
|
|
99
|
+
position: sticky;
|
|
100
|
+
z-index: 2;
|
|
101
|
+
background: inherit;
|
|
102
|
+
}
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
declare const openGridThemeTokens: {
|
|
2
|
+
readonly fontFamily: "--og-font-family";
|
|
3
|
+
readonly fontSize: "--og-font-size";
|
|
4
|
+
readonly fontWeightMedium: "--og-font-weight-medium";
|
|
5
|
+
readonly fontWeightSemibold: "--og-font-weight-semibold";
|
|
6
|
+
readonly borderColor: "--og-border-color";
|
|
7
|
+
readonly border: "--og-border";
|
|
8
|
+
readonly borderSubtle: "--og-border-subtle";
|
|
9
|
+
readonly borderStrong: "--og-border-strong";
|
|
10
|
+
readonly surface: "--og-surface";
|
|
11
|
+
readonly surfaceRaised: "--og-surface-raised";
|
|
12
|
+
readonly surfaceMuted: "--og-surface-muted";
|
|
13
|
+
readonly surfaceSubtle: "--og-surface-subtle";
|
|
14
|
+
readonly surfaceHover: "--og-surface-hover";
|
|
15
|
+
readonly surfaceSelected: "--og-surface-selected";
|
|
16
|
+
readonly text: "--og-text";
|
|
17
|
+
readonly textMuted: "--og-text-muted";
|
|
18
|
+
readonly textSubtle: "--og-text-subtle";
|
|
19
|
+
readonly accent: "--og-accent";
|
|
20
|
+
readonly accentHover: "--og-accent-hover";
|
|
21
|
+
readonly accentSoft: "--og-accent-soft";
|
|
22
|
+
readonly focus: "--og-focus";
|
|
23
|
+
readonly danger: "--og-danger";
|
|
24
|
+
readonly dangerSoft: "--og-danger-soft";
|
|
25
|
+
readonly rowHeight: "--og-row-height";
|
|
26
|
+
readonly headerHeight: "--og-header-height";
|
|
27
|
+
readonly controlHeight: "--og-control-height";
|
|
28
|
+
readonly radiusSmall: "--og-radius-sm";
|
|
29
|
+
readonly radius: "--og-radius";
|
|
30
|
+
readonly radiusLarge: "--og-radius-lg";
|
|
31
|
+
readonly shadowSmall: "--og-shadow-sm";
|
|
32
|
+
readonly shadowMedium: "--og-shadow-md";
|
|
33
|
+
readonly shadowPinnedLeft: "--og-shadow-pinned-left";
|
|
34
|
+
readonly shadowPinnedRight: "--og-shadow-pinned-right";
|
|
35
|
+
readonly transition: "--og-transition";
|
|
36
|
+
};
|
|
37
|
+
type OpenGridThemeToken = keyof typeof openGridThemeTokens;
|
|
38
|
+
type OpenGridTheme = Partial<Record<OpenGridThemeToken, string>>;
|
|
39
|
+
type OpenGridThemeCustomProperty = (typeof openGridThemeTokens)[OpenGridThemeToken];
|
|
40
|
+
type OpenGridThemeStyle = Partial<Record<OpenGridThemeCustomProperty, string>>;
|
|
41
|
+
declare function createOpenGridThemeStyle(theme: OpenGridTheme): OpenGridThemeStyle;
|
|
42
|
+
declare function createOpenGridThemeCssText(theme: OpenGridTheme): string;
|
|
43
|
+
|
|
44
|
+
export { type OpenGridTheme, type OpenGridThemeCustomProperty, type OpenGridThemeStyle, type OpenGridThemeToken, createOpenGridThemeCssText, createOpenGridThemeStyle, openGridThemeTokens };
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/tokens.ts
|
|
2
|
+
var openGridThemeTokens = {
|
|
3
|
+
fontFamily: "--og-font-family",
|
|
4
|
+
fontSize: "--og-font-size",
|
|
5
|
+
fontWeightMedium: "--og-font-weight-medium",
|
|
6
|
+
fontWeightSemibold: "--og-font-weight-semibold",
|
|
7
|
+
borderColor: "--og-border-color",
|
|
8
|
+
border: "--og-border",
|
|
9
|
+
borderSubtle: "--og-border-subtle",
|
|
10
|
+
borderStrong: "--og-border-strong",
|
|
11
|
+
surface: "--og-surface",
|
|
12
|
+
surfaceRaised: "--og-surface-raised",
|
|
13
|
+
surfaceMuted: "--og-surface-muted",
|
|
14
|
+
surfaceSubtle: "--og-surface-subtle",
|
|
15
|
+
surfaceHover: "--og-surface-hover",
|
|
16
|
+
surfaceSelected: "--og-surface-selected",
|
|
17
|
+
text: "--og-text",
|
|
18
|
+
textMuted: "--og-text-muted",
|
|
19
|
+
textSubtle: "--og-text-subtle",
|
|
20
|
+
accent: "--og-accent",
|
|
21
|
+
accentHover: "--og-accent-hover",
|
|
22
|
+
accentSoft: "--og-accent-soft",
|
|
23
|
+
focus: "--og-focus",
|
|
24
|
+
danger: "--og-danger",
|
|
25
|
+
dangerSoft: "--og-danger-soft",
|
|
26
|
+
rowHeight: "--og-row-height",
|
|
27
|
+
headerHeight: "--og-header-height",
|
|
28
|
+
controlHeight: "--og-control-height",
|
|
29
|
+
radiusSmall: "--og-radius-sm",
|
|
30
|
+
radius: "--og-radius",
|
|
31
|
+
radiusLarge: "--og-radius-lg",
|
|
32
|
+
shadowSmall: "--og-shadow-sm",
|
|
33
|
+
shadowMedium: "--og-shadow-md",
|
|
34
|
+
shadowPinnedLeft: "--og-shadow-pinned-left",
|
|
35
|
+
shadowPinnedRight: "--og-shadow-pinned-right",
|
|
36
|
+
transition: "--og-transition"
|
|
37
|
+
};
|
|
38
|
+
var themeTokenNames = new Set(Object.keys(openGridThemeTokens));
|
|
39
|
+
function getValidatedThemeEntries(theme) {
|
|
40
|
+
const entries = [];
|
|
41
|
+
for (const [token, rawValue] of Object.entries(theme)) {
|
|
42
|
+
if (!themeTokenNames.has(token)) {
|
|
43
|
+
throw new TypeError(`Unknown Open Grid theme token: ${token}`);
|
|
44
|
+
}
|
|
45
|
+
if (typeof rawValue !== "string" || rawValue.trim().length === 0) {
|
|
46
|
+
throw new TypeError(`Open Grid theme token ${token} must be a non-empty string`);
|
|
47
|
+
}
|
|
48
|
+
entries.push([openGridThemeTokens[token], rawValue.trim()]);
|
|
49
|
+
}
|
|
50
|
+
return entries;
|
|
51
|
+
}
|
|
52
|
+
function createOpenGridThemeStyle(theme) {
|
|
53
|
+
return Object.fromEntries(getValidatedThemeEntries(theme));
|
|
54
|
+
}
|
|
55
|
+
function createOpenGridThemeCssText(theme) {
|
|
56
|
+
return getValidatedThemeEntries(theme).map(([property, value]) => {
|
|
57
|
+
if (/[;{}]/u.test(value)) {
|
|
58
|
+
throw new TypeError(`Open Grid theme token ${property} cannot contain CSS declaration delimiters`);
|
|
59
|
+
}
|
|
60
|
+
return `${property}: ${value}`;
|
|
61
|
+
}).join("; ");
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
createOpenGridThemeCssText,
|
|
65
|
+
createOpenGridThemeStyle,
|
|
66
|
+
openGridThemeTokens
|
|
67
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@open-grid/theme",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CSS variables, base themes, and typed product token adapters for Open Grid.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"data-grid",
|
|
7
|
+
"grid",
|
|
8
|
+
"table",
|
|
9
|
+
"css",
|
|
10
|
+
"theme"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://goatshave.github.io/open-grid/packages#theme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Goatshave/open-grid/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"dist/index.css",
|
|
23
|
+
"src/index.css"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./dist/index.css",
|
|
27
|
+
"./css": "./dist/index.css",
|
|
28
|
+
"./tokens": {
|
|
29
|
+
"types": "./dist/tokens.d.ts",
|
|
30
|
+
"import": "./dist/tokens.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup src/tokens.ts --format esm --dts --clean && cp src/index.css dist/index.css",
|
|
39
|
+
"check": "tsc --noEmit && test -f src/index.css",
|
|
40
|
+
"test": "pnpm build && node --test test/*.test.mjs",
|
|
41
|
+
"lint": "tsc --noEmit && test -f src/index.css"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"tsup": "^8.3.5",
|
|
45
|
+
"typescript": "^5.7.2"
|
|
46
|
+
},
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/Goatshave/open-grid.git",
|
|
50
|
+
"directory": "packages/theme"
|
|
51
|
+
}
|
|
52
|
+
}
|