@brickflow/ui 0.0.44 → 0.0.46

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "configKey": "brickflowUi",
6
6
  "name": "@brickflow/ui",
7
- "version": "0.0.44",
7
+ "version": "0.0.46",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,18 +1,66 @@
1
1
  import { defineNuxtModule, createResolver, resolvePath, addTypeTemplate, addTemplate, updateTemplates, addImportsDir, addComponentsDir } from '@nuxt/kit';
2
2
  import tailwindcss from '@tailwindcss/vite';
3
3
  import { createJiti } from 'jiti';
4
- import { readdir, mkdir, readFile, writeFile } from 'node:fs/promises';
5
- import { join, basename, extname, dirname, resolve, relative } from 'node:path';
4
+ import { mkdir, access, readFile, writeFile, readdir } from 'node:fs/promises';
5
+ import { join, parse, basename, extname, dirname, resolve, relative } from 'node:path';
6
6
  import { isBrickflowUiStyleReference, getBrickflowUiStyleReferencePath, defineBrickflowUi } from '../dist/runtime/tailwind.js';
7
7
  import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon';
8
8
 
9
- const ICON_FILE_PATTERN = /\.svg$/i;
10
- const minifyCss = (css) => css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;\}/g, "}").trim();
11
- const normalizeGeneratedCss = (css) => `${css.replace(/"/g, "'").replace(/^ {4}/gm, " ").replace(/(\.(?:eot|ttf|woff2?))\?[^#'")]+(#iefix)?/gi, "$1$2").replace(/src: ([^\n]+),\n([^\n]+),\n([^\n]+);/, "src:\n $1,\n $2,\n $3;").replace(
12
- /i\[class\^='icon-'\]:before, i\[class\*=' icon-'\]:before \{/,
13
- "@layer base {\n i[class^='icon-'],\n i[class*=' icon-'] {\n container-type: inline-size;\n display: inline-flex;justify-content: center;align-items: center;\n width: 1em;\n }\n}\n\ni[class^='icon-']:before,\ni[class*=' icon-']:before {\n font-size: 100cqw;"
14
- ).replace(/\n{3,}/g, "\n\n").trim()}
9
+ const getIconFontCssPath$1 = (outputDir, name) => join(outputDir, `${name}.minify.css`);
10
+ async function generateIcons({ inputDir, name, outputDir }) {
11
+ await mkdir(outputDir, { recursive: true });
12
+ await generateFonts({
13
+ assetTypes: [OtherAssetType.CSS, OtherAssetType.JSON],
14
+ fontsUrl: ".",
15
+ fontTypes: [FontAssetType.EOT, FontAssetType.WOFF2, FontAssetType.WOFF],
16
+ formatOptions: {
17
+ json: {
18
+ indent: 2
19
+ }
20
+ },
21
+ inputDir,
22
+ name,
23
+ normalize: true,
24
+ outputDir
25
+ });
26
+ let cssSourceFile;
27
+ for (const file of [`${name}.css`, "icons.css", "icon.css"]) {
28
+ try {
29
+ await access(join(outputDir, file));
30
+ cssSourceFile = file;
31
+ break;
32
+ } catch {
33
+ }
34
+ }
35
+ if (!cssSourceFile) {
36
+ throw new Error(`CSS output file was not generated for icon set "${name}"`);
37
+ }
38
+ const cssPath = join(outputDir, cssSourceFile);
39
+ const minifiedCssPath = join(outputDir, `${parse(cssSourceFile).name}.minify.css`);
40
+ const cssContent = await readFile(cssPath, "utf8");
41
+ const normalizedCssContent = normalizeGeneratedCss(cssContent);
42
+ if (normalizedCssContent !== cssContent) {
43
+ await writeFile(cssPath, normalizedCssContent);
44
+ }
45
+ await writeFile(minifiedCssPath, minifyCss(normalizedCssContent));
46
+ return {
47
+ cssPath,
48
+ minifiedCssPath
49
+ };
50
+ }
51
+ function minifyCss(css) {
52
+ return css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;\}/g, "}").trim();
53
+ }
54
+ function normalizeGeneratedCss(css) {
55
+ return `${css.replace(/"/g, "'").replace(/^ {4}/gm, " ").replace(/src: ([^\n]+),\n([^\n]+),\n([^\n]+);/, "src:\n $1,\n $2,\n $3;").replace(
56
+ /i\[class\^='icon-'\]:before, i\[class\*=' icon-'\]:before \{/,
57
+ "i[class^='icon-']:before,\ni[class*=' icon-']:before {"
58
+ ).replace(/\n{3,}/g, "\n\n").trim()}
15
59
  `;
60
+ }
61
+
62
+ const ICON_FILE_PATTERN = /\.svg$/i;
63
+ const ICON_FONT_NAME = "brickflow-icon";
16
64
  const getIconFontNames = async (inputDir) => {
17
65
  const entries = await readdir(inputDir, { withFileTypes: true });
18
66
  const invalidEntries = entries.filter((entry) => !entry.isFile() || !ICON_FILE_PATTERN.test(entry.name));
@@ -26,7 +74,7 @@ const getIconFontNames = async (inputDir) => {
26
74
  }
27
75
  return entries.map((entry) => entry.name.replace(ICON_FILE_PATTERN, "")).sort((a, b) => a.localeCompare(b));
28
76
  };
29
- const getIconFontCssPath = (outputDir) => join(outputDir, "icon.minify.css");
77
+ const getIconFontCssPath = (outputDir) => getIconFontCssPath$1(outputDir, ICON_FONT_NAME);
30
78
  const createIconFontAssetsInlineLimit = (outputDir, currentLimit) => {
31
79
  const normalizedOutputDir = outputDir.replaceAll("\\", "/");
32
80
  return (filePath, content) => {
@@ -41,20 +89,11 @@ const createIconFontAssetsInlineLimit = (outputDir, currentLimit) => {
41
89
  };
42
90
  const generateIconFont = async ({ inputDir, outputDir }) => {
43
91
  await getIconFontNames(inputDir);
44
- await mkdir(outputDir, { recursive: true });
45
- await generateFonts({
46
- assetTypes: [OtherAssetType.CSS],
47
- fontsUrl: ".",
48
- fontTypes: [FontAssetType.EOT, FontAssetType.WOFF2, FontAssetType.WOFF],
92
+ await generateIcons({
49
93
  inputDir,
50
- name: "icon",
51
- normalize: true,
94
+ name: ICON_FONT_NAME,
52
95
  outputDir
53
96
  });
54
- const cssPath = join(outputDir, "icon.css");
55
- const css = normalizeGeneratedCss(await readFile(cssPath, "utf8"));
56
- await writeFile(cssPath, css);
57
- await writeFile(getIconFontCssPath(outputDir), minifyCss(css));
58
97
  };
59
98
  const brickflowUiIconFontPlugin = (options) => ({
60
99
  buildStart: () => generateIconFont(options),
@@ -43,5 +43,20 @@
43
43
  class="text-2xl text-red-400"
44
44
  />
45
45
  </div>
46
+
47
+ <p>
48
+ Text with icon
49
+ <Icon :name="iconName" />
50
+ sample words.
51
+ </p>
52
+
53
+ <div class="flex items-start gap-2">
54
+ <div class="bg-gray-700">
55
+ <Icon :name="iconName" />
56
+ </div>
57
+ <div class="bg-gray-700 leading-0">
58
+ <Icon :name="iconName" />
59
+ </div>
60
+ </div>
46
61
  </div>
47
62
  </template>
@@ -18,7 +18,28 @@
18
18
  <template>
19
19
  <i
20
20
  v-bind="$attrs"
21
- :class="[classes, 'aspect-square']"
21
+ :class="classes"
22
22
  role="img"
23
23
  />
24
24
  </template>
25
+
26
+ <style scoped>
27
+ @layer base {
28
+ i {
29
+ aspect-ratio: 1;
30
+ container-type: inline-size;
31
+ display: inline-flex;
32
+ flex-shrink: 0;
33
+ align-items: center;
34
+ justify-content: center;
35
+ width: 1em;
36
+ line-height: 1;
37
+ vertical-align: -0.125em;
38
+ }
39
+
40
+ i::before {
41
+ font-size: 100cqi;
42
+ line-height: 1;
43
+ }
44
+ }
45
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brickflow/ui",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
4
  "type": "module",
5
5
  "description": "brickflow UI Nuxt module.",
6
6
  "files": [