mirror of
https://github.com/ionic-team/ionicons.git
synced 2026-11-30 16:48:16 +01:00
fix(): mode support
This commit is contained in:
@@ -36,11 +36,13 @@
|
||||
<meta name="msapplication-TileImage" content="/assets/img/meta/ms-icon-144x144.png">
|
||||
<meta name="theme-color" content="#16161d">
|
||||
|
||||
<script type="module" src="/build/docssite.esm.js"></script>
|
||||
<script nomodule src="/build/docssite.js"></script>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:500" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/ionicons.min.css">
|
||||
<link rel="stylesheet" href="/build/docssite.css">
|
||||
<script type="module" src="/build/docssite.esm.js"></script>
|
||||
<script nomodule src="/build/docssite.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
+14
-13
@@ -11,6 +11,7 @@
|
||||
"types": "dist/types/index.d.ts",
|
||||
"unpkg": "dist/ionicons.js",
|
||||
"collection": "dist/collection/collection-manifest.json",
|
||||
"collection:main": "dist/collection/index.js",
|
||||
"scripts": {
|
||||
"build": "npm run clean && npm run lint.ts && npm run build.icon && npm run generate && npm run build.data && npm run build.css && npm run build.docs && npm run copy.tasks && npm run test",
|
||||
"build.css": "node scripts/build-css.js",
|
||||
@@ -33,24 +34,24 @@
|
||||
"test": "stencil test --spec"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@stencil/core": "one",
|
||||
"@stencil/core": "1.0.0",
|
||||
"@stencil/router": "one",
|
||||
"@stencil/sass": "latest",
|
||||
"@types/highlight.js": "^9.12.3",
|
||||
"@types/jest": "^23.1.3",
|
||||
"@types/puppeteer": "1.6.4",
|
||||
"archiver": "^2.1.1",
|
||||
"fs-extra": "4.0.2",
|
||||
"highlight.js": "^9.12.0",
|
||||
"jest": "23.6.0",
|
||||
"jest-cli": "23.6.0",
|
||||
"node-sass": "4.9.3",
|
||||
"np": "3.0.4",
|
||||
"@types/jest": "24.0.13",
|
||||
"@types/puppeteer": "1.12.4",
|
||||
"archiver": "^3.0.0",
|
||||
"fs-extra": "8.0.1",
|
||||
"highlight.js": "^9.15.8",
|
||||
"jest": "24.8.0",
|
||||
"jest-cli": "24.8.0",
|
||||
"np": "5.0.3",
|
||||
"pixelmatch": "4.0.2",
|
||||
"puppeteer": "1.7.0",
|
||||
"svgo": "1.1.1",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-ionic-rules": "0.0.20",
|
||||
"sass": "^1.20.3",
|
||||
"svgo": "1.2.2",
|
||||
"tslint": "^5.17.0",
|
||||
"tslint-ionic-rules": "0.0.21",
|
||||
"workbox-build": "4.3.1"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var sass = require('node-sass');
|
||||
var sass = require('sass');
|
||||
var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
|
||||
@@ -10,7 +10,6 @@ fs.emptyDirSync(distCssDir);
|
||||
generateCss('ionicons');
|
||||
generateCss('ionicons-core');
|
||||
|
||||
|
||||
function generateCss(fileName) {
|
||||
var input = path.join(distScssDir, fileName + '.scss');
|
||||
var output = path.join(distCssDir, fileName + '.css');
|
||||
|
||||
Vendored
+18
-22
@@ -39,9 +39,9 @@ export namespace Components {
|
||||
*/
|
||||
'md'?: string;
|
||||
/**
|
||||
* The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`.
|
||||
* The mode determines which platform styles to use.
|
||||
*/
|
||||
'mode'?: 'ios' | 'md';
|
||||
'mode'?: "ios" | "md";
|
||||
/**
|
||||
* Specifies which icon to use from the built-in set of icons.
|
||||
*/
|
||||
@@ -57,8 +57,21 @@ export namespace Components {
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
|
||||
interface HTMLIonIconElement extends Components.IonIcon, HTMLStencilElement {}
|
||||
var HTMLIonIconElement: {
|
||||
prototype: HTMLIonIconElement;
|
||||
new (): HTMLIonIconElement;
|
||||
};
|
||||
interface HTMLElementTagNameMap {
|
||||
'ion-icon': HTMLIonIconElement;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace LocalJSX {
|
||||
interface IonIcon extends JSXBase.HTMLAttributes {
|
||||
interface IonIcon extends JSXBase.HTMLAttributes<HTMLIonIconElement> {
|
||||
/**
|
||||
* Specifies the label to use for accessibility. Defaults to the icon name.
|
||||
*/
|
||||
@@ -88,9 +101,9 @@ declare namespace LocalJSX {
|
||||
*/
|
||||
'md'?: string;
|
||||
/**
|
||||
* The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`.
|
||||
* The mode determines which platform styles to use.
|
||||
*/
|
||||
'mode'?: 'ios' | 'md';
|
||||
'mode'?: "ios" | "md";
|
||||
/**
|
||||
* Specifies which icon to use from the built-in set of icons.
|
||||
*/
|
||||
@@ -120,20 +133,3 @@ declare module "@stencil/core" {
|
||||
}
|
||||
|
||||
|
||||
declare global {
|
||||
|
||||
|
||||
|
||||
interface HTMLIonIconElement extends Components.IonIcon, HTMLStencilElement {}
|
||||
var HTMLIonIconElement: {
|
||||
prototype: HTMLIonIconElement;
|
||||
new (): HTMLIonIconElement;
|
||||
};
|
||||
|
||||
interface HTMLElementTagNameMap {
|
||||
'ion-icon': HTMLIonIconElement;
|
||||
}
|
||||
|
||||
interface ElementTagNameMap extends HTMLElementTagNameMap {}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { setMode } from '@stencil/core';
|
||||
|
||||
setMode((el: any) => el.tagName === 'ION-ICON' ? el.mode || el.getAttribute('mode') : null);
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Build, Component, Element, Host, Prop, State, Watch, getAssetPath, h } from '@stencil/core';
|
||||
import { Build, Component, Element, Host, Prop, State, Watch, getAssetPath, getMode, h } from '@stencil/core';
|
||||
import { getIconMap, getName, getSrc, isSrc, isValid } from './utils';
|
||||
|
||||
/**
|
||||
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
|
||||
*/
|
||||
@Component({
|
||||
tag: 'ion-icon',
|
||||
assetsDir: 'svg',
|
||||
@@ -9,6 +12,7 @@ import { getIconMap, getName, getSrc, isSrc, isValid } from './utils';
|
||||
})
|
||||
export class Icon {
|
||||
private io?: IntersectionObserver;
|
||||
private mode = getIonMode(this);
|
||||
|
||||
@Element() el!: HTMLElement;
|
||||
|
||||
@@ -20,12 +24,6 @@ export class Icon {
|
||||
*/
|
||||
@Prop() color?: string;
|
||||
|
||||
/**
|
||||
* The mode determines which platform styles to use.
|
||||
* Possible values are: `"ios"` or `"md"`.
|
||||
*/
|
||||
@Prop() mode?: 'ios' | 'md';
|
||||
|
||||
/**
|
||||
* Specifies the label to use for accessibility. Defaults to the icon name.
|
||||
*/
|
||||
@@ -75,7 +73,7 @@ export class Icon {
|
||||
*/
|
||||
@Prop() lazy = false;
|
||||
|
||||
componentWillLoad() {
|
||||
connectedCallback() {
|
||||
// purposely do not return the promise here because loading
|
||||
// the svg file should not hold up loading the app
|
||||
// only load the svg if it's visible
|
||||
@@ -85,7 +83,7 @@ export class Icon {
|
||||
});
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
if (this.io) {
|
||||
this.io.disconnect();
|
||||
this.io = undefined;
|
||||
@@ -93,7 +91,7 @@ export class Icon {
|
||||
}
|
||||
|
||||
private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {
|
||||
if (this.lazy && typeof window !== 'undefined' && (window as any).IntersectionObserver) {
|
||||
if (Build.isBrowser && this.lazy && typeof window !== 'undefined' && (window as any).IntersectionObserver) {
|
||||
const io = this.io = new (window as any).IntersectionObserver((data: IntersectionObserverEntry[]) => {
|
||||
if (data[0].isIntersecting) {
|
||||
io.disconnect();
|
||||
@@ -139,7 +137,7 @@ export class Icon {
|
||||
}
|
||||
}
|
||||
|
||||
getName() {
|
||||
private getName() {
|
||||
if (this.name !== undefined) {
|
||||
return this.name;
|
||||
}
|
||||
@@ -149,7 +147,7 @@ export class Icon {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getUrl() {
|
||||
private getUrl() {
|
||||
let url = getSrc(this.src);
|
||||
if (url) {
|
||||
return url;
|
||||
@@ -168,7 +166,6 @@ export class Icon {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
const mode = this.mode || 'md';
|
||||
const flipRtl = this.flipRtl || (this.ariaLabel && this.ariaLabel.indexOf('arrow') > -1 && this.flipRtl !== false);
|
||||
@@ -180,15 +177,19 @@ export class Icon {
|
||||
[`icon-${this.size}`]: !!this.size,
|
||||
'flip-rtl': !!flipRtl && (this.el.ownerDocument as Document).dir === 'rtl'
|
||||
}}>{(
|
||||
(Build.isBrowser && this.svgContent) ?
|
||||
<div class="icon-inner" innerHTML={this.svgContent}></div> :
|
||||
<div class="icon-inner"></div>
|
||||
(Build.isBrowser && this.svgContent)
|
||||
? <div class="icon-inner" innerHTML={this.svgContent}></div>
|
||||
: <div class="icon-inner"></div>
|
||||
)}
|
||||
</Host>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const getIonMode = (ref: any) => {
|
||||
return getMode(ref) || document.documentElement.getAttribute('mode') || 'md';
|
||||
};
|
||||
|
||||
const getNamedUrl = (name: string) => {
|
||||
const url = getIconMap().get(name);
|
||||
if (url) {
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Attribute | Description | Type | Default |
|
||||
| ----------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------- | ----------- |
|
||||
| `ariaLabel` | `aria-label` | Specifies the label to use for accessibility. Defaults to the icon name. | `string \| undefined` | `undefined` |
|
||||
| `color` | `color` | The color to use for the background of the item. | `string \| undefined` | `undefined` |
|
||||
| `flipRtl` | `flip-rtl` | Specifies whether the icon should horizontally flip when `dir` is `"rtl"`. | `boolean \| undefined` | `undefined` |
|
||||
| `icon` | `icon` | A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property. | `string \| undefined` | `undefined` |
|
||||
| `ios` | `ios` | Specifies which icon to use on `ios` mode. | `string \| undefined` | `undefined` |
|
||||
| `lazy` | `lazy` | If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`. | `boolean` | `false` |
|
||||
| `md` | `md` | Specifies which icon to use on `md` mode. | `string \| undefined` | `undefined` |
|
||||
| `mode` | `mode` | The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`. | `"ios" \| "md" \| undefined` | `undefined` |
|
||||
| `name` | `name` | Specifies which icon to use from the built-in set of icons. | `string \| undefined` | `undefined` |
|
||||
| `size` | `size` | The size of the icon. Available options are: `"small"` and `"large"`. | `string \| undefined` | `undefined` |
|
||||
| `src` | `src` | Specifies the exact `src` of an SVG file to use. | `string \| undefined` | `undefined` |
|
||||
| Property | Attribute | Description | Type | Default |
|
||||
| ----------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------- | ----------- |
|
||||
| `ariaLabel` | `aria-label` | Specifies the label to use for accessibility. Defaults to the icon name. | `string \| undefined` | `undefined` |
|
||||
| `color` | `color` | The color to use for the background of the item. | `string \| undefined` | `undefined` |
|
||||
| `flipRtl` | `flip-rtl` | Specifies whether the icon should horizontally flip when `dir` is `"rtl"`. | `boolean \| undefined` | `undefined` |
|
||||
| `icon` | `icon` | A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property. | `string \| undefined` | `undefined` |
|
||||
| `ios` | `ios` | Specifies which icon to use on `ios` mode. | `string \| undefined` | `undefined` |
|
||||
| `lazy` | `lazy` | If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`. | `boolean` | `false` |
|
||||
| `md` | `md` | Specifies which icon to use on `md` mode. | `string \| undefined` | `undefined` |
|
||||
| `mode` | `mode` | The mode determines which platform styles to use. | `"ios" \| "md"` | `undefined` |
|
||||
| `name` | `name` | Specifies which icon to use from the built-in set of icons. | `string \| undefined` | `undefined` |
|
||||
| `size` | `size` | The size of the icon. Available options are: `"small"` and `"large"`. | `string \| undefined` | `undefined` |
|
||||
| `src` | `src` | Specifies the exact `src` of an SVG file to use. | `string \| undefined` | `undefined` |
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
Vendored
+62
-67
@@ -10,7 +10,6 @@ import {
|
||||
MatchResults,
|
||||
} from '@stencil/router';
|
||||
|
||||
|
||||
export namespace Components {
|
||||
interface FooterBar {}
|
||||
interface HeaderBar {
|
||||
@@ -47,72 +46,9 @@ export namespace Components {
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace LocalJSX {
|
||||
interface FooterBar extends JSXBase.HTMLAttributes {}
|
||||
interface HeaderBar extends JSXBase.HTMLAttributes {
|
||||
'isSearchVisible'?: boolean;
|
||||
'onToggleHeaderSearch'?: (event: CustomEvent<any>) => void;
|
||||
'query'?: string;
|
||||
'version'?: string;
|
||||
}
|
||||
interface IconList extends JSXBase.HTMLAttributes {
|
||||
'data'?: any;
|
||||
'query'?: string;
|
||||
}
|
||||
interface IconSearch extends JSXBase.HTMLAttributes {
|
||||
'autofocus'?: string;
|
||||
'onHasSearched'?: (event: CustomEvent<any>) => void;
|
||||
'query'?: string;
|
||||
'size'?: string;
|
||||
}
|
||||
interface IoniconsSite extends JSXBase.HTMLAttributes {}
|
||||
interface LandingPage extends JSXBase.HTMLAttributes {
|
||||
'data'?: any;
|
||||
'query'?: string;
|
||||
}
|
||||
interface NotfoundPage extends JSXBase.HTMLAttributes {}
|
||||
interface ToastBar extends JSXBase.HTMLAttributes {
|
||||
'onClearToast'?: (event: CustomEvent<any>) => void;
|
||||
'onToggleHeaderSearch'?: (event: CustomEvent<any>) => void;
|
||||
'selectedIcon'?: {
|
||||
name: string,
|
||||
icons: string[],
|
||||
tags: string[]
|
||||
};
|
||||
'selectedIconType'?: string;
|
||||
}
|
||||
interface UsagePage extends JSXBase.HTMLAttributes {
|
||||
'data'?: any;
|
||||
'match'?: MatchResults;
|
||||
}
|
||||
|
||||
interface IntrinsicElements {
|
||||
'footer-bar': FooterBar;
|
||||
'header-bar': HeaderBar;
|
||||
'icon-list': IconList;
|
||||
'icon-search': IconSearch;
|
||||
'ionicons-site': IoniconsSite;
|
||||
'landing-page': LandingPage;
|
||||
'notfound-page': NotfoundPage;
|
||||
'toast-bar': ToastBar;
|
||||
'usage-page': UsagePage;
|
||||
}
|
||||
}
|
||||
|
||||
export { LocalJSX as JSX };
|
||||
|
||||
|
||||
declare module "@stencil/core" {
|
||||
export namespace JSX {
|
||||
interface IntrinsicElements extends LocalJSX.IntrinsicElements {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
declare global {
|
||||
|
||||
|
||||
|
||||
interface HTMLFooterBarElement extends Components.FooterBar, HTMLStencilElement {}
|
||||
var HTMLFooterBarElement: {
|
||||
prototype: HTMLFooterBarElement;
|
||||
@@ -166,7 +102,6 @@ declare global {
|
||||
prototype: HTMLUsagePageElement;
|
||||
new (): HTMLUsagePageElement;
|
||||
};
|
||||
|
||||
interface HTMLElementTagNameMap {
|
||||
'footer-bar': HTMLFooterBarElement;
|
||||
'header-bar': HTMLHeaderBarElement;
|
||||
@@ -178,7 +113,67 @@ declare global {
|
||||
'toast-bar': HTMLToastBarElement;
|
||||
'usage-page': HTMLUsagePageElement;
|
||||
}
|
||||
|
||||
interface ElementTagNameMap extends HTMLElementTagNameMap {}
|
||||
}
|
||||
|
||||
declare namespace LocalJSX {
|
||||
interface FooterBar extends JSXBase.HTMLAttributes<HTMLFooterBarElement> {}
|
||||
interface HeaderBar extends JSXBase.HTMLAttributes<HTMLHeaderBarElement> {
|
||||
'isSearchVisible'?: boolean;
|
||||
'onToggleHeaderSearch'?: (event: CustomEvent<any>) => void;
|
||||
'query'?: string;
|
||||
'version'?: string;
|
||||
}
|
||||
interface IconList extends JSXBase.HTMLAttributes<HTMLIconListElement> {
|
||||
'data'?: any;
|
||||
'query'?: string;
|
||||
}
|
||||
interface IconSearch extends JSXBase.HTMLAttributes<HTMLIconSearchElement> {
|
||||
'autofocus'?: string;
|
||||
'onHasSearched'?: (event: CustomEvent<any>) => void;
|
||||
'query'?: string;
|
||||
'size'?: string;
|
||||
}
|
||||
interface IoniconsSite extends JSXBase.HTMLAttributes<HTMLIoniconsSiteElement> {}
|
||||
interface LandingPage extends JSXBase.HTMLAttributes<HTMLLandingPageElement> {
|
||||
'data'?: any;
|
||||
'query'?: string;
|
||||
}
|
||||
interface NotfoundPage extends JSXBase.HTMLAttributes<HTMLNotfoundPageElement> {}
|
||||
interface ToastBar extends JSXBase.HTMLAttributes<HTMLToastBarElement> {
|
||||
'onClearToast'?: (event: CustomEvent<any>) => void;
|
||||
'onToggleHeaderSearch'?: (event: CustomEvent<any>) => void;
|
||||
'selectedIcon'?: {
|
||||
name: string,
|
||||
icons: string[],
|
||||
tags: string[]
|
||||
};
|
||||
'selectedIconType'?: string;
|
||||
}
|
||||
interface UsagePage extends JSXBase.HTMLAttributes<HTMLUsagePageElement> {
|
||||
'data'?: any;
|
||||
'match'?: MatchResults;
|
||||
}
|
||||
|
||||
interface IntrinsicElements {
|
||||
'footer-bar': FooterBar;
|
||||
'header-bar': HeaderBar;
|
||||
'icon-list': IconList;
|
||||
'icon-search': IconSearch;
|
||||
'ionicons-site': IoniconsSite;
|
||||
'landing-page': LandingPage;
|
||||
'notfound-page': NotfoundPage;
|
||||
'toast-bar': ToastBar;
|
||||
'usage-page': UsagePage;
|
||||
}
|
||||
}
|
||||
|
||||
export { LocalJSX as JSX };
|
||||
|
||||
|
||||
declare module "@stencil/core" {
|
||||
export namespace JSX {
|
||||
interface IntrinsicElements extends LocalJSX.IntrinsicElements {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,11 +36,13 @@
|
||||
<meta name="msapplication-TileImage" content="/assets/img/meta/ms-icon-144x144.png">
|
||||
<meta name="theme-color" content="#16161d">
|
||||
|
||||
<script type="module" src="/build/docssite.esm.js"></script>
|
||||
<script nomodule src="/build/docssite.js"></script>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:500" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/ionicons.min.css">
|
||||
<link rel="stylesheet" href="/build/docssite.css">
|
||||
<script type="module" src="/build/docssite.esm.js"></script>
|
||||
<script nomodule src="/build/docssite.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Config } from '@stencil/core';
|
||||
export const config: Config = {
|
||||
namespace: 'ionicons',
|
||||
srcDir: 'src/components/',
|
||||
globalScript: 'src/components/global.ts',
|
||||
outputTargets: [
|
||||
{
|
||||
type: 'dist',
|
||||
|
||||
Reference in New Issue
Block a user