Skip to content

Commit 4c648d3

Browse files
committed
feat(select): add css vars for color, screenshot tests and updated snapshots
1 parent c610a03 commit 4c648d3

17 files changed

+58
-7
lines changed

core/src/components/select/select.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
*
2727
* @prop --ripple-color: The color of the ripple effect on MD mode.
2828
*
29-
* TODO: add supporting text css vars
29+
* @prop --helper-text-color: The color of the supporting text displayed beneath the select when the select is valid.
30+
* @prop --error-text-color: The color of the supporting text displayed beneath the select when the select is invalid and touched.
3031
*/
3132
--padding-top: 0px;
3233
--padding-end: 0px;
@@ -39,6 +40,8 @@
3940
--highlight-color-focused: #{ion-color(primary, base)};
4041
--highlight-color-valid: #{ion-color(success, base)};
4142
--highlight-color-invalid: #{ion-color(danger, base)};
43+
--helper-text-color: #{$text-color-step-300};
44+
--error-text-color: var(--highlight-color-invalid);
4245

4346
/**
4447
* This is a private API that is used to switch
@@ -325,13 +328,13 @@ button {
325328
.select-bottom .error-text {
326329
display: none;
327330

328-
color: var(--highlight-color-invalid);
331+
color: var(--error-text-color);
329332
}
330333

331334
.select-bottom .helper-text {
332335
display: block;
333336

334-
color: $text-color-step-300;
337+
color: var(--helper-text-color);
335338
}
336339

337340
:host(.ion-touched.ion-invalid) .select-bottom .error-text {

core/src/components/select/test/bottom-content/select.e2e.ts

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ configs({ modes: ['ios', 'md'], directions: ['ltr'] }).forEach(({ title, screens
151151
*/
152152
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
153153
test.describe(title('select: supporting text customization'), () => {
154-
test('should not have visual regressions when rendering helper text with a custom color', async ({ page }) => {
154+
test('should not have visual regressions when rendering helper text with a custom color via css parts', async ({ page }) => {
155155
await page.setContent(
156156
`
157157
<style>
@@ -169,9 +169,25 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c
169169
);
170170

171171
const errorText = page.locator('ion-select');
172-
await expect(errorText).toHaveScreenshot(screenshot(`select-helper-text-custom`));
172+
await expect(errorText).toHaveScreenshot(screenshot(`select-helper-text-custom-parts`));
173173
});
174-
test('should not have visual regressions when rendering error text with a custom color', async ({ page }) => {
174+
test('should not have visual regressions when rendering helper text with a custom color via css var', async ({ page }) => {
175+
await page.setContent(
176+
`
177+
<style>
178+
ion-select.custom-select {
179+
--helper-text-color: green;
180+
}
181+
</style>
182+
<ion-select class="custom-select" label="Label" helper-text="Helper text"></ion-select>
183+
`,
184+
config
185+
);
186+
187+
const helperText = page.locator('ion-select');
188+
await expect(helperText).toHaveScreenshot(screenshot(`select-helper-text-custom-color-var`));
189+
});
190+
test('should not have visual regressions when rendering error text with a custom color via css parts', async ({ page }) => {
175191
await page.setContent(
176192
`
177193
<style>
@@ -189,7 +205,39 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c
189205
);
190206

191207
const errorText = page.locator('ion-select');
192-
await expect(errorText).toHaveScreenshot(screenshot(`select-error-text-custom`));
208+
await expect(errorText).toHaveScreenshot(screenshot(`select-error-text-custom-parts`));
209+
});
210+
test('should not have visual regressions when rendering error text with a custom color via css var', async ({ page }) => {
211+
await page.setContent(
212+
`
213+
<style>
214+
ion-select.custom-select {
215+
--error-text-color: purple;
216+
}
217+
</style>
218+
<ion-select class="ion-invalid ion-touched custom-select" label="Label" error-text="Error text"></ion-select>
219+
`,
220+
config
221+
);
222+
223+
const errorText = page.locator('ion-select');
224+
await expect(errorText).toHaveScreenshot(screenshot(`select-error-text-custom-color-var`));
225+
});
226+
test('should not have visual regressions when rendering error text with a custom color via css highlight var', async ({ page }) => {
227+
await page.setContent(
228+
`
229+
<style>
230+
ion-select.custom-select {
231+
--highlight-color-invalid: purple;
232+
}
233+
</style>
234+
<ion-select class="ion-invalid ion-touched custom-select" label="Label" error-text="Error text"></ion-select>
235+
`,
236+
config
237+
);
238+
239+
const errorText = page.locator('ion-select');
240+
await expect(errorText).toHaveScreenshot(screenshot(`select-error-text-custom-highlight-var`));
193241
});
194242
});
195243
});
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)