Skip to content

Commit 52fba11

Browse files
feat(item-option): add hue property for the ionic theme (#30332)
Issue number: internal --------- ## What is the current behavior? The item option component does not support the `hue` property. ## What is the new behavior? Adds support for the `subtle` hue for the item option. Defaults to `subtle`. ## Does this introduce a breaking change? - [ ] Yes - [x] No
1 parent b31e0ef commit 52fba11

File tree

85 files changed

+393
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+393
-42
lines changed

core/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,7 @@ ion-item-option,prop,disabled,boolean,false,false,false
11901190
ion-item-option,prop,download,string | undefined,undefined,false,false
11911191
ion-item-option,prop,expandable,boolean,false,false,false
11921192
ion-item-option,prop,href,string | undefined,undefined,false,false
1193+
ion-item-option,prop,hue,"bold" | "subtle" | undefined,'subtle',false,false
11931194
ion-item-option,prop,mode,"ios" | "md",undefined,false,false
11941195
ion-item-option,prop,rel,string | undefined,undefined,false,false
11951196
ion-item-option,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,false

core/src/components.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,10 @@ export namespace Components {
17041704
* Contains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered.
17051705
*/
17061706
"href": string | undefined;
1707+
/**
1708+
* Set to `"bold"` for an option with vibrant, bold colors or to `"subtle"` for an option with muted, subtle colors. Only applies to the `ionic` theme.
1709+
*/
1710+
"hue"?: 'bold' | 'subtle';
17071711
/**
17081712
* The mode determines the platform behaviors of the component.
17091713
*/
@@ -7204,6 +7208,10 @@ declare namespace LocalJSX {
72047208
* Contains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered.
72057209
*/
72067210
"href"?: string | undefined;
7211+
/**
7212+
* Set to `"bold"` for an option with vibrant, bold colors or to `"subtle"` for an option with muted, subtle colors. Only applies to the `ionic` theme.
7213+
*/
7214+
"hue"?: 'bold' | 'subtle';
72077215
/**
72087216
* The mode determines the platform behaviors of the component.
72097217
*/

core/src/components/item-option/item-option.scss renamed to core/src/components/item-option/item-option.common.scss

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
1-
@import "./item-option.vars";
1+
@import "../../themes/mixins";
22

3-
// Item Option
3+
// Common Item Option
44
// --------------------------------------------------
55

66
:host {
77
/**
88
* @prop --background: Background of the item option
99
* @prop --color: Color of the item option
1010
*/
11-
--background: #{ion-color(primary, base)};
12-
--color: #{ion-color(primary, contrast)};
13-
1411
background: var(--background);
1512
color: var(--color);
16-
17-
font-family: $font-family-base;
18-
}
19-
20-
:host(.ion-color) {
21-
background: current-color(base);
22-
color: current-color(contrast);
2313
}
2414

2515
.button-native {
2616
@include text-inherit();
27-
@include padding(0, 0.7em);
2817

2918
display: inline-block;
3019

@@ -72,23 +61,6 @@
7261
flex-shrink: 0;
7362
}
7463

75-
::slotted([slot="start"]) {
76-
@include margin(0, 5px, 0, 0);
77-
}
78-
79-
::slotted([slot="end"]) {
80-
@include margin(0, 0, 0, 5px);
81-
}
82-
83-
::slotted([slot="icon-only"]) {
84-
@include padding(0);
85-
@include margin(0, 10px);
86-
87-
min-width: 0.9em;
88-
89-
font-size: 1.8em;
90-
}
91-
9264
// Item Expandable Animation
9365
// --------------------------------------------------
9466

@@ -100,7 +72,7 @@
10072
transition-timing-function: cubic-bezier(0.65, 0.05, 0.36, 1);
10173
}
10274

103-
// Item Disabled Styling
75+
// Item Option: Disabled
10476
// --------------------------------------------------
10577

10678
:host(.item-option-disabled) {
@@ -109,6 +81,5 @@
10981

11082
:host(.item-option-disabled) .button-native {
11183
cursor: default;
112-
opacity: 0.5;
11384
pointer-events: none;
11485
}

core/src/components/item-option/item-option.ionic.scss

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@use "../../themes/ionic/ionic.globals.scss" as globals;
2-
@import "./item-option";
2+
@use "./item-option.common";
33

44
// Ionic Item Option
55
// --------------------------------------------------
@@ -29,11 +29,11 @@
2929
}
3030

3131
::slotted([slot="start"]) {
32-
@include margin(0, globals.$ion-space-100, 0, 0);
32+
@include globals.margin(0, globals.$ion-space-100, 0, 0);
3333
}
3434

3535
::slotted([slot="end"]) {
36-
@include margin(0, 0, 0, globals.$ion-space-100);
36+
@include globals.margin(0, 0, 0, globals.$ion-space-100);
3737
}
3838

3939
::slotted(ion-icon),
@@ -75,3 +75,31 @@
7575
:host(.item-option-disabled) .button-native {
7676
opacity: 1;
7777
}
78+
79+
// Subtle Item Option
80+
// --------------------------------------------------
81+
82+
:host(.item-option-subtle) {
83+
--background: #{globals.ion-color(primary, base, $subtle: true)};
84+
--background-activated: #{globals.ion-color(primary, shade, $subtle: true)};
85+
--color: #{globals.ion-color(primary, contrast, $subtle: true)};
86+
}
87+
88+
:host(.item-option-subtle.ion-color) {
89+
background: globals.current-color(base, $subtle: true);
90+
color: globals.current-color(contrast, $subtle: true);
91+
}
92+
93+
// Bold Item Option
94+
// --------------------------------------------------
95+
96+
:host(.item-option-bold) {
97+
--background: #{globals.ion-color(primary, base)};
98+
--background-activated: #{globals.ion-color(primary, shade)};
99+
--color: #{globals.ion-color(primary, contrast)};
100+
}
101+
102+
:host(.item-option-bold.ion-color) {
103+
background: globals.current-color(base);
104+
color: globals.current-color(contrast);
105+
}

core/src/components/item-option/item-option.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "./item-option";
1+
@import "./item-option.native";
22
@import "./item-option.ios.vars";
33

44
// iOS Item Option

core/src/components/item-option/item-option.md.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "./item-option";
1+
@import "./item-option.native";
22
@import "./item-option.md.vars";
33

44
// Material Design Item Option
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@import "../../themes/native/native.globals";
2+
@import "./item-option.vars";
3+
@import "./item-option.common";
4+
5+
// Native Item Option
6+
// --------------------------------------------------
7+
8+
:host {
9+
--background: #{ion-color(primary, base)};
10+
--color: #{ion-color(primary, contrast)};
11+
12+
font-family: $font-family-base;
13+
}
14+
15+
:host(.ion-color) {
16+
background: current-color(base);
17+
color: current-color(contrast);
18+
}
19+
20+
.button-native {
21+
@include padding(0, 0.7em);
22+
}
23+
24+
::slotted([slot="start"]) {
25+
@include margin(0, 5px, 0, 0);
26+
}
27+
28+
::slotted([slot="end"]) {
29+
@include margin(0, 0, 0, 5px);
30+
}
31+
32+
::slotted([slot="icon-only"]) {
33+
@include padding(0);
34+
@include margin(0, 10px);
35+
36+
min-width: 0.9em;
37+
38+
font-size: 1.8em;
39+
}
40+
41+
// Item Option: Disabled
42+
// --------------------------------------------------
43+
44+
:host(.item-option-disabled) .button-native {
45+
opacity: 0.5;
46+
}

core/src/components/item-option/item-option.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ export class ItemOption implements ComponentInterface, AnchorInterface, ButtonIn
6262
*/
6363
@Prop() href: string | undefined;
6464

65+
/**
66+
* Set to `"bold"` for an option with vibrant, bold colors or to `"subtle"` for
67+
* an option with muted, subtle colors.
68+
*
69+
* Only applies to the `ionic` theme.
70+
*/
71+
@Prop() hue?: 'bold' | 'subtle' = 'subtle';
72+
6573
/**
6674
* Specifies the relationship of the target object to the link object.
6775
* The value is a space-separated list of [link types](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types).
@@ -113,7 +121,7 @@ export class ItemOption implements ComponentInterface, AnchorInterface, ButtonIn
113121
}
114122

115123
render() {
116-
const { disabled, expandable, href } = this;
124+
const { disabled, expandable, href, hue } = this;
117125
const TagType = href === undefined ? 'button' : ('a' as any);
118126
const theme = getIonTheme(this);
119127
const shape = this.getShape();
@@ -133,6 +141,7 @@ export class ItemOption implements ComponentInterface, AnchorInterface, ButtonIn
133141
class={createColorClasses(this.color, {
134142
[theme]: true,
135143
[`item-option-${shape}`]: shape !== undefined,
144+
[`item-option-${hue}`]: hue !== undefined,
136145
'item-option-disabled': disabled,
137146
'item-option-expandable': expandable,
138147
'ion-activatable': true,
Loading
Loading

0 commit comments

Comments
 (0)