Skip to content
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

feat(chip): add hue property for the ionic theme #30308

Merged
merged 38 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
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
5d79e3c
feat(chip): add subtle hue for the ionic theme
brandyscarney Mar 26, 2025
8a94fd4
chore: build
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
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
5811fbd
Merge branch 'FW-6252' into FW-6252-chip
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
d5a79c5
Merge branch 'FW-6252' into FW-6252-chip
brandyscarney Apr 4, 2025
465a5ef
lint again and again and again
brandyscarney Apr 4, 2025
ed28ff0
Merge branch 'FW-6252' into FW-6252-chip
brandyscarney Apr 4, 2025
feb8cf6
chore(): add updated snapshots
Ionitron 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
e62292f
Merge branch 'FW-6252' into FW-6252-chip
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
7ec8f9d
test(chip): add hue test for ionic theme
brandyscarney Apr 7, 2025
3fd42cb
Merge branch 'FW-6252' into FW-6252-chip
brandyscarney Apr 7, 2025
1cd9598
refactor(chip): only apply the color / background to hue classes
brandyscarney Apr 8, 2025
d737ccc
docs
brandyscarney Apr 11, 2025
fd300b2
style: add in jira ticket
brandyscarney Apr 11, 2025
3e8037c
Merge branch 'next' into FW-6252-chip
brandyscarney Apr 11, 2025
d50eec1
Merge branch 'next' into FW-6252-chip
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
6 changes: 6 additions & 0 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -596,17 +596,23 @@ ion-checkbox,part,supporting-text
ion-chip,shadow
ion-chip,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true
ion-chip,prop,disabled,boolean,false,false,false
ion-chip,prop,hue,"bold" | "subtle" | undefined,'subtle',false,false
ion-chip,prop,mode,"ios" | "md",undefined,false,false
ion-chip,prop,outline,boolean,false,false,false
ion-chip,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,false
ion-chip,prop,size,"large" | "small" | undefined,undefined,false,false
ion-chip,prop,theme,"ios" | "md" | "ionic",undefined,false,false
ion-chip,css-prop,--background,ionic
ion-chip,css-prop,--background,ios
ion-chip,css-prop,--background,md
ion-chip,css-prop,--border-radius,ionic
ion-chip,css-prop,--border-radius,ios
ion-chip,css-prop,--border-radius,md
ion-chip,css-prop,--color,ionic
ion-chip,css-prop,--color,ios
ion-chip,css-prop,--color,md
ion-chip,css-prop,--focus-ring-color,ionic
ion-chip,css-prop,--focus-ring-width,ionic

ion-col,shadow
ion-col,prop,mode,"ios" | "md",undefined,false,false
Expand Down
8 changes: 8 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@ export namespace Components {
* If `true`, the user cannot interact with the chip.
*/
"disabled": boolean;
/**
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Only applies to the `ionic` theme.
*/
"hue"?: 'bold' | 'subtle';
/**
* The mode determines the platform behaviors of the component.
*/
Expand Down Expand Up @@ -6287,6 +6291,10 @@ declare namespace LocalJSX {
* If `true`, the user cannot interact with the chip.
*/
"disabled"?: boolean;
/**
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Only applies to the `ionic` theme.
*/
"hue"?: 'bold' | 'subtle';
/**
* The mode determines the platform behaviors of the component.
*/
Expand Down
36 changes: 36 additions & 0 deletions core/src/components/chip/chip.common.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@import "../../themes/mixins";

// Chip: Common Styles
// --------------------------------------------------

:host {
/**
* @prop --background: Background of the chip
* @prop --color: Color of the chip
* @prop --border-radius: Border radius of the chip
*/
@include font-smoothing();

display: inline-flex;

position: relative;

align-items: center;
justify-content: center;

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

cursor: pointer;

overflow: hidden;

box-sizing: border-box;

vertical-align: middle;
}

:host(.chip-disabled) {
cursor: default;
pointer-events: none;
}
97 changes: 57 additions & 40 deletions core/src/components/chip/chip.ionic.scss
Original file line number Diff line number Diff line change
@@ -1,42 +1,26 @@
@use "../../themes/ionic/ionic.globals.scss" as globals;
@use "./chip.common";

// Ionic Chip
// --------------------------------------------------

:host {
--background: #{globals.$ion-primitives-neutral-100};
--color: #{globals.$ion-primitives-neutral-900};
/**
* @prop --focus-ring-color: Color of the focus ring
* @prop --focus-ring-width: Width of the focus ring
*/
--focus-ring-color: #{globals.$ion-border-focus-default};
--focus-ring-width: #{globals.$ion-border-size-050};

@include globals.font-smoothing;
@include globals.padding(globals.$ion-space-150, globals.$ion-space-200);
@include globals.border-radius(var(--border-radius));

display: inline-flex;

position: relative;

align-items: center;
justify-content: center;

gap: globals.$ion-space-100;

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

font-family: globals.$ion-font-family;
font-weight: globals.$ion-font-weight-medium;

line-height: globals.$ion-font-line-height-full;

cursor: pointer;

overflow: hidden;

box-sizing: border-box;

vertical-align: middle;
}

// Outline Chip
Expand All @@ -45,13 +29,6 @@
:host(.chip-outline) {
border-width: globals.$ion-border-size-025;
border-style: globals.$ion-border-style-solid;
border-color: globals.$ion-primitives-neutral-100;

background: transparent;
}

:host(.chip-outline.ion-color) {
border-color: globals.current-color(base, 0.32);
}

// Chip: Focus
Expand All @@ -66,12 +43,20 @@
// ---------------------------------------------

@media (any-hover: hover) {
:host(:hover) {
:host(.chip-subtle:hover) {
--background: #{globals.$ion-primitives-neutral-200};
}

:host(.ion-color:hover) {
background: globals.current-color(base, 0.12);
:host(.chip-bold:hover) {
--background: #{globals.$ion-primitives-neutral-1100};
}

:host(.chip-subtle.ion-color:hover) {
background: globals.current-color(tint, $subtle: true);
}

:host(.chip-bold.ion-color:hover) {
background: globals.current-color(shade);
}
}

Expand All @@ -80,7 +65,6 @@

:host(.chip-disabled) {
opacity: 0.6;
pointer-events: none;
}

// Chip Shapes
Expand Down Expand Up @@ -110,7 +94,7 @@
:host(.chip-small) {
min-height: globals.$ion-scale-600;

font-size: #{globals.$ion-font-size-300};
font-size: globals.$ion-font-size-300;
}

:host(.chip-large) {
Expand All @@ -119,18 +103,51 @@
font-size: globals.$ion-font-size-350;
}

// Subtle Chip
// ---------------------------------------------

:host(.chip-subtle) {
--background: #{globals.$ion-primitives-neutral-100};
--color: #{globals.$ion-primitives-neutral-800};
}

:host(.chip-outline.chip-subtle) {
border-color: globals.$ion-primitives-neutral-300;
}

// Bold Chip
// ---------------------------------------------

:host(.chip-bold) {
--background: #{globals.$ion-bg-neutral-bold-default};
--color: #{globals.$ion-primitives-base-white};
}

:host(.chip-outline.chip-bold) {
// TODO(FW-6450): this is a made up design choice based on a
// darker shade of the background color
border-color: globals.$ion-primitives-neutral-1200;
}

// Chip Colors
// ---------------------------------------------

:host(.ion-color) {
background: globals.current-color(base, 0.08);
color: globals.current-color(shade);
// Subtle
:host(.chip-subtle.ion-color) {
background: globals.current-color(base, $subtle: true);
color: globals.current-color(contrast, $subtle: true);
}

:host(.chip-subtle.chip-outline.ion-color) {
border-color: globals.current-color(shade, $subtle: true);
}

:host(.ion-color:focus) {
background: globals.current-color(base, 0.12);
// Bold
:host(.chip-bold.ion-color) {
background: globals.current-color(base);
color: globals.current-color(contrast);
}

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

:host {
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/chip/chip.md.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "./chip";
@import "./chip.native";
@import "./chip.vars";

:host {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,22 @@
@import "../../themes/native/native.globals";
@import "./chip.vars";
@import "./chip.common";

:host {
/**
* @prop --background: Background of the chip
* @prop --color: Color of the chip
* @prop --border-radius: Border radius of the chip
*/
--background: #{rgba($text-color-rgb, 0.12)};
--color: #{rgba($text-color-rgb, 0.87)};

@include border-radius(var(--border-radius));
@include font-smoothing();
@include margin(4px);
@include padding(6px, 12px);

display: inline-flex;

position: relative;

align-items: center;

min-height: 32px;

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

font-family: $font-family-base;

cursor: pointer;

overflow: hidden;

vertical-align: middle;
box-sizing: border-box;
}

:host(.chip-disabled) {
cursor: default;
opacity: 0.4;
pointer-events: none;
}

// Chip Colors
Expand All @@ -58,6 +35,15 @@
background: current-color(base, 0.16);
}

// Chip: Hover
// ---------------------------------------------

@media (any-hover: hover) {
:host(.ion-color:hover) {
background: current-color(base, 0.12);
}
}

// Outline Chip
// ---------------------------------------------

Expand Down
11 changes: 10 additions & 1 deletion core/src/components/chip/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export class Chip implements ComponentInterface {
*/
@Prop() disabled = false;

/**
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for
* a chip with muted, subtle colors.
*
* Only applies to the `ionic` theme.
*/
@Prop() hue?: 'bold' | 'subtle' = 'subtle';

/**
* Set to `"soft"` for a chip with slightly rounded corners, `"round"` for a chip with fully
* rounded corners, or `"rectangular"` for a chip without rounded corners.
Expand Down Expand Up @@ -81,9 +89,9 @@ export class Chip implements ComponentInterface {
}

render() {
const { hue } = this;
const theme = getIonTheme(this);
const size = this.getSize();

const shape = this.getShape();

return (
Expand All @@ -97,6 +105,7 @@ export class Chip implements ComponentInterface {
'ion-activatable': true,
'ion-focusable': !this.disabled,
[`chip-${size}`]: size !== undefined,
[`chip-${hue}`]: hue !== undefined,
})}
>
<slot></slot>
Expand Down
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
Loading