origam 2.39.1 → 2.40.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/CHANGELOG.md +8 -0
- package/dist/src/assets/css/tokens/dark-pinned.css +3229 -0
- package/dist/src/assets/css/tokens/dark-system.css +3053 -0
- package/dist/src/interfaces/Commons/theme.interface.d.ts +13 -0
- package/dist/src/nuxt/plugin.server.cjs +4 -5
- package/dist/src/nuxt/plugin.server.js +5 -10
- package/dist/src/ssr.cjs +38 -0
- package/dist/src/ssr.d.ts +11 -0
- package/dist/src/ssr.js +3 -0
- package/dist/src/utils/Commons/theme-ssr.util.cjs +20 -0
- package/dist/src/utils/Commons/theme-ssr.util.d.ts +17 -0
- package/dist/src/utils/Commons/theme-ssr.util.js +18 -0
- package/dist/src/utils/index.cjs +11 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/package.json +4 -1
|
@@ -164,3 +164,16 @@ export interface IOrigamTheme {
|
|
|
164
164
|
********************************************************/
|
|
165
165
|
variants?: TVariantPresetRegistry;
|
|
166
166
|
}
|
|
167
|
+
/*********************************************************
|
|
168
|
+
* IRenderThemeCssOptions (#1386)
|
|
169
|
+
*
|
|
170
|
+
* @description
|
|
171
|
+
* Options of `renderThemeCss`: which brand and which mode the page is served
|
|
172
|
+
* with. `theme` absent / `'auto'` = the unnamed (DS default) theme. `mode`
|
|
173
|
+
* absent / `'auto'` = NOT pinned: both modes, dark under
|
|
174
|
+
* `@media (prefers-color-scheme: dark)`.
|
|
175
|
+
********************************************************/
|
|
176
|
+
export interface IRenderThemeCssOptions {
|
|
177
|
+
theme?: TTheme;
|
|
178
|
+
mode?: TMode;
|
|
179
|
+
}
|
|
@@ -8,6 +8,7 @@ var _origamCreate = require("#origam-create");
|
|
|
8
8
|
var _nuxtIcons = require("../utils/Commons/nuxt-icons.util.cjs");
|
|
9
9
|
var _nuxtLocale = require("../utils/Commons/nuxt-locale.util.cjs");
|
|
10
10
|
var _applyTheme = require("../utils/Commons/apply-theme.util.cjs");
|
|
11
|
+
var _themeSsr = require("../utils/Commons/theme-ssr.util.cjs");
|
|
11
12
|
var _ssrStyles = require("../utils/Commons/ssr-styles.util.cjs");
|
|
12
13
|
var _theme = require("../consts/Commons/theme.const.cjs");
|
|
13
14
|
var _app = require("#app");
|
|
@@ -54,12 +55,10 @@ module.exports = (0, _app.defineNuxtPlugin)({
|
|
|
54
55
|
htmlAttrs[_theme.ORIGAM_THEME_ATTR] = resolvedTheme;
|
|
55
56
|
}
|
|
56
57
|
const themes = config.themes ?? [];
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return brandMatches && modeMatches;
|
|
58
|
+
const ssrThemeCss = (0, _themeSsr.renderThemeCss)(themes, {
|
|
59
|
+
theme: resolvedTheme,
|
|
60
|
+
mode: modePinned ? resolvedMode : "auto"
|
|
61
61
|
});
|
|
62
|
-
const ssrThemeCss = modePinned ? activeThemes.map(_applyTheme.themeToCss).join("\n") : [...activeThemes.filter(t => t.mode !== "light" && t.mode !== "dark").map(_applyTheme.themeToCss), ...activeThemes.filter(t => t.mode === "light").map(_applyTheme.themeToUnpinnedCss), ...activeThemes.filter(t => t.mode === "dark").map(_applyTheme.themeToUnpinnedCss)].join("\n");
|
|
63
62
|
(0, _app.useHead)({
|
|
64
63
|
htmlAttrs,
|
|
65
64
|
style: ssrThemeCss ? [{
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createOrigamForNuxt as createOrigam } from "#origam-create";
|
|
2
2
|
import { nuxtIconsOptions } from "../utils/Commons/nuxt-icons.util.js";
|
|
3
3
|
import { nuxtLocaleOptions } from "../utils/Commons/nuxt-locale.util.js";
|
|
4
|
-
import { isModePinned, knownBrand
|
|
4
|
+
import { isModePinned, knownBrand } from "../utils/Commons/apply-theme.util.js";
|
|
5
|
+
import { renderThemeCss } from "../utils/Commons/theme-ssr.util.js";
|
|
5
6
|
import { getSsrStyles } from "../utils/Commons/ssr-styles.util.js";
|
|
6
7
|
import { ORIGAM_MODE_ATTR, ORIGAM_MODE_DARK, ORIGAM_MODE_LIGHT, ORIGAM_THEME_ATTR, ORIGAM_THEME_AUTO } from "../consts/Commons/theme.const.js";
|
|
7
8
|
import { defineNuxtPlugin, useCookie, useHead, useRuntimeConfig } from "#app";
|
|
@@ -48,16 +49,10 @@ export default defineNuxtPlugin({
|
|
|
48
49
|
htmlAttrs[ORIGAM_THEME_ATTR] = resolvedTheme;
|
|
49
50
|
}
|
|
50
51
|
const themes = config.themes ?? [];
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return brandMatches && modeMatches;
|
|
52
|
+
const ssrThemeCss = renderThemeCss(themes, {
|
|
53
|
+
theme: resolvedTheme,
|
|
54
|
+
mode: modePinned ? resolvedMode : "auto"
|
|
55
55
|
});
|
|
56
|
-
const ssrThemeCss = modePinned ? activeThemes.map(themeToCss).join("\n") : [
|
|
57
|
-
...activeThemes.filter((t) => t.mode !== "light" && t.mode !== "dark").map(themeToCss),
|
|
58
|
-
...activeThemes.filter((t) => t.mode === "light").map(themeToUnpinnedCss),
|
|
59
|
-
...activeThemes.filter((t) => t.mode === "dark").map(themeToUnpinnedCss)
|
|
60
|
-
].join("\n");
|
|
61
56
|
useHead({
|
|
62
57
|
htmlAttrs,
|
|
63
58
|
style: ssrThemeCss ? [{ id: "origam-theme-ssr", key: "origam-theme-ssr", innerHTML: ssrThemeCss }] : []
|
package/dist/src/ssr.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "getSsrStyles", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ssrStyles.getSsrStyles;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "isModePinned", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _applyTheme.isModePinned;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "knownBrand", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _applyTheme.knownBrand;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "renderSsrStyles", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _ssrStyles.renderSsrStyles;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "renderThemeCss", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _themeSsr.renderThemeCss;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _themeSsr = require("./utils/Commons/theme-ssr.util.cjs");
|
|
37
|
+
var _ssrStyles = require("./utils/Commons/ssr-styles.util.cjs");
|
|
38
|
+
var _applyTheme = require("./utils/Commons/apply-theme.util.cjs");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*********************************************************
|
|
2
|
+
* origam/ssr (#1386)
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* Documented, lean server-side theme/style helpers. Replaces the internal
|
|
6
|
+
* `origam/utils/Commons/{apply-theme,ssr-styles}.util.js` paths.
|
|
7
|
+
********************************************************/
|
|
8
|
+
export { renderThemeCss } from './utils/Commons/theme-ssr.util';
|
|
9
|
+
export { getSsrStyles, renderSsrStyles } from './utils/Commons/ssr-styles.util';
|
|
10
|
+
export { isModePinned, knownBrand } from './utils/Commons/apply-theme.util';
|
|
11
|
+
export type { IRenderThemeCssOptions } from './interfaces/Commons/theme.interface';
|
package/dist/src/ssr.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderThemeCss = renderThemeCss;
|
|
7
|
+
var _applyTheme = require("./apply-theme.util.cjs");
|
|
8
|
+
function renderThemeCss(themes, options = {}) {
|
|
9
|
+
const brand = options.theme && options.theme !== "auto" ? options.theme : "";
|
|
10
|
+
const pinned = options.mode === "light" || options.mode === "dark" ? options.mode : null;
|
|
11
|
+
const active = themes.filter(theme => {
|
|
12
|
+
const brandMatches = brand ? theme.name === brand : !theme.name;
|
|
13
|
+
const modeMatches = !pinned || theme.mode === void 0 || theme.mode === "auto" || theme.mode === pinned;
|
|
14
|
+
return brandMatches && modeMatches;
|
|
15
|
+
});
|
|
16
|
+
if (pinned) {
|
|
17
|
+
return active.map(_applyTheme.themeToCss).join("\n");
|
|
18
|
+
}
|
|
19
|
+
return [...active.filter(t => t.mode !== "light" && t.mode !== "dark").map(_applyTheme.themeToCss), ...active.filter(t => t.mode === "light").map(_applyTheme.themeToUnpinnedCss), ...active.filter(t => t.mode === "dark").map(_applyTheme.themeToUnpinnedCss)].join("\n");
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IOrigamTheme, IRenderThemeCssOptions } from '../../interfaces';
|
|
2
|
+
/*********************************************************
|
|
3
|
+
* renderThemeCss (#1386)
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Server-side theme CSS for ONE page: only the active brand, and only the
|
|
7
|
+
* active mode when it is pinned, never every installed theme. Same selection
|
|
8
|
+
* as the Nuxt server plugin (which now calls this function), so a plain Vue /
|
|
9
|
+
* Nitro host gets the identical no-flash first paint without importing
|
|
10
|
+
* `apply-theme.util` by its internal path.
|
|
11
|
+
* @description
|
|
12
|
+
* Mode pinned (`light` | `dark`): the blocks of that mode and the
|
|
13
|
+
* mode-agnostic ones. Not pinned: agnostic blocks, then light, then dark, the
|
|
14
|
+
* last two under `@media (prefers-color-scheme)` so dark wins (#1103).
|
|
15
|
+
* Put the result in a `<style>` in `<head>`.
|
|
16
|
+
********************************************************/
|
|
17
|
+
export declare function renderThemeCss(themes: readonly IOrigamTheme[], options?: IRenderThemeCssOptions): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { themeToCss, themeToUnpinnedCss } from "./apply-theme.util.js";
|
|
2
|
+
export function renderThemeCss(themes, options = {}) {
|
|
3
|
+
const brand = options.theme && options.theme !== "auto" ? options.theme : "";
|
|
4
|
+
const pinned = options.mode === "light" || options.mode === "dark" ? options.mode : null;
|
|
5
|
+
const active = themes.filter((theme) => {
|
|
6
|
+
const brandMatches = brand ? theme.name === brand : !theme.name;
|
|
7
|
+
const modeMatches = !pinned || theme.mode === void 0 || theme.mode === "auto" || theme.mode === pinned;
|
|
8
|
+
return brandMatches && modeMatches;
|
|
9
|
+
});
|
|
10
|
+
if (pinned) {
|
|
11
|
+
return active.map(themeToCss).join("\n");
|
|
12
|
+
}
|
|
13
|
+
return [
|
|
14
|
+
...active.filter((t) => t.mode !== "light" && t.mode !== "dark").map(themeToCss),
|
|
15
|
+
...active.filter((t) => t.mode === "light").map(themeToUnpinnedCss),
|
|
16
|
+
...active.filter((t) => t.mode === "dark").map(themeToUnpinnedCss)
|
|
17
|
+
].join("\n");
|
|
18
|
+
}
|
package/dist/src/utils/index.cjs
CHANGED
|
@@ -860,4 +860,15 @@ Object.keys(_applyTheme).forEach(function (key) {
|
|
|
860
860
|
return _applyTheme[key];
|
|
861
861
|
}
|
|
862
862
|
});
|
|
863
|
+
});
|
|
864
|
+
var _themeSsr = require("./Commons/theme-ssr.util.cjs");
|
|
865
|
+
Object.keys(_themeSsr).forEach(function (key) {
|
|
866
|
+
if (key === "default" || key === "__esModule") return;
|
|
867
|
+
if (key in exports && exports[key] === _themeSsr[key]) return;
|
|
868
|
+
Object.defineProperty(exports, key, {
|
|
869
|
+
enumerable: true,
|
|
870
|
+
get: function () {
|
|
871
|
+
return _themeSsr[key];
|
|
872
|
+
}
|
|
873
|
+
});
|
|
863
874
|
});
|
package/dist/src/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "origam",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.40.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "origam — a Vue 3 design system with multi-theme design tokens, CSS-first components and TypeScript types.",
|
|
6
6
|
"keywords": [
|
|
@@ -59,6 +59,8 @@
|
|
|
59
59
|
"./tokens/css/primitive": "./dist/src/assets/css/tokens/primitive.css",
|
|
60
60
|
"./tokens/css/light": "./dist/src/assets/css/tokens/light.css",
|
|
61
61
|
"./tokens/css/dark": "./dist/src/assets/css/tokens/dark.css",
|
|
62
|
+
"./tokens/css/dark-pinned": "./dist/src/assets/css/tokens/dark-pinned.css",
|
|
63
|
+
"./tokens/css/dark-system": "./dist/src/assets/css/tokens/dark-system.css",
|
|
62
64
|
"./tokens/css/utilities": "./dist/src/assets/css/tokens/origam-utilities.css",
|
|
63
65
|
"./tokens/scss": "./dist/src/assets/scss/tokens/_primitive.scss",
|
|
64
66
|
"./tokens/scss/primitive": "./dist/src/assets/scss/tokens/_primitive.scss",
|
|
@@ -68,6 +70,7 @@
|
|
|
68
70
|
"./tokens/types": "./dist/src/types/tokens.type.d.ts",
|
|
69
71
|
"./origam": "./dist/src/origam.js",
|
|
70
72
|
"./core": "./dist/src/origam-core.js",
|
|
73
|
+
"./ssr": "./dist/src/ssr.js",
|
|
71
74
|
"./nuxt": {
|
|
72
75
|
"types": "./dist/src/nuxt/module.d.ts",
|
|
73
76
|
"import": "./dist/src/nuxt/module.js",
|