-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(datetime): add shadow parts and CSS variables for styling wheel …
…pickers (#27529) Issue number: resolves #25945 --------- <!-- 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. --> Datetime wheel pickers cannot be styled. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Adds styling APIs in accordance with the Wheel Pickers and Time Picker sections of [this design doc](https://github.com/ionic-team/ionic-framework-design-documents/blob/main/projects/ionic-framework/components/datetime/datetime-styling.md). Shadow parts added: - `wheel-item` - `wheel-item active` - `time-button` - `time-button active` CSS properties added: - `--wheel-highlight-background` - `--wheel-fade-background-rgb` ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `7.0.7-dev.11685554390.10c2ca9b` Docs PR: ionic-team/ionic-docs#2982
- Loading branch information
1 parent
ea817a5
commit f2c1845
Showing
40 changed files
with
206 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expect } from '@playwright/test'; | ||
import { configs, test } from '@utils/test/playwright'; | ||
|
||
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||
test.describe(title('datetime: custom'), () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(`/src/components/datetime/test/custom`, config); | ||
}); | ||
|
||
test('should allow styling wheel style datetimes', async ({ page }) => { | ||
const datetime = page.locator('#custom-wheel'); | ||
|
||
await expect(datetime).toHaveScreenshot(screenshot(`datetime-custom-wheel`)); | ||
}); | ||
|
||
test('should allow styling month/year picker in grid style datetimes', async ({ page }) => { | ||
const datetime = page.locator('#custom-grid'); | ||
const monthYearToggle = datetime.locator('.calendar-month-year'); | ||
|
||
await monthYearToggle.click(); | ||
await page.waitForChanges(); | ||
|
||
await expect(datetime).toHaveScreenshot(screenshot(`datetime-custom-month-year`)); | ||
}); | ||
|
||
test('should allow styling time picker in grid style datetimes', async ({ page }) => { | ||
const timeButton = page.locator('ion-datetime .time-body'); | ||
const popover = page.locator('.popover-viewport'); | ||
const ionPopoverDidPresent = await page.spyOnEvent('ionPopoverDidPresent'); | ||
|
||
await expect(timeButton).toHaveScreenshot(screenshot(`datetime-custom-time-button`)); | ||
|
||
await timeButton.click(); | ||
await ionPopoverDidPresent.next(); | ||
|
||
await expect(popover).toHaveScreenshot(screenshot(`datetime-custom-time-picker`)); | ||
await expect(timeButton).toHaveScreenshot(screenshot(`datetime-custom-time-button-active`)); | ||
}); | ||
}); | ||
}); |
Binary file added
BIN
+14.6 KB
...ime.e2e.ts-snapshots/datetime-custom-month-year-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.7 KB
...me.e2e.ts-snapshots/datetime-custom-month-year-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.7 KB
...ime.e2e.ts-snapshots/datetime-custom-month-year-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16 KB
...time.e2e.ts-snapshots/datetime-custom-month-year-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.6 KB
...ime.e2e.ts-snapshots/datetime-custom-month-year-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.6 KB
...time.e2e.ts-snapshots/datetime-custom-month-year-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.39 KB
...ts-snapshots/datetime-custom-time-button-active-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.83 KB
...s-snapshots/datetime-custom-time-button-active-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.31 KB
...ts-snapshots/datetime-custom-time-button-active-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.44 KB
....ts-snapshots/datetime-custom-time-button-active-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.78 KB
...ts-snapshots/datetime-custom-time-button-active-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.3 KB
....ts-snapshots/datetime-custom-time-button-active-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.48 KB
...me.e2e.ts-snapshots/datetime-custom-time-button-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.73 KB
...e.e2e.ts-snapshots/datetime-custom-time-button-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.4 KB
...me.e2e.ts-snapshots/datetime-custom-time-button-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.49 KB
...ime.e2e.ts-snapshots/datetime-custom-time-button-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.73 KB
...me.e2e.ts-snapshots/datetime-custom-time-button-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.35 KB
...ime.e2e.ts-snapshots/datetime-custom-time-button-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.82 KB
...me.e2e.ts-snapshots/datetime-custom-time-picker-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.54 KB
...e.e2e.ts-snapshots/datetime-custom-time-picker-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.4 KB
...me.e2e.ts-snapshots/datetime-custom-time-picker-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.64 KB
...ime.e2e.ts-snapshots/datetime-custom-time-picker-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.25 KB
...me.e2e.ts-snapshots/datetime-custom-time-picker-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.11 KB
...ime.e2e.ts-snapshots/datetime-custom-time-picker-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.3 KB
...datetime.e2e.ts-snapshots/datetime-custom-wheel-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.6 KB
...atetime.e2e.ts-snapshots/datetime-custom-wheel-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+11.4 KB
...datetime.e2e.ts-snapshots/datetime-custom-wheel-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+17.7 KB
.../datetime.e2e.ts-snapshots/datetime-custom-wheel-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+19.6 KB
...datetime.e2e.ts-snapshots/datetime-custom-wheel-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+13.3 KB
.../datetime.e2e.ts-snapshots/datetime-custom-wheel-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Datetime - Custom</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" /> | ||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" /> | ||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" /> | ||
<script src="../../../../../scripts/testing/scripts.js"></script> | ||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script> | ||
<style> | ||
.grid { | ||
display: grid; | ||
grid-template-columns: repeat(3, minmax(250px, 1fr)); | ||
grid-row-gap: 20px; | ||
grid-column-gap: 20px; | ||
} | ||
|
||
h2 { | ||
font-size: 12px; | ||
font-weight: normal; | ||
|
||
color: #6f7378; | ||
|
||
margin-top: 10px; | ||
margin-left: 5px; | ||
} | ||
|
||
@media screen and (max-width: 800px) { | ||
.grid { | ||
grid-template-columns: 1fr; | ||
padding: 0; | ||
} | ||
} | ||
|
||
/* | ||
The second selectors that target ion-picker(-column)-internal | ||
directly are for styling the time picker. This is currently | ||
undocumented usage. | ||
*/ | ||
|
||
ion-datetime, | ||
ion-picker-internal { | ||
--wheel-highlight-background: rgb(218, 216, 255); | ||
--wheel-fade-background-rgb: 245, 235, 247; | ||
} | ||
|
||
ion-datetime { | ||
--background: rgb(245, 235, 247); | ||
--background-rgb: 245, 235, 247; | ||
} | ||
|
||
ion-picker-internal { | ||
background-color: rgb(245, 235, 247); | ||
} | ||
|
||
ion-datetime::part(wheel-item), | ||
ion-picker-column-internal::part(wheel-item) { | ||
color: rgb(255, 134, 154); | ||
} | ||
|
||
ion-datetime::part(wheel-item active), | ||
ion-picker-column-internal::part(wheel-item active) { | ||
color: rgb(128, 30, 171); | ||
} | ||
|
||
ion-datetime::part(time-button) { | ||
color: rgb(128, 30, 171); | ||
} | ||
|
||
ion-datetime::part(time-button active) { | ||
background-color: rgb(248, 215, 255); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-header translucent="true"> | ||
<ion-toolbar> | ||
<ion-title>Datetime - Custom</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content class="ion-padding"> | ||
<div class="grid"> | ||
<div class="grid-item"> | ||
<h2>Grid Style</h2> | ||
<ion-datetime id="custom-grid" value="2020-03-14T14:23:00.000Z"></ion-datetime> | ||
</div> | ||
<div class="grid-item"> | ||
<h2>Wheel Style</h2> | ||
<ion-datetime id="custom-wheel" prefer-wheel="true" value="2020-03-14T14:23:00.000Z"></ion-datetime> | ||
</div> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
@import "./picker-internal.scss"; | ||
@import "./picker-internal.vars.scss"; | ||
@import "../../themes/ionic.globals.ios"; | ||
|
||
:host .picker-before { | ||
background: linear-gradient(to bottom, var(--background, var(--ion-background-color, #fff)) 20%, rgba(var(--background-rgb, var(--ion-background-color-rgb, 255, 255, 255)), 0.8) 100%); | ||
background: linear-gradient(to bottom, rgba(#{$picker-fade-background}, 1) 20%, rgba(#{$picker-fade-background}, 0.8) 100%); | ||
} | ||
|
||
:host .picker-after { | ||
background: linear-gradient(to top, var(--background, var(--ion-background-color, #fff)) 20%, rgba(var(--background-rgb, var(--ion-background-color-rgb, 255, 255, 255)), 0.8) 100%); | ||
background: linear-gradient(to top, rgba(#{$picker-fade-background}, 1) 20%, rgba(#{$picker-fade-background}, 0.8) 100%); | ||
} | ||
|
||
:host .picker-highlight { | ||
background: var(--ion-color-step-150, #eeeeef); | ||
background: var(--wheel-highlight-background, var(--ion-color-step-150, #eeeeef)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
@import "./picker-internal.scss"; | ||
@import "./picker-internal.vars.scss"; | ||
@import "../../themes/ionic.globals.md"; | ||
|
||
:host .picker-before { | ||
background: linear-gradient(to bottom, var(--background, var(--ion-background-color, #fff)) 20%, rgba(var(--background-rgb, var(--ion-background-color-rgb, 255, 255, 255)), 0) 90%); | ||
background: linear-gradient(to bottom, rgba(#{$picker-fade-background}, 1) 20%, rgba(#{$picker-fade-background}, 0) 90%); | ||
} | ||
|
||
:host .picker-after { | ||
background: linear-gradient(to top, var(--background, var(--ion-background-color, #fff)) 30%, rgba(var(--background-rgb, var(--ion-background-color-rgb, 255, 255, 255)), 0) 90%); | ||
background: linear-gradient(to top, rgba(#{$picker-fade-background}, 1) 30%, rgba(#{$picker-fade-background}, 0) 90%); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
core/src/components/picker-internal/picker-internal.vars.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$picker-fade-background-fallback: var(--background-rgb, var(--ion-background-color-rgb, 255, 255, 255)); | ||
$picker-fade-background: var(--wheel-fade-background-rgb, $picker-fade-background-fallback); |