mirror of
https://github.com/tabler/tabler-icons.git
synced 2025-01-17 04:38:28 +01:00
b54c86433e
* fix: fix icons svelte package * add missing svelte condition #941 * build fix * react components * preact components * solidjs components * vue components * add unit tests * build cleanup * build fixes * add icons aliases * dependencies update * update gemfile * dependencies update * iconfont cache * Release 3.0.0-alpha.0 * build fix * rollup plugins fix * build v3 * Rename 7 icons and add aliases for them * init react-native package * React Native new package (#999) * remove build files * build files remove (#1000) * init react-native package * remove build files * remove build files * turbo update * remove build files * categories build fix * 22 new icons: `badge-3d-filled`, `badge-4k-filled`, `badge-8k-filled`, `badge-ad-filled`, `badge-ar-filled`, `badge-cc-filled`, `badge-hd-filled`, `badge-sd-filled`, `badge-tm-filled`, `badge-vo-filled`, `badge-vr-filled`, `badge-wc-filled`, `boom`, `brand-astro`, `car-4wd`, `car-fan-1`, `car-fan-2`, `car-fan-3`, `car-fan-auto`, `car-fan`, `scan-position`, `typeface` Fixed icons: `badge-3d` * 25 new icons: `cash-banknote-filled`, `clock-hour-1-filled`, `clock-hour-10-filled`, `clock-hour-11-filled`, `clock-hour-12-filled`, `clock-hour-2-filled`, `clock-hour-3-filled`, `clock-hour-4-filled`, `clock-hour-5-filled`, `clock-hour-6-filled`, `clock-hour-7-filled`, `clock-hour-8-filled`, `clock-hour-9-filled`, `gps-filled`, `layout-align-bottom-filled`, `layout-align-center-filled`, `layout-align-left-filled`, `layout-align-middle-filled`, `layout-align-right-filled`, `layout-align-top-filled`, `radar-filled`, `relation-many-to-many-filled`, `relation-one-to-many-filled`, `relation-one-to-one-filled`, `section-filled` Fixed icons: `ce-off` * 7 new icons: `crop-1-1-filled`, `crop-16-9-filled`, `crop-3-2-filled`, `crop-5-4-filled`, `crop-7-5-filled`, `crop-landscape-filled`, `crop-portrait-filled` * 80 new icons: `circle-letter-a-filled`, `circle-letter-b-filled`, `circle-letter-c-filled`, `circle-letter-d-filled`, `circle-letter-e-filled`, `circle-letter-f-filled`, `circle-letter-g-filled`, `circle-letter-h-filled`, `circle-letter-i-filled`, `circle-letter-j-filled`, `circle-letter-k-filled`, `circle-letter-l-filled`, `circle-letter-letter-v-filled`, `circle-letter-m-filled`, `circle-letter-n-filled`, `circle-letter-o-filled`, `circle-letter-p-filled`, `circle-letter-q-filled`, `circle-letter-r-filled`, `circle-letter-s-filled`, `circle-letter-t-filled`, `circle-letter-u-filled`, `circle-letter-v-filled`, `circle-letter-w-filled`, `circle-letter-x-filled`, `circle-letter-y-filled`, `circle-letter-z-filled`, `square-letter-a-filled`, `square-letter-b-filled`, `square-letter-c-filled`, `square-letter-d-filled`, `square-letter-e-filled`, `square-letter-f-filled`, `square-letter-g-filled`, `square-letter-h-filled`, `square-letter-i-filled`, `square-letter-j-filled`, `square-letter-k-filled`, `square-letter-l-filled`, `square-letter-letter-v-filled`, `square-letter-m-filled`, `square-letter-n-filled`, `square-letter-o-filled`, `square-letter-p-filled`, `square-letter-q-filled`, `square-letter-r-filled`, `square-letter-s-filled`, `square-letter-t-filled`, `square-letter-u-filled`, `square-letter-v-filled`, `square-letter-w-filled`, `square-letter-x-filled`, `square-letter-y-filled`, `square-letter-z-filled`, `square-rounded-letter-a-filled`, `square-rounded-letter-b-filled`, `square-rounded-letter-c-filled`, `square-rounded-letter-d-filled`, `square-rounded-letter-e-filled`, `square-rounded-letter-f-filled`, `square-rounded-letter-g-filled`, `square-rounded-letter-h-filled`, `square-rounded-letter-i-filled`, `square-rounded-letter-j-filled`, `square-rounded-letter-k-filled`, `square-rounded-letter-l-filled`, `square-rounded-letter-m-filled`, `square-rounded-letter-n-filled`, `square-rounded-letter-o-filled`, `square-rounded-letter-p-filled`, `square-rounded-letter-q-filled`, `square-rounded-letter-r-filled`, `square-rounded-letter-s-filled`, `square-rounded-letter-t-filled`, `square-rounded-letter-u-filled`, `square-rounded-letter-v-filled`, `square-rounded-letter-w-filled`, `square-rounded-letter-x-filled`, `square-rounded-letter-y-filled`, `square-rounded-letter-z-filled` * 3 new icons: `stack-2-filled`, `stack-3-filled`, `stack-filled` * Fixed icons: `cookie-man`, `cookie`, `copy-check`, `copy-minus`, `copy-x`, `stack-2-filled`, `stack-3-filled`, `stack-filled` * 3 new icons: `cone-2-filled`, `cone-filled`, `contrast-filled` * 1 new icons: `contrast-2-filled` Fixed icons: `contrast-2` * 4 new icons: `transition-bottom-filled`, `transition-left-filled`, `transition-right-filled`, `transition-top-filled` * Fixed icons: `square-letter-a-filled`, `square-letter-b-filled`, `square-letter-c-filled`, `square-letter-d-filled`, `square-letter-e-filled`, `square-letter-f-filled`, `square-letter-g-filled`, `square-letter-h-filled`, `square-letter-i-filled`, `square-letter-j-filled`, `square-letter-k-filled`, `square-letter-l-filled`, `square-letter-m-filled`, `square-letter-n-filled`, `square-letter-o-filled`, `square-letter-p-filled`, `square-letter-q-filled`, `square-letter-r-filled`, `square-letter-s-filled`, `square-letter-t-filled`, `square-letter-u-filled`, `square-letter-v-filled`, `square-letter-w-filled`, `square-letter-x-filled`, `square-letter-y-filled`, `square-letter-z-filled` * 6 new icons: `cookie-filled`, `cookie-man-filled`, `copy-check-filled`, `copy-minus-filled`, `copy-plus-filled`, `copy-x-filled` Fixed icons: `cookie-man`, `cookie`, `copy-check`, `copy-minus`, `copy-plus`, `copy-x` * Fixed icons: `brand-graphql` * icons fix * 4 new icons: `biohazard-filled`, `microphone-filled`, `microwave-filled`, `soup-filled` Fixed icons: `bowl-filled` * Release 3.0.0-alpha.1 * react native package fix * separate icons to `filled` and `outline` directories (#1002) * separate icons to solid * icons separate * move icons * init svg icons * init svg icons * separate icons * separate icons * optimize icons * optimize icons * random icons generate * generate icons preview * preview icons * build * optimize fix * icons separate * icons preview * optimize icons * 81 new icons: `filled/assembly`, `filled/asset`, `filled/baby-carriage`, `filled/barbell`, `filled/barrier-block`, `filled/bed-flat`, `filled/bone`, `filled/boom`, `filled/bow`, `filled/bowl-chopsticks`, `filled/bowl-spoon`, `filled/brand-spotify`, `filled/bread`, `filled/briefcase-2`, `filled/brightness-auto`, `filled/brightness`, `filled/building-broadcast-tower`, `filled/hexagon-letter-a`, `filled/hexagon-letter-b`, `filled/hexagon-letter-c`, `filled/hexagon-letter-d`, `filled/hexagon-letter-e`, `filled/hexagon-letter-f`, `filled/hexagon-letter-g`, `filled/hexagon-letter-h`, `filled/hexagon-letter-i`, `filled/hexagon-letter-j`, `filled/hexagon-letter-k`, `filled/hexagon-letter-l`, `filled/hexagon-letter-m`, `filled/hexagon-letter-n`, `filled/hexagon-letter-o`, `filled/hexagon-letter-p`, `filled/hexagon-letter-q`, `filled/hexagon-letter-r`, `filled/hexagon-letter-s`, `filled/hexagon-letter-t`, `filled/hexagon-letter-u`, `filled/hexagon-letter-v`, `filled/hexagon-letter-w`, `filled/hexagon-letter-x`, `filled/hexagon-letter-y`, `filled/hexagon-letter-z`, `filled/hexagon-minus`, `filled/hexagon-plus`, `filled/home`, `filled/ironing`, `filled/jetpack`, `filled/key`, `filled/layout-2`, `filled/layout-cards`, `filled/layout-dashboard`, `filled/layout-distribute-horizontal`, `filled/layout-distribute-vertical`, `filled/layout-grid`, `filled/layout-kanban`, `filled/layout-list`, `filled/layout-sidebar-right`, `filled/layout-sidebar`, `filled/layout`, `filled/lego`, `filled/lock`, `filled/lungs`, `filled/macro`, `filled/magnet`, `filled/man`, `filled/manual-gearbox`, `filled/woman`, `filled/xbox-a`, `filled/xbox-b`, `filled/xbox-x`, `filled/xbox-y`, `filled/zeppelin`, `filled/zoom-cancel`, `filled/zoom-code`, `filled/zoom-exclamation`, `filled/zoom-money`, `filled/zoom-out-area`, `filled/zoom-pan`, `filled/zoom-question`, `filled/zoom-scan` Fixed icons: `filled/archive`, `filled/basket`, `outline/layout-dashboard`, `outline/zoom-pan` * Fixed icon: `filled/biohazard` * 4 new icons: `outline/border-bottom-plus`, `outline/border-left-plus`, `outline/border-right-plus`, `outline/border-top-plus` * debug off * build `@tabler/icons` package * build `@tabler/icons` package * build `@tabler/icons-eps` , `@tabler/icons-pdf`, `@tabler/icons-png` package * build `@tabler/icons-react` , `@tabler/icons-preact`, `@tabler/icons-svelte`, `@tabler/icons-vue`, `@tabler/icons-solidjs` package * build fixes * remove unused files * iconfont build * build fixes * update icons unicode * update icons * build fixes * changelog update * build fixes * icons images * Release 3.0.0-beta * build fix * icons version fixes * Fix kerning icon typo for v3 (#1010) Co-authored-by: Bartłomiej Gawęda <bgaweda@abis.krakow.pl> * Remove box-seam icon (package duplicate) (#1008) Co-authored-by: Paweł Kuna <1282324+codecalm@users.noreply.github.com> * Fix ski jumping icon typo for v3 (#1007) Change added to aliases.json. Co-authored-by: Paweł Kuna <1282324+codecalm@users.noreply.github.com> * dependencies update * validate icons * pnpm init * validate icons * validate icons --------- Co-authored-by: Bartłomiej Gawęda <bgaweda@abis.krakow.pl> Co-authored-by: BG-Software-BG <73077398+BG-Software-BG@users.noreply.github.com>
107 lines
4.8 KiB
JavaScript
107 lines
4.8 KiB
JavaScript
import { globSync } from 'glob'
|
|
import { readFileSync, writeFileSync } from 'fs'
|
|
import { join, basename } from 'path'
|
|
import { optimizePath, ICONS_SRC_DIR, iconTemplate, types } from './helpers.mjs'
|
|
|
|
types.forEach(type => {
|
|
const files = globSync(join(ICONS_SRC_DIR, type, '*.svg'))
|
|
|
|
files.forEach(function (file, i) {
|
|
console.log(`Optimize ${basename(file)}`);
|
|
|
|
// Read files
|
|
let svgFile = readFileSync(file),
|
|
svgFileContent = svgFile.toString()
|
|
|
|
// Optimize SVG
|
|
svgFileContent = svgFileContent.replace(/><\/(polyline|line|rect|circle|path|ellipse)>/g, '/>')
|
|
.replace(/rx="([^"]+)"\s+ry="\1"/g, 'rx="$1"')
|
|
.replace(/<path stroke="red" stroke-width="\.1"([^>]+)?\/>/g, '')
|
|
.replace(/<path[^>]+d="M0 0h24v24h-24z"[^>]+\/>/g, '')
|
|
.replace(/\s?\/>/g, ' />')
|
|
.replace(/\n\s*<(line|circle|path|polyline|rect|ellipse)/g, '\n <$1')
|
|
// .replace(/polyline points="([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s([0-9.]+)"/g, 'line x1="$1" y1="$2" x2="$3" y2="$4"')
|
|
.replace(/<line x1="([^"]+)" y1="([^"]+)" x2="([^"]+)" y2="([^"]+)"\s*\/>/g, function (f, x1, y1, x2, y2) {
|
|
return `<path d="M${x1} ${y1}L${x2} ${y2}" />`
|
|
})
|
|
.replace(/<circle cx="([^"]+)" cy="([^"]+)" r="([^"]+)"\s+\/>/g, function (f, cx, cy, r) {
|
|
return `<path d="M ${cx} ${cy}m -${r} 0a ${r} ${r} 0 1 0 ${r * 2} 0a ${r} ${r} 0 1 0 ${r * -2} 0" />`
|
|
})
|
|
.replace(/<ellipse cx="([^"]+)" cy="([^"]+)" rx="([^"]+)"\s+\/>/g, function (f, cx, cy, rx) {
|
|
return `<ellipse cx="${cx}" cy="${cy}" rx="${rx}" ry="${rx}" />`
|
|
})
|
|
.replace(/<ellipse cx="([^"]+)" cy="([^"]+)" rx="([^"]+)" ry="([^"]+)"\s+\/>/g, function (f, cx, cy, rx, ry) {
|
|
return `<path d="M${cx} ${cy}m -${rx} 0a${rx} ${ry} 0 1 0 ${rx * 2} 0a ${rx} ${ry} 0 1 0 -${rx * 2} 0" />`
|
|
})
|
|
.replace(/<rect width="([^"]+)" height="([^"]+)" x="([^"]+)" y="([^"]+)" rx="([^"]+)"\s+\/>/g, function (f, width, height, x, y, rx) {
|
|
return `<rect x="${x}" y="${y}" width="${width}" height="${height}" rx="${rx}" />`
|
|
})
|
|
.replace(/<rect x="([^"]+)" y="([^"]+)" rx="([^"]+)" width="([^"]+)" height="([^"]+)"\s+\/>/g, function (f, x, y, rx, width, height) {
|
|
return `<rect x="${x}" y="${y}" width="${height}" height="${height}" rx="${rx}" />`
|
|
})
|
|
.replace(/<rect x="([^"]+)" y="([^"]+)" width="([^"]+)" height="([^"]+)" rx="([^"]+)"\s+\/>/g, function (f, x, y, width, height, rx) {
|
|
return `<path d="M ${x} ${y}m 0 ${rx}a${rx} ${rx} 0 0 1 ${rx} ${-rx}h${width - rx * 2}a${rx} ${rx} 0 0 1 ${rx} ${rx}v${height - rx * 2}a${rx} ${rx} 0 0 1 ${-rx} ${rx}h${-width + rx * 2}a${rx} ${rx} 0 0 1 ${-rx} ${-rx}Z" />`
|
|
})
|
|
.replace(/<rect x="([^"]+)" y="([^"]+)" width="([^"]+)" height="([^"]+)"\s+\/>/g, function (f, x, y, width, height) {
|
|
return `<path d="M ${x} ${y}h${width}v${height}h${-width}Z" />`
|
|
})
|
|
.replace(/<polyline points="([^"]+)\s?"\s+\/>/g, function (f, points) {
|
|
const path = points.split(' ').reduce(
|
|
(accumulator, currentValue, currentIndex) => `${accumulator}${currentIndex % 2 === 0 ? (currentIndex === 0 ? 'M' : 'L') : ''}${currentValue} `,
|
|
''
|
|
)
|
|
return `<path d="${path}" />`
|
|
})
|
|
.replace(/<path d="([^"]+)"/g, function (f, r1) {
|
|
r1 = optimizePath(r1)
|
|
|
|
return `<path d="${r1}"`
|
|
})
|
|
.replace(/<path\s+d="([^"]+)"/g, function (f, d) {
|
|
|
|
const d2 = d
|
|
.replace(/m0 0/g, (f, m) => ``)
|
|
.replace(/ 0\./g, ' .')
|
|
.replace(/ -0\./g, ' -.')
|
|
.replace(/([amcvhslAMCVHLS]) /g, '$1')
|
|
|
|
return `<path d="${d2}"`
|
|
})
|
|
.replace(/d="m/g, 'd="M')
|
|
.replace(/([Aa])\s?([0-9.]+)[\s,]([0-9.]+)[\s,]([0-9.]+)[\s,]?([0-1])[\s,]?([0-1])[\s,]?(-?[0-9.]+)[\s,]?(-?[0-9.]+)/gi, '$1$2 $3 $4 $5 $6 $7 $8')
|
|
.replace(/\n\s+\n+/g, '\n')
|
|
|
|
// Add icon template
|
|
svgFileContent = svgFileContent.replace(/<svg[^>]+>/, iconTemplate(type))
|
|
|
|
// Remove stroke and fill
|
|
if (file.match(/\/filled\//)) {
|
|
svgFileContent = svgFileContent
|
|
.replace(/stroke-width="0" fill="currentColor"/gm, '')
|
|
.replace('stroke-width="2"', '')
|
|
.replace('stroke-linecap="round"', '')
|
|
.replace('stroke-linejoin="round"', '')
|
|
.replace('stroke="currentColor"', '')
|
|
.replace('fill="none"', 'fill="currentColor"')
|
|
.replace(/^\s*[\r\n]/gm, '')
|
|
.replace(/\s{2,}\//g, ' /')
|
|
}
|
|
|
|
// Add comment if not exists
|
|
if (!svgFileContent.includes('<!--')) {
|
|
svgFileContent = '<!--\n-->\n' + svgFileContent
|
|
}
|
|
|
|
svgFileContent = svgFileContent.replace(/tags: \[([^]+)\]/, (m, tags) => {
|
|
tags = [...new Set(tags.split(',').map(t => t.trim()))].filter(t => t).join(', ')
|
|
|
|
return `tags: [${tags}]`
|
|
})
|
|
|
|
// Write files
|
|
if (svgFile.toString() !== svgFileContent) {
|
|
writeFileSync(file, svgFileContent)
|
|
}
|
|
})
|
|
})
|