gulp-stacksvg 1.0.2 → 1.0.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.
- package/README.md +10 -10
- package/index.js +2 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,11 +49,11 @@ Unlike all other methods for assembling a sprite, the stack does not limit us in
|
|
|
49
49
|
We can use the stack in all four possible ways:
|
|
50
50
|
|
|
51
51
|
- in markup:
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
- in `src` of `img` tag — static,
|
|
53
|
+
- in the `href` of the `use` tag — with the possibility of repainting,
|
|
54
54
|
- in styles:
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
- in `url()` properties `background` — static,
|
|
56
|
+
- in `url()` properties `mask` — with the possibility of repainting.
|
|
57
57
|
|
|
58
58
|
[Demo page](https://firefoxic.github.io/gulp-stacksvg/test/) to prove it.
|
|
59
59
|
|
|
@@ -63,7 +63,7 @@ This method was first mentioned in a Simurai [article](https://simurai.com/blog/
|
|
|
63
63
|
|
|
64
64
|
This can be done much easier. In general, the stack is arranged almost like a symbol sprite, but without changing the icon tag (it remain the `svg` tag, as in the original icon files) and with the addition of a tiny bit of style.
|
|
65
65
|
|
|
66
|
-
```
|
|
66
|
+
```xml
|
|
67
67
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
68
68
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
69
69
|
|
|
@@ -75,7 +75,7 @@ This can be done much easier. In general, the stack is arranged almost like a sy
|
|
|
75
75
|
|
|
76
76
|
<img align="left" width="90" height="90" title="sun" src="https://raw.githubusercontent.com/firefoxic/gulp-stacksvg/main/test/stack.svg#sun-alpha">
|
|
77
77
|
|
|
78
|
-
```
|
|
78
|
+
```xml
|
|
79
79
|
<svg id="sun" viewBox="0 0 24 24">
|
|
80
80
|
<!-- Inner code of sun icon -->
|
|
81
81
|
</svg>
|
|
@@ -83,7 +83,7 @@ This can be done much easier. In general, the stack is arranged almost like a sy
|
|
|
83
83
|
|
|
84
84
|
<img align="left" width="90" height="90" title="heart" src="https://raw.githubusercontent.com/firefoxic/gulp-stacksvg/main/test/stack.svg#heart-red">
|
|
85
85
|
|
|
86
|
-
```
|
|
86
|
+
```xml
|
|
87
87
|
<svg id="heart" viewBox="0 0 24 24">
|
|
88
88
|
<!-- Inner code of heart icon -->
|
|
89
89
|
</svg>
|
|
@@ -91,13 +91,13 @@ This can be done much easier. In general, the stack is arranged almost like a sy
|
|
|
91
91
|
|
|
92
92
|
<img align="left" width="90" height="90" title="thumbup" src="https://raw.githubusercontent.com/firefoxic/gulp-stacksvg/main/test/stack.svg#thumbup-alpha">
|
|
93
93
|
|
|
94
|
-
```
|
|
94
|
+
```xml
|
|
95
95
|
<svg id="thumbup" viewBox="0 0 24 24">
|
|
96
96
|
<!-- Inner code of thumbup icon -->
|
|
97
97
|
</svg>
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
```
|
|
100
|
+
```xml
|
|
101
101
|
</svg>
|
|
102
102
|
```
|
|
103
103
|
|
|
@@ -141,7 +141,7 @@ And now the icons from the external sprite are available in the styles <img widt
|
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
> ⚠️ Note:
|
|
144
|
-
>
|
|
144
|
+
> We still need the [autoprefixer](https://github.com/postcss/autoprefixer) for the mask property.
|
|
145
145
|
|
|
146
146
|
For an icon inserted via `mask`, simply change the `background`. Moreover, unlike `use`, you can draw anything in the background under the mask, for example, a gradient.
|
|
147
147
|
|
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export function stacksvg ({ output = `stack.svg`, separator = `_`, spacer = `-`
|
|
|
20
20
|
let isEmpty = true
|
|
21
21
|
const ids = {}
|
|
22
22
|
const namespaces = {}
|
|
23
|
-
const stack = parse(
|
|
23
|
+
const stack = parse(`<svg xmlns="http://www.w3.org/2000/svg"><style>:root{visibility:hidden}:target{visibility:visible}</style></svg>`)
|
|
24
24
|
const rootSvg = stack.querySelector(`svg`)
|
|
25
25
|
const stream = new Transform({ objectMode: true })
|
|
26
26
|
|
|
@@ -36,9 +36,7 @@ export function stacksvg ({ output = `stack.svg`, separator = `_`, spacer = `-`
|
|
|
36
36
|
|
|
37
37
|
const icon = parse(file.contents.toString()).querySelector(`svg`)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
isEmpty = false
|
|
41
|
-
}
|
|
39
|
+
isEmpty = false
|
|
42
40
|
|
|
43
41
|
const iconId = basename(
|
|
44
42
|
file.relative.split(sep).join(separator).replace(/\s/g, spacer),
|