@@ -42,6 +42,140 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
4242 await expect ( datetime ) . toHaveScreenshot ( screenshot ( `datetime-custom-calendar-days` ) ) ;
4343 } ) ;
4444 } ) ;
45+
46+ test . describe ( title ( 'CSS shadow parts' ) , ( ) => {
47+ test ( 'should be able to customize wheel part within the wheel style' , async ( { page } , testInfo ) => {
48+ testInfo . annotations . push ( {
49+ type : 'issue' ,
50+ description : 'https://github.com/ionic-team/ionic-framework/issues/30420' ,
51+ } ) ;
52+
53+ await page . setContent (
54+ `
55+ <style>
56+ ion-datetime::part(wheel) {
57+ background-color: red;
58+ }
59+ </style>
60+ <ion-datetime
61+ prefer-wheel="true"
62+ value="2020-03-14T14:23:00.000Z"
63+ ></ion-datetime>
64+ ` ,
65+ config
66+ ) ;
67+
68+ const datetime = page . locator ( 'ion-datetime' ) ;
69+ const pickerColumn = datetime . locator ( 'ion-picker-column' ) . first ( ) ;
70+
71+ const backgroundColor = await pickerColumn . evaluate ( ( el ) => {
72+ return window . getComputedStyle ( el ) . backgroundColor ;
73+ } ) ;
74+
75+ expect ( backgroundColor ) . toBe ( 'rgb(255, 0, 0)' ) ;
76+ } ) ;
77+
78+ test ( 'should be able to customize wheel part within the month/year picker' , async ( { page } , testInfo ) => {
79+ testInfo . annotations . push ( {
80+ type : 'issue' ,
81+ description : 'https://github.com/ionic-team/ionic-framework/issues/30420' ,
82+ } ) ;
83+
84+ await page . setContent (
85+ `
86+ <style>
87+ ion-datetime::part(wheel) {
88+ background-color: orange;
89+ }
90+ </style>
91+ <ion-datetime
92+ value="2020-03-14T14:23:00.000Z"
93+ ></ion-datetime>
94+ ` ,
95+ config
96+ ) ;
97+
98+ const datetime = page . locator ( 'ion-datetime' ) ;
99+ const monthYearButton = datetime . locator ( '.calendar-month-year-toggle' ) ;
100+
101+ await monthYearButton . click ( ) ;
102+
103+ const pickerColumn = datetime . locator ( 'ion-picker-column' ) . first ( ) ;
104+
105+ const backgroundColor = await pickerColumn . evaluate ( ( el ) => {
106+ return window . getComputedStyle ( el ) . backgroundColor ;
107+ } ) ;
108+
109+ expect ( backgroundColor ) . toBe ( 'rgb(255, 165, 0)' ) ;
110+ } ) ;
111+
112+ test ( 'should be able to customize wheel part within the time picker' , async ( { page } , testInfo ) => {
113+ testInfo . annotations . push ( {
114+ type : 'issue' ,
115+ description : 'https://github.com/ionic-team/ionic-framework/issues/30420' ,
116+ } ) ;
117+
118+ await page . setContent (
119+ `
120+ <style>
121+ ion-picker-column {
122+ background-color: green;
123+ }
124+ </style>
125+ <ion-datetime
126+ value="2020-03-14T14:23:00.000Z"
127+ ></ion-datetime>
128+ ` ,
129+ config
130+ ) ;
131+
132+ const datetime = page . locator ( 'ion-datetime' ) ;
133+ const timeButton = datetime . locator ( '.time-body' ) ;
134+
135+ await timeButton . click ( ) ;
136+
137+ const pickerColumn = page . locator ( 'ion-picker-column' ) . first ( ) ;
138+
139+ const backgroundColor = await pickerColumn . evaluate ( ( el ) => {
140+ return window . getComputedStyle ( el ) . backgroundColor ;
141+ } ) ;
142+
143+ expect ( backgroundColor ) . toBe ( 'rgb(0, 128, 0)' ) ;
144+ } ) ;
145+
146+ test ( 'should be able to customize wheel part when focused' , async ( { page } , testInfo ) => {
147+ testInfo . annotations . push ( {
148+ type : 'issue' ,
149+ description : 'https://github.com/ionic-team/ionic-framework/issues/30420' ,
150+ } ) ;
151+
152+ await page . setContent (
153+ `
154+ <style>
155+ ion-datetime::part(wheel):focus {
156+ background-color: blue;
157+ }
158+ </style>
159+ <ion-datetime
160+ prefer-wheel="true"
161+ value="2020-03-14T14:23:00.000Z"
162+ ></ion-datetime>
163+ ` ,
164+ config
165+ ) ;
166+
167+ const datetime = page . locator ( 'ion-datetime' ) ;
168+ const pickerColumn = datetime . locator ( 'ion-picker-column' ) . first ( ) ;
169+
170+ await pickerColumn . click ( { position : { x : 10 , y : 10 } } ) ;
171+
172+ const backgroundColor = await pickerColumn . evaluate ( ( el ) => {
173+ return window . getComputedStyle ( el ) . backgroundColor ;
174+ } ) ;
175+
176+ expect ( backgroundColor ) . toBe ( 'rgb(0, 0, 255)' ) ;
177+ } ) ;
178+ } ) ;
45179} ) ;
46180
47181/**
0 commit comments