heroicons_helper 0.7.0 → 0.8.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.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-23 00:00:00.000000000 Z
11
+ date: 2024-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6'
27
+ force_ruby_platform: false
27
28
  description: A package that distributes Heroicons as a gem, for easy inclusion in
28
29
  Ruby projects.
29
30
  email:
@@ -33,6 +34,8 @@ extensions: []
33
34
  extra_rdoc_files: []
34
35
  files:
35
36
  - ".rubocop.yml"
37
+ - ".ruby-version"
38
+ - ".vscode/settings.json"
36
39
  - CHANGELOG.md
37
40
  - Gemfile
38
41
  - LICENSE.txt
@@ -54,7 +57,7 @@ licenses:
54
57
  metadata:
55
58
  funding_uri: https://github.com/sponsors/gjtorikian/
56
59
  rubygems_mfa_required: 'true'
57
- post_install_message:
60
+ post_install_message:
58
61
  rdoc_options: []
59
62
  require_paths:
60
63
  - lib
@@ -72,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
75
  - !ruby/object:Gem::Version
73
76
  version: '0'
74
77
  requirements: []
75
- rubygems_version: 3.3.7
76
- signing_key:
78
+ rubygems_version: 3.4.6
79
+ signing_key:
77
80
  specification_version: 4
78
81
  summary: Heroicons port for Ruby
79
82
  test_files: []