feat(modal): ensure header and content background color is inherit from modal

This commit is contained in:
José Rio
2025-06-17 10:46:06 +01:00
parent 911684f83a
commit a92718b40a
4 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,8 @@
@import "./content.scss";
// Ionic Content
// --------------------------------------------------
:host(.in-modal) {
--background: var(--ion-bg-surface-default, var(--ion-primitives-base-white));
}

View File

@ -24,8 +24,12 @@ import type { ScrollBaseDetail, ScrollDetail } from './content-interface';
*/ */
@Component({ @Component({
tag: 'ion-content', tag: 'ion-content',
styleUrl: 'content.scss',
shadow: true, shadow: true,
styleUrls: {
ios: 'content.scss',
md: 'content.scss',
ionic: 'content.ionic.scss',
},
}) })
export class Content implements ComponentInterface { export class Content implements ComponentInterface {
private watchDog: ReturnType<typeof setInterval> | null = null; private watchDog: ReturnType<typeof setInterval> | null = null;
@ -458,6 +462,7 @@ export class Content implements ComponentInterface {
'content-sizing': hostContext('ion-popover', this.el), 'content-sizing': hostContext('ion-popover', this.el),
overscroll: forceOverscroll, overscroll: forceOverscroll,
[`content-${rtl}`]: true, [`content-${rtl}`]: true,
'in-modal': hostContext('ion-modal', this.el),
})} })}
style={{ style={{
'--offset-top': `${this.cTop}px`, '--offset-top': `${this.cTop}px`,

View File

@ -11,6 +11,10 @@ ion-header {
&.header-divider { &.header-divider {
border-bottom: globals.$ion-border-size-025 globals.$ion-border-style-solid globals.$ion-primitives-neutral-300; border-bottom: globals.$ion-border-size-025 globals.$ion-border-style-solid globals.$ion-primitives-neutral-300;
} }
&.in-modal {
--background: var(--ion-bg-surface-default, var(--ion-primitives-base-white));
}
} }
ion-toolbar + ion-toolbar { ion-toolbar + ion-toolbar {

View File

@ -236,6 +236,7 @@ export class Header implements ComponentInterface {
[`header-collapse-${collapse}`]: true, [`header-collapse-${collapse}`]: true,
[`header-translucent-${theme}`]: this.translucent, [`header-translucent-${theme}`]: this.translucent,
['header-divider']: divider, ['header-divider']: divider,
'in-modal': hostContext('ion-modal', this.el),
}} }}
{...inheritedAttributes} {...inheritedAttributes}
> >