diff --git a/demo/e2e/md3-color-roles.spec.ts b/demo/e2e/md3-color-roles.spec.ts index 5394881f..0d5194c3 100644 --- a/demo/e2e/md3-color-roles.spec.ts +++ b/demo/e2e/md3-color-roles.spec.ts @@ -43,6 +43,8 @@ for (const mode of ['light', 'dark'] as const) { 'disabled', 'toolbar-action', ]; + // Read native colors only after every sampled component has hydrated. + await Promise.all(ids.map((id) => expect(page.getByTestId(`palette-${id}`)).toHaveClass(/hydrated/))); const before = Object.fromEntries(await Promise.all(ids.map(async (id) => [id, await colors(page.getByTestId(`palette-${id}`))]))); expect(before['toolbar-action'].foreground).toEqual(before['filled'].foreground); expect(before['tonal'].background).not.toEqual(before['filled'].background); diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-all-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-all-dark.png index 4897a32f..49ceca89 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-all-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-all-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-all.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-all.png index 9fd2666c..9dad56b2 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-all.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-all.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-button-only-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-button-only-dark.png index c75c5d33..f09d0a3d 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-button-only-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-button-only-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-button-only.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-button-only.png index 0571c701..34144f64 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-button-only.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-button-only.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-checkbox-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-checkbox-dark.png new file mode 100644 index 00000000..86606d93 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/alert-checkbox-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-checkbox.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-checkbox.png new file mode 100644 index 00000000..25187787 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/alert-checkbox.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-input-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-input-dark.png new file mode 100644 index 00000000..889b6897 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/alert-input-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-input.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-input.png new file mode 100644 index 00000000..c09de7c2 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/alert-input.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-no-cancel-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-no-cancel-dark.png index 3d414697..d87d3251 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-no-cancel-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-no-cancel-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-no-cancel.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-no-cancel.png index 7d7fc779..c1ec7c3a 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-no-cancel.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-no-cancel.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-preferred-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-preferred-dark.png index 2abb0e98..3892f8a6 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-preferred-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-preferred-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-preferred.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-preferred.png index b00feeb4..eca071cb 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-preferred.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-preferred.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-radio-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-radio-dark.png new file mode 100644 index 00000000..af623780 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/alert-radio-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-radio.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-radio.png new file mode 100644 index 00000000..1c54ece7 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/alert-radio.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-remove-app-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-remove-app-dark.png index 2b5ee0fb..08e2a197 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-remove-app-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-remove-app-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-remove-app.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-remove-app.png index 02185b56..07297ea7 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/alert-remove-app.png and b/demo/e2e/screenshot.spec.ts-snapshots/alert-remove-app.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-textarea-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-textarea-dark.png new file mode 100644 index 00000000..a1b734bf Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/alert-textarea-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/alert-textarea.png b/demo/e2e/screenshot.spec.ts-snapshots/alert-textarea.png new file mode 100644 index 00000000..9c0a7911 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/alert-textarea.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-all-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-all-dark.png index 372fc6ac..df5638d6 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-all-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-all-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-all-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-all-light.png index d35caec9..934823af 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-all-light.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-all-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-button-only-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-button-only-dark.png index aa9cb9ba..95a06cdb 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-button-only-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-button-only-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-button-only-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-button-only-light.png index c821e89a..4939714f 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-button-only-light.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-button-only-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-checkbox-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-checkbox-dark.png new file mode 100644 index 00000000..1a60c697 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-checkbox-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-checkbox-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-checkbox-light.png new file mode 100644 index 00000000..6b8f70d1 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-checkbox-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-input-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-input-dark.png new file mode 100644 index 00000000..cc96a405 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-input-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-input-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-input-light.png new file mode 100644 index 00000000..090c8091 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-input-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-no-cancel-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-no-cancel-dark.png index b4a3da7a..0230a2d1 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-no-cancel-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-no-cancel-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-no-cancel-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-no-cancel-light.png index ca30caef..6696b275 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-no-cancel-light.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-no-cancel-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-preferred-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-preferred-dark.png index d7adc14d..d9401e77 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-preferred-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-preferred-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-preferred-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-preferred-light.png index 5145121f..011d52d6 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-preferred-light.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-preferred-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-radio-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-radio-dark.png new file mode 100644 index 00000000..b861a4d2 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-radio-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-radio-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-radio-light.png new file mode 100644 index 00000000..c28db22d Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-radio-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-remove-app-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-remove-app-dark.png index 900cbd5b..08914152 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-remove-app-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-remove-app-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-remove-app-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-remove-app-light.png index 52726252..31edfb50 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-remove-app-light.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-remove-app-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-textarea-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-textarea-dark.png new file mode 100644 index 00000000..7ad1a8e4 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-textarea-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-alert-textarea-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-textarea-light.png new file mode 100644 index 00000000..e8bcdbf3 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-alert-textarea-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-select-alert-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-select-alert-dark.png index c240b00f..b8bb0cd6 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-select-alert-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-select-alert-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-select-alert-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-select-alert-light.png index 5843e791..44179ae3 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/device-select-alert-light.png and b/demo/e2e/screenshot.spec.ts-snapshots/device-select-alert-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/select-alert-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/select-alert-dark.png index 7c05d4bf..b326c49f 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/select-alert-dark.png and b/demo/e2e/screenshot.spec.ts-snapshots/select-alert-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/select-alert.png b/demo/e2e/screenshot.spec.ts-snapshots/select-alert.png index d35c0ddd..6648e4bf 100644 Binary files a/demo/e2e/screenshot.spec.ts-snapshots/select-alert.png and b/demo/e2e/screenshot.spec.ts-snapshots/select-alert.png differ diff --git a/demo/src/app/index/pages/alert/alert.page.html b/demo/src/app/index/pages/alert/alert.page.html index c97b17f9..9bae6cde 100644 --- a/demo/src/app/index/pages/alert/alert.page.html +++ b/demo/src/app/index/pages/alert/alert.page.html @@ -27,6 +27,10 @@

alert

present:button-only present:no-cancel present:preferred + present:checkbox + present:radio + present:input + present:textarea present:remove-app diff --git a/demo/src/app/index/pages/alert/alert.page.ts b/demo/src/app/index/pages/alert/alert.page.ts index d6e2872b..7b80d279 100644 --- a/demo/src/app/index/pages/alert/alert.page.ts +++ b/demo/src/app/index/pages/alert/alert.page.ts @@ -3,6 +3,7 @@ import { Component, effect, inject, OnInit } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { AlertController, + type AlertOptions, IonBackButton, IonContent, IonHeader, @@ -56,7 +57,32 @@ export class AlertPage implements OnInit { ngOnInit() {} async present(type: (typeof alertTypes)[number]) { - const applyConfig = ((type) => { + const applyConfig = ((type): AlertOptions => { + if (type === 'checkbox' || type === 'radio') { + return { + header: 'Choose options', + inputs: [ + { type, label: 'Apple', value: 'apple', checked: true }, + { type, label: 'Banana', value: 'banana' }, + { type, label: 'A longer option that wraps onto another line', value: 'orange' }, + { type, label: 'Unavailable', value: 'disabled', disabled: true }, + ], + buttons: [ + { text: 'Cancel', role: 'cancel' }, + { text: 'OK', role: 'preferred' }, + ], + }; + } + if (type === 'input' || type === 'textarea') { + return { + header: type === 'input' ? 'Device name' : 'Description', + inputs: [{ type: type === 'input' ? 'text' : 'textarea', value: type === 'input' ? 'Pixel 8a' : '', placeholder: 'Enter text' }], + buttons: [ + { text: 'Cancel', role: 'cancel' }, + { text: 'OK', role: 'preferred' }, + ], + }; + } if (type === 'preferred') { return { ...alertUtil(), diff --git a/demo/src/app/overlay-types.ts b/demo/src/app/overlay-types.ts index dcb5ba5a..f8059358 100644 --- a/demo/src/app/overlay-types.ts +++ b/demo/src/app/overlay-types.ts @@ -1,4 +1,4 @@ -export const alertTypes = ['all', 'button-only', 'no-cancel', 'remove-app', 'preferred']; +export const alertTypes = ['all', 'button-only', 'no-cancel', 'remove-app', 'preferred', 'checkbox', 'radio', 'input', 'textarea']; export const actionSheetTypes = ['all', 'button-only', 'no-cancel', 'preferred']; export const toastTypes = ['top', 'middle', 'bottom', 'anchor']; export const modalTypes = ['normal', 'card', 'sheet']; diff --git a/src/styles/components/_colors.scss b/src/styles/components/_colors.scss index b405da28..b253f0fc 100644 --- a/src/styles/components/_colors.scss +++ b/src/styles/components/_colors.scss @@ -298,6 +298,52 @@ ion-alert.md:where(:not(.md3-disabled)) .alert-message { color: var(--md-sys-color-on-surface-variant, var(--ion-color-step-550, var(--ion-text-color-step-450, #737373))); } +// Alert inputs are native elements, not ion-checkbox / ion-radio / ion-input. +// Map state colors explicitly so Material roles reach the embedded controls. +// Beat Ionic’s scoped checked-state selectors, including its extra scope classes. +ion-alert.md:not(.md3-disabled) { + .alert-checkbox-icon, + .alert-radio-icon { + border-color: #{md3.color(on-surface-variant)}; + } + + .alert-checkbox-label, + .alert-radio-label, + .alert-input { + color: #{md3.color(on-surface)}; + } + + [aria-checked='true'] .alert-checkbox-icon { + background: #{md3.color(primary)}; + border-color: #{md3.color(primary)}; + } + + [aria-checked='true'] .alert-checkbox-inner { + border-color: #{md3.color(on-primary)}; + } + + [aria-checked='true'] .alert-radio-icon { + border-color: #{md3.color(primary)}; + } + + .alert-radio-inner { + background: #{md3.color(primary)}; + } + + .alert-input { + border-bottom-color: #{md3.color(on-surface-variant)}; + caret-color: #{md3.color(primary)}; + } + + .alert-input::placeholder { + color: #{md3.color(on-surface-variant)}; + } + + .alert-input:focus { + border-bottom-color: #{md3.color(primary)}; + } +} + ion-alert.md:where(:not(.md3-disabled)) .alert-button { background: transparent; color: var(--md-sys-color-on-surface, var(--ion-color-primary, #0054e9)); diff --git a/src/styles/components/ion-alert.scss b/src/styles/components/ion-alert.scss index 5dd20375..b92d0c21 100644 --- a/src/styles/components/ion-alert.scss +++ b/src/styles/components/ion-alert.scss @@ -46,6 +46,57 @@ ion-alert.md:not(.md3-disabled) { padding-bottom: 16px; } + // Android 17 Settings choice dialogs have no persistent list dividers. + // Keep space between the last option and the rounded action buttons; + // action-only and text-input alerts already supply their own content gap. + .alert-radio-group, + .alert-checkbox-group { + border: 0; + padding-bottom: 24px; + } + + // Settings uses an 18dp checkbox. Keep the rotated check inside Ionic's + // strictly contained icon; Ionic retains option placement and RTL ordering. + .alert-checkbox-icon { + flex-shrink: 0; + width: 18px; + height: 18px; + } + + // Ionic 8 has no placement classes and uses different checkbox column + // offsets. Bring that legacy markup to the same columns as Ionic 9 while + // retaining Ionic 9's explicit placement/justification options. + .alert-checkbox-button > .alert-button-inner:not(.checkbox-label-placement-start):not(.checkbox-label-placement-end) { + justify-content: flex-start; + + .alert-checkbox-icon { + inset-inline-start: 24px; + } + + .alert-checkbox-label { + flex: 0 1 auto; + width: auto; + max-width: calc(100% - 16px); + padding-inline: 56px 24px; + } + } + + [aria-checked='true'] .alert-checkbox-inner { + top: 1px; + inset-inline-start: 4px; + } + + // The header already supplies spacing. Ionic adds another 20px above + // inputs even when the intervening message is empty. + .alert-head:not(:empty) + .alert-message:empty + .alert-input-group { + padding-top: 0; + } + + .alert-input { + font-size: 1.125rem; + line-height: 1.5; + } + .alert-button-group { padding: 0 24px 24px; column-gap: 8px;