mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-11-30 16:48:16 +01:00
* chore: update project dependencies * remove lerna * update build * plugin fixes * Icons do not display when the svg is loaded from a file:// URL in Safari fixes #1298 * Update path fill in warning-outline.svg exclamation mark * set currentColor - fixes #1420 * add bell tag to notifications icon - fixes #1090 * add sliders and filters tags to option icon - fixes #1060 * add loveseat tag to bed icon - closes #503 * add contacts tag to people-circle closes #779 * fix data.json * update data.json * set up prettier * fix contributing link * prettier after rebase * add missing rimraf * add more comments * run prettier as part of the build * set module resolution to bundle * consolidate contributing guidelines and coc as part of the root directory * fix link * copy svg into www * cut me some visual slack * Update readme.md Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com> * Update package.json Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com> * Update CONTRIBUTING.md Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com> * remove generating collections * ensure all directories exist * only define snapshot tolerance in config * update dependencies * Update src/components/icon/request.ts Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com> * Update src/components/icon/request.ts Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com> * Update src/components/icon/request.ts Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com> * Update src/components/icon/request.ts Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com> * prettier * update release pipeline * fix exports * recommend to use esm.sh as cdn --------- Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com> Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
89 lines
2.5 KiB
TypeScript
89 lines
2.5 KiB
TypeScript
import { PluginConfig } from 'svgo';
|
|
import type { CustomPlugin } from './types';
|
|
|
|
const setRootIoniconClass: PluginConfig = {
|
|
name: 'addClassesToSVGElement',
|
|
params: {
|
|
className: 'ionicon',
|
|
},
|
|
};
|
|
|
|
const addFillNoneCss: PluginConfig = {
|
|
name: 'addFillNoneCss',
|
|
fn: () => ({
|
|
element: {
|
|
enter: (element) => {
|
|
if (element.attributes.fill) {
|
|
if (element.attributes.fill === 'none') {
|
|
element.attributes.class = [...(element.attributes.class?.split(' ') || []), 'ionicon-fill-none'].join(' ');
|
|
}
|
|
delete element.attributes.fill;
|
|
}
|
|
if (element.attributes.stroke) {
|
|
delete element.attributes.stroke;
|
|
}
|
|
if (
|
|
element.attributes['stroke-width'] &&
|
|
(element.attributes['stroke-width'] === '32px' || element.attributes['stroke-width'] === '32')
|
|
) {
|
|
delete element.attributes['stroke-width'];
|
|
element.attributes.class = [...(element.attributes.class?.split(' ') || []), 'ionicon-stroke-width'].join(
|
|
' ',
|
|
);
|
|
}
|
|
},
|
|
},
|
|
}),
|
|
};
|
|
|
|
const forceCurrentColor: PluginConfig = {
|
|
name: 'forceCurrentColor',
|
|
fn: () => ({
|
|
element: {
|
|
enter: (element) => {
|
|
const attr = element.attributes.stroke || element.attributes.fill;
|
|
const attrName = element.attributes.stroke ? 'stroke' : element.attributes.fill ? 'fill' : undefined;
|
|
|
|
if (attrName) {
|
|
if (attr === '#000' || attr === 'currentColor') {
|
|
element.attributes[attrName] = 'currentColor';
|
|
} else if (attr !== 'none') {
|
|
throw new Error(`invalid "${attrName}" value: ${element.attributes[attrName]}`);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}),
|
|
};
|
|
|
|
const validatePlugin: PluginConfig = {
|
|
name: 'validate',
|
|
fn: () => ({
|
|
element: {
|
|
enter: (element) => {
|
|
if (element.attributes.style) {
|
|
console.warn(
|
|
`Inline style attributed detected: <${element.name} style="${element.attributes.style}">...</${element.name}>`,
|
|
);
|
|
}
|
|
if (element.name === 'style') {
|
|
console.warn('Inline style element detected');
|
|
}
|
|
},
|
|
},
|
|
}),
|
|
};
|
|
|
|
const basePlugins: PluginConfig[] = [
|
|
'removeStyleElement',
|
|
'convertStyleToAttrs',
|
|
'removeScriptElement',
|
|
'removeDimensions',
|
|
setRootIoniconClass,
|
|
validatePlugin,
|
|
];
|
|
|
|
export const webComponentPassPlugins: PluginConfig[] = [...basePlugins, addFillNoneCss];
|
|
|
|
export const sourcePassPlugins: PluginConfig[] = [...basePlugins, forceCurrentColor];
|