From a58d9fa2e163ddfa6c9a6dbc1eb97d79e12e1c99 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Wed, 8 May 2024 16:22:12 -0700 Subject: [PATCH] feat(many): expand global config for icons (#29373) Co-authored-by: Brandy Carney --- core/api.txt | 8 +- core/src/components.d.ts | 8 +- core/src/components/accordion/accordion.tsx | 7 +- .../components/back-button/back-button.tsx | 2 +- core/src/components/breadcrumb/breadcrumb.tsx | 8 +- core/src/components/datetime/datetime.tsx | 42 ++++++-- core/src/components/fab-button/fab-button.tsx | 6 +- .../input-password-toggle.tsx | 8 +- core/src/components/input/input.tsx | 30 +++++- core/src/components/item/item.tsx | 9 +- core/src/components/reorder/reorder.tsx | 20 +++- core/src/components/searchbar/searchbar.tsx | 62 +++++++++-- core/src/components/select/select.tsx | 60 +++++++++-- core/src/components/toggle/toggle.ios.scss | 2 + core/src/components/toggle/toggle.tsx | 58 ++++++++-- core/src/utils/config.ts | 102 ++++++++++++++++++ 16 files changed, 370 insertions(+), 62 deletions(-) diff --git a/core/api.txt b/core/api.txt index a22af182dcc..65124d53ce7 100644 --- a/core/api.txt +++ b/core/api.txt @@ -4,7 +4,7 @@ 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,theme,"ios" | "md" | "ionic",undefined,false,false -ion-accordion,prop,toggleIcon,string,chevronDown,false,false +ion-accordion,prop,toggleIcon,string | undefined,undefined,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 @@ -494,7 +494,7 @@ ion-fab,method,close,close() => Promise 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 | undefined,undefined,false,false ion-fab-button,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record | undefined,undefined,false,true ion-fab-button,prop,disabled,boolean,false,false,false ion-fab-button,prop,download,string | undefined,undefined,false,false @@ -669,7 +669,7 @@ ion-item,shadow ion-item,prop,button,boolean,false,false,false ion-item,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record | undefined,undefined,false,true ion-item,prop,detail,boolean | undefined,undefined,false,false -ion-item,prop,detailIcon,string,chevronForward,false,false +ion-item,prop,detailIcon,string | undefined,undefined,false,false ion-item,prop,disabled,boolean,false,false,false ion-item,prop,download,string | undefined,undefined,false,false ion-item,prop,href,string | undefined,undefined,false,false @@ -1282,7 +1282,7 @@ ion-searchbar,prop,animated,boolean,false,false,false ion-searchbar,prop,autocapitalize,string,'off',false,false ion-searchbar,prop,autocomplete,"name" | "email" | "tel" | "url" | "on" | "off" | "honorific-prefix" | "given-name" | "additional-name" | "family-name" | "honorific-suffix" | "nickname" | "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-country-code" | "tel-national" | "tel-area-code" | "tel-local" | "tel-extension" | "impp" | "photo",'off',false,false ion-searchbar,prop,autocorrect,"off" | "on",'off',false,false -ion-searchbar,prop,cancelButtonIcon,string,config.get('backButtonIcon', arrowBackSharp) as string,false,false +ion-searchbar,prop,cancelButtonIcon,string | undefined,undefined,false,false ion-searchbar,prop,cancelButtonText,string,'Cancel',false,false ion-searchbar,prop,clearIcon,string | undefined,undefined,false,false ion-searchbar,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record | undefined,undefined,false,true diff --git a/core/src/components.d.ts b/core/src/components.d.ts index a329698bd64..39e6460148c 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -96,7 +96,7 @@ export namespace Components { /** * The toggle icon to use. This icon will be rotated when the accordion is expanded or collapsed. */ - "toggleIcon": string; + "toggleIcon"?: string; /** * The slot inside of `ion-item` to place the toggle icon. Defaults to `"end"`. */ @@ -1153,7 +1153,7 @@ export namespace Components { /** * 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. */ - "closeIcon": string; + "closeIcon"?: string; /** * 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). */ @@ -1530,7 +1530,7 @@ export namespace Components { /** * The icon to use when `detail` is set to `true`. */ - "detailIcon": string; + "detailIcon"?: string; /** * If `true`, the user cannot interact with the item. */ @@ -2989,7 +2989,7 @@ export namespace Components { /** * Set the cancel button icon. Only available when the theme is `"md"`. Defaults to `"arrow-back-sharp"`. */ - "cancelButtonIcon": string; + "cancelButtonIcon"?: string; /** * Set the the cancel button text. Only available when the theme is `"ios"`. */ diff --git a/core/src/components/accordion/accordion.tsx b/core/src/components/accordion/accordion.tsx index a74aaa95926..891c7aafd45 100644 --- a/core/src/components/accordion/accordion.tsx +++ b/core/src/components/accordion/accordion.tsx @@ -79,7 +79,7 @@ export class Accordion implements ComponentInterface { * rotated when the accordion is expanded * or collapsed. */ - @Prop() toggleIcon = chevronDown; + @Prop() toggleIcon?: string; /** * The slot inside of `ion-item` to @@ -193,7 +193,8 @@ export class Accordion implements ComponentInterface { return; } - const { toggleIconSlot, toggleIcon } = this; + const { toggleIconSlot } = this; + const accordionToggleIcon = this.toggleIcon ?? config.get('accordionToggleIcon', chevronDown); /** * Check if there already is a toggle icon. @@ -208,7 +209,7 @@ export class Accordion implements ComponentInterface { iconEl.slot = toggleIconSlot; iconEl.lazy = false; iconEl.classList.add('ion-accordion-toggle-icon'); - iconEl.icon = toggleIcon; + iconEl.icon = accordionToggleIcon; iconEl.setAttribute('aria-hidden', 'true'); ionItem.appendChild(iconEl); diff --git a/core/src/components/back-button/back-button.tsx b/core/src/components/back-button/back-button.tsx index f9824603fd3..f2e1c0731fb 100644 --- a/core/src/components/back-button/back-button.tsx +++ b/core/src/components/back-button/back-button.tsx @@ -82,7 +82,7 @@ export class BackButton implements ComponentInterface, ButtonInterface { get backButtonIcon() { const icon = this.icon; if (icon != null) { - // icon is set on the component or by the config + // Icon is set on the component or by the config. return icon; } diff --git a/core/src/components/breadcrumb/breadcrumb.tsx b/core/src/components/breadcrumb/breadcrumb.tsx index 0833a0dd02d..1f396314c0b 100644 --- a/core/src/components/breadcrumb/breadcrumb.tsx +++ b/core/src/components/breadcrumb/breadcrumb.tsx @@ -5,6 +5,7 @@ import { inheritAriaAttributes } from '@utils/helpers'; import { createColorClasses, hostContext, openURL } from '@utils/theme'; import { chevronForwardOutline, ellipsisHorizontal } from 'ionicons/icons'; +import { config } from '../../global/config'; import { getIonTheme } from '../../global/ionic-global'; import type { AnimationBuilder, Color } from '../../interface'; import type { RouterDirection } from '../router/utils/interface'; @@ -167,6 +168,9 @@ export class Breadcrumb implements ComponentInterface { const clickable = this.isClickable(); const TagType = this.href === undefined ? 'span' : ('a' as any); + const breadcrumbSeparatorIcon = config.get('breadcrumbSeparatorIcon', chevronForwardOutline); + const breadcrumbCollapsedIcon = config.get('breadcrumbCollapsedIcon', ellipsisHorizontal); + // Links can still be tabbed to when set to disabled if they have an href // in order to truly disable them we can keep it as an anchor but remove the href const href = disabled ? undefined : this.href; @@ -224,7 +228,7 @@ export class Breadcrumb implements ComponentInterface { 'breadcrumbs-collapsed-indicator': true, }} > - + )} {showSeparator && ( @@ -236,7 +240,7 @@ export class Breadcrumb implements ComponentInterface {