diff --git a/docs/usage/index.html b/docs/usage/index.html
index 36220005..f1a668da 100644
--- a/docs/usage/index.html
+++ b/docs/usage/index.html
@@ -36,11 +36,13 @@
+
+
+
-
-
+
diff --git a/package.json b/package.json
index b1d513c7..1a61bad9 100755
--- a/package.json
+++ b/package.json
@@ -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": [
diff --git a/scripts/build-css.js b/scripts/build-css.js
index f8bcc7c9..40eb19d2 100644
--- a/scripts/build-css.js
+++ b/scripts/build-css.js
@@ -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');
diff --git a/src/components/components.d.ts b/src/components/components.d.ts
index a4f3fdc1..efe681bc 100644
--- a/src/components/components.d.ts
+++ b/src/components/components.d.ts
@@ -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 {
/**
* 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 {}
-}
-
diff --git a/src/components/global.ts b/src/components/global.ts
new file mode 100644
index 00000000..7d6db1a5
--- /dev/null
+++ b/src/components/global.ts
@@ -0,0 +1,3 @@
+import { setMode } from '@stencil/core';
+
+setMode((el: any) => el.tagName === 'ION-ICON' ? el.mode || el.getAttribute('mode') : null);
diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx
index 2d63b0b6..910e488d 100755
--- a/src/components/icon/icon.tsx
+++ b/src/components/icon/icon.tsx
@@ -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) ?
- :
-
+ (Build.isBrowser && this.svgContent)
+ ?
+ :
)}
);
}
}
+const getIonMode = (ref: any) => {
+ return getMode(ref) || document.documentElement.getAttribute('mode') || 'md';
+};
+
const getNamedUrl = (name: string) => {
const url = getIconMap().get(name);
if (url) {
diff --git a/src/components/icon/readme.md b/src/components/icon/readme.md
index 5a59dbd6..9cd87520 100644
--- a/src/components/icon/readme.md
+++ b/src/components/icon/readme.md
@@ -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` |
----------------------------------------------
diff --git a/src/docs/site/components.d.ts b/src/docs/site/components.d.ts
index 3ebc4aeb..8cbe1fee 100644
--- a/src/docs/site/components.d.ts
+++ b/src/docs/site/components.d.ts
@@ -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) => void;
- 'query'?: string;
- 'version'?: string;
- }
- interface IconList extends JSXBase.HTMLAttributes {
- 'data'?: any;
- 'query'?: string;
- }
- interface IconSearch extends JSXBase.HTMLAttributes {
- 'autofocus'?: string;
- 'onHasSearched'?: (event: CustomEvent) => 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) => void;
- 'onToggleHeaderSearch'?: (event: CustomEvent) => 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 {}
+ interface HeaderBar extends JSXBase.HTMLAttributes {
+ 'isSearchVisible'?: boolean;
+ 'onToggleHeaderSearch'?: (event: CustomEvent) => void;
+ 'query'?: string;
+ 'version'?: string;
+ }
+ interface IconList extends JSXBase.HTMLAttributes {
+ 'data'?: any;
+ 'query'?: string;
+ }
+ interface IconSearch extends JSXBase.HTMLAttributes {
+ 'autofocus'?: string;
+ 'onHasSearched'?: (event: CustomEvent) => 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) => void;
+ 'onToggleHeaderSearch'?: (event: CustomEvent) => 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 {}
+ }
+}
+
+
diff --git a/src/docs/site/index.html b/src/docs/site/index.html
index 36220005..f1a668da 100644
--- a/src/docs/site/index.html
+++ b/src/docs/site/index.html
@@ -36,11 +36,13 @@
+
+
+
-
-
+
diff --git a/stencil.config.ts b/stencil.config.ts
index 87c66e5e..602991a8 100755
--- a/stencil.config.ts
+++ b/stencil.config.ts
@@ -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',