mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-12-01 16:56:28 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8fc2d1915 | ||
|
|
9af4171924 | ||
|
|
cdbd383603 | ||
|
|
a9c147b2b1 |
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ionicons",
|
||||
"version": "4.6.3",
|
||||
"version": "4.6.4-1",
|
||||
"description": "Premium icons for Ionic.",
|
||||
"files": [
|
||||
"dist/",
|
||||
@@ -13,7 +13,7 @@
|
||||
"collection": "dist/collection/collection-manifest.json",
|
||||
"collection:main": "dist/collection/index.js",
|
||||
"scripts": {
|
||||
"build": "npm run lint.ts && npm run build.data && npm run build.icon && npm run generate && npm run build.css && npm run copy.tasks && npm run test",
|
||||
"build": "npm run lint.ts && npm run build.icon && npm run generate && npm run build.css && npm run copy.tasks && npm run test && npm run build.data",
|
||||
"build.css": "node scripts/build-css.js",
|
||||
"build.data": "node scripts/data.js",
|
||||
"build.icon": "stencil build",
|
||||
|
||||
+32
-48
@@ -15,11 +15,8 @@ const DST_ICONS_ESM = path.join(DST_ICONS_DIR, 'index.mjs');
|
||||
const DST_ICONS_CJS = path.join(DST_ICONS_DIR, 'index.js');
|
||||
const DST_ICONS_DTS = path.join(DST_ICONS_DIR, 'index.d.ts');
|
||||
|
||||
const DST_ICONS_IMPORTS_DIR = path.join(DST_ICONS_DIR, 'imports');
|
||||
|
||||
|
||||
fs.emptyDirSync(DST_ICONS_DIR);
|
||||
fs.emptyDirSync(DST_ICONS_IMPORTS_DIR);
|
||||
|
||||
console.log('checking icon data: ' + SRC_JSON);
|
||||
|
||||
@@ -68,13 +65,13 @@ function camelize(text) {
|
||||
|
||||
|
||||
const moduleData = {};
|
||||
const esmIndex = [
|
||||
const esm = [
|
||||
`/* Ionicons, ES Modules */`, ``
|
||||
];
|
||||
const cjsIndex = [
|
||||
const cjs = [
|
||||
`/* Ionicons, CommonJS */`, ``
|
||||
];
|
||||
const dtsIndex = [
|
||||
const dts = [
|
||||
`/* Ionicons, Types */`, ``
|
||||
];
|
||||
|
||||
@@ -119,8 +116,6 @@ svgFiles.forEach(fileName => {
|
||||
modes: {}
|
||||
};
|
||||
moduleData[exportCommonName] = commonIconData;
|
||||
|
||||
esmIndex.push(`import ${exportCommonName} from './imports/${commonName}.mjs';`);
|
||||
}
|
||||
|
||||
commonIconData.modes[mode] = {
|
||||
@@ -131,77 +126,66 @@ svgFiles.forEach(fileName => {
|
||||
};
|
||||
});
|
||||
|
||||
esmIndex.push(``);
|
||||
|
||||
|
||||
const sortedKeys = Object.keys(moduleData).sort();
|
||||
|
||||
sortedKeys.forEach(key => {
|
||||
const d = moduleData[key];
|
||||
const esmFilePath = path.join(DST_ICONS_IMPORTS_DIR, d.commonName + '.mjs');
|
||||
const cjsFilePath = path.join(DST_ICONS_IMPORTS_DIR, d.commonName + '.js');
|
||||
const esm = [];
|
||||
const cjs = [];
|
||||
|
||||
const modes = Object.keys(d.modes).sort();
|
||||
|
||||
if (modes.length > 1) {
|
||||
for (let i = 0; i < modes.length; i++) {
|
||||
const mode = modes[i];
|
||||
esm.push(`import ${mode} from '../../dist/ionicons/svg/${d.modes[mode].fileName}';`);
|
||||
}
|
||||
|
||||
esm.push(``);
|
||||
esm.push(`export default /*#__PURE__*/ {`);
|
||||
|
||||
cjs.push(`module.exports = /*#__PURE__*/ {`);
|
||||
|
||||
dtsIndex.push(`export declare var ${d.exportCommonName}: {`);
|
||||
esm.push(`export const ${d.exportCommonName} = {`);
|
||||
cjs.push(`exports.${d.exportCommonName} = {`);
|
||||
dts.push(`export declare var ${d.exportCommonName}: {`);
|
||||
|
||||
for (let i = 0; i < modes.length; i++) {
|
||||
const mode = modes[i];
|
||||
const suffix = i < modes.length - 1 ? ',' : '';
|
||||
|
||||
esm.push(` ${mode}: ${mode}${suffix}`);
|
||||
const svgContent = getDataUrl(d.modes[mode].fileName);
|
||||
|
||||
cjs.push(` ${mode}: require('../../dist/ionicons/svg/${d.modes[mode].fileName}')${suffix}`);
|
||||
esm.push(` ${mode}: ${svgContent}${suffix}`);
|
||||
cjs.push(` ${mode}: ${svgContent}${suffix}`);
|
||||
|
||||
dtsIndex.push(` ${mode}: string;`);
|
||||
dts.push(` ${mode}: string;`);
|
||||
}
|
||||
|
||||
esm.push(`};`);
|
||||
cjs.push(`};`);
|
||||
dtsIndex.push(`};`);
|
||||
dts.push(`};`);
|
||||
|
||||
} else {
|
||||
esm.push(`import icon from '../../dist/ionicons/svg/${d.fileName}'`);
|
||||
esm.push(``);
|
||||
esm.push(`export default /*#__PURE__*/ icon;`);
|
||||
const svgContent = getDataUrl(d.fileName);
|
||||
|
||||
cjs.push(`module.exports = /*#__PURE__*/ require('../../dist/ionicons/svg/${d.fileName}');`);
|
||||
esm.push(`export const ${d.exportCommonName} = ${svgContent};`);
|
||||
|
||||
dtsIndex.push(`export declare var ${d.exportCommonName}: string;`);
|
||||
cjs.push(`exports.${d.exportCommonName} = ${svgContent};`);
|
||||
|
||||
dts.push(`export declare var ${d.exportCommonName}: string;`);
|
||||
}
|
||||
|
||||
esmIndex.push(`export { ${d.exportCommonName} }`);
|
||||
|
||||
cjsIndex.push(`exports.${d.exportCommonName} = /*#__PURE__*/ require('./imports/${d.commonName}.js');`);
|
||||
|
||||
fs.writeFileSync(esmFilePath, esm.join('\n'));
|
||||
fs.writeFileSync(cjsFilePath, cjs.join('\n'));
|
||||
});
|
||||
|
||||
fs.writeFileSync(DST_ICONS_ESM, esmIndex.join('\n') + '\n');
|
||||
fs.writeFileSync(DST_ICONS_CJS, cjsIndex.join('\n') + '\n');
|
||||
fs.writeFileSync(DST_ICONS_DTS, dtsIndex.join('\n') + '\n');
|
||||
fs.writeFileSync(DST_ICONS_ESM, esm.join('\n') + '\n');
|
||||
fs.writeFileSync(DST_ICONS_CJS, cjs.join('\n') + '\n');
|
||||
fs.writeFileSync(DST_ICONS_DTS, dts.join('\n') + '\n');
|
||||
|
||||
fs.writeFileSync(DST_ICONS_PKGJSON, JSON.stringify({
|
||||
"name": "ionicons/icons",
|
||||
"module": "index.mjs",
|
||||
"main": "index.js",
|
||||
"typings": "index.d.ts",
|
||||
"sideEffects": [
|
||||
"imports/"
|
||||
],
|
||||
"private": true
|
||||
}, null, 2));
|
||||
|
||||
function getDataUrl(filePath) {
|
||||
filePath = path.join(__dirname, '..', 'dist', 'ionicons', 'svg', filePath);
|
||||
let svg = fs.readFileSync(filePath, 'utf8');
|
||||
if (svg.includes(`'`)) {
|
||||
throw new Error(`oh no! no single quotes allowed! ${filePath}`);
|
||||
}
|
||||
if (svg.includes(`\n`) || svg.includes(`\r`)) {
|
||||
throw new Error(`oh no! no new lines allowed! ${filePath}`);
|
||||
}
|
||||
svg = svg.replace(/"/g, "'");
|
||||
return `"data:image/svg+xml;utf8,${svg}"`;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@
|
||||
<ion-icon src="./assets/web_asset.svg"></ion-icon>
|
||||
<ion-icon src="./assets/work_outline.svg"></ion-icon>
|
||||
|
||||
<h2>Data Url SVG</h2>
|
||||
<ion-icon src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M256 48C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48zM76 256c0-48.1 18.7-93.3 52.7-127.3S207.9 76 256 76c48.1 0 93.3 18.7 127.3 52.7 32.2 32.2 50.7 74.5 52.6 119.7-8.8-10.3-24.2-24-43.8-24-27.5 0-41.7 25.7-51 42.7-1.4 2.5-2.7 4.9-3.9 7-11.4 19.2-27.3 30-42.5 28.9-13.4-.9-24.8-11.2-32.2-28.8-9.2-22.1-29.1-45.8-52.9-49.2-11.3-1.6-28.1.8-44.7 21.4-3.2 4-6.9 9.4-11.1 15.6-10.4 15.5-26.2 38.8-38.1 40.8-17.3 2.8-30.9-7.5-36.4-12.3-2.2-11.2-3.3-22.8-3.3-34.5z'/></svg>"></ion-icon>
|
||||
<ion-icon id="dataUrl"></ion-icon>
|
||||
|
||||
<h2>Custom SVGs: colors</h2>
|
||||
<ion-icon color="primary" src="./assets/bug_report.svg"></ion-icon>
|
||||
<ion-icon color="secondary" src="./assets/chat.svg"></ion-icon>
|
||||
@@ -848,6 +852,9 @@
|
||||
fill: blue;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
document.getElementById('dataUrl').src = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M368.5 240H272v-96.5c0-8.8-7.2-16-16-16s-16 7.2-16 16V240h-96.5c-8.8 0-16 7.2-16 16 0 4.4 1.8 8.4 4.7 11.3 2.9 2.9 6.9 4.7 11.3 4.7H240v96.5c0 4.4 1.8 8.4 4.7 11.3 2.9 2.9 6.9 4.7 11.3 4.7 8.8 0 16-7.2 16-16V272h96.5c8.8 0 16-7.2 16-16s-7.2-16-16-16z"/></svg>';
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user