Skip to content

Commit 5da9cc6

Browse files
BenOsodracIonitron
andauthored
feat(header): add translucent support on ionic theme (#30493)
Issue number: internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> When using ionic theme there's no support for translucent prop on the ion-header. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Add support for translucent prop on Ionic theme - Adjusted tests to also run for ionic-md ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> [Ionic header fade](https://ionic-framework-git-rou-11911-ionic1.vercel.app/src/components/header/test/fade?ionic:theme=ionic) --------- Co-authored-by: ionitron <hi@ionicframework.com>
1 parent 911684f commit 5da9cc6

10 files changed

+19
-6
lines changed

core/src/components.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ export namespace Components {
14601460
*/
14611461
"theme"?: "ios" | "md" | "ionic";
14621462
/**
1463-
* If `true`, the header will be translucent. Only applies when the theme is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility). Note: In order to scroll content behind the header, the `fullscreen` attribute needs to be set on the content.
1463+
* If `true`, the header will be translucent. Only applies when the theme is `"ios"` or `"ionic"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility). Note: In order to scroll content behind the header, the `fullscreen` attribute needs to be set on the content.
14641464
* @default false
14651465
*/
14661466
"translucent": boolean;
@@ -7369,7 +7369,7 @@ declare namespace LocalJSX {
73697369
*/
73707370
"theme"?: "ios" | "md" | "ionic";
73717371
/**
7372-
* If `true`, the header will be translucent. Only applies when the theme is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility). Note: In order to scroll content behind the header, the `fullscreen` attribute needs to be set on the content.
7372+
* If `true`, the header will be translucent. Only applies when the theme is `"ios"` or `"ionic"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility). Note: In order to scroll content behind the header, the `fullscreen` attribute needs to be set on the content.
73737373
* @default false
73747374
*/
73757375
"translucent"?: boolean;

core/src/components/header/header.ionic.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,16 @@ ion-toolbar + ion-toolbar {
1717
--padding-start: #{globals.$ion-space-400};
1818
--padding-end: #{globals.$ion-space-400};
1919
}
20+
21+
@supports (backdrop-filter: blur(0)) {
22+
.header-background {
23+
@include globals.position(0, 0, 0, 0);
24+
25+
position: absolute;
26+
27+
backdrop-filter: saturate(180%) blur(globals.$ion-scale-100);
28+
}
29+
.header-translucent-ionic ion-toolbar {
30+
--opacity: 0.7;
31+
}
32+
}

core/src/components/header/header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class Header implements ComponentInterface {
5555

5656
/**
5757
* If `true`, the header will be translucent.
58-
* Only applies when the theme is `"ios"` and the device supports
58+
* Only applies when the theme is `"ios"` or `"ionic"` and the device supports
5959
* [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
6060
*
6161
* Note: In order to scroll content behind the header, the `fullscreen`
@@ -239,7 +239,7 @@ export class Header implements ComponentInterface {
239239
}}
240240
{...inheritedAttributes}
241241
>
242-
{theme === 'ios' && translucent && <div class="header-background"></div>}
242+
{theme !== 'md' && translucent && <div class="header-background"></div>}
243243
<slot></slot>
244244
</Host>
245245
);

core/src/components/header/test/fade/header.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { expect } from '@playwright/test';
22
import { configs, test } from '@utils/test/playwright';
33

44
/**
5-
* Translucent effect is only available in iOS mode.
5+
* Translucent effect is only available in iOS and Ionic mode.
66
*/
7-
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
7+
configs({ modes: ['ios', 'ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
88
test.describe(title('header: fade'), () => {
99
test('should not have visual regressions with fade header', async ({ page }) => {
1010
await page.goto('/src/components/header/test/fade', config);

0 commit comments

Comments
 (0)