feat: fix icon whiten method

pull/35/merge
Amio 2018-07-27 21:16:31 +08:00
rodzic e7460fb302
commit 1b80ed3f82
8 zmienionych plików z 20 dodań i 21 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
const fs = require('fs')
const { join, parse } = require('path')
function genIcons (iconFolder) {
function genIcons (iconFolder, whiten) {
const icons = {}
fs.readdirSync(join(__dirname, iconFolder)).forEach(filename => {
@ -14,10 +14,8 @@ function genIcons (iconFolder) {
const key = parse(filename).name
const iconFile = join(__dirname, iconFolder, filename)
const svg = fs.readFileSync(iconFile, 'utf8')
.replace(/fill="#\w{3,6}"/g, 'fill="white"')
.replace(/stroke="#\w{3,6}"/g, 'stroke="white"')
// .replace(/<path /g, '<path fill="white" ')
const svgSource = fs.readFileSync(iconFile, 'utf8')
const svg = whiten ? whitenSVG(svgSource) : svgSource
const b64 = Buffer.from(svg).toString('base64')
icons[key] = `data:image/${imageType};base64,${b64}`
@ -26,7 +24,14 @@ function genIcons (iconFolder) {
return icons
}
function whitenSVG (svg, whiten) {
return svg
.replace(/fill="#\w{3,6}"/g, 'fill="white"')
.replace(/stroke="#\w{3,6}"/g, 'stroke="white"')
.replace(/<path /g, '<path fill="white" ')
}
module.exports = {
builtin: genIcons('icons'),
simple: genIcons('../node_modules/simple-icons/icons')
simple: genIcons('../node_modules/simple-icons/icons', true)
}

Wyświetl plik

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.5 14.5">
<g fill="#FFF">
<path d="M10.67 7.33c-.02-1.75 1.42-2.58 1.49-2.63a3.22 3.22 0 0 0-2.53-1.36c-1.07-.11-2.1.63-2.64.63s-1.38-.62-2.27-.6A3.38 3.38 0 0 0 1.86 5.1c-1.22 2.11-.31 5.24.87 6.96.58.83 1.28 1.77 2.18 1.74.88-.03 1.2-.57 2.26-.57s1.36.57 2.28.55c.94-.01 1.54-.85 2.11-1.7.67-.96.94-1.9.96-1.95-.02-.02-1.83-.7-1.85-2.8zM8.93 2.2c.48-.58.8-1.4.72-2.2-.7.03-1.54.46-2.04 1.04a2.9 2.9 0 0 0-.73 2.14c.78.06 1.57-.4 2.05-.98z"/>
</g>
</svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 519 B

Wyświetl plik

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
<path fill="#ddd" d="M20 0c11 0 20 9 20 20s-9 20-20 20S0 31 0 20 9 0 20 0zm4.9 23.9c2.2-2.8 1.9-6.8-.9-8.9-2.7-2.1-6.7-1.6-9 1.2-2.2 2.8-1.9 6.8.9 8.9 2.8 2.1 6.8 1.6 9-1.2zm-10.7 13c1.2.5 3.8 1 5.1 1L28 25.3c2.8-4.2 2.1-9.9-1.8-13-3.5-2.8-8.4-2.7-11.9 0L2.2 21.6c.3 3.2 1.2 4.8 1.2 4.9l6.9-7.5c-.5 3.3.7 6.7 3.5 8.8 2.4 1.9 5.3 2.4 8.1 1.8l-7.7 7.3z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="#EEE" width="40" height="40" viewBox="0 0 40 40">
<path d="M20 0c11 0 20 9 20 20s-9 20-20 20S0 31 0 20 9 0 20 0zm4.9 23.9c2.2-2.8 1.9-6.8-.9-8.9-2.7-2.1-6.7-1.6-9 1.2-2.2 2.8-1.9 6.8.9 8.9 2.8 2.1 6.8 1.6 9-1.2zm-10.7 13c1.2.5 3.8 1 5.1 1L28 25.3c2.8-4.2 2.1-9.9-1.8-13-3.5-2.8-8.4-2.7-11.9 0L2.2 21.6c.3 3.2 1.2 4.8 1.2 4.9l6.9-7.5c-.5 3.3.7 6.7 3.5 8.8 2.4 1.9 5.3 2.4 8.1 1.8l-7.7 7.3z"/>
</svg>

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 446 B

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 448 B

Wyświetl plik

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 85.323601 85.333336" height="85.333" width="85.324"><defs><clipPath id="a"><path d="M0 64h63.993V0H0z"/></clipPath></defs><g clip-path="url(#a)" transform="matrix(1.33333 0 0 -1.33333 0 85.333)"><path d="M63.04 24.26C58.767 7.115 41.403-3.317 24.258.957 7.12 5.233-3.312 22.597.963 39.737c4.272 17.146 21.635 27.58 38.774 23.306C56.882 58.77 67.313 41.403 63.04 24.26" fill="#f7931a"/><path d="M39.173 36.622c-.99-3.966-7.1-1.95-9.083-1.457l1.748 7.01c1.982-.494 8.367-1.416 7.335-5.553M38.088 25.31c-1.086-4.36-8.426-2.003-10.807-1.412l1.93 7.73c2.38-.595 10.01-1.77 8.88-6.318m8.02 11.25c.637 4.257-2.605 6.546-7.04 8.073l1.44 5.768-3.513.877-1.4-5.616c-.92.23-1.87.448-2.81.663l1.41 5.653-3.51.875-1.44-5.765c-.763.174-1.513.346-2.24.527l.003.02-4.843 1.208-.934-3.75s2.605-.597 2.55-.634c1.422-.355 1.68-1.296 1.636-2.042l-1.64-6.57c.1-.026.225-.062.365-.118l-.37.092-2.297-9.205c-.175-.43-.616-1.08-1.61-.833.035-.05-2.552.637-2.552.637l-1.743-4.02 4.57-1.14c.85-.212 1.683-.436 2.502-.645l-1.453-5.837L24.7 13.9l1.44 5.773c.957-.26 1.887-.5 2.797-.725L27.504 13.2l3.51-.875 1.454 5.823c5.987-1.132 10.49-.675 12.383 4.738 1.53 4.36-.073 6.875-3.223 8.516 2.294.53 4.023 2.04 4.484 5.157" fill="#fff"/></g></svg>

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.2 KiB

Wyświetl plik

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="12 12 40 40">
<path fill="#333333" d="M32,13.4c-10.5,0-19,8.5-19,19c0,8.4,5.5,15.5,13,18c1,0.2,1.3-0.4,1.3-0.9c0-0.5,0-1.7,0-3.2 c-5.3,1.1-6.4-2.6-6.4-2.6C20,41.6,18.8,41,18.8,41c-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ość:  |  Rozmiar: 680 B

Wyświetl plik

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="16 16 96 96">
<path fill="#663300" d="M63.998,16C37.49,16,16,37.489,16,63.998C16,90.509,37.49,112,63.998,112 c26.514,0,48-21.491,48-48.002C111.998,37.489,90.513,16,63.998,16z M86.169,59.827L64.33,89.394L42.492,59.827 c-1.848-2.173-3.692-9.738,2.65-13.919c5.402-3.561,10.533-0.864,13.222,2.261c1.003,1.166,2.722,2.539,5.966,2.539 c3.245,0,4.964-1.373,5.967-2.539c2.688-3.125,7.819-5.822,13.222-2.261C89.861,50.089,88.016,57.653,86.169,59.827z"/>
</svg>

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 524 B

Wyświetl plik

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80"><path d="M80.058 72.37a7.734 7.734 0 0 1-7.735 7.734H7.789A7.737 7.737 0 0 1 .054 72.37V7.836A7.737 7.737 0 0 1 7.789.1h64.534a7.734 7.734 0 0 1 7.735 7.735v64.533" fill="#f6c915"/><g fill="#fff"><path d="M32.658 56.149c-2.577 0-4.6-.336-6.07-1.007-1.469-.672-2.522-1.587-3.156-2.75-.636-1.16-.944-2.49-.926-4 .018-1.506.226-3.111.626-4.817l6.913-28.902 8.437-1.306-7.566 31.352a9.843 9.843 0 0 0-.245 1.795c-.019.544.082 1.026.3 1.442.217.419.589.754 1.115 1.007.525.255 1.26.419 2.205.49l-1.633 6.692M63.131 38.135c0 2.648-.435 5.07-1.306 7.266-.87 2.197-2.078 4.092-3.62 5.688-1.542 1.598-3.392 2.84-5.551 3.728-2.16.889-4.51 1.334-7.048 1.334-1.234 0-2.468-.11-3.701-.328l-2.45 9.853h-8.056l9.035-37.662c1.451-.435 3.112-.826 4.98-1.17 1.87-.345 3.893-.517 6.07-.517 2.032 0 3.784.308 5.252.925 1.47.616 2.677 1.46 3.62 2.53.943 1.071 1.642 2.323 2.095 3.756.453 1.433.68 2.967.68 4.6M43.373 49.298c.617.145 1.379.218 2.286.218 1.415 0 2.703-.263 3.864-.79a8.52 8.52 0 0 0 2.967-2.204c.815-.943 1.45-2.076 1.904-3.402.454-1.324.68-2.784.68-4.381 0-1.56-.345-2.885-1.033-3.974-.69-1.088-1.887-1.633-3.592-1.633-1.162 0-2.25.109-3.267.327l-3.809 15.839"/></g></svg>

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 1.2 KiB

Wyświetl plik

@ -1,6 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240">
<path d="M66.964 134.874s-32.08-10.062-51.344-16.002c-17.542-6.693-1.57-14.928 6.015-17.59 7.585-2.66 186.38-71.948 194.94-75.233 8.94-4.147 19.884-.35 14.767 18.656-4.416 20.407-30.166 142.874-33.827 158.812-3.66 15.937-18.447 6.844-18.447 6.844l-83.21-61.442z" fill="none" stroke="#000" stroke-width="10"/>
<path d="M92.412 201.62s4.295.56 8.83-3.702c4.536-4.26 26.303-25.603 26.303-25.603" fill="none" stroke="#000" stroke-width="10"/>
<path d="M66.985 134.887l28.922 14.082-3.488 52.65s-4.928.843-6.25-3.613c-1.323-4.455-19.185-63.12-19.185-63.12z" fill-rule="evenodd" stroke="#000" stroke-width="10" stroke-linejoin="bevel"/>
<path d="M66.985 134.887s127.637-77.45 120.09-71.138c-7.55 6.312-91.168 85.22-91.168 85.22z" fill-rule="evenodd" stroke="#000" stroke-width="9.67" stroke-linejoin="bevel"/>
</svg>

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 882 B