heroicons_helper 0.7.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,9 +19,10 @@ const { argv } = yargs
19
19
  type: "array",
20
20
  describe: "Input SVG files",
21
21
  default: [
22
+ "node_modules/heroicons/16/solid/*.svg",
23
+ "node_modules/heroicons/20/solid/*.svg",
22
24
  "node_modules/heroicons/24/outline/*.svg",
23
25
  "node_modules/heroicons/24/solid/*.svg",
24
- "node_modules/heroicons/20/solid/*.svg",
25
26
  ],
26
27
  })
27
28
  .option("output", {
@@ -45,24 +46,31 @@ if (svgFilepaths.length === 0) {
45
46
 
46
47
  let exitCode = 0;
47
48
 
48
- const validTypes = ["solid", "outline", "mini"];
49
+ const validTypes = ["micro", "mini", "outline", "solid"];
49
50
  const defaultOutlineWidth = parseInt("24");
50
51
  const defaultSolidWidth = parseInt("24");
51
52
  const defaultMiniWidth = parseInt("20");
53
+ const defaultMicroWidth = parseInt("16");
54
+
55
+ function omit(obj, key) {
56
+ const { [key]: ignore, ...rest } = obj;
57
+ return rest;
58
+ }
52
59
 
53
60
  const icons = svgFilepaths.map((filepath) => {
54
61
  try {
55
62
  const filename = path.parse(filepath).base;
56
63
  let splitDir = path.parse(filepath).dir.split("/");
57
- let type = splitDir.pop();
64
+ let variant = splitDir.pop();
58
65
  const size = splitDir.pop();
59
66
 
60
67
  const svg = fs.readFileSync(path.resolve(filepath), "utf8");
61
68
  const svgElement = cheerio.load(svg)("svg");
69
+ let svgAttributes = omit(svgElement[0].attribs, "aria-hidden");
62
70
  let svgWidth = parseInt(svgElement.attr("width")) || parseInt(size);
63
71
  let svgHeight = parseInt(svgElement.attr("height")) || parseInt(size);
64
72
  const svgViewBox = svgElement.attr("viewBox");
65
- const svgPath = trimNewlines(svgElement.html()).trim();
73
+ const svgInner = trimNewlines(svgElement.html()).trim();
66
74
 
67
75
  if (!svgWidth) {
68
76
  svgWidth = parseInt(widthSize);
@@ -100,18 +108,21 @@ const icons = svgFilepaths.map((filepath) => {
100
108
  );
101
109
  }
102
110
 
103
- if (svgWidth == defaultMiniWidth && type == "solid") {
104
- type = "mini";
111
+ if (svgWidth == defaultMicroWidth && variant == "solid") {
112
+ variant = "micro";
113
+ } else if (svgWidth == defaultMiniWidth && variant == "solid") {
114
+ variant = "mini";
105
115
  }
106
116
  const name = filename.slice(0, -4);
107
117
 
108
118
  return {
109
119
  name,
110
120
  keywords: keywords[name] || [],
111
- type: type,
121
+ variant: variant,
112
122
  width: svgWidth,
113
123
  height: svgHeight,
114
- path: svgPath,
124
+ attributes: svgAttributes,
125
+ inner: svgInner,
115
126
  };
116
127
  } catch (error) {
117
128
  // eslint-disable-next-line no-console
@@ -138,10 +149,11 @@ const iconsByName = icons.reduce(
138
149
  name: icon.name,
139
150
  keywords: icon.keywords,
140
151
  variants: {
141
- [icon.type]: {
152
+ [icon.variant]: {
153
+ attributes: icon.attributes,
142
154
  width: icon.width,
143
155
  height: icon.height,
144
- path: icon.path,
156
+ inner: icon.inner,
145
157
  },
146
158
  },
147
159
  },
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroicons_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-14 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.4.18
78
+ rubygems_version: 3.4.6
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Heroicons port for Ruby