sdaia-ui 1.2.2 → 1.2.3

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.
Files changed (2) hide show
  1. package/dist/index.js +32 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -128,6 +128,7 @@ var DEFAULT_COMPONENT_DIR = "src/components/ui";
128
128
  var DEFAULT_UTILS_DIR = "src/lib";
129
129
  var TAILWIND_IMPORT = '@import "tailwindcss";';
130
130
  var TOKENS_IMPORT = '@import "@sdaia-ds/tokens/css";';
131
+ var DARK_VARIANT_RULE = "@custom-variant dark (&:where(.dark, .dark *, .theme-dark, .theme-dark *));";
131
132
  function isTailwindInstalled() {
132
133
  const pkgJsonPath = path3.resolve(process.cwd(), "package.json");
133
134
  if (!fs3.existsSync(pkgJsonPath)) return false;
@@ -166,6 +167,24 @@ ${content}`);
166
167
  }
167
168
  return true;
168
169
  }
170
+ function ensureDarkVariantRule(cssFilePath) {
171
+ const content = fs3.readFileSync(cssFilePath, "utf-8");
172
+ if (/@custom-variant\s+dark\b/.test(content)) return false;
173
+ const lines = content.split("\n");
174
+ let lastImportIdx = -1;
175
+ for (let i = 0; i < lines.length; i++) {
176
+ if (/^\s*@import\s+/.test(lines[i])) lastImportIdx = i;
177
+ }
178
+ if (lastImportIdx === -1) {
179
+ fs3.writeFileSync(cssFilePath, `${DARK_VARIANT_RULE}
180
+
181
+ ${content}`);
182
+ } else {
183
+ lines.splice(lastImportIdx + 1, 0, "", DARK_VARIANT_RULE);
184
+ fs3.writeFileSync(cssFilePath, lines.join("\n"));
185
+ }
186
+ return true;
187
+ }
169
188
  async function init() {
170
189
  logger.break();
171
190
  logger.info("Initializing SDAIA Design System in your project...");
@@ -308,16 +327,25 @@ export default config;
308
327
  }
309
328
  const cssFilePath = findCssEntryFile();
310
329
  if (cssFilePath) {
311
- const added = ensureCssImport(cssFilePath, TOKENS_IMPORT, "@sdaia-ds/tokens/css");
312
- if (added) {
330
+ const addedTokens = ensureCssImport(cssFilePath, TOKENS_IMPORT, "@sdaia-ds/tokens/css");
331
+ if (addedTokens) {
313
332
  logger.success(`Added tokens import to ${path3.relative(process.cwd(), cssFilePath)}`);
314
333
  } else {
315
334
  logger.info("Tokens import already present in CSS file");
316
335
  }
336
+ const addedDark = ensureDarkVariantRule(cssFilePath);
337
+ if (addedDark) {
338
+ logger.success(
339
+ `Added @custom-variant dark rule to ${path3.relative(process.cwd(), cssFilePath)}`
340
+ );
341
+ } else {
342
+ logger.info("Dark variant rule already present in CSS file");
343
+ }
317
344
  } else {
318
345
  logger.warn(
319
- `Could not find a CSS entry file. Add this to your main CSS file:
320
- ${TOKENS_IMPORT}`
346
+ `Could not find a CSS entry file. Add these to your main CSS file:
347
+ ${TOKENS_IMPORT}
348
+ ${DARK_VARIANT_RULE}`
321
349
  );
322
350
  }
323
351
  const utilsPath = path3.resolve(process.cwd(), config.utilsDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdaia-ui",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "CLI for installing SDAIA Design System components into your project",
5
5
  "type": "module",
6
6
  "bin": {