Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions core/src/components/alert/alert.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,20 @@
}

.alert-message {
max-height: $alert-md-content-max-height;

font-size: $alert-md-message-font-size;
}

/**
* MD Alerts on tablets can expand vertically up to
* a total maximum height. We only want to set a max-height
* on mobile phones.
*/
@include mobile-viewport() {
.alert-message {
max-height: $alert-md-content-max-height;
}
}

.alert-message:empty {
@include padding($alert-md-message-empty-padding-top, $alert-md-message-empty-padding-end, $alert-md-message-empty-padding-bottom, $alert-md-message-empty-padding-start);
}
Expand Down Expand Up @@ -102,14 +111,24 @@
.alert-checkbox-group {
position: relative;

max-height: $alert-md-content-max-height;

border-top: $alert-md-list-border-top;
border-bottom: $alert-md-list-border-bottom;

overflow: auto;
}

/**
* MD Alerts on tablets can expand vertically up to
* a total maximum height. We only want to set a max-height
* on mobile phones.
*/
@include mobile-viewport() {
.alert-radio-group,
.alert-checkbox-group {
max-height: $alert-md-content-max-height;
}
}

.alert-tappable {
position: relative;

Expand Down Expand Up @@ -282,3 +301,14 @@
.alert-button-inner {
justify-content: $alert-md-button-group-justify-content;
}

/**
* MD alerts should scale up to 560px x 560px
* on tablet dimensions.
*/
@include tablet-viewport() {
:host {
--max-width: #{$alert-md-max-width-tablet};
--max-height: #{$alert-md-max-height-tablet};
}
}
14 changes: 14 additions & 0 deletions core/src/components/alert/alert.md.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ $alert-md-font-size: dynamic-font(14px) !default;
/// @prop - Max width of the alert
$alert-md-max-width: 280px !default;

/// @prop - Max width of the alert on a tablet
/**
* Large display requirements for MD Alert:
* 1. Maintain a minimum of 48px distance from the leading and
* trailing edges of the screen. (48px * 2 = 96px)
* 2. The width can increase up to 560px.
* 3. The height can increase up to 560px.
* Source: https://m2.material.io/components/dialogs#behavior
*/
$alert-md-max-width-tablet: min(calc(100vw - 96px), 560px) !default;

/// @prop - Max width of the alert on a tablet
$alert-md-max-height-tablet: min(calc(100vh - 96px), 560px) !default;

/// @prop - Border radius of the alert
$alert-md-border-radius: 4px !default;

Expand Down
10 changes: 9 additions & 1 deletion core/src/components/alert/alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@
font-weight: normal;
}

.alert-message {
/**
* Alert has a maximum height in scenarios
* such as the MD alert on tablet devices.
* As a result, we need to make sure the inner
* containers can scroll otherwise content
* may be cut off.
*/
.alert-message,
.alert-input-group {
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
overflow-y: auto;
Expand Down
47 changes: 47 additions & 0 deletions core/src/components/alert/test/basic/alert-tablet.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { expect } from '@playwright/test';
import { configs, test, Viewports } from '@utils/test/playwright';

/**
* This behavior does not vary across directions.
*/
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('alert: rendering - tablet'), () => {
test.beforeEach(async ({ page }) => {
await page.setViewportSize(Viewports.tablet.portrait);
await page.goto('/src/components/alert/test/basic', config);
});

test('should expand width and height on larger displays with text', async ({ page }) => {
const ionAlertDidPresent = await page.spyOnEvent('ionAlertDidPresent');
const button = page.locator('#longMessage');
const alert = page.locator('ion-alert');

await button.click();
await ionAlertDidPresent.next();

await expect(alert).toHaveScreenshot(screenshot('alert-tablet-text'));
});

test('should expand width and height on larger displays with checkboxes', async ({ page }) => {
const ionAlertDidPresent = await page.spyOnEvent('ionAlertDidPresent');
const button = page.locator('#checkbox');
const alert = page.locator('ion-alert');

await button.click();
await ionAlertDidPresent.next();

await expect(alert).toHaveScreenshot(screenshot('alert-tablet-checkboxes'));
});

test('should expand width and height on larger displays with radios', async ({ page }) => {
const ionAlertDidPresent = await page.spyOnEvent('ionAlertDidPresent');
const button = page.locator('#radio');
const alert = page.locator('ion-alert');

await button.click();
await ionAlertDidPresent.next();

await expect(alert).toHaveScreenshot(screenshot('alert-tablet-radios'));
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions core/src/components/modal/modal.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// iOS Card Modal
// --------------------------------------------------

@media screen and (max-width: 767px) {
@include mobile-viewport() {
@supports (width: max(0px, 1px)) {
:host(.modal-card) {
--height: calc(100% - max(30px, var(--ion-safe-area-top)) - 10px);
Expand Down Expand Up @@ -60,7 +60,7 @@
}
}

@media screen and (min-width: 768px) {
@include tablet-viewport() {
:host(.modal-card) {
--width: calc(100% - 120px);
--height: calc(100% - (120px + var(--ion-safe-area-top) + var(--ion-safe-area-bottom)));
Expand Down
37 changes: 36 additions & 1 deletion core/src/themes/ionic.mixins.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@

/**
* A heuristic that applies CSS to tablet
* viewports.
*
* Usage:
* @include tablet-viewport() {
* :host {
* background-color: green;
* }
* }
*/
@mixin tablet-viewport() {
@media screen and (min-width: 768px) {
@content;
}
}

/**
* A heuristic that applies CSS to mobile
* viewports (i.e. phones, not tablets).
*
* Usage:
* @include mobile-viewport() {
* :host {
* background-color: blue;
* }
* }
*/
@mixin mobile-viewport() {
@media screen and (max-width: 767px) {
@content;
}
}

@mixin input-cover() {
@include position(0, null, null, 0);
@include margin(0);
Expand Down Expand Up @@ -217,7 +252,7 @@
$restSelectors: append($restSelectors, $selector, comma);
}
}

// Supported by Chrome.
@if length($hostContextSelectors) > 0 {
@at-root #{$hostContextSelectors} {
Expand Down