-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat(chip): add recipe and variables #30873
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
base: ionic-modular
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
core/src/themes/md/default.tokens.ts
Outdated
| }, | ||
|
|
||
| avatar: { | ||
| size: `${24 / fontSizes.chipBase}em`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These numbers seem made up - maybe we need to define these calculations better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The avatar size is based on the existing values from the original vars file.
| } | ||
|
|
||
| const fontSizes = { | ||
| chipBase: 14, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the base 14 for Chip? Shouldn't all components have the same base size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original value is 14 based on the vars file. I don't remember why 14 was chosen.
Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>
Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>
Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>
Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>
| @include mixins.border-radius(var(--border-radius)); | ||
| @include mixins.margin(vars.$chip-margin); | ||
| @include mixins.padding(vars.$chip-padding-vertical, vars.$chip-padding-horizontal); | ||
| @include mixins.typography(vars.$chip-typography); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The font family for chip on ionic-modular and this branch do not match when it comes to the ionic theme. The ionic theme uses ion-body-sm-medium to set the typography for chip. This variable includes font family with the value of -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol". This is exactly what is being rendered on this branch. However, the ionic-modular renders it with a value of var(--ion-font-family, inherit). Based on my investigation, ionic-modular and next are not loading the correct font family. This branch fixes it.
| const customConfig = customTheme?.config; | ||
| if (customConfig) { | ||
| Object.entries(customConfig).forEach(([key, value]) => { | ||
| config.set(key as keyof IonicConfig, value); | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed for configs like rippleEffect to be set if the user passed them through the customTheme obj.
brandyscarney
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really good, great work! You've made a lot of improvements here. I reviewed this over the past couple of days and GitHub stopped showing me some of my previous comments so sorry if I repeated anything. I am going to leave a comment on the Jira ticket outlining some changes I think we should make which may overlap with some of my comments here. I decided to kind of consolidate my thoughts there.
| <div id="container"> | ||
| <ion-chip> | ||
| <ion-chip hue="subtle"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to define hue here if this is the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For personal preference 😅. It's nice to be able to read the HTML and know immediately what prop is being used without having to go to the component file and seeing what the default is. I'm not a stickler so I can revert if you prefer the original version.
| <h2>Chip Hue: Subtle</h2> | ||
|
|
||
| <ion-chip> | ||
| <ion-chip hue="subtle"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to define hue here if this is the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider removing this test from avatar and having it in chip instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make a note to do that in main that way it trickles down to all the branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this color change right? The default bold chip is no longer a dark gray and is now a light gray.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core/src/components/chip/chip.tsx
Outdated
| md: 'chip.md.scss', | ||
| ionic: 'chip.ionic.scss', | ||
| }, | ||
| styleUrl: 'chip.base.scss', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just call this chip.scss now? Or do we expect to add more variants later and want to keep base for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, we can always change the name again if we do go down that route without impacting the community: 67b6342
| } | ||
|
|
||
| :host(.chip-subtle:hover) { | ||
| --background: var(--ion-chip-hue-subtle-state-hover-bg, var(--ion-chip-hue-subtle-bg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we fallback here?
| } | ||
|
|
||
| :host(.chip-subtle.ion-color:hover) { | ||
| background: var(--ion-chip-hue-subtle-semantic-state-hover-bg, var(--ion-chip-hue-subtle-semantic-bg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we fallback here?
| size: string | number; | ||
|
|
||
| // Styles for the media component only if it is the first element in the slot | ||
| firstChild?: IonChipMediaMargin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about if we use leading and trailing instead of firstChild and lastChild? Something like this:
export type IonMargin = {
margin?: {
top?: string | number;
end?: string | number;
bottom?: string | number;
start?: string | number;
};
};
export type IonChipMediaTheme = {
leading?: IonMargin;
trailing?: IonMargin;
};avatar?: IonChipMediaTheme;
icon?: IonChipMediaTheme;
| margin: string | number; | ||
|
|
||
| fontWeight?: string | number; | ||
| gap?: string | number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gap seems like a weird property to define here - shouldn't this be determined by spacing somehow?
| var(--ion-chip-icon-last-child-margin-vertical), | ||
| var(--ion-chip-icon-last-child-margin-end), | ||
| $start: var(--ion-chip-icon-last-child-margin-start) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is very confusing to have vertical and then end and start - we should be defining all 4.
Issue number: resolves internal
What is the current behavior?
Component styles for
ion-chipare fragmented across multiple files (ios,md,ionic). Developers were restricted to those themes and how those themes structured the logic and styles.What is the new behavior?
chip.base.scssfile that consumes CSS variables, ensuring a single source of truth for component logic.IonChiptype and tokens to prioritize a Property-First approach. Instead of flat or element-centric tokens, they are nested by element and then by property (e.g.,icon.firstChild.margin.end). This ensures:paddingandborder.chip.interfaces.tswith reusable utility types likeHueRefto standardize the "Bold vs. Subtle" logic used in variants and interaction states.mdandios.mdandios.Does this introduce a breaking change?
This PR introduces a breaking change to how
IonChipis styled. Existing manual CSS overrides targeting internal chip structures or old token names will no longer work due to the shift to a Property-First token hierarchy and a unified base SCSS file.Migration Path:
Token Updates: Update any custom theme configurations to match the new nested structure.
CSS Overrides: Ensure selectors align with the new slotted element logic and variable names (e.g.,
--ion-chip-hue-bold-bg).--backgroundshould no longer be used. Setting the value withIonChip.hue.bold.bgandIonChip.hue.subtle.bgwithin the tokens file should be used to change the background based on the hue.If
mdorioswith no shape, then update the component to default tosoft.Other information
This PR significantly improves the developer experience for theming. By moving logic into
default.tokens.tsand away from hardcoded SCSS functions, designers and developers can now override complex states (like an activated outline chip) purely through token configuration.Preview: