Skip to content

Commit d5627c7

Browse files
committed
feat(datetime): add border property to highlightedDates (#30534)
Issue number: resolves #29833 --------- - Adds the `border` property for customizing the border of highlighted dates - Adds the `border` to the e2e test for highlightedDates - Updates screenshots --------- Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
1 parent 74cd71a commit d5627c7

23 files changed

+27
-10
lines changed

core/src/components/datetime/datetime-interface.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ export type DatetimePresentation = 'date-time' | 'time-date' | 'date' | 'time' |
2222

2323
export type TitleSelectedDatesFormatter = (selectedDates: string[]) => string;
2424

25-
export type DatetimeHighlightStyle =
26-
| {
27-
textColor: string;
28-
backgroundColor?: string;
29-
}
30-
| {
31-
textColor?: string;
32-
backgroundColor: string;
33-
};
25+
/**
26+
* DatetimeHighlightStyle must include textColor, backgroundColor, or border.
27+
* It cannot be an empty object.
28+
*/
29+
export type DatetimeHighlightStyle = {
30+
textColor?: string;
31+
backgroundColor?: string;
32+
border?: string;
33+
} & ({ textColor: string } | { backgroundColor: string } | { border: string });
3434

3535
export type DatetimeHighlight = { date: string } & DatetimeHighlightStyle;
3636

core/src/components/datetime/datetime.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,7 @@ export class Datetime implements ComponentInterface {
23352335
`${dateStyle ? dateStyle.backgroundColor : ''}`,
23362336
'important'
23372337
);
2338+
el.style.setProperty('border', `${dateStyle ? dateStyle.border : ''}`, 'important');
23382339
}
23392340
}}
23402341
tabindex="-1"

core/src/components/datetime/test/highlighted-dates/datetime.e2e.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
2121
date: '2023-01-01', // ensure selected date style overrides highlight
2222
textColor: '#800080',
2323
backgroundColor: '#ffc0cb',
24+
border: '2px solid purple',
2425
},
2526
{
2627
date: '2023-01-02',
2728
textColor: '#b22222',
2829
backgroundColor: '#fa8072',
30+
border: '2px solid purple',
2931
},
3032
{
3133
date: '2023-01-03',
3234
textColor: '#0000ff',
3335
backgroundColor: '#add8e6',
36+
border: '2px solid purple',
3437
},
3538
];
3639
});
@@ -52,20 +55,23 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
5255
return {
5356
textColor: '#b22222',
5457
backgroundColor: '#fa8072',
58+
border: '2px solid purple',
5559
};
5660
}
5761

5862
if (utcDay % 5 === 0) {
5963
return {
6064
textColor: '#800080',
6165
backgroundColor: '#ffc0cb',
66+
border: '2px solid purple',
6267
};
6368
}
6469

6570
if (utcDay % 3 === 0) {
6671
return {
6772
textColor: '#0000ff',
6873
backgroundColor: '#add8e6',
74+
border: '2px solid purple',
6975
};
7076
}
7177

@@ -77,7 +83,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
7783
await expect(datetime).toHaveScreenshot(screenshot(`datetime-highlightedDates-callback`));
7884
});
7985

80-
test('should render highlights correctly when only using one color or the other', async ({ page }) => {
86+
test('should render highlights correctly when only using only one color property', async ({ page }) => {
8187
const datetime = page.locator('ion-datetime');
8288

8389
await datetime.evaluate((el: HTMLIonDatetimeElement) => {
@@ -90,6 +96,10 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
9096
date: '2023-01-03',
9197
textColor: '#0000ff',
9298
},
99+
{
100+
date: '2023-01-04',
101+
border: '2px solid purple',
102+
},
93103
];
94104
});
95105

0 commit comments

Comments
 (0)