gd-bs 6.6.19 → 6.6.21
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/build/icons/generate.js +10 -1
- package/dist/gd-bs-icons.js +1 -1
- package/dist/gd-bs-icons.min.js +1 -1
- package/generateIcons.js +11 -2
- package/package.json +1 -1
- package/src/icons/generate.ts +12 -1
package/generateIcons.js
CHANGED
|
@@ -135,7 +135,16 @@ fs.readdir(dirIcons, function (err, files) {
|
|
|
135
135
|
stream = fs.createWriteStream("./src/icons/generate.ts");
|
|
136
136
|
stream.write([
|
|
137
137
|
'// Generates the html for an icon',
|
|
138
|
-
'export const generateIcon = (svg: string, height: number = 32, width: number = 32, className?: string) => {',
|
|
138
|
+
'export const generateIcon = (svg: string, height: number = 32, width: number = 32, className?: string, placeholders?: number) => {',
|
|
139
|
+
'\t// See if placeholders exist',
|
|
140
|
+
'\tif (placeholders > 0) {',
|
|
141
|
+
'\t\t// Parse the number of placeholders',
|
|
142
|
+
'\t\tfor (let i = 0; i < placeholders; i++) {',
|
|
143
|
+
'\t\t\tlet regex = new RegExp("/\\{" + i + "\\}/g");\n',
|
|
144
|
+
'\t\t\t// Replace the placeholder',
|
|
145
|
+
'\t\t\tsvg = svg.replace(regex, Date.now().toString());',
|
|
146
|
+
'\t\t}',
|
|
147
|
+
'\t}\n',
|
|
139
148
|
'\t// Get the icon element',
|
|
140
149
|
'\tlet elDiv = document.createElement("div");',
|
|
141
150
|
'\telDiv.innerHTML = svg;',
|
|
@@ -151,7 +160,7 @@ fs.readdir(dirIcons, function (err, files) {
|
|
|
151
160
|
'\t }',
|
|
152
161
|
'\t }\n',
|
|
153
162
|
'\t // Make this icon invisible to the screen reader',
|
|
154
|
-
|
|
163
|
+
'\t icon.setAttribute("aria-hidden", "true");\n',
|
|
155
164
|
'\t // Set the height/width',
|
|
156
165
|
'\t icon.setAttribute("height", (height ? height : 32).toString());',
|
|
157
166
|
'\t icon.setAttribute("width", (width ? width : 32).toString());\n',
|
package/package.json
CHANGED
package/src/icons/generate.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
// Generates the html for an icon
|
|
2
|
-
export const generateIcon = (svg: string, height: number = 32, width: number = 32, className?: string) => {
|
|
2
|
+
export const generateIcon = (svg: string, height: number = 32, width: number = 32, className?: string, placeholders?: number) => {
|
|
3
|
+
// See if placeholders exist
|
|
4
|
+
if (placeholders > 0) {
|
|
5
|
+
// Parse the number of placeholders
|
|
6
|
+
for (let i = 0; i < placeholders; i++) {
|
|
7
|
+
let regex = new RegExp("/\{" + i + "\}/g");
|
|
8
|
+
|
|
9
|
+
// Replace the placeholder
|
|
10
|
+
svg = svg.replace(regex, Date.now().toString());
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
// Get the icon element
|
|
4
15
|
let elDiv = document.createElement("div");
|
|
5
16
|
elDiv.innerHTML = svg;
|