@skafform/vite-plugin 0.1.3 → 0.1.4

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/base.css CHANGED
@@ -42,6 +42,7 @@
42
42
 
43
43
  /* Mise en page */
44
44
  --skafform-navbar-height: 60px;
45
+ --skafform-page-gutter: 40px;
45
46
  }
46
47
 
47
48
  html, body {
package/dist/index.js CHANGED
@@ -85,13 +85,81 @@ function skafform() {
85
85
  ${vars}
86
86
  }`;
87
87
  }
88
+ const TAILWIND_TOKEN_MAP = {
89
+ "primary": "--color-primary",
90
+ "primary-fg": "--color-primary-fg",
91
+ "primary-hover": "--color-primary-hover",
92
+ "background": "--color-background",
93
+ "foreground": "--color-foreground",
94
+ "muted": "--color-muted",
95
+ "muted-fg": "--color-muted-fg",
96
+ "border": "--color-border",
97
+ "border-subtle": "--color-border-subtle",
98
+ "error": "--color-error",
99
+ "font": "--font-sans",
100
+ "font-heading": "--font-heading",
101
+ "font-body": "--font-body",
102
+ "font-size-xs": "--text-xs",
103
+ "font-size-sm": "--text-sm",
104
+ "font-size-base": "--text-base",
105
+ "font-size-lg": "--text-lg",
106
+ "font-size-xl": "--text-xl",
107
+ "font-size-2xl": "--text-2xl",
108
+ "radius": "--radius",
109
+ "radius-sm": "--radius-sm",
110
+ "radius-md": "--radius-md",
111
+ "radius-lg": "--radius-lg",
112
+ "radius-full": "--radius-full",
113
+ "shadow-sm": "--shadow-sm",
114
+ "shadow-md": "--shadow-md",
115
+ "shadow-lg": "--shadow-lg"
116
+ };
117
+ function generateTailwindTheme(tokens) {
118
+ const lines = [];
119
+ for (const key of Object.keys(tokens)) {
120
+ const twVar = TAILWIND_TOKEN_MAP[key];
121
+ if (twVar) lines.push(` ${twVar}: var(--skafform-${key});`);
122
+ }
123
+ if (lines.length === 0) return "";
124
+ return `@theme inline {
125
+ ${lines.join("\n")}
126
+ }`;
127
+ }
128
+ function generateDarkTokensCss(darkTokens, lightTokens) {
129
+ const entries = Object.entries(darkTokens);
130
+ if (entries.length === 0) return "";
131
+ const darkVars = entries.map(([k, v]) => ` --skafform-${k}: ${v};`).join("\n");
132
+ const classVars = entries.map(([k, v]) => ` --skafform-${k}: ${v};`).join("\n");
133
+ const lightVars = entries.filter(([k]) => k in lightTokens).map(([k]) => ` --skafform-${k}: ${lightTokens[k]};`).join("\n");
134
+ return [
135
+ `@media (prefers-color-scheme: dark) {
136
+ :root {
137
+ ${darkVars}
138
+ }
139
+ }`,
140
+ `.dark {
141
+ ${classVars}
142
+ }`,
143
+ lightVars ? `.light {
144
+ ${lightVars}
145
+ }` : ""
146
+ ].filter(Boolean).join("\n");
147
+ }
88
148
  function getCssString() {
89
149
  const themeJson = getThemeJson(config.theme);
90
150
  const themeCssPath = resolve(root, `themes/${config.theme}/styles/theme.css`);
91
151
  const base = readCss(baseCssPath);
92
152
  const theme = existsSync(themeCssPath) ? readCss(themeCssPath) : "";
93
153
  const tokens = generateTokensCss(themeJson.tokens ?? {});
94
- return base + "\n" + theme + (tokens ? "\n" + tokens : "");
154
+ const dark = themeJson.tokens_dark ? generateDarkTokensCss(themeJson.tokens_dark, themeJson.tokens ?? {}) : "";
155
+ const css = base + "\n" + theme + (tokens ? "\n" + tokens : "") + (dark ? "\n" + dark : "");
156
+ if (config.tailwind) {
157
+ const tailwindTheme = generateTailwindTheme(themeJson.tokens ?? {});
158
+ return `@import "tailwindcss";
159
+
160
+ ` + css + (tailwindTheme ? "\n" + tailwindTheme : "");
161
+ }
162
+ return css;
95
163
  }
96
164
  return {
97
165
  name: "skafform",
@@ -133,7 +201,8 @@ ${vars}
133
201
  const themeJson = getThemeJson(config.theme);
134
202
  return `export default ${JSON.stringify({
135
203
  ...config,
136
- customize: { ...themeJson.customize ?? {}, ...config.customize ?? {} }
204
+ customize: { ...themeJson.customize ?? {}, ...config.customize ?? {} },
205
+ fonts: themeJson.fonts ?? []
137
206
  })}`;
138
207
  }
139
208
  if (id === RESOLVED_ADMIN_SECTIONS) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skafform/vite-plugin",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {