@pie-qti/theme 0.1.12

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 ADDED
@@ -0,0 +1,38 @@
1
+ # @pie-qti/theme
2
+
3
+ Shared QTI player theme tokens.
4
+
5
+ QTI components consume canonical `--pie-qti-*` CSS variables. Hosts may set
6
+ these variables directly or import one of the theme bridges, such as
7
+ `@pie-qti/theme-daisyui/bridge.css`.
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import '@pie-qti/theme/tokens.css';
13
+ ```
14
+
15
+ The default token stylesheet provides readable light and dark fallback palettes:
16
+
17
+ ```html
18
+ <div data-qti-theme="dark">
19
+ <pie-qti-item-player></pie-qti-item-player>
20
+ </div>
21
+ ```
22
+
23
+ ## Token Contract
24
+
25
+ Core tokens include:
26
+
27
+ - `--pie-qti-primary`
28
+ - `--pie-qti-secondary`
29
+ - `--pie-qti-accent`
30
+ - `--pie-qti-base-100`
31
+ - `--pie-qti-base-200`
32
+ - `--pie-qti-base-300`
33
+ - `--pie-qti-base-content`
34
+ - `--pie-qti-info`
35
+ - `--pie-qti-success`
36
+ - `--pie-qti-warning`
37
+ - `--pie-qti-error`
38
+ - `--pie-qti-focus`
@@ -0,0 +1 @@
1
+ export { normalizeQtiThemeVariables, type QtiThemeVariables } from './theme-types.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { normalizeQtiThemeVariables } from './theme-types.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAA0B,MAAM,kBAAkB,CAAC","sourcesContent":["export { normalizeQtiThemeVariables, type QtiThemeVariables } from './theme-types.js';\n"]}
@@ -0,0 +1,2 @@
1
+ export type QtiThemeVariables = Record<`--pie-qti-${string}`, string>;
2
+ export declare function normalizeQtiThemeVariables(value: unknown): QtiThemeVariables;
@@ -0,0 +1,22 @@
1
+ export function normalizeQtiThemeVariables(value) {
2
+ if (!value || typeof value !== 'object') {
3
+ return {};
4
+ }
5
+ const output = {};
6
+ for (const [key, rawValue] of Object.entries(value)) {
7
+ if (!key.startsWith('--pie-qti-')) {
8
+ continue;
9
+ }
10
+ if (typeof rawValue === 'string') {
11
+ const trimmed = rawValue.trim();
12
+ if (trimmed) {
13
+ output[key] = trimmed;
14
+ }
15
+ }
16
+ else if (typeof rawValue === 'number') {
17
+ output[key] = String(rawValue);
18
+ }
19
+ }
20
+ return output;
21
+ }
22
+ //# sourceMappingURL=theme-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-types.js","sourceRoot":"","sources":["../src/theme-types.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACxD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACnC,SAAS;QACV,CAAC;QAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAClC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;YAChC,IAAI,OAAO,EAAE,CAAC;gBACb,MAAM,CAAC,GAA4B,CAAC,GAAG,OAAO,CAAC;YAChD,CAAC;QACF,CAAC;aAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,CAAC,GAA4B,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["export type QtiThemeVariables = Record<`--pie-qti-${string}`, string>;\n\nexport function normalizeQtiThemeVariables(value: unknown): QtiThemeVariables {\n\tif (!value || typeof value !== 'object') {\n\t\treturn {};\n\t}\n\n\tconst output: QtiThemeVariables = {};\n\tfor (const [key, rawValue] of Object.entries(value as Record<string, unknown>)) {\n\t\tif (!key.startsWith('--pie-qti-')) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof rawValue === 'string') {\n\t\t\tconst trimmed = rawValue.trim();\n\t\t\tif (trimmed) {\n\t\t\t\toutput[key as `--pie-qti-${string}`] = trimmed;\n\t\t\t}\n\t\t} else if (typeof rawValue === 'number') {\n\t\t\toutput[key as `--pie-qti-${string}`] = String(rawValue);\n\t\t}\n\t}\n\n\treturn output;\n}\n"]}
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Canonical PIE QTI theme variables.
3
+ *
4
+ * These defaults keep QTI players readable in hosts that do not load a theme
5
+ * bridge. Host apps may override any --pie-qti-* variable on :root or on a
6
+ * container that wraps QTI player elements.
7
+ */
8
+
9
+ :root,
10
+ [data-qti-theme='light'] {
11
+ --pie-qti-primary: oklch(45% 0.24 277);
12
+ --pie-qti-primary-content: oklch(98% 0.01 277);
13
+ --pie-qti-secondary: oklch(65% 0.241 354.308);
14
+ --pie-qti-secondary-content: oklch(98% 0.01 354.308);
15
+ --pie-qti-accent: oklch(77% 0.152 181.912);
16
+ --pie-qti-accent-content: oklch(20% 0.03 181.912);
17
+ --pie-qti-neutral: oklch(32% 0 0);
18
+ --pie-qti-neutral-content: oklch(98% 0 0);
19
+ --pie-qti-base-100: oklch(100% 0 0);
20
+ --pie-qti-base-200: oklch(98% 0 0);
21
+ --pie-qti-base-300: oklch(95% 0 0);
22
+ --pie-qti-base-content: oklch(21% 0 0);
23
+ --pie-qti-info: oklch(74% 0.16 232.661);
24
+ --pie-qti-info-content: oklch(20% 0.03 232.661);
25
+ --pie-qti-success: oklch(76% 0.177 163.223);
26
+ --pie-qti-success-content: oklch(20% 0.03 163.223);
27
+ --pie-qti-warning: oklch(82% 0.189 84.429);
28
+ --pie-qti-warning-content: oklch(20% 0.04 84.429);
29
+ --pie-qti-error: oklch(71% 0.194 13.428);
30
+ --pie-qti-error-content: oklch(98% 0.01 13.428);
31
+ --pie-qti-focus: var(--pie-qti-primary);
32
+ }
33
+
34
+ [data-qti-theme='dark'] {
35
+ --pie-qti-primary: oklch(65% 0.24 277);
36
+ --pie-qti-primary-content: oklch(15% 0.04 277);
37
+ --pie-qti-secondary: oklch(75% 0.2 354.308);
38
+ --pie-qti-secondary-content: oklch(18% 0.04 354.308);
39
+ --pie-qti-accent: oklch(82% 0.14 181.912);
40
+ --pie-qti-accent-content: oklch(16% 0.04 181.912);
41
+ --pie-qti-neutral: oklch(70% 0 0);
42
+ --pie-qti-neutral-content: oklch(14% 0 0);
43
+ --pie-qti-base-100: oklch(25% 0.02 255);
44
+ --pie-qti-base-200: oklch(22% 0.02 255);
45
+ --pie-qti-base-300: oklch(18% 0.02 255);
46
+ --pie-qti-base-content: oklch(97% 0.01 255);
47
+ --pie-qti-info: oklch(74% 0.16 232.661);
48
+ --pie-qti-info-content: oklch(15% 0.04 232.661);
49
+ --pie-qti-success: oklch(76% 0.177 163.223);
50
+ --pie-qti-success-content: oklch(15% 0.04 163.223);
51
+ --pie-qti-warning: oklch(82% 0.189 84.429);
52
+ --pie-qti-warning-content: oklch(15% 0.04 84.429);
53
+ --pie-qti-error: oklch(71% 0.194 13.428);
54
+ --pie-qti-error-content: oklch(98% 0.01 13.428);
55
+ --pie-qti-focus: var(--pie-qti-primary);
56
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@pie-qti/theme",
3
+ "version": "0.1.12",
4
+ "description": "Shared PIE QTI theme tokens and CSS variable contracts",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc && cp src/*.css dist/",
10
+ "test": "bun test",
11
+ "typecheck": "tsc --noEmit",
12
+ "lint": "biome check .",
13
+ "lint:fix": "biome check --write .",
14
+ "format": "biome format --write ."
15
+ },
16
+ "keywords": [
17
+ "qti",
18
+ "qti2",
19
+ "qti3",
20
+ "assessment",
21
+ "theme",
22
+ "css-variables"
23
+ ],
24
+ "license": "MIT",
25
+ "devDependencies": {
26
+ "@biomejs/biome": "^2.4.8",
27
+ "typescript": "^5.9.3"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./tokens.css": {
36
+ "style": "./dist/tokens.css",
37
+ "default": "./dist/tokens.css"
38
+ }
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/pie-framework/pie-qti.git",
43
+ "directory": "packages/theme"
44
+ },
45
+ "homepage": "https://github.com/pie-framework/pie-qti/tree/master/packages/theme",
46
+ "bugs": {
47
+ "url": "https://github.com/pie-framework/pie-qti/issues"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "sideEffects": [
53
+ "./dist/*.css"
54
+ ],
55
+ "engines": {
56
+ "node": ">=20.19.0"
57
+ },
58
+ "files": [
59
+ "dist",
60
+ "README.md"
61
+ ]
62
+ }