mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-11-30 16:48:16 +01:00
feat(): using shadow-dom
This commit is contained in:
Generated
+2025
-2036
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -20,13 +20,13 @@
|
||||
"copy.tasks": "node scripts/copy-tasks.js",
|
||||
"dev": "npm run build && sd concurrent \"stencil build --dev --es5 --config src/docs/stencil.config.js --watch\" \"stencil-dev-server\" ",
|
||||
"mode.comparison": "node scripts/mode-comparison.js",
|
||||
"generate": "python scripts/generate.py",
|
||||
"generate": "python2 scripts/generate.py",
|
||||
"release": "npm run build && np --any-branch",
|
||||
"test": "jest",
|
||||
"test.watch": "jest --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@stencil/core": "^0.9.2",
|
||||
"@stencil/core": "^0.9.7",
|
||||
"@stencil/dev-server": "latest",
|
||||
"@stencil/router": "^0.1.6",
|
||||
"@stencil/sass": "0.0.4",
|
||||
|
||||
@@ -93,10 +93,7 @@
|
||||
|
||||
ion-icon {
|
||||
display: block;
|
||||
min-height: 38px;
|
||||
}
|
||||
|
||||
ion-icon svg {
|
||||
margin: 5px 0;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
@@ -109,16 +106,13 @@
|
||||
|
||||
.heart {
|
||||
display: inline-block;
|
||||
|
||||
}
|
||||
|
||||
.heart svg {
|
||||
display: inline-block;
|
||||
padding-top: 4px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
fill: red;
|
||||
color: red;
|
||||
vertical-align: sub;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="ionicons.js"></script>
|
||||
</head>
|
||||
|
||||
Vendored
+4
-1
@@ -13,9 +13,12 @@ declare global {
|
||||
}
|
||||
namespace JSXElements {}
|
||||
|
||||
interface HTMLElement {
|
||||
componentOnReady?: () => Promise<this | null>;
|
||||
}
|
||||
|
||||
interface HTMLStencilElement extends HTMLElement {
|
||||
componentOnReady(): Promise<this>;
|
||||
componentOnReady(done: (ele?: this) => void): void;
|
||||
|
||||
forceUpdate(): void;
|
||||
}
|
||||
|
||||
@@ -1,120 +1,73 @@
|
||||
ion-icon {
|
||||
:host {
|
||||
display: inline-block;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
ion-icon .icon-inner,
|
||||
ion-icon svg {
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
|
||||
contain: strict;
|
||||
|
||||
--ion-color-base: currentColor;
|
||||
}
|
||||
|
||||
ion-icon svg {
|
||||
fill: currentColor;
|
||||
stroke: currentColor;
|
||||
}
|
||||
|
||||
.icon-small .icon-inner {
|
||||
:host(.icon-small) {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.icon-large .icon-inner {
|
||||
:host(.icon-large){
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.icon-inner {
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
.icon-inner,
|
||||
svg {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
svg {
|
||||
fill: var(--ion-color-base);
|
||||
stroke: var(--ion-color-base);
|
||||
}
|
||||
|
||||
/* Set iOS Icon Colors */
|
||||
/* ------------------- */
|
||||
|
||||
.icon-ios-primary svg {
|
||||
fill: var(--ion-color-ios-primary, var(--ion-color-primary, #3880ff));
|
||||
stroke: var(--ion-color-ios-primary, var(--ion-color-primary, #3880ff));
|
||||
:host(.ion-color-primary) {
|
||||
--ion-color-base: var(--ion-color-primary, #3880ff);
|
||||
}
|
||||
|
||||
.icon-ios-secondary svg {
|
||||
fill: var(--ion-color-ios-secondary, var(--ion-color-secondary, #0cd1e8));
|
||||
stroke: var(--ion-color-ios-secondary, var(--ion-color-secondary, #0cd1e8));
|
||||
:host(.ion-color-secondary) {
|
||||
--ion-color-base: var(--ion-color-secondary, #0cd1e8);
|
||||
}
|
||||
|
||||
.icon-ios-tertiary svg {
|
||||
fill: var(--ion-color-ios-tertiary, var(--ion-color-tertiary, #f4a942));
|
||||
stroke: var(--ion-color-ios-tertiary, var(--ion-color-tertiary, #f4a942));
|
||||
:host(.ion-color-tertiary) {
|
||||
--ion-color-base: var(--ion-color-tertiary, #f4a942);
|
||||
}
|
||||
|
||||
.icon-ios-success svg {
|
||||
fill: var(--ion-color-ios-success, var(--ion-color-success, #10dc60));
|
||||
stroke: var(--ion-color-ios-success, var(--ion-color-success, #10dc60));
|
||||
:host(.ion-color-success) {
|
||||
--ion-color-base: var(--ion-color-success, #10dc60);
|
||||
}
|
||||
|
||||
.icon-ios-warning svg {
|
||||
fill: var(--ion-color-ios-warning, var(--ion-color-warning, #ffce00));
|
||||
stroke: var(--ion-color-ios-warning, var(--ion-color-warning, #ffce00));
|
||||
:host(.ion-color-warning) {
|
||||
--ion-color-base: var(--ion-color-warning, #ffce00);
|
||||
}
|
||||
|
||||
.icon-ios-danger svg {
|
||||
fill: var(--ion-color-ios-danger, var(--ion-color-danger, #f14141));
|
||||
stroke: var(--ion-color-ios-danger, var(--ion-color-danger, #f14141));
|
||||
:host(.ion-color-danger) {
|
||||
--ion-color-base: var(--ion-color-danger, #f14141);
|
||||
}
|
||||
|
||||
.icon-ios-light svg {
|
||||
fill: var(--ion-color-ios-light, var(--ion-color-light, #f4f5f8));
|
||||
stroke: var(--ion-color-ios-light, var(--ion-color-light, #f4f5f8));
|
||||
:host(.ion-color-light) {
|
||||
--ion-color-base: var(--ion-color-light, #f4f5f8);
|
||||
}
|
||||
|
||||
.icon-ios-medium svg {
|
||||
fill: var(--ion-color-ios-medium, var(--ion-color-medium, #989aa2));
|
||||
stroke: var(--ion-color-ios-medium, var(--ion-color-medium, #989aa2));
|
||||
:host(.ion-color-medium) {
|
||||
--ion-color-base: var(--ion-color-medium, #989aa2);
|
||||
}
|
||||
|
||||
.icon-ios-dark svg {
|
||||
fill: var(--ion-color-ios-dark, var(--ion-color-dark, #222428));
|
||||
stroke: var(--ion-color-ios-dark, var(--ion-color-dark, #222428));
|
||||
}
|
||||
|
||||
|
||||
/* Set Material Design Icon Colors */
|
||||
/* ------------------------------- */
|
||||
|
||||
.icon-md-primary svg {
|
||||
fill: var(--ion-color-md-primary, var(--ion-color-primary, #3880ff));
|
||||
stroke: var(--ion-color-md-primary, var(--ion-color-primary, #3880ff));
|
||||
}
|
||||
|
||||
.icon-md-secondary svg {
|
||||
fill: var(--ion-color-md-secondary, var(--ion-color-secondary, #0cd1e8));
|
||||
stroke: var(--ion-color-md-secondary, var(--ion-color-secondary, #0cd1e8));
|
||||
}
|
||||
|
||||
.icon-md-tertiary svg {
|
||||
fill: var(--ion-color-md-tertiary, var(--ion-color-tertiary, #f4a942));
|
||||
stroke: var(--ion-color-md-tertiary, var(--ion-color-tertiary, #f4a942));
|
||||
}
|
||||
|
||||
.icon-md-success svg {
|
||||
fill: var(--ion-color-md-success, var(--ion-color-success, #10dc60));
|
||||
stroke: var(--ion-color-md-success, var(--ion-color-success, #10dc60));
|
||||
}
|
||||
|
||||
.icon-md-warning svg {
|
||||
fill: var(--ion-color-md-warning, var(--ion-color-warning, #ffce00));
|
||||
stroke: var(--ion-color-md-warning, var(--ion-color-warning, #ffce00));
|
||||
}
|
||||
|
||||
.icon-md-danger svg {
|
||||
fill: var(--ion-color-md-danger, var(--ion-color-danger, #f14141));
|
||||
stroke: var(--ion-color-md-danger, var(--ion-color-danger, #f14141));
|
||||
}
|
||||
|
||||
.icon-md-light svg {
|
||||
fill: var(--ion-color-md-light, var(--ion-color-light, #f4f5f8));
|
||||
stroke: var(--ion-color-md-light, var(--ion-color-light, #f4f5f8));
|
||||
}
|
||||
|
||||
.icon-md-medium svg {
|
||||
fill: var(--ion-color-md-medium, var(--ion-color-medium, #989aa2));
|
||||
stroke: var(--ion-color-md-medium, var(--ion-color-medium, #989aa2));
|
||||
}
|
||||
|
||||
.icon-md-dark svg {
|
||||
fill: var(--ion-color-md-dark, var(--ion-color-dark, #222428));
|
||||
stroke: var(--ion-color-md-dark, var(--ion-color-dark, #222428));
|
||||
:host(.ion-color-dark) {
|
||||
--ion-color-base: var(--ion-color-dark, #222428);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ import { Component, Element, Prop, State, Watch } from '@stencil/core';
|
||||
|
||||
@Component({
|
||||
tag: 'ion-icon',
|
||||
host: {
|
||||
theme: 'icon'
|
||||
},
|
||||
assetsDir: 'svg',
|
||||
styleUrl: 'icon.css'
|
||||
styleUrl: 'icon.css',
|
||||
shadow: true
|
||||
})
|
||||
export class Icon {
|
||||
@Element() el: HTMLElement;
|
||||
@@ -15,8 +13,8 @@ export class Icon {
|
||||
@State() private svgContent: string = null;
|
||||
@State() private isVisible: boolean;
|
||||
|
||||
@Prop({ context: 'isServer'}) isServer: boolean;
|
||||
@Prop({ context: 'resourcesUrl'}) resourcesUrl: string;
|
||||
@Prop({ context: 'isServer' }) isServer: boolean;
|
||||
@Prop({ context: 'resourcesUrl' }) resourcesUrl: string;
|
||||
@Prop({ context: 'mode' }) mode: string;
|
||||
@Prop({ context: 'document' }) doc: Document;
|
||||
@Prop({ context: 'window' }) win: any;
|
||||
@@ -26,7 +24,7 @@ export class Icon {
|
||||
/**
|
||||
* Specifies the label to use for accessibility. Defaults to the icon name.
|
||||
*/
|
||||
@Prop() ariaLabel = '';
|
||||
@Prop({mutable: true, reflectToAttr: true}) ariaLabel = '';
|
||||
|
||||
/**
|
||||
* Specifies which icon to use on `ios` mode.
|
||||
@@ -101,10 +99,22 @@ export class Icon {
|
||||
|
||||
if (url) {
|
||||
getSvgContent(url).then(svgContent => {
|
||||
this.svgContent = svgContent;
|
||||
this.svgContent = validateContent(this.doc, svgContent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.ariaLabel) {
|
||||
const name = getName(this.name, this.mode, this.ios, this.md);
|
||||
// user did not provide a label
|
||||
// come up with the label based on the icon name
|
||||
if (name) {
|
||||
this.ariaLabel = this.name
|
||||
.replace('ios-', '')
|
||||
.replace('md-', '')
|
||||
.replace(/\-/g, ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,30 +147,12 @@ export class Icon {
|
||||
}
|
||||
|
||||
hostData() {
|
||||
const attrs: {[attrName: string]: string} = {
|
||||
'role': 'img'
|
||||
};
|
||||
|
||||
if (!this.ariaLabel) {
|
||||
const name = getName(this.name, this.mode, this.ios, this.md);
|
||||
// user did not provide a label
|
||||
// come up with the label based on the icon name
|
||||
if (name) {
|
||||
attrs['aria-label'] = this.name
|
||||
.replace('ios-', '')
|
||||
.replace('md-', '')
|
||||
.replace(/\-/g, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
const iconClasses = {};
|
||||
if (this.size) {
|
||||
iconClasses[`icon-${this.size}`] = true;
|
||||
}
|
||||
|
||||
return {
|
||||
...attrs,
|
||||
class: iconClasses
|
||||
'role': 'img',
|
||||
class: {
|
||||
...createColorClasses(this.color),
|
||||
[`icon-${this.size}`]: !!this.size,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -170,7 +162,7 @@ export class Icon {
|
||||
// we've already loaded up this svg at one point
|
||||
// and the svg content we've loaded and assigned checks out
|
||||
// render this svg!!
|
||||
return <div class="icon-inner" innerHTML={validateContent(this.doc, this.svgContent)}></div>;
|
||||
return <div class="icon-inner" innerHTML={this.svgContent}></div>;
|
||||
}
|
||||
|
||||
// actively requesting the svg
|
||||
@@ -297,3 +289,10 @@ export function isValid(elm: HTMLElement) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function createColorClasses(color: string | undefined) {
|
||||
return (color) ? {
|
||||
'ion-color': true,
|
||||
[`ion-color-${color}`]: true
|
||||
} : null;
|
||||
}
|
||||
|
||||
Vendored
+4
-1
@@ -13,9 +13,12 @@ declare global {
|
||||
}
|
||||
namespace JSXElements {}
|
||||
|
||||
interface HTMLElement {
|
||||
componentOnReady?: () => Promise<this | null>;
|
||||
}
|
||||
|
||||
interface HTMLStencilElement extends HTMLElement {
|
||||
componentOnReady(): Promise<this>;
|
||||
componentOnReady(done: (ele?: this) => void): void;
|
||||
|
||||
forceUpdate(): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user