Skip to content

Commit

Permalink
perf(various): don't use lazy-loaded icon names in components (#24671)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandaejohnston committed Jan 28, 2022
1 parent bdb5c42 commit 484de50
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 125 deletions.
8 changes: 4 additions & 4 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ion-accordion,shadow
ion-accordion,prop,disabled,boolean,false,false,false
ion-accordion,prop,mode,"ios" | "md",undefined,false,false
ion-accordion,prop,readonly,boolean,false,false,false
ion-accordion,prop,toggleIcon,string,'chevron-down',false,false
ion-accordion,prop,toggleIcon,string,chevronDown,false,false
ion-accordion,prop,toggleIconSlot,"end" | "start",'end',false,false
ion-accordion,prop,value,string,`ion-accordion-${accordionIds++}`,false,false
ion-accordion,part,content
Expand Down Expand Up @@ -416,7 +416,7 @@ ion-fab,method,close,close() => Promise<void>

ion-fab-button,shadow
ion-fab-button,prop,activated,boolean,false,false,false
ion-fab-button,prop,closeIcon,string,'close',false,false
ion-fab-button,prop,closeIcon,string,close,false,false
ion-fab-button,prop,color,string | undefined,undefined,false,true
ion-fab-button,prop,disabled,boolean,false,false,false
ion-fab-button,prop,download,string | undefined,undefined,false,false
Expand Down Expand Up @@ -557,7 +557,7 @@ ion-item,prop,button,boolean,false,false,false
ion-item,prop,color,string | undefined,undefined,false,true
ion-item,prop,counter,boolean,false,false,false
ion-item,prop,detail,boolean | undefined,undefined,false,false
ion-item,prop,detailIcon,string,'chevron-forward',false,false
ion-item,prop,detailIcon,string,chevronForward,false,false
ion-item,prop,disabled,boolean,false,false,false
ion-item,prop,download,string | undefined,undefined,false,false
ion-item,prop,fill,"outline" | "solid" | undefined,undefined,false,false
Expand Down Expand Up @@ -1070,7 +1070,7 @@ ion-searchbar,scoped
ion-searchbar,prop,animated,boolean,false,false,false
ion-searchbar,prop,autocomplete,"off" | "on" | "name" | "honorific-prefix" | "given-name" | "additional-name" | "family-name" | "honorific-suffix" | "nickname" | "email" | "username" | "new-password" | "current-password" | "one-time-code" | "organization-title" | "organization" | "street-address" | "address-line1" | "address-line2" | "address-line3" | "address-level4" | "address-level3" | "address-level2" | "address-level1" | "country" | "country-name" | "postal-code" | "cc-name" | "cc-given-name" | "cc-additional-name" | "cc-family-name" | "cc-number" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-csc" | "cc-type" | "transaction-currency" | "transaction-amount" | "language" | "bday" | "bday-day" | "bday-month" | "bday-year" | "sex" | "tel" | "tel-country-code" | "tel-national" | "tel-area-code" | "tel-local" | "tel-extension" | "impp" | "url" | "photo",'off',false,false
ion-searchbar,prop,autocorrect,"off" | "on",'off',false,false
ion-searchbar,prop,cancelButtonIcon,string,config.get('backButtonIcon', 'arrow-back-sharp') as string,false,false
ion-searchbar,prop,cancelButtonIcon,string,config.get('backButtonIcon', arrowBackSharp) as string,false,false
ion-searchbar,prop,cancelButtonText,string,'Cancel',false,false
ion-searchbar,prop,clearIcon,string | undefined,undefined,false,false
ion-searchbar,prop,color,string | undefined,undefined,false,true
Expand Down
12 changes: 6 additions & 6 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2272,15 +2272,15 @@ export namespace Components {
*/
"autocorrect": 'on' | 'off';
/**
* Set the cancel button icon. Only applies to `md` mode. Defaults to `"arrow-back-sharp"`.
* Set the cancel button icon. Only applies to `md` mode. Defaults to `arrow-back-sharp`.
*/
"cancelButtonIcon": string;
/**
* Set the the cancel button text. Only applies to `ios` mode.
*/
"cancelButtonText": string;
/**
* Set the clear icon. Defaults to `"close-circle"` for `ios` and `"close-sharp"` for `md`.
* Set the clear icon. Defaults to `close-circle` for `ios` and `close-sharp` for `md`.
*/
"clearIcon"?: string;
/**
Expand Down Expand Up @@ -2316,7 +2316,7 @@ export namespace Components {
*/
"placeholder": string;
/**
* The icon to use as the search icon. Defaults to `"search-outline"` in `ios` mode and `"search-sharp"` in `md` mode.
* The icon to use as the search icon. Defaults to `search-outline` in `ios` mode and `search-sharp` in `md` mode.
*/
"searchIcon"?: string;
/**
Expand Down Expand Up @@ -5943,15 +5943,15 @@ declare namespace LocalJSX {
*/
"autocorrect"?: 'on' | 'off';
/**
* Set the cancel button icon. Only applies to `md` mode. Defaults to `"arrow-back-sharp"`.
* Set the cancel button icon. Only applies to `md` mode. Defaults to `arrow-back-sharp`.
*/
"cancelButtonIcon"?: string;
/**
* Set the the cancel button text. Only applies to `ios` mode.
*/
"cancelButtonText"?: string;
/**
* Set the clear icon. Defaults to `"close-circle"` for `ios` and `"close-sharp"` for `md`.
* Set the clear icon. Defaults to `close-circle` for `ios` and `close-sharp` for `md`.
*/
"clearIcon"?: string;
/**
Expand Down Expand Up @@ -6011,7 +6011,7 @@ declare namespace LocalJSX {
*/
"placeholder"?: string;
/**
* The icon to use as the search icon. Defaults to `"search-outline"` in `ios` mode and `"search-sharp"` in `md` mode.
* The icon to use as the search icon. Defaults to `search-outline` in `ios` mode and `search-sharp` in `md` mode.
*/
"searchIcon"?: string;
/**
Expand Down
3 changes: 2 additions & 1 deletion core/src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, ComponentInterface, Element, Host, Prop, State, h } from '@stencil/core';
import { chevronDown } from 'ionicons/icons';

import { config } from '../../global/config';
import { getIonMode } from '../../global/ionic-global';
Expand Down Expand Up @@ -71,7 +72,7 @@ export class Accordion implements ComponentInterface {
* rotated when the accordion is expanded
* or collapsed.
*/
@Prop() toggleIcon = 'chevron-down';
@Prop() toggleIcon = chevronDown;

/**
* The slot inside of `ion-item` to
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/accordion/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ export const AccordionExample {
| `disabled` | `disabled` | If `true`, the accordion cannot be interacted with. | `boolean` | `false` |
| `mode` | `mode` | The mode determines which platform styles to use. | `"ios" \| "md"` | `undefined` |
| `readonly` | `readonly` | If `true`, the accordion cannot be interacted with, but does not alter the opacity. | `boolean` | `false` |
| `toggleIcon` | `toggle-icon` | The toggle icon to use. This icon will be rotated when the accordion is expanded or collapsed. | `string` | `'chevron-down'` |
| `toggleIcon` | `toggle-icon` | The toggle icon to use. This icon will be rotated when the accordion is expanded or collapsed. | `string` | `chevronDown` |
| `toggleIconSlot` | `toggle-icon-slot` | The slot inside of `ion-item` to place the toggle icon. Defaults to `'end'`. | `"end" \| "start"` | `'end'` |
| `value` | `value` | The value of the accordion. Defaults to an autogenerated value. | `string` | ``ion-accordion-${accordionIds++}`` |

Expand Down
5 changes: 3 additions & 2 deletions core/src/components/back-button/back-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, ComponentInterface, Element, Host, Prop, h } from '@stencil/core';
import { arrowBackSharp, chevronBack } from 'ionicons/icons';

import { config } from '../../global/config';
import { getIonMode } from '../../global/ionic-global';
Expand Down Expand Up @@ -83,11 +84,11 @@ export class BackButton implements ComponentInterface, ButtonInterface {

if (getIonMode(this) === 'ios') {
// default ios back button icon
return config.get('backButtonIcon', 'chevron-back');
return config.get('backButtonIcon', chevronBack);
}

// default md back button icon
return config.get('backButtonIcon', 'arrow-back-sharp');
return config.get('backButtonIcon', arrowBackSharp);
}

get backButtonText() {
Expand Down
6 changes: 4 additions & 2 deletions core/src/components/back-button/test/back-button.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { arrowBackSharp, chevronBack } from 'ionicons/icons';

import { newSpecPage } from '@stencil/core/testing';
import { BackButton } from "../back-button";
import { config } from "../../../global/config";
Expand Down Expand Up @@ -46,12 +48,12 @@ describe('back button', () => {

it('default icon for ios mode', async () => {
const bb = await newBackButton('ios');
expect(bb.backButtonIcon).toBe('chevron-back');
expect(bb.backButtonIcon).toBe(chevronBack);
});

it('default icon', async () => {
const bb = await newBackButton();
expect(bb.backButtonIcon).toBe('arrow-back-sharp');
expect(bb.backButtonIcon).toBe(arrowBackSharp);
});

});
Expand Down
3 changes: 2 additions & 1 deletion core/src/components/fab-button/fab-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Prop, h } from '@stencil/core';
import { close } from 'ionicons/icons';

import { getIonMode } from '../../global/ionic-global';
import { AnimationBuilder, Color, RouterDirection } from '../../interface';
Expand Down Expand Up @@ -105,7 +106,7 @@ export class FabButton implements ComponentInterface, AnchorInterface, ButtonInt
* is pressed. Only applies if it is the main button inside of a fab containing a
* fab list.
*/
@Prop() closeIcon = 'close';
@Prop() closeIcon = close;

/**
* Emitted when the button has focus.
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/fab-button/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default defineComponent({
| Property | Attribute | Description | Type | Default |
| ----------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ----------- |
| `activated` | `activated` | If `true`, the fab button will be show a close icon. | `boolean` | `false` |
| `closeIcon` | `close-icon` | The icon name to use for the close icon. This will appear when the fab button is pressed. Only applies if it is the main button inside of a fab containing a fab list. | `string` | `'close'` |
| `closeIcon` | `close-icon` | The icon name to use for the close icon. This will appear when the fab button is pressed. Only applies if it is the main button inside of a fab containing a fab list. | `string` | `close` |
| `color` | `color` | The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). | `string \| undefined` | `undefined` |
| `disabled` | `disabled` | If `true`, the user cannot interact with the fab button. | `boolean` | `false` |
| `download` | `download` | This attribute instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. If the attribute has a value, it is used as the pre-filled file name in the Save prompt (the user can still change the file name if they want). | `string \| undefined` | `undefined` |
Expand Down
3 changes: 2 additions & 1 deletion core/src/components/item/item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, ComponentInterface, Element, Host, Listen, Prop, State, forceUpdate, h } from '@stencil/core';
import { chevronForward } from 'ionicons/icons';

import { getIonMode } from '../../global/ionic-global';
import { AnimationBuilder, Color, CssClassMap, RouterDirection, StyleEventDetail } from '../../interface';
Expand Down Expand Up @@ -61,7 +62,7 @@ export class Item implements ComponentInterface, AnchorInterface, ButtonInterfac
/**
* The icon to use when `detail` is set to `true`.
*/
@Prop() detailIcon = 'chevron-forward';
@Prop() detailIcon = chevronForward;

/**
* If `true`, the user cannot interact with the item.
Expand Down

0 comments on commit 484de50

Please sign in to comment.