Skip to content

Commit

Permalink
fix(components): apply translucent if backdrop-filter is supported (i…
Browse files Browse the repository at this point in the history
…onic-team#18832)

This updates the components and the docs so that translucent is only applied when backdrop filter is supported, this prevents it from being applied when viewing iOS in Chrome, for example.

closes ionic-team/ionic-docs#666
  • Loading branch information
brandyscarney authored Jul 19, 2019
1 parent fbfc076 commit 6b5a59d
Show file tree
Hide file tree
Showing 29 changed files with 156 additions and 121 deletions.
40 changes: 20 additions & 20 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export namespace Components {
*/
'subHeader'?: string;
/**
* If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports backdrop-filter.
* If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent': boolean;
}
Expand Down Expand Up @@ -220,7 +220,7 @@ export namespace Components {
*/
'subHeader'?: string;
/**
* If `true`, the alert will be translucent.
* If `true`, the alert will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent': boolean;
}
Expand Down Expand Up @@ -433,7 +433,7 @@ export namespace Components {
*/
'mode'?: "ios" | "md";
/**
* If `true`, the card header will be translucent.
* If `true`, the card header will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent': boolean;
}
Expand Down Expand Up @@ -807,7 +807,7 @@ export namespace Components {
*/
'target': string | undefined;
/**
* If `true`, the fab button will be translucent. Only applies to `ios` mode on devices that support [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
* If `true`, the fab button will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent': boolean;
/**
Expand All @@ -831,7 +831,7 @@ export namespace Components {
*/
'mode'?: "ios" | "md";
/**
* If `true`, the footer will be translucent. Only applies to `ios` mode. Note: In order to scroll content behind the footer, the `fullscreen` attribute needs to be set on the content.
* If `true`, the footer will be translucent. Only applies when the mode 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 footer, the `fullscreen` attribute needs to be set on the content.
*/
'translucent': boolean;
}
Expand All @@ -847,7 +847,7 @@ export namespace Components {
*/
'mode'?: "ios" | "md";
/**
* If `true`, the header will be translucent. Only applies to `ios` mode. Note: In order to scroll content behind the header, the `fullscreen` attribute needs to be set on the content.
* If `true`, the header will be translucent. Only applies when the mode 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.
*/
'translucent': boolean;
}
Expand Down Expand Up @@ -1252,7 +1252,7 @@ export namespace Components {
*/
'spinner'?: SpinnerTypes | null;
/**
* If `true`, the loading indicator will be translucent.
* If `true`, the loading indicator will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent': boolean;
}
Expand Down Expand Up @@ -1740,7 +1740,7 @@ export namespace Components {
*/
'showBackdrop': boolean;
/**
* If `true`, the popover will be translucent.
* If `true`, the popover will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent': boolean;
}
Expand Down Expand Up @@ -2397,7 +2397,7 @@ export namespace Components {
*/
'selectedTab'?: string;
/**
* If `true`, the tab bar will be translucent.
* If `true`, the tab bar will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent': boolean;
}
Expand Down Expand Up @@ -2634,7 +2634,7 @@ export namespace Components {
*/
'showCloseButton': boolean;
/**
* If `true`, the toast will be translucent.
* If `true`, the toast will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent': boolean;
}
Expand Down Expand Up @@ -3500,7 +3500,7 @@ declare namespace LocalJSX {
*/
'subHeader'?: string;
/**
* If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports backdrop-filter.
* If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent'?: boolean;
}
Expand Down Expand Up @@ -3571,7 +3571,7 @@ declare namespace LocalJSX {
*/
'subHeader'?: string;
/**
* If `true`, the alert will be translucent.
* If `true`, the alert will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent'?: boolean;
}
Expand Down Expand Up @@ -3783,7 +3783,7 @@ declare namespace LocalJSX {
*/
'mode'?: "ios" | "md";
/**
* If `true`, the card header will be translucent.
* If `true`, the card header will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent'?: boolean;
}
Expand Down Expand Up @@ -4177,7 +4177,7 @@ declare namespace LocalJSX {
*/
'target'?: string | undefined;
/**
* If `true`, the fab button will be translucent. Only applies to `ios` mode on devices that support [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
* If `true`, the fab button will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent'?: boolean;
/**
Expand All @@ -4201,7 +4201,7 @@ declare namespace LocalJSX {
*/
'mode'?: "ios" | "md";
/**
* If `true`, the footer will be translucent. Only applies to `ios` mode. Note: In order to scroll content behind the footer, the `fullscreen` attribute needs to be set on the content.
* If `true`, the footer will be translucent. Only applies when the mode 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 footer, the `fullscreen` attribute needs to be set on the content.
*/
'translucent'?: boolean;
}
Expand All @@ -4217,7 +4217,7 @@ declare namespace LocalJSX {
*/
'mode'?: "ios" | "md";
/**
* If `true`, the header will be translucent. Only applies to `ios` mode. Note: In order to scroll content behind the header, the `fullscreen` attribute needs to be set on the content.
* If `true`, the header will be translucent. Only applies when the mode 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.
*/
'translucent'?: boolean;
}
Expand Down Expand Up @@ -4624,7 +4624,7 @@ declare namespace LocalJSX {
*/
'spinner'?: SpinnerTypes | null;
/**
* If `true`, the loading indicator will be translucent.
* If `true`, the loading indicator will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent'?: boolean;
}
Expand Down Expand Up @@ -4959,7 +4959,7 @@ declare namespace LocalJSX {
*/
'showBackdrop'?: boolean;
/**
* If `true`, the popover will be translucent.
* If `true`, the popover will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent'?: boolean;
}
Expand Down Expand Up @@ -5670,7 +5670,7 @@ declare namespace LocalJSX {
*/
'selectedTab'?: string;
/**
* If `true`, the tab bar will be translucent.
* If `true`, the tab bar will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent'?: boolean;
}
Expand Down Expand Up @@ -5907,7 +5907,7 @@ declare namespace LocalJSX {
*/
'showCloseButton'?: boolean;
/**
* If `true`, the toast will be translucent.
* If `true`, the toast will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
'translucent'?: boolean;
}
Expand Down
4 changes: 3 additions & 1 deletion core/src/components/action-sheet/action-sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export class ActionSheet implements ComponentInterface, OverlayInterface {
@Prop() subHeader?: string;

/**
* If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports backdrop-filter.
* If `true`, the action sheet will be translucent.
* Only applies when the mode is `"ios"` and the device supports
* [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
@Prop() translucent = false;

Expand Down
26 changes: 13 additions & 13 deletions core/src/components/action-sheet/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,19 @@ export default {
## Properties
| Property | Attribute | Description | Type | Default |
| ----------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ----------- |
| `animated` | `animated` | If `true`, the action sheet will animate. | `boolean` | `true` |
| `backdropDismiss` | `backdrop-dismiss` | If `true`, the action sheet will be dismissed when the backdrop is clicked. | `boolean` | `true` |
| `buttons` | -- | An array of buttons for the action sheet. | `(string \| ActionSheetButton)[]` | `[]` |
| `cssClass` | `css-class` | Additional classes to apply for custom CSS. If multiple classes are provided they should be separated by spaces. | `string \| string[] \| undefined` | `undefined` |
| `enterAnimation` | -- | Animation to use when the action sheet is presented. | `((Animation: Animation, baseEl: any, opts?: any) => Promise<Animation>) \| undefined` | `undefined` |
| `header` | `header` | Title for the action sheet. | `string \| undefined` | `undefined` |
| `keyboardClose` | `keyboard-close` | If `true`, the keyboard will be automatically dismissed when the overlay is presented. | `boolean` | `true` |
| `leaveAnimation` | -- | Animation to use when the action sheet is dismissed. | `((Animation: Animation, baseEl: any, opts?: any) => Promise<Animation>) \| undefined` | `undefined` |
| `mode` | `mode` | The mode determines which platform styles to use. | `"ios" \| "md"` | `undefined` |
| `subHeader` | `sub-header` | Subtitle for the action sheet. | `string \| undefined` | `undefined` |
| `translucent` | `translucent` | If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports backdrop-filter. | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| ----------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ----------- |
| `animated` | `animated` | If `true`, the action sheet will animate. | `boolean` | `true` |
| `backdropDismiss` | `backdrop-dismiss` | If `true`, the action sheet will be dismissed when the backdrop is clicked. | `boolean` | `true` |
| `buttons` | -- | An array of buttons for the action sheet. | `(string \| ActionSheetButton)[]` | `[]` |
| `cssClass` | `css-class` | Additional classes to apply for custom CSS. If multiple classes are provided they should be separated by spaces. | `string \| string[] \| undefined` | `undefined` |
| `enterAnimation` | -- | Animation to use when the action sheet is presented. | `((Animation: Animation, baseEl: any, opts?: any) => Promise<Animation>) \| undefined` | `undefined` |
| `header` | `header` | Title for the action sheet. | `string \| undefined` | `undefined` |
| `keyboardClose` | `keyboard-close` | If `true`, the keyboard will be automatically dismissed when the overlay is presented. | `boolean` | `true` |
| `leaveAnimation` | -- | Animation to use when the action sheet is dismissed. | `((Animation: Animation, baseEl: any, opts?: any) => Promise<Animation>) \| undefined` | `undefined` |
| `mode` | `mode` | The mode determines which platform styles to use. | `"ios" \| "md"` | `undefined` |
| `subHeader` | `sub-header` | Subtitle for the action sheet. | `string \| undefined` | `undefined` |
| `translucent` | `translucent` | If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility). | `boolean` | `false` |
## Events
Expand Down
9 changes: 5 additions & 4 deletions core/src/components/alert/alert.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
// iOS Translucent Alert
// -----------------------------------------

:host(.alert-translucent) .alert-wrapper {
background: $alert-ios-translucent-background-color;
backdrop-filter: $alert-ios-translucent-filter;
@supports (backdrop-filter: blur(0)) {
:host(.alert-translucent) .alert-wrapper {
background: $alert-ios-translucent-background-color;
backdrop-filter: $alert-ios-translucent-filter;
}
}


// iOS Alert Header
// --------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions core/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export class Alert implements ComponentInterface, OverlayInterface {

/**
* If `true`, the alert will be translucent.
* Only applies when the mode is `"ios"` and the device supports
* [`backdrop-filter`](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility).
*/
@Prop() translucent = false;

Expand Down
Loading

0 comments on commit 6b5a59d

Please sign in to comment.