Skip to content

feat(item-option): add hue property for the ionic theme #30332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Apr 11, 2025
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9b25ed0
feat(css): add support for the subtle color map
brandyscarney Mar 26, 2025
2a0fdf3
Merge branch 'next' into FW-6252
brandyscarney Mar 26, 2025
e8605e7
test(theme): skip test because all tests fail on one or more colors
brandyscarney Mar 26, 2025
5391165
chore(): add updated snapshots
Ionitron Mar 26, 2025
19c944a
style: comments
brandyscarney Mar 26, 2025
147550a
Merge branch 'next' into FW-6252
brandyscarney Mar 28, 2025
e13d85d
Merge branch 'next' into FW-6252
brandyscarney Apr 2, 2025
8fc775f
refactor(themes): add foreground color for colors when used as text
brandyscarney Apr 2, 2025
58c251b
feat(item-option): add subtle hue for the ionic theme
brandyscarney Apr 2, 2025
9bfe374
test(theme): use proper color variants
brandyscarney Apr 2, 2025
caf3c2d
style: lint
brandyscarney Apr 3, 2025
aed941f
test(themes): re-enable tests with correct checks
brandyscarney Apr 3, 2025
e86e9d5
chore(): add updated snapshots
Ionitron Apr 3, 2025
59d713f
revert back to tokens
brandyscarney Apr 3, 2025
6306fe6
style: lint
brandyscarney Apr 3, 2025
c9f24c8
Merge branch 'FW-6252' into FW-6252-item-option
brandyscarney Apr 3, 2025
a84f282
Merge branch 'next' into FW-6252
brandyscarney Apr 4, 2025
60a241f
fix(themes): add tertiary, remove TODOs
brandyscarney Apr 4, 2025
465a5ef
lint again and again and again
brandyscarney Apr 4, 2025
3187866
chore(): add updated snapshots
Ionitron Apr 4, 2025
75421d3
fix(themes): update other palettes to include foreground
brandyscarney Apr 4, 2025
eca3566
fix(themes): do not require the foreground variant for ios and md
brandyscarney Apr 7, 2025
67f8334
Merge branch 'next' into FW-6252
brandyscarney Apr 7, 2025
8bba021
Merge branch 'FW-6252' into FW-6252-item-option
brandyscarney Apr 7, 2025
22ddb4c
fix(css): remove the unused foreground vars
brandyscarney Apr 7, 2025
6d05513
style: comment cleanup
brandyscarney Apr 7, 2025
da4e069
fix(themes): fallback to base if foreground is undefined
brandyscarney Apr 7, 2025
61c573e
Merge branch 'FW-6252' into FW-6252-item-option
brandyscarney Apr 7, 2025
ab14b1e
fix(item-option): default hue should be subtle
brandyscarney Apr 7, 2025
6c64829
test(item-option): move color test to hue test and add screenshots
brandyscarney Apr 7, 2025
1173e54
chore: build
brandyscarney Apr 7, 2025
c40cf2d
style: lint
brandyscarney Apr 7, 2025
bffa469
chore(): add updated snapshots
brandyscarney Apr 7, 2025
5aa343e
refactor(item-option): only apply the color / background to hue classes
brandyscarney Apr 8, 2025
65e08a4
docs
brandyscarney Apr 11, 2025
324394f
Merge branch 'next' into FW-6252-item-option
brandyscarney Apr 11, 2025
1a0c4ce
test(item-sliding): improve visibility check
brandyscarney Apr 11, 2025
4186b1d
Merge branch 'next' into FW-6252-item-option
brandyscarney Apr 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/api.txt
Original file line number Diff line number Diff line change
@@ -1190,6 +1190,7 @@ ion-item-option,prop,disabled,boolean,false,false,false
ion-item-option,prop,download,string | undefined,undefined,false,false
ion-item-option,prop,expandable,boolean,false,false,false
ion-item-option,prop,href,string | undefined,undefined,false,false
ion-item-option,prop,hue,"bold" | "subtle" | undefined,'subtle',false,false
ion-item-option,prop,mode,"ios" | "md",undefined,false,false
ion-item-option,prop,rel,string | undefined,undefined,false,false
ion-item-option,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,false
8 changes: 8 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
@@ -1704,6 +1704,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 an option with vibrant, bold colors or to `"subtle"` for an option with muted, subtle colors. Only applies to the `ionic` theme.
*/
"hue"?: 'bold' | 'subtle';
/**
* The mode determines the platform behaviors of the component.
*/
@@ -7204,6 +7208,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 an option with vibrant, bold colors or to `"subtle"` for an option with muted, subtle colors. Only applies to the `ionic` theme.
*/
"hue"?: 'bold' | 'subtle';
/**
* The mode determines the platform behaviors of the component.
*/
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
@import "./item-option.vars";
@import "../../themes/mixins";

// Item Option
// Common Item Option
// --------------------------------------------------

:host {
/**
* @prop --background: Background of the item option
* @prop --color: Color of the item option
*/
--background: #{ion-color(primary, base)};
--color: #{ion-color(primary, contrast)};

background: var(--background);
color: var(--color);

font-family: $font-family-base;
}

:host(.ion-color) {
background: current-color(base);
color: current-color(contrast);
}

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

display: inline-block;

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

::slotted([slot="start"]) {
@include margin(0, 5px, 0, 0);
}

::slotted([slot="end"]) {
@include margin(0, 0, 0, 5px);
}

::slotted([slot="icon-only"]) {
@include padding(0);
@include margin(0, 10px);

min-width: 0.9em;

font-size: 1.8em;
}

// Item Expandable Animation
// --------------------------------------------------

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

// Item Disabled Styling
// Item Option: Disabled
// --------------------------------------------------

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

:host(.item-option-disabled) .button-native {
cursor: default;
opacity: 0.5;
pointer-events: none;
}
34 changes: 31 additions & 3 deletions core/src/components/item-option/item-option.ionic.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use "../../themes/ionic/ionic.globals.scss" as globals;
@import "./item-option";
@use "./item-option.common";

// Ionic Item Option
// --------------------------------------------------
@@ -29,11 +29,11 @@
}

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

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

::slotted(ion-icon),
@@ -75,3 +75,31 @@
:host(.item-option-disabled) .button-native {
opacity: 1;
}

// Subtle Item Option
// --------------------------------------------------

:host(.item-option-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)};
}

:host(.item-option-subtle.ion-color) {
background: globals.current-color(base, $subtle: true);
color: globals.current-color(contrast, $subtle: true);
}

// Bold Item Option
// --------------------------------------------------

:host(.item-option-bold) {
--background: #{globals.ion-color(primary, base)};
--background-activated: #{globals.ion-color(primary, shade)};
--color: #{globals.ion-color(primary, contrast)};
}

:host(.item-option-bold.ion-color) {
background: globals.current-color(base);
color: globals.current-color(contrast);
}
2 changes: 1 addition & 1 deletion core/src/components/item-option/item-option.ios.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "./item-option";
@import "./item-option.native";
@import "./item-option.ios.vars";

// iOS Item Option
2 changes: 1 addition & 1 deletion core/src/components/item-option/item-option.md.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "./item-option";
@import "./item-option.native";
@import "./item-option.md.vars";

// Material Design Item Option
46 changes: 46 additions & 0 deletions core/src/components/item-option/item-option.native.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@import "../../themes/native/native.globals";
@import "./item-option.vars";
@import "./item-option.common";

// Native Item Option
// --------------------------------------------------

:host {
--background: #{ion-color(primary, base)};
--color: #{ion-color(primary, contrast)};

font-family: $font-family-base;
}

:host(.ion-color) {
background: current-color(base);
color: current-color(contrast);
}

.button-native {
@include padding(0, 0.7em);
}

::slotted([slot="start"]) {
@include margin(0, 5px, 0, 0);
}

::slotted([slot="end"]) {
@include margin(0, 0, 0, 5px);
}

::slotted([slot="icon-only"]) {
@include padding(0);
@include margin(0, 10px);

min-width: 0.9em;

font-size: 1.8em;
}

// Item Option: Disabled
// --------------------------------------------------

:host(.item-option-disabled) .button-native {
opacity: 0.5;
}
11 changes: 10 additions & 1 deletion core/src/components/item-option/item-option.tsx
Original file line number Diff line number Diff line change
@@ -62,6 +62,14 @@ export class ItemOption implements ComponentInterface, AnchorInterface, ButtonIn
*/
@Prop() href: string | undefined;

/**
* 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.
*/
@Prop() hue?: 'bold' | 'subtle' = 'subtle';

/**
* Specifies the relationship of the target object to the link object.
* 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
}

render() {
const { disabled, expandable, href } = this;
const { disabled, expandable, href, hue } = this;
const TagType = href === undefined ? 'button' : ('a' as any);
const theme = getIonTheme(this);
const shape = this.getShape();
@@ -133,6 +141,7 @@ export class ItemOption implements ComponentInterface, AnchorInterface, ButtonIn
class={createColorClasses(this.color, {
[theme]: true,
[`item-option-${shape}`]: shape !== undefined,
[`item-option-${hue}`]: hue !== undefined,
'item-option-disabled': disabled,
'item-option-expandable': expandable,
'ion-activatable': true,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 135 additions & 0 deletions core/src/components/item-sliding/test/hue/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Item Sliding - Hue</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
/>
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
<script src="../../../../../scripts/testing/scripts.js"></script>
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
</head>

<body onLoad="openItems()">
<ion-app>
<ion-header>
<ion-toolbar>
<ion-title>Item Sliding - Hue</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<ion-list>
<ion-list-header>
<ion-label>Default Colors</ion-label>
</ion-list-header>
<ion-item-sliding>
<ion-item>
<ion-label> Bold </ion-label>
</ion-item>
<ion-item-options side="start">
<ion-item-option hue="bold">Default</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item>
<ion-label> Subtle </ion-label>
</ion-item>
<ion-item-options side="start">
<ion-item-option>Default</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-list-header>
<ion-label>Core Colors</ion-label>
</ion-list-header>
<ion-item-sliding>
<ion-item>
<ion-label> Bold </ion-label>
</ion-item>
<ion-item-options side="start">
<ion-item-option hue="bold" color="primary">Primary</ion-item-option>
<ion-item-option hue="bold" color="secondary">Secondary</ion-item-option>
<ion-item-option hue="bold" color="tertiary">Tertiary</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item>
<ion-label> Subtle </ion-label>
</ion-item>
<ion-item-options side="start">
<ion-item-option color="primary">Primary</ion-item-option>
<ion-item-option color="secondary">Secondary</ion-item-option>
<ion-item-option color="tertiary">Tertiary</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-list-header>
<ion-label>Status Colors</ion-label>
</ion-list-header>
<ion-item-sliding>
<ion-item>
<ion-label> Bold </ion-label>
</ion-item>
<ion-item-options side="start">
<ion-item-option hue="bold" color="success">Success</ion-item-option>
<ion-item-option hue="bold" color="warning">Warning</ion-item-option>
<ion-item-option hue="bold" color="danger">Danger</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item>
<ion-label> Subtle </ion-label>
</ion-item>
<ion-item-options side="start">
<ion-item-option color="success">Success</ion-item-option>
<ion-item-option color="warning">Warning</ion-item-option>
<ion-item-option color="danger">Danger</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-list-header>
<ion-label>Neutral Colors</ion-label>
</ion-list-header>
<ion-item-sliding>
<ion-item>
<ion-label> Bold </ion-label>
</ion-item>
<ion-item-options side="start">
<ion-item-option hue="bold" color="light">Light</ion-item-option>
<ion-item-option hue="bold" color="medium">Medium</ion-item-option>
<ion-item-option hue="bold" color="dark">Dark</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding>
<ion-item>
<ion-label> Subtle </ion-label>
</ion-item>
<ion-item-options side="start">
<ion-item-option color="light">Light</ion-item-option>
<ion-item-option color="medium">Medium</ion-item-option>
<ion-item-option color="dark">Dark</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-list>

<script>
// Open all sliding items on load
function openItems() {
document.querySelectorAll('ion-item-sliding').forEach((item) => {
item.open();
});
}
</script>
</ion-content>
</ion-app>
</body>
</html>
Loading
Loading