Compare commits

...
3 Commits
Author SHA1 Message Date
Manu Mtz.-Almeida 43b4fff014 4.4.4 2018-09-25 23:36:58 +02:00
Manu Mtz.-Almeida c14505fb28 chore(): update to latest stencil 2018-09-25 23:36:30 +02:00
Manu Mtz.-Almeida 7f4291e460 fix(webpack): fix warning 2018-09-25 22:52:59 +02:00
8 changed files with 133 additions and 146 deletions
+1 -3
View File
@@ -1,4 +1,2 @@
if (require && require.context) {
require.context('!!file-loader?name=[name].[ext]&outputPath=svg!./', false, /.svg$/);
}
require.context('!!file-loader?name=[name].[ext]&outputPath=svg!./', false, /.svg$/);
+8 -19
View File
@@ -1,6 +1,6 @@
{
"name": "ionicons",
"version": "4.4.3",
"version": "4.4.4",
"description": "Premium icons for Ionic.",
"files": [
"dist/"
@@ -24,21 +24,23 @@
"lint.ts": "tslint --project .",
"lint.ts.fix": "tslint --project . --fix",
"release": "np --any-branch --yolo",
"test": "jest",
"test.watch": "jest --watch"
"test": "stencil test --spec"
},
"devDependencies": {
"@stencil/core": "0.12.1",
"@stencil/core": "0.13.0-14",
"@stencil/router": "~0.2.2",
"@stencil/sass": "0.0.5",
"@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.2.0",
"jest": "23.5.0",
"node-sass": "4.9.0",
"np": "3.0.4",
"pixelmatch": "4.0.2",
"puppeteer": "1.7.0",
"svgo": "1.0.5",
"tslint": "^5.11.0",
"tslint-ionic-rules": "0.0.17"
@@ -72,18 +74,5 @@
"bugs": {
"url": "https://github.com/ionic-team/ionicons/issues"
},
"license": "MIT",
"jest": {
"transform": {
"^.+\\.(js|ts|tsx)$": "<rootDir>/node_modules/@stencil/core/testing/jest.preprocessor.js"
},
"testRegex": "src/.*\\.spec\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"d.ts"
]
}
"license": "MIT"
}
+1 -3
View File
@@ -49,8 +49,6 @@ fs.writeFileSync(DST_JSON, jsonContent);
const jsContent = `
if (require && require.context) {
require.context('!!file-loader?name=[name].[ext]&outputPath=svg!./', false, /\.svg$/);
}
require.context('!!file-loader?name=[name].[ext]&outputPath=svg!./', false, /\.svg$/);
`;
fs.writeFileSync(DST_JS, jsContent)
+14 -13
View File
@@ -1,8 +1,9 @@
/**
* This is an autogenerated file created by the Stencil compiler.
* It contains typing information for all components that exist in this project.
*/
/* tslint:disable */
/**
* This is an autogenerated file created by the Stencil compiler.
* It contains typing information for all components that exist in this project.
*/
import '@stencil/core';
@@ -15,19 +16,19 @@ export namespace Components {
/**
* Specifies the label to use for accessibility. Defaults to the icon name.
*/
'ariaLabel': string;
'ariaLabel'?: string;
/**
* The color to use for the background of the item.
*/
'color': string;
'color'?: string;
/**
* 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.
*/
'icon': string;
'icon'?: string;
/**
* Specifies which icon to use on `ios` mode.
*/
'ios': string;
'ios'?: string;
/**
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`.
*/
@@ -35,23 +36,23 @@ export namespace Components {
/**
* Specifies which icon to use on `md` mode.
*/
'md': string;
'md'?: string;
/**
* The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`.
*/
'mode': 'ios' | 'md';
'mode'?: 'ios' | 'md';
/**
* Specifies which icon to use from the built-in set of icons.
*/
'name': string;
'name'?: string;
/**
* The size of the icon. Available options are: `"small"` and `"large"`.
*/
'size': string;
'size'?: string;
/**
* Specifies the exact `src` of an SVG file to use.
*/
'src': string;
'src'?: string;
}
interface IonIconAttributes extends StencilHTMLAttributes {
/**
+28 -27
View File
@@ -1,4 +1,5 @@
import * as icon from './icon';
import { Icon } from './icon';
import { getName, getSrc, isValid } from './utils';
describe('isValid', () => {
@@ -10,7 +11,7 @@ describe('isValid', () => {
attributes: [{ value: 'onload' }],
childNodes: []
} as any;
expect(icon.isValid(el)).toBe(false);
expect(isValid(el)).toBe(false);
});
it('invalid onclick attr', () => {
@@ -20,46 +21,46 @@ describe('isValid', () => {
attributes: [{ value: 'OnClIcK' }],
childNodes: []
} as any;
expect(icon.isValid(el)).toBe(false);
expect(isValid(el)).toBe(false);
});
it('invalid child SCRIPT elm', () => {
const el = { nodeType: 1, nodeName: 'svg', attributes: [], childNodes: [
{ nodeType: 1, nodeName: 'SCRIPT', attributes: [], childNodes: [] }
] } as any;
expect(icon.isValid(el)).toBe(false);
expect(isValid(el)).toBe(false);
});
it('invalid script elm', () => {
const el = { nodeType: 1, nodeName: 'script', attributes: [], childNodes: [] } as any;
expect(icon.isValid(el)).toBe(false);
expect(isValid(el)).toBe(false);
});
it('is valid circle elm', () => {
const el = { nodeType: 1, nodeName: 'circle', attributes: [], childNodes: [] } as any;
expect(icon.isValid(el)).toBe(true);
expect(isValid(el)).toBe(true);
});
it('is valid SVG elm', () => {
const el = { nodeType: 1, nodeName: 'SVG', attributes: [], childNodes: [
{ nodeType: 1, nodeName: 'line', attributes: [], childNodes: [] }
] } as any;
expect(icon.isValid(el)).toBe(true);
expect(isValid(el)).toBe(true);
});
it('is valid text node', () => {
const el = { nodeType: 3, nodeName: '#text' } as any;
expect(icon.isValid(el)).toBe(true);
expect(isValid(el)).toBe(true);
});
});
describe('getUrl', () => {
let i: icon.Icon;
let i: Icon;
beforeEach(() => {
i = new icon.Icon();
i = new Icon();
i.resourcesUrl = '/build/ionicons/';
});
@@ -104,23 +105,23 @@ describe('getUrl', () => {
describe('getSrc', () => {
it('both . and /', () => {
expect(icon.getSrc('./somefile.svg')).toBe('./somefile.svg');
expect(getSrc('./somefile.svg')).toBe('./somefile.svg');
});
it('url', () => {
expect(icon.getSrc('https://ionicons/somefile.svg')).toBe('https://ionicons/somefile.svg');
expect(getSrc('https://ionicons/somefile.svg')).toBe('https://ionicons/somefile.svg');
});
it('just a .', () => {
expect(icon.getSrc('somefile.svg')).toBe('somefile.svg');
expect(getSrc('somefile.svg')).toBe('somefile.svg');
});
it('just a /', () => {
expect(icon.getSrc('/somesvg')).toBe('/somesvg');
expect(getSrc('/somesvg')).toBe('/somesvg');
});
it('no . or /', () => {
expect(icon.getSrc('some-name')).toBe(null);
expect(getSrc('some-name')).toBe(null);
});
});
@@ -129,39 +130,39 @@ describe('getSrc', () => {
describe('getName', () => {
it('not allow special chars', () => {
expect(icon.getName('some\\name', 'io', '', '')).toBe(null);
expect(icon.getName('some$name', 'io', '', '')).toBe(null);
expect(icon.getName('some:name', 'io', '', '')).toBe(null);
expect(icon.getName('some.name', 'io', '', '')).toBe(null);
expect(icon.getName('some/name', 'io', '', '')).toBe(null);
expect(getName('some\\name', 'io', '', '')).toBe(null);
expect(getName('some$name', 'io', '', '')).toBe(null);
expect(getName('some:name', 'io', '', '')).toBe(null);
expect(getName('some.name', 'io', '', '')).toBe(null);
expect(getName('some/name', 'io', '', '')).toBe(null);
});
it('use ios mode from mode property', () => {
expect(icon.getName('some-name', 'ios', '', '')).toBe('ios-some-name');
expect(getName('some-name', 'ios', '', '')).toBe('ios-some-name');
});
it('use md mode from mode property', () => {
expect(icon.getName('some-name', 'md', '', '')).toBe('md-some-name');
expect(getName('some-name', 'md', '', '')).toBe('md-some-name');
});
it('use ios mode prefixed', () => {
expect(icon.getName('ios-some-name', '', '', '')).toBe('ios-some-name');
expect(getName('ios-some-name', '', '', '')).toBe('ios-some-name');
});
it('use md mode prefixed', () => {
expect(icon.getName('md-some-name', '', '', '')).toBe('md-some-name');
expect(getName('md-some-name', '', '', '')).toBe('md-some-name');
});
it('always lowercase name and mode', () => {
expect(icon.getName('SOME-NAME', 'IOS', '', '')).toBe('ios-some-name');
expect(getName('SOME-NAME', 'IOS', '', '')).toBe('ios-some-name');
});
it('default md name w/out mode, ios or md', () => {
expect(icon.getName('some-name', '', '', '')).toBe('md-some-name');
expect(getName('some-name', '', '', '')).toBe('md-some-name');
});
it('should not use name if no name, ios or md', () => {
expect(icon.getName('', '', '', '')).toBe(null);
expect(getName('', '', '', '')).toBe(null);
});
});
+1 -74
View File
@@ -1,4 +1,5 @@
import { Component, Element, Prop, State, Watch } from '@stencil/core';
import { getName, getSrc, isValid } from './utils';
@Component({
@@ -217,57 +218,6 @@ function getSvgContent(url: string) {
}
export function getName(
name: string | undefined,
mode: string | undefined,
ios: string | undefined,
md: string | undefined
) {
// default to "md" if somehow the mode wasn't set
mode = (mode || 'md').toLowerCase();
// if an icon was passed in using the ios or md attributes
// set the iconName to whatever was passed in
if (ios && mode === 'ios') {
name = ios.toLowerCase();
} else if (md && mode === 'md') {
name = md.toLowerCase();
} else if (name) {
name = name.toLowerCase();
if (!/^md-|^ios-|^logo-/.test(name)) {
// this does not have one of the defaults
// so lets auto add in the mode prefix for them
name = `${mode}-${name}`;
}
}
if (typeof name !== 'string' || name.trim() === '') {
return null;
}
// only allow alpha characters and dash
const invalidChars = name.replace(/[a-z]|-|\d/gi, '');
if (invalidChars !== '') {
return null;
}
return name;
}
export function getSrc(src: string | undefined) {
if (typeof src === 'string') {
src = src.trim();
if (src.length > 0 && /(\/|\.)/.test(src)) {
return src;
}
}
return null;
}
function validateContent(
document: Document,
svgContent: string | null,
@@ -303,29 +253,6 @@ function validateContent(
return '';
}
export function isValid(elm: HTMLElement) {
if (elm.nodeType === 1) {
if (elm.nodeName.toLowerCase() === 'script') {
return false;
}
for (let i = 0; i < elm.attributes.length; i++) {
const val = elm.attributes[i].value;
if (typeof val === 'string' && val.toLowerCase().indexOf('on') === 0) {
return false;
}
}
for (let i = 0; i < elm.childNodes.length; i++) {
if (!isValid(elm.childNodes[i] as any)) {
return false;
}
}
}
return true;
}
function createColorClasses(color: string | undefined) {
return (color) ? {
'ion-color': true,
+72
View File
@@ -0,0 +1,72 @@
export function getName(
name: string | undefined,
mode: string | undefined,
ios: string | undefined,
md: string | undefined
) {
// default to "md" if somehow the mode wasn't set
mode = (mode || 'md').toLowerCase();
// if an icon was passed in using the ios or md attributes
// set the iconName to whatever was passed in
if (ios && mode === 'ios') {
name = ios.toLowerCase();
} else if (md && mode === 'md') {
name = md.toLowerCase();
} else if (name) {
name = name.toLowerCase();
if (!/^md-|^ios-|^logo-/.test(name)) {
// this does not have one of the defaults
// so lets auto add in the mode prefix for them
name = `${mode}-${name}`;
}
}
if (typeof name !== 'string' || name.trim() === '') {
return null;
}
// only allow alpha characters and dash
const invalidChars = name.replace(/[a-z]|-|\d/gi, '');
if (invalidChars !== '') {
return null;
}
return name;
}
export function getSrc(src: string | undefined) {
if (typeof src === 'string') {
src = src.trim();
if (src.length > 0 && /(\/|\.)/.test(src)) {
return src;
}
}
return null;
}
export function isValid(elm: HTMLElement) {
if (elm.nodeType === 1) {
if (elm.nodeName.toLowerCase() === 'script') {
return false;
}
for (let i = 0; i < elm.attributes.length; i++) {
const val = elm.attributes[i].value;
if (typeof val === 'string' && val.toLowerCase().indexOf('on') === 0) {
return false;
}
}
for (let i = 0; i < elm.childNodes.length; i++) {
if (!isValid(elm.childNodes[i] as any)) {
return false;
}
}
}
return true;
}
+8 -7
View File
@@ -1,13 +1,14 @@
/**
* This is an autogenerated file created by the Stencil compiler.
* It contains typing information for all components that exist in this project.
*/
/* tslint:disable */
/**
* This is an autogenerated file created by the Stencil compiler.
* It contains typing information for all components that exist in this project.
*/
import '@stencil/core';
import '@stencil/router'
import '@stencil/state-tunnel'
import '@stencil/router';
import '@stencil/state-tunnel';
import {
MatchResults,
} from '@stencil/router';
@@ -87,7 +88,7 @@ export namespace Components {
interface UsagePage {
'data': any;
'match': MatchResults;
'match'?: MatchResults;
}
interface UsagePageAttributes extends StencilHTMLAttributes {
'data'?: any;