From d824af31a1802cbc139cbf585b7b4329613658e6 Mon Sep 17 00:00:00 2001 From: Brandy Smith <6577830+brandyscarney@users.noreply.github.com> Date: Wed, 26 Mar 2025 11:54:32 -0400 Subject: [PATCH] feat(button): add subtle hue for the ionic theme --- core/api.txt | 1 + core/src/components.d.ts | 8 + core/src/components/button/button.ionic.scss | 19 ++ core/src/components/button/button.tsx | 23 +- .../components/button/test/basic/index.html | 241 ++++++++++-------- packages/angular/src/directives/proxies.ts | 4 +- .../standalone/src/directives/proxies.ts | 4 +- packages/vue/src/proxies.ts | 1 + 8 files changed, 194 insertions(+), 107 deletions(-) diff --git a/core/api.txt b/core/api.txt index 3db9b064b25..13ed1d71157 100644 --- a/core/api.txt +++ b/core/api.txt @@ -390,6 +390,7 @@ ion-button,prop,expand,"block" | "full" | undefined,undefined,false,true ion-button,prop,fill,"clear" | "default" | "outline" | "solid" | undefined,undefined,false,true ion-button,prop,form,HTMLFormElement | string | undefined,undefined,false,false ion-button,prop,href,string | undefined,undefined,false,false +ion-button,prop,hue,"bold" | "subtle" | undefined,'bold',false,false ion-button,prop,mode,"ios" | "md",undefined,false,false ion-button,prop,rel,string | undefined,undefined,false,false ion-button,prop,routerAnimation,((baseEl: any, opts?: any) => Animation) | undefined,undefined,false,false diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 1ce0b2fba36..afe452f461d 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -562,6 +562,10 @@ export namespace Components { * Contains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered. */ "href": string | undefined; + /** + * Set to `"bold"` for a button with vibrant, bold colors or to `"subtle"` for a button with muted, subtle colors. + */ + "hue"?: 'bold' | 'subtle'; /** * The mode determines the platform behaviors of the component. */ @@ -6019,6 +6023,10 @@ declare namespace LocalJSX { * Contains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered. */ "href"?: string | undefined; + /** + * Set to `"bold"` for a button with vibrant, bold colors or to `"subtle"` for a button with muted, subtle colors. + */ + "hue"?: 'bold' | 'subtle'; /** * The mode determines the platform behaviors of the component. */ diff --git a/core/src/components/button/button.ionic.scss b/core/src/components/button/button.ionic.scss index 93ccbbde884..b4fabe670d9 100644 --- a/core/src/components/button/button.ionic.scss +++ b/core/src/components/button/button.ionic.scss @@ -52,6 +52,12 @@ --ripple-color: var(--background-activated); } +:host(.button-solid.button-subtle) { + --background: #{globals.ion-color(primary, base, $subtle: true)}; + --background-activated: #{globals.ion-color(primary, shade, $subtle: true)}; + --color: #{globals.ion-color(primary, contrast, $subtle: true)}; +} + // Outline Button // -------------------------------------------------- @@ -81,6 +87,19 @@ // Ripple Effect // ------------------------------------------------------------------------------- +:host(.button-solid.button-subtle.ion-color) .button-native { + background: globals.current-color(base, $subtle: true); + color: globals.current-color(contrast, $subtle: true); +} + +:host(.button-solid.button-subtle.ion-color.ion-activated) .button-native::after { + background: globals.current-color(shade, $subtle: true); +} + +:host(.button-solid.button-subtle.ion-color.ion-focused) .button-native::after { + background: globals.current-color(tint, $subtle: true); +} + :host(.button-solid.ion-color) ion-ripple-effect { color: globals.current-color(shade); } diff --git a/core/src/components/button/button.tsx b/core/src/components/button/button.tsx index b6760263188..b735c7c47b5 100644 --- a/core/src/components/button/button.tsx +++ b/core/src/components/button/button.tsx @@ -75,6 +75,12 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf */ @Prop({ reflect: true }) expand?: 'full' | 'block'; + /** + * Set to `"bold"` for a button with vibrant, bold colors or to `"subtle"` for + * a button with muted, subtle colors. + */ + @Prop() hue?: 'bold' | 'subtle' = 'bold'; + /** * Set to `"clear"` for a transparent button that resembles a flat button, to `"outline"` * for a transparent button with a border, or to `"solid"` for a button with a filled background. @@ -349,8 +355,20 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf }; render() { - const { buttonType, type, disabled, rel, target, href, color, expand, hasIconOnly, strong, inheritedAttributes } = - this; + const { + buttonType, + type, + disabled, + rel, + target, + href, + color, + expand, + hue, + hasIconOnly, + strong, + inheritedAttributes, + } = this; const theme = getIonTheme(this); const mode = getIonMode(this); @@ -394,6 +412,7 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf [theme]: true, [buttonType]: true, [`${buttonType}-${expand}`]: expand !== undefined, + [`${buttonType}-${hue}`]: hue !== undefined, [`${buttonType}-${size}`]: size !== undefined, [`${buttonType}-${shape}`]: true, [`${buttonType}-${fill}`]: true, diff --git a/core/src/components/button/test/basic/index.html b/core/src/components/button/test/basic/index.html index 19efe474cea..4f1283d5f81 100644 --- a/core/src/components/button/test/basic/index.html +++ b/core/src/components/button/test/basic/index.html @@ -12,6 +12,17 @@ + +
@@ -23,108 +34,136 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+