Skip to content

Commit 82457d8

Browse files
fix(action-sheet): remove the height shift on press and update iOS design (#16862)
This changes the border into a linear gradient background image which allows us to avoid the height decrease on press and have the same border as the background color when pressed. - merges all action sheet tests to the basic directory (except standalone, translucent), references #16715 - removes the height shift on press, fixes #16790 - fixes the cancel button on iOS so it is `#ffffff` by default - gets the look of the action sheet closer to native for iOS - only applies the translucent and backdrop filter if it is supported by the browser (chrome will not show transparent anymore) - updates documentation to describe when translucent will show up - adds documentation on how to use screenshot tests
1 parent 509edbc commit 82457d8

File tree

38 files changed

+757
-919
lines changed

38 files changed

+757
-919
lines changed

.github/CONTRIBUTING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,19 @@ Please see our [Contributor Code of Conduct](https://github.com/ionic-team/ionic
8686

8787
1. Locate the test to modify inside the `test/` folder in the component's directory.
8888
2. If a test exists, modify the test by adding an example to reproduce the problem fixed or feature added.
89-
3. If a new test is needed, the easiest way is to copy the `basic/` directory from the component's `test/` directory, rename it, and edit the content in both the `index.html` and `e2e.ts` file (if it exists).
89+
3. If a new test is needed, the easiest way is to copy the `basic/` directory from the component's `test/` directory, rename it, and edit the content in both the `index.html` and `e2e.ts` file (see [Screenshot Tests](#screenshot-tests) for more information on this file).
9090
4. The `preview/` directory is used in the documentation as a demo. Only update this test if there is a bug in the test or if the API has a change that hasn't been updated in the test.
9191

92+
##### Screenshot Tests
93+
94+
1. If the test exists in screenshot, there will be a file named `e2e.ts` in the directory of the test.
95+
2. A screenshot test can be added by including this file and adding one or more `test()` calls that include a call to `page.compareScreenshot()`. See [Stencil end-to-end testing](https://stenciljs.com/docs/end-to-end-testing) and existing tests in `core/` for examples.
96+
3. **Important:** each `test()` should have only one screenshot (`page.compareScreenshot()`) call **or** it should check the expect at the end of each test. If there is a mismatch it will fail the test which will prevent the rest of the test from running, i.e. if the first screenshot fails the remaining screenshot calls would not be called _unless_ they are in a separate test or all of the expects are called at the end.
97+
4. To run screenshot locally, use the following command: `npm run test.screenshot`.
98+
- To run screenshot for a specific test, pass the path to the test or a string to search for.
99+
- For example, running all `alert` tests: `npm run test.screenshot alert`.
100+
- Or, running the basic `alert` tests: `npm run test.screenshot src/components/alert/test/basic/e2e.ts`.
101+
92102

93103
#### Building Changes
94104

core/src/components.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export namespace Components {
156156
*/
157157
'subHeader'?: string;
158158
/**
159-
* If `true`, the action sheet will be translucent.
159+
* If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports backdrop-filter.
160160
*/
161161
'translucent': boolean;
162162
}
@@ -218,7 +218,7 @@ export namespace Components {
218218
*/
219219
'subHeader'?: string;
220220
/**
221-
* If `true`, the action sheet will be translucent.
221+
* If `true`, the action sheet will be translucent. Only applies when the mode is `"ios"` and the device supports backdrop-filter.
222222
*/
223223
'translucent'?: boolean;
224224
}

core/src/components/action-sheet/action-sheet.ios.scss

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
@import "./action-sheet.ios.vars";
33

44
// iOS Action Sheet
5-
// --------------------------------------------------
5+
// ---------------------------------------------------
66

77
:host {
88
--background: #{$action-sheet-ios-background-color};
9-
--background-selected: #{var(--background, $action-sheet-ios-button-background-selected)};
9+
--background-selected: #{$action-sheet-ios-button-background-selected)};
1010
--background-activated: #{$action-sheet-ios-button-background-activated};
1111

1212
text-align: $action-sheet-ios-text-align;
@@ -18,19 +18,21 @@
1818

1919

2020
// iOS Action Sheet Container
21-
// -----------------------------------------
21+
// ---------------------------------------------------
2222

2323
.action-sheet-container {
2424
@include padding($action-sheet-ios-padding-top, $action-sheet-ios-padding-end, $action-sheet-ios-padding-bottom, $action-sheet-ios-padding-start);
2525
}
2626

2727

2828
// iOS Action Sheet Group
29-
// -----------------------------------------
29+
// ---------------------------------------------------
3030

3131
.action-sheet-group {
3232
@include border-radius($action-sheet-ios-border-radius);
3333
@include margin(null, null, $action-sheet-ios-group-margin-bottom - 2, null);
34+
35+
overflow: hidden;
3436
}
3537

3638
.action-sheet-group:first-child {
@@ -43,22 +45,63 @@
4345

4446

4547
// iOS Translucent Action Sheet
46-
// -----------------------------------------
48+
// ---------------------------------------------------
49+
50+
@supports (backdrop-filter: blur(0)) {
51+
:host(.action-sheet-translucent) .action-sheet-group {
52+
background-color: transparent;
53+
backdrop-filter: $action-sheet-ios-group-translucent-filter;
54+
}
55+
56+
:host(.action-sheet-translucent) .action-sheet-title,
57+
:host(.action-sheet-translucent) .action-sheet-button {
58+
background-color: transparent;
59+
background-image:
60+
linear-gradient(0deg, $action-sheet-ios-translucent-background-color, $action-sheet-ios-translucent-background-color 100%),
61+
linear-gradient(0deg, $action-sheet-ios-translucent-border-color, $action-sheet-ios-translucent-border-color 50%, $action-sheet-ios-translucent-background-color 50%);
62+
background-repeat: no-repeat;
63+
64+
/* stylelint-disable-next-line all */
65+
background-position: top, bottom;
66+
67+
background-size: 100% calc(100% - 1px), 100% 1px;
68+
backdrop-filter: $action-sheet-ios-button-translucent-filter;
69+
}
4770

48-
:host(.action-sheet-translucent) .action-sheet-group {
49-
background: $action-sheet-ios-translucent-background-color;
50-
backdrop-filter: $action-sheet-ios-translucent-filter;
71+
:host(.action-sheet-translucent) .action-sheet-button.activated {
72+
background-color: $action-sheet-ios-translucent-background-color-activated;
73+
background-image: none;
74+
}
75+
76+
:host(.action-sheet-translucent) .action-sheet-cancel {
77+
background: var(--background-selected);
78+
}
79+
}
80+
81+
// iOS Action Sheet Border
82+
// ---------------------------------------------------
83+
// Border is made with a linear gradient in order
84+
// to get the proper color and iOS blur effect
85+
86+
.action-sheet-title,
87+
.action-sheet-button {
88+
background-color: transparent;
89+
background-image: linear-gradient(0deg, $action-sheet-ios-button-border-color, $action-sheet-ios-button-border-color 50%, transparent 50%);
90+
background-repeat: no-repeat;
91+
92+
/* stylelint-disable-next-line all */
93+
background-position: bottom;
94+
95+
background-size: 100% 1px;
5196
}
5297

5398

5499
// iOS Action Sheet Title
55-
// -----------------------------------------
100+
// ---------------------------------------------------
56101

57102
.action-sheet-title {
58103
@include padding($action-sheet-ios-title-padding-top, $action-sheet-ios-title-padding-end, $action-sheet-ios-title-padding-bottom, $action-sheet-ios-title-padding-start);
59104

60-
border-bottom: $action-sheet-ios-title-border-width $action-sheet-ios-title-border-style $action-sheet-ios-title-border-color;
61-
62105
color: var(--color, $action-sheet-ios-title-color);
63106

64107
font-size: $action-sheet-ios-title-font-size;
@@ -75,17 +118,13 @@
75118

76119

77120
// iOS Action Sheet Buttons
78-
// -----------------------------------------
121+
// ---------------------------------------------------
79122

80123
.action-sheet-button {
81-
@include margin(0);
82124
@include padding($action-sheet-ios-button-padding);
83125

84126
height: $action-sheet-ios-button-height;
85127

86-
border-bottom: $action-sheet-ios-button-border-width $action-sheet-ios-button-border-style $action-sheet-ios-button-border-color;
87-
88-
background: transparent;
89128
color: var(--color, $action-sheet-ios-button-text-color);
90129

91130
font-size: $action-sheet-ios-button-font-size;
@@ -100,17 +139,12 @@
100139
}
101140

102141
.action-sheet-button:last-child {
103-
border-bottom-color: transparent;
104-
}
105-
106-
.action-sheet-button.activated {
107-
@include margin(-$action-sheet-ios-button-border-width, null, null, null);
108-
109-
border-top: $action-sheet-ios-button-border-width $action-sheet-ios-button-border-style var(--background-activated);
110-
border-bottom-color: var(--background-activated);
142+
background-image: none;
111143
}
112144

113145
.action-sheet-selected {
146+
background: var(--background-selected);
147+
114148
font-weight: bold;
115149
}
116150

0 commit comments

Comments
 (0)