mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-12-02 17:06:06 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8a17ea0db | ||
|
|
c9f08cd1c7 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ionicons",
|
||||
"version": "4.5.2",
|
||||
"version": "4.5.3",
|
||||
"description": "Premium icons for Ionic.",
|
||||
"files": [
|
||||
"dist/",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, Element, Prop, State, Watch } from '@stencil/core';
|
||||
import { getIconMap, getName, getSrc, isValid } from './utils';
|
||||
import { getIconMap, getName, getSrc, isSrc, isValid } from './utils';
|
||||
|
||||
@Component({
|
||||
tag: 'ion-icon',
|
||||
@@ -132,7 +132,7 @@ export class Icon {
|
||||
}
|
||||
|
||||
if (!this.ariaLabel) {
|
||||
const name = getName(this.name, this.mode, this.ios, this.md);
|
||||
const name = getName(this.getName(), this.mode, this.ios, this.md);
|
||||
// user did not provide a label
|
||||
// come up with the label based on the icon name
|
||||
if (name) {
|
||||
@@ -144,13 +144,23 @@ export class Icon {
|
||||
}
|
||||
}
|
||||
|
||||
getName() {
|
||||
if (this.name !== undefined) {
|
||||
return this.name;
|
||||
}
|
||||
if (this.icon && !isSrc(this.icon)) {
|
||||
return this.icon;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getUrl() {
|
||||
let url = getSrc(this.src);
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = getName(this.name, this.mode, this.ios, this.md);
|
||||
url = getName(this.getName(), this.mode, this.ios, this.md);
|
||||
if (url) {
|
||||
return this.getNamedUrl(url);
|
||||
}
|
||||
@@ -160,11 +170,6 @@ export class Icon {
|
||||
return url;
|
||||
}
|
||||
|
||||
url = getName(this.icon, this.mode, this.ios, this.md);
|
||||
if (url) {
|
||||
return this.getNamedUrl(url);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,13 +60,16 @@ export function getName(
|
||||
export function getSrc(src: string | undefined) {
|
||||
if (typeof src === 'string') {
|
||||
src = src.trim();
|
||||
if (src.length > 0 && /(\/|\.)/.test(src)) {
|
||||
if (isSrc(src)) {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isSrc(str: string) {
|
||||
return str.length > 0 && /(\/|\.)/.test(str);
|
||||
}
|
||||
|
||||
export function isValid(elm: HTMLElement) {
|
||||
if (elm.nodeType === 1) {
|
||||
|
||||
@@ -71,6 +71,28 @@
|
||||
<ion-icon icon="/ionicons/svg/md-image.svg"></ion-icon>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<code>
|
||||
<ion-icon icon="ios-baseball"></ion-icon>
|
||||
</code>
|
||||
<ion-icon icon="ios-baseball"></ion-icon>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<code>
|
||||
<ion-icon icon="md-baseball"></ion-icon>
|
||||
</code>
|
||||
<ion-icon icon="md-baseball"></ion-icon>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<code>
|
||||
<ion-icon icon="baseball"></ion-icon>
|
||||
</code>
|
||||
<ion-icon icon="baseball"></ion-icon>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<code>
|
||||
<ion-icon name="ios-airplane"></ion-icon>
|
||||
|
||||
Reference in New Issue
Block a user