mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-12-02 17:06:06 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8fc2d1915 | ||
|
|
9af4171924 | ||
|
|
cdbd383603 | ||
|
|
a9c147b2b1 | ||
|
|
f57e4988b0 | ||
|
|
0df64cf8b8 | ||
|
|
444dc18700 | ||
|
|
aacebf599d | ||
|
|
8839341860 |
@@ -14,6 +14,7 @@ log.txt
|
||||
node_modules/
|
||||
tmp/
|
||||
dist/
|
||||
icons/
|
||||
.DS_Store
|
||||
|
||||
www/
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
export * from '../dist/ionicons/svg/index';
|
||||
@@ -1 +0,0 @@
|
||||
module.export = require('../dist/ionicons/svg/index.js');
|
||||
@@ -1 +0,0 @@
|
||||
export * from '../dist/ionicons/svg/index.mjs';
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"name": "ionicons/icons",
|
||||
"module": "./index.mjs",
|
||||
"main": "./index.js",
|
||||
"typings": "./index.d.ts",
|
||||
"private": true
|
||||
}
|
||||
+6
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ionicons",
|
||||
"version": "4.6.1",
|
||||
"version": "4.6.4-1",
|
||||
"description": "Premium icons for Ionic.",
|
||||
"files": [
|
||||
"dist/",
|
||||
@@ -32,7 +32,7 @@
|
||||
"test": "stencil test --spec"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@stencil/core": "1.1.3",
|
||||
"@stencil/core": "1.3.0",
|
||||
"@stencil/sass": "^1.0.1",
|
||||
"@types/highlight.js": "^9.12.3",
|
||||
"@types/jest": "24.0.13",
|
||||
@@ -80,5 +80,8 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/ionic-team/ionicons/issues"
|
||||
},
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"sideEffects": [
|
||||
"icons/imports/"
|
||||
]
|
||||
}
|
||||
|
||||
+66
-57
@@ -8,10 +8,15 @@ const PKG_JSON = path.join(ROOT_DIR, 'package.json');
|
||||
const SRC_JSON = path.join(SRC_DIR, 'data.json');
|
||||
const DST_DIR = path.join(ROOT_DIR, 'dist');
|
||||
const DST_JSON = path.join(DST_DIR, 'ionicons', 'data.json');
|
||||
const DST_ESM = path.join(DST_DIR, 'ionicons', 'svg', 'index.mjs');
|
||||
const DST_CJS = path.join(DST_DIR, 'ionicons', 'svg', 'index.js');
|
||||
const DST_DTS = path.join(DST_DIR, 'ionicons', 'svg', 'index.d.ts');
|
||||
|
||||
const DST_ICONS_DIR = path.join(ROOT_DIR, 'icons');
|
||||
const DST_ICONS_PKGJSON = path.join(DST_ICONS_DIR, 'package.json');
|
||||
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');
|
||||
|
||||
|
||||
fs.emptyDirSync(DST_ICONS_DIR);
|
||||
|
||||
console.log('checking icon data: ' + SRC_JSON);
|
||||
|
||||
@@ -20,7 +25,7 @@ let svgFiles = fs.readdirSync(SRC_SVG_DIR);
|
||||
let pkgData = fs.readJsonSync(PKG_JSON);
|
||||
srcData['version'] = pkgData.version;
|
||||
|
||||
svgFiles = svgFiles.filter(f => f.indexOf('.svg') > -1);
|
||||
svgFiles = svgFiles.filter(f => f.indexOf('.svg') > -1).sort();
|
||||
svgFiles.forEach(svgFile => {
|
||||
let iconName = svgFile.split('.')[0];
|
||||
|
||||
@@ -49,8 +54,6 @@ const jsonContent = JSON.stringify(srcData);
|
||||
fs.writeFileSync(DST_JSON, jsonContent);
|
||||
|
||||
|
||||
const BASE_PATH = '.'
|
||||
|
||||
function upFirst(word) {
|
||||
return word[0].toUpperCase() + word.toLowerCase().slice(1);
|
||||
}
|
||||
@@ -62,8 +65,15 @@ function camelize(text) {
|
||||
|
||||
|
||||
const moduleData = {};
|
||||
const esmImports = [];
|
||||
const cjsImports = [];
|
||||
const esm = [
|
||||
`/* Ionicons, ES Modules */`, ``
|
||||
];
|
||||
const cjs = [
|
||||
`/* Ionicons, CommonJS */`, ``
|
||||
];
|
||||
const dts = [
|
||||
`/* Ionicons, Types */`, ``
|
||||
];
|
||||
|
||||
svgFiles.forEach(fileName => {
|
||||
// fileName: ios-add-circle-outline.svg
|
||||
@@ -111,72 +121,71 @@ svgFiles.forEach(fileName => {
|
||||
commonIconData.modes[mode] = {
|
||||
mode,
|
||||
modeName,
|
||||
modeImportName
|
||||
modeImportName,
|
||||
fileName
|
||||
};
|
||||
|
||||
const esmImport = `import ${modeImportName} from './${fileName}';`
|
||||
esmImports.push(esmImport);
|
||||
|
||||
const cjsImport = `const ${modeImportName} = require('./${fileName}');`
|
||||
cjsImports.push(cjsImport);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
export const addCircleOutline = {
|
||||
ios: iosAddCircleOutlineSvg,
|
||||
md: mdAddCircleOutlineSvg
|
||||
};
|
||||
|
||||
export const logoFlickr = logoFlickrSvg;
|
||||
*/
|
||||
|
||||
const esmOutput = [...esmImports.sort()];
|
||||
const cjsOutput = [];
|
||||
const dtsOutput = [];
|
||||
|
||||
const sortedKeys = Object.keys(moduleData).sort();
|
||||
|
||||
sortedKeys.forEach(key => {
|
||||
const d = moduleData[key];
|
||||
|
||||
const modes = Object.keys(d.modes).sort();
|
||||
|
||||
if (modes.length === 1) {
|
||||
const esm = `export var ${d.exportCommonName} = ${d.modes[modes[0]].modeImportName};`;
|
||||
esmOutput.push(esm);
|
||||
|
||||
const cjs = `exports.${d.exportCommonName} = ${d.modes[modes[0]].modeImportName};`;
|
||||
cjsOutput.push(cjs);
|
||||
|
||||
const dts = `export declare const ${d.exportCommonName}: string;`;
|
||||
dtsOutput.push(dts);
|
||||
|
||||
} else {
|
||||
const esm = `export var ${d.exportCommonName} = {`
|
||||
esmOutput.push(esm);
|
||||
|
||||
const cjs = `exports.${d.exportCommonName} = {`;
|
||||
cjsOutput.push(cjs);
|
||||
|
||||
const dts = `export declare const ${d.exportCommonName}: {`;
|
||||
dtsOutput.push(dts);
|
||||
if (modes.length > 1) {
|
||||
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 ? ',' : '';
|
||||
|
||||
esmOutput.push(` ${mode}: ${d.modes[mode].modeImportName}${suffix}`);
|
||||
cjsOutput.push(` ${mode}: ${d.modes[mode].modeImportName}${suffix}`);
|
||||
dtsOutput.push(` ${mode}: string;`);
|
||||
const svgContent = getDataUrl(d.modes[mode].fileName);
|
||||
|
||||
esm.push(` ${mode}: ${svgContent}${suffix}`);
|
||||
cjs.push(` ${mode}: ${svgContent}${suffix}`);
|
||||
|
||||
dts.push(` ${mode}: string;`);
|
||||
}
|
||||
|
||||
esmOutput.push(`};`);
|
||||
cjsOutput.push(`};`);
|
||||
dtsOutput.push(`};`);
|
||||
esm.push(`};`);
|
||||
cjs.push(`};`);
|
||||
dts.push(`};`);
|
||||
|
||||
} else {
|
||||
const svgContent = getDataUrl(d.fileName);
|
||||
|
||||
esm.push(`export const ${d.exportCommonName} = ${svgContent};`);
|
||||
|
||||
cjs.push(`exports.${d.exportCommonName} = ${svgContent};`);
|
||||
|
||||
dts.push(`export declare var ${d.exportCommonName}: string;`);
|
||||
}
|
||||
});
|
||||
|
||||
fs.writeFileSync(DST_ESM, esmOutput.join('\n') + '\n');
|
||||
fs.writeFileSync(DST_CJS, cjsOutput.join('\n') + '\n');
|
||||
fs.writeFileSync(DST_DTS, dtsOutput.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",
|
||||
"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}"`;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { setMode } from '@stencil/core';
|
||||
|
||||
setMode((el: any) => el.tagName === 'ION-ICON' ? el.mode || el.getAttribute('mode') : null);
|
||||
export default () => {
|
||||
setMode((el: any) => el.tagName === 'ION-ICON' ? el.mode || el.getAttribute('mode') : null);
|
||||
};
|
||||
|
||||
@@ -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