feat(content): add recipe and tokens#31095
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| flex-shrink: 2; | ||
| overscroll-behavior-y: contain; | ||
| overflow-y: auto; | ||
| -webkit-overflow-scrolling: touch; |
There was a problem hiding this comment.
-webkit-overflow-scrolling has become obsolete since iOS 13.
| contain: size style; | ||
| } | ||
|
|
||
| :host(.ion-color) .inner-scroll { |
There was a problem hiding this comment.
There seems to be a lot deleted, but they were just moved around in the file.
| @Method() | ||
| async getBackgroundElement(): Promise<HTMLElement> { | ||
| if (!this.backgroundContentEl) { | ||
| await new Promise((resolve) => componentOnReady(this.el, resolve)); |
There was a problem hiding this comment.
Created a util for this since a lot of components are using the same code
| :host(.ion-color) .inner-scroll { | ||
| background: color.current-color(base); | ||
| color: color.current-color(contrast); | ||
| } |
There was a problem hiding this comment.
I didn't make this customizable because all themes are using the same styles. If the community requests it, then we can update the recipe to include it.
There was a problem hiding this comment.
What is this referring to?
| } | ||
|
|
||
| .transition-shadow { | ||
| @include mixins.position-horizontal(null, 0); |
There was a problem hiding this comment.
We can now use this mixin instead of having to use left/right!
|
|
||
| :host(.ion-color) .inner-scroll { | ||
| background: color.current-color(base); | ||
| color: color.current-color(contrast); |
There was a problem hiding this comment.
There was a problem hiding this comment.
The foreground color should only be used when it's a text-only component. So if setting color on the content changes its text but not its background. You can look at ion-text as an example of a text-only component that uses color. Since we are changing the background on this component, contrast is the correct text value.
ShaneK
left a comment
There was a problem hiding this comment.
Looking awesome! Mostly just have a few clarafication/documentation questions
ShaneK
left a comment
There was a problem hiding this comment.
Looks good to me! Just a question and a nit, but non-blocking
brandyscarney
left a comment
There was a problem hiding this comment.
Looking good! Minor changes requested.
| $padding-top: var(--padding-top, var(--ion-content-padding-top, 0px)); | ||
| $padding-end: var(--padding-end, var(--ion-content-padding-end, 0px)); | ||
| $padding-bottom: var(--padding-bottom, var(--ion-content-padding-bottom, 0px)); | ||
| $padding-start: var(--padding-start, var(--ion-content-padding-start, 0px)); |
There was a problem hiding this comment.
Why did we go this route instead of having the .ion-padding class set --ion-content-padding-top, --ion-content-padding-end, etc directly?
| customTheme: { | ||
| components: { | ||
| IonContent: { | ||
| background: '#f1f1f1', |
There was a problem hiding this comment.
How do we determine when this should be used over just keeping the css that was here and updating the variable?
<style>
ion-content {
--ion-content-background: #f1f1f1;
}
</style>| - Specific theme classes (e.g., `ion-chip.md`) are no longer supported. Style modifications based on the active theme must be implemented using theme tokens rather than direct class targeting. | ||
| - The `border-radius` of the `ios` and `md` chip now defaults to `10px` and `8px`, respectively, instead of `16px` in accordance with the iOS and Material Design 3 guidelines. To revert to the previous appearance, set the `shape` to `"round"`, or override the `IonChip.shape.round.border.radius` to specify a different value for global styles and `--ion-chip-shape-round-border-radius` for component-specific styles. | ||
|
|
||
| <h4 id="version-9x-content">Content</h4> |
There was a problem hiding this comment.
Could we clean this section up a bit? It's kind of hard to hard to read through. Maybe we can use a numbered list or dividers?
| * component readiness before accessing internal refs (e.g. in early lifecycle | ||
| * hooks like Vue onMounted with the custom elements build). | ||
| */ | ||
| export const waitForComponent = <T extends Element>(el: T): Promise<T> => { |
There was a problem hiding this comment.
Nit: should this be called waitForComponentReady?
| --offset-bottom: 0px; | ||
| --overflow: auto; | ||
| /** | ||
| * TODO(FW-6698): Remove this comment in v10. |
There was a problem hiding this comment.
Do we need this comment to begin with?
| :host(.ion-color) .inner-scroll { | ||
| background: color.current-color(base); | ||
| color: color.current-color(contrast); | ||
| } |
There was a problem hiding this comment.
What is this referring to?
|
|
||
| .scroll-y { | ||
| overflow-y: var(--overflow); | ||
| overflow-y: var(--ion-content-overflow); |
There was a problem hiding this comment.
Should this fall back to auto?
|
|
||
| .scroll-x { | ||
| overflow-x: var(--overflow); | ||
| overflow-x: var(--ion-content-overflow); |
There was a problem hiding this comment.
Should this fall back to auto?
|
|
||
| :host(.ion-color) .inner-scroll { | ||
| background: color.current-color(base); | ||
| color: color.current-color(contrast); |
There was a problem hiding this comment.
The foreground color should only be used when it's a text-only component. So if setting color on the content changes its text but not its background. You can look at ion-text as an example of a text-only component that uses color. Since we are changing the background on this component, contrast is the correct text value.
| transform: translateZ(0); | ||
| } | ||
|
|
||
| // Content: iOS Mode Transition |
There was a problem hiding this comment.
Maybe we should add this on to FW-7295?


Issue number: resolves internal
What is the current behavior?
ion-contentdoes not fragment styles based on themes. All 3 themes share one style. However, it's not configured to the Modular Ionic.What is the new behavior?
content-interface.tstocontent.interfaces.tsand addedIonContentRecipetype.--offset-top/--offset-bottomto--internal-offset-top/--internal-offset-bottomto clearly separate them from the public CSS API..transition-effectand.transition-shadowwith theposition-horizontalmixin.-webkit-overflow-scrolling: touchfrom styles as this property has been a no-op since iOS 13.transitionShadow(present iniosmode, absent inmdmode) and thegetScrollElement()/getBackgroundElement()element ref methods.new Promise((resolve) => componentOnReady(...))patterns with a sharedwaitForComponenthelper, reducing boilerplate and improving type safety.Does this introduce a breaking change?
This PR introduces breaking changes to how
ion-contentis styled.Migration Path:
--backgroundand--colorhave been removed. Use the new token structure:--padding-*is still supported..ion-padding,.ion-padding-*classes incss/padding.scssset--padding-*directly on the host.ion-contentcontinues to honor those values (falling back to the new token when unset). Existing usage of the utility classes and direct--padding-*overrides will keep working.New code is encouraged to use the token-based API instead:
Note:
core/api.txtonly lists the new--ion-content-padding-*variables. The--padding-*overrides remain functional but are no longer part of the documented public API.If per-component customization is needed, the CSS variables can be used directly.
@props onion-contentand have been renamed to the--internal-*namespace, removing them from the public API:These are managed by
ion-contentitself (keyboard avoidance and header/footer offsets) and were never intended for consumer override. There is no replacement - any code that was setting them directly should be removed.ion-content.md,ion-content.ios.Other information
Previews:
The framework (Angular, React, Vue) test apps are not being styled correctly anymore because the new tokens are not being passed to them. This is expected until we can export the tokens as mentioned in the design doc. The functionality in those test apps are still working.