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
There was a problem hiding this comment.
This change was because I synced the padding between themes to be consistent. ionic wasn't using padding-* on ion-content.
| @@ -32,7 +44,7 @@ | |||
| </ion-toolbar> | |||
| </ion-header> | |||
|
|
|||
| <ion-content class="ion-padding-space-400" id="content" no-bounce> | |||
There was a problem hiding this comment.
Removed the class because it wasn't set anywhere.
github.com:ionic-team/ionic-framework into FW-6896 # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
There was a problem hiding this comment.
The goal is to delete this file but that won't be until we can consolidate everything into one base. In the mean time, we should make updates so screenshots don't fail.
| </ion-header> | ||
|
|
||
| <ion-content class="ion-padding ion-text-center" id="content" no-bounce> | ||
| <ion-content class="ion-text-center" id="content" no-bounce> |
There was a problem hiding this comment.
Added the padding through the config since I already had to pass the background value there. Figured that I would keep it all in one place by adding the padding.
| background: yellow; | ||
| } | ||
|
|
||
| #content { |
There was a problem hiding this comment.
The values are being passed for this specific instance only. The other content components are using the values provided by scripts.js.
| * @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the content | ||
| * @prop --ion-content-font-family: Font family of the content | ||
| * | ||
| * @prop --keyboard-offset: Keyboard offset of the content |
There was a problem hiding this comment.
I removed the comments for the internal variables.
| transform: translateZ(0); | ||
| } | ||
|
|
||
| // Content: iOS Mode Transition |
There was a problem hiding this comment.
The design doc did not account for animations based on mode. Should we be aiming to convert them to be based on themes? If so, then we can allow devs to customize the certain parts of the animations. In this instance, they could provide their preferred background color during the transition.
If we do decide to convert, then a ticket should be made and a TODO should be added here.
| * The transition shadow effect is only animated by the iOS transition | ||
| * builder, so these elements are only rendered in iOS mode. | ||
| */ | ||
| const transitionShadow = mode === 'ios'; |
There was a problem hiding this comment.
As mentioned in the comment, this is only available in the ios mode as shown in the ios.transition.ts file.
| ...customTheme.palette, | ||
| }, | ||
| }; | ||
| theme = deepMerge(theme, customTheme); |
There was a problem hiding this comment.
This change mimics exactly how we are loading themes in the theme.ts file.
| $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.
In order for the padding classes (.ion-padding) to still be functional, we should be incorporating them as the first check.
| :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.
| } | ||
|
|
||
| .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.


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:
--background,--color, and--padding-*have been removed. Use the new token structure instead:If per-component customization is needed, the CSS variables can be used directly.
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.