Skip to content
Open
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
1 change: 1 addition & 0 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ ion-datetime,part,calendar-day today
ion-datetime,part,month-year-button
ion-datetime,part,time-button
ion-datetime,part,time-button active
ion-datetime,part,wheel
ion-datetime,part,wheel-item
ion-datetime,part,wheel-item active

Expand Down
9 changes: 9 additions & 0 deletions core/src/components/datetime/datetime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import { checkForPresentationFormatMismatch, warnIfTimeZoneProvided } from './ut
* @slot buttons - The buttons in the datetime.
* @slot time-label - The label for the time selector in the datetime.
*
* @part wheel - The wheel container when using a wheel style layout, or in the month/year picker when using a grid style layout.
* @part wheel-item - The individual items when using a wheel style layout, or in the
* month/year picker when using a grid style layout.
* @part wheel-item active - The currently selected wheel-item.
Expand Down Expand Up @@ -1724,6 +1725,7 @@ export class Datetime implements ComponentInterface {

return (
<ion-picker-column
part={WHEEL_PART}
aria-label="Select a date"
class="date-column"
color={this.color}
Expand Down Expand Up @@ -1844,6 +1846,7 @@ export class Datetime implements ComponentInterface {

return (
<ion-picker-column
part={WHEEL_PART}
aria-label="Select a day"
class="day-column"
color={this.color}
Expand Down Expand Up @@ -1888,6 +1891,7 @@ export class Datetime implements ComponentInterface {

return (
<ion-picker-column
part={WHEEL_PART}
aria-label="Select a month"
class="month-column"
color={this.color}
Expand Down Expand Up @@ -1931,6 +1935,7 @@ export class Datetime implements ComponentInterface {

return (
<ion-picker-column
part={WHEEL_PART}
aria-label="Select a year"
class="year-column"
color={this.color}
Expand Down Expand Up @@ -2005,6 +2010,7 @@ export class Datetime implements ComponentInterface {

return (
<ion-picker-column
part={WHEEL_PART}
aria-label="Select an hour"
color={this.color}
disabled={disabled}
Expand Down Expand Up @@ -2045,6 +2051,7 @@ export class Datetime implements ComponentInterface {

return (
<ion-picker-column
part={WHEEL_PART}
aria-label="Select a minute"
color={this.color}
disabled={disabled}
Expand Down Expand Up @@ -2088,6 +2095,7 @@ export class Datetime implements ComponentInterface {

return (
<ion-picker-column
part={WHEEL_PART}
aria-label="Select a day period"
style={isDayPeriodRTL ? { order: '-1' } : {}}
color={this.color}
Expand Down Expand Up @@ -2716,5 +2724,6 @@ export class Datetime implements ComponentInterface {
let datetimeIds = 0;
const CANCEL_ROLE = 'datetime-cancel';
const CONFIRM_ROLE = 'datetime-confirm';
const WHEEL_PART = 'wheel';
const WHEEL_ITEM_PART = 'wheel-item';
const WHEEL_ITEM_ACTIVE_PART = `active`;
66 changes: 66 additions & 0 deletions core/src/components/datetime/test/custom/datetime.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,72 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
await expect(datetime).toHaveScreenshot(screenshot(`datetime-custom-calendar-days`));
});
});

test.describe(title('CSS shadow parts'), () => {
test('should be able to customize wheel part', async ({ page }, testInfo) => {
testInfo.annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/30420',
});

await page.setContent(
`
<style>
ion-datetime::part(wheel) {
background-color: red;
}
</style>
<ion-datetime
prefer-wheel="true"
value="2020-03-14T14:23:00.000Z"
></ion-datetime>
`,
config
);

const datetime = page.locator('ion-datetime');
const pickerColumn = datetime.locator('ion-picker-column').first();

const backgroundColor = await pickerColumn.evaluate((el) => {
return window.getComputedStyle(el).backgroundColor;
});

expect(backgroundColor).toBe('rgb(255, 0, 0)');
});

test('should be able to customize wheel part when focused', async ({ page }, testInfo) => {
testInfo.annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/30420',
});

await page.setContent(
`
<style>
ion-datetime::part(wheel):focus {
background-color: blue;
}
</style>
<ion-datetime
prefer-wheel="true"
value="2020-03-14T14:23:00.000Z"
></ion-datetime>
`,
config
);

const datetime = page.locator('ion-datetime');
const pickerColumn = datetime.locator('ion-picker-column').first();

await pickerColumn.click({ position: { x: 10, y: 10 } });

const backgroundColor = await pickerColumn.evaluate((el) => {
return window.getComputedStyle(el).backgroundColor;
});

expect(backgroundColor).toBe('rgb(0, 0, 255)');
});
});
});

/**
Expand Down
5 changes: 5 additions & 0 deletions core/src/components/datetime/test/custom/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
color: rgb(128, 30, 171);
}

.custom-grid-wheel::part(wheel):focus,
ion-picker-column:focus {
background-color: rgba(138, 238, 69, 0.37);
}

/*
* Custom Datetime Day Parts
* -------------------------------------------
Expand Down
Loading