Compare commits

...
9 Commits
Author SHA1 Message Date
Liam DeBeasi 24caaad7d9 fix(build): add old ionicons.js file (#982) 2021-06-17 09:51:50 -04:00
Liam DeBeasi 8c2a507fcf 5.5.1 2021-03-22 14:11:16 -04:00
Liam DeBeasi c76f2a2556 fix(): adding aria-hidden no longer disables automatic rtl switching (#954) 2021-03-22 14:09:03 -04:00
Rafael Kraut 0d7f507677 chore: add tag "globe" to earth (#919) 2021-02-09 16:14:09 -06:00
Adam Bradley b3155d9603 5.5.0 2021-02-09 16:04:52 -06:00
Adam Bradley 9139a01e18 5.5.0-1 2021-02-02 09:46:20 -06:00
Adam Bradley 0541db0f28 chore: add "components/" to package json files 2021-02-02 09:45:34 -06:00
Adam Bradley 200678a619 5.5.0-0 2021-02-01 15:36:05 -06:00
Adam Bradley 66556ea45c feat(custom-elements): export ionicons/components
Also provide ionicons as a custom element which can be defined using `customElements.define()`

```
import { IonIcon } from "ionicons/components/ion-icon";
customElements.define("ion-icon", IonIcon);
```

The custom element build works the same as the lazy load build, and is also able to lazy load svgs on demand, either by giving it an exact url in the `src` attribute `<ion-icon src="./path/to/airplane.svg"></ion-icon>`, or by providing the name of the ionicon to load `<ion-icon name="airplane"></ion-icon>`.

If using the `name` attribute, you'll also need to set where to find the svg directory using `setAssetPath()`

```
import { setAssetPath } from "ionicons/components";
setAssetPath(location.href);
```
2021-02-01 15:28:33 -06:00
9 changed files with 1501 additions and 14751 deletions
+1
View File
@@ -10,6 +10,7 @@ log.txt
.idea/
.versions/
.vscode/
components/
node_modules/
tmp/
dist/
+1419 -14728
View File
File diff suppressed because it is too large Load Diff
+17 -14
View File
@@ -1,13 +1,14 @@
{
"name": "ionicons",
"version": "5.4.0",
"version": "5.5.1",
"description": "Premium icons for Ionic.",
"files": [
"components/",
"dist/",
"icons/"
],
"module": "dist/index.mjs",
"main": "dist/index.js",
"main": "./dist/index.cjs.js",
"module": "./dist/index.js",
"types": "dist/types/index.d.ts",
"unpkg": "dist/ionicons.js",
"collection": "dist/collection/collection-manifest.json",
@@ -22,17 +23,20 @@
"release": "np --no-2fa",
"version": "npm run build"
},
"dependencies": {
"@stencil/core": "^2.5.0"
},
"devDependencies": {
"@stencil/core": "^1.15.0",
"@types/fs-extra": "^9.0.1",
"@types/jest": "^26.0.14",
"@types/node": "^14.11.5",
"@types/fs-extra": "^9.0.6",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.22",
"@types/svgo": "^1.3.3",
"fs-extra": "9.0.1",
"jest": "^26.5.2",
"jest-cli": "^26.5.2",
"np": "^6.5.0",
"svgo": "1.3.2"
"fs-extra": "^9.1.0",
"jest": "^26.6.3",
"jest-cli": "^26.6.3",
"np": "^7.2.0",
"svgo": "1.3.2",
"typescript": "^4.1.3"
},
"keywords": [
"icon pack",
@@ -67,6 +71,5 @@
"license": "MIT",
"sideEffects": [
"icons/imports/"
],
"dependencies": {}
]
}
+1 -1
View File
@@ -1,5 +1,5 @@
import fs from 'fs-extra';
import { join, basename } from 'path';
import { join } from 'path';
import Svgo from 'svgo';
async function build(rootDir: string) {
+30 -2
View File
@@ -1,7 +1,6 @@
import fs from 'fs-extra';
import { join } from 'path';
async function collectionCopy(rootDir: string) {
// move optimized svgs to correct collection location
const optimizedSrc = join(rootDir, 'dist', 'ionicons', 'svg');
@@ -11,6 +10,35 @@ async function collectionCopy(rootDir: string) {
// we don't to copy the src svgs to collection
await fs.remove(join(rootDir, 'dist', 'collection', 'svg'));
const cePackageDir = join(rootDir, 'components');
const cePackageJsonPath = join(cePackageDir, 'package.json');
const ceCjsPath = join(cePackageDir, 'index.cjs.js');
const emptyCjs = `/*empty cjs*/`;
await fs.writeFile(ceCjsPath, emptyCjs);
const cePackageJson = {
name: 'ionicons/components',
description: 'Ionicons custom element.',
main: './index.cjs.js',
module: './index.js',
types: './index.d.ts',
private: true,
};
await fs.writeFile(cePackageJsonPath, JSON.stringify(cePackageJson, null, 2));
/**
* TODO: Remove this in Ionicons v6.0
* Stencil 2 removed the legacy loader,
* but that is what Ionicons users were using
* to load Ionicons from a CDN. The lines
* below will add in a legacy loader for users
* to use so there is no breaking change in usage.
*/
const installLoaderSrc = join(rootDir, 'scripts', 'install-loader.js');
const installLoaderDest = join(rootDir, 'dist', 'ionicons.js');
await fs.copyFile(installLoaderSrc, installLoaderDest)
// this is temporary!!!!
// removing the `type` from the d.ts export
// to make it easier for users migrating between
@@ -23,4 +51,4 @@ async function collectionCopy(rootDir: string) {
await fs.writeFile(typesDist, types);
}
collectionCopy(join(__dirname, '..'));
collectionCopy(join(__dirname, '..'));
+8 -5
View File
@@ -4,12 +4,13 @@ import { getName, getUrl } from './utils';
@Component({
tag: 'ion-icon',
assetsDir: 'svg',
assetsDirs: ['svg'],
styleUrl: 'icon.css',
shadow: true,
})
export class Icon {
private io?: IntersectionObserver;
private iconName: string | null = null;
@Element() el!: HTMLElement;
@@ -29,7 +30,7 @@ export class Icon {
/**
* Specifies the label to use for accessibility. Defaults to the icon name.
*/
@Prop({ mutable: true, reflectToAttr: true }) ariaLabel?: string;
@Prop({ mutable: true, reflect: true }) ariaLabel?: string;
/**
* Set the icon to hidden, respectively `true`, to remove it from the accessibility tree.
@@ -143,8 +144,9 @@ export class Icon {
}
}
const label = this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md);
if (!this.ariaLabel && this.ariaHidden !== 'true') {
const label = getName(this.name, this.icon, this.mode, this.ios, this.md);
// user did not provide a label
// come up with the label based on the icon name
if (label) {
@@ -154,11 +156,12 @@ export class Icon {
}
render() {
const { iconName } = this;
const mode = this.mode || 'md';
const flipRtl =
this.flipRtl ||
(this.ariaLabel &&
(this.ariaLabel.indexOf('arrow') > -1 || this.ariaLabel.indexOf('chevron') > -1) &&
(iconName &&
(iconName.indexOf('arrow') > -1 || iconName.indexOf('chevron') > -1) &&
this.flipRtl !== false);
return (
+16
View File
@@ -29,4 +29,20 @@ describe('icon', () => {
</ion-icon>
`);
});
it('renders rtl with aria-hidden', async () => {
const { root } = await newSpecPage({
components: [Icon],
direction: 'rtl',
html: `<ion-icon name="chevron-forward" aria-hidden="true"></ion-icon>`,
});
expect(root).toEqualHtml(`
<ion-icon class="md flip-rtl" name="chevron-forward" role="img" aria-hidden="true">
<mock:shadow-root>
<div class="icon-inner"></div>
</mock:shadow-root>
</ion-icon>
`);
});
});
+4 -1
View File
@@ -3752,13 +3752,15 @@
{
"name": "earth",
"tags": [
"earth"
"earth",
"globe"
]
},
{
"name": "earth-outline",
"tags": [
"earth",
"globe",
"outline"
]
},
@@ -3766,6 +3768,7 @@
"name": "earth-sharp",
"tags": [
"earth",
"globe",
"sharp"
]
},
+5
View File
@@ -2,11 +2,16 @@ import { Config } from '@stencil/core';
export const config: Config = {
namespace: 'ionicons',
buildEs5: 'prod',
outputTargets: [
{
type: 'dist',
empty: false,
},
{
type: 'dist-custom-elements',
dir: './components',
},
{
type: 'docs-readme',
},