From 5c10f88b2eb4d869966ea9a6d1db34185cefe676 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Wed, 24 May 2023 10:54:18 -0400 Subject: [PATCH] feat(select): expose container and label as CSS parts (#27541) Issue number: resolves #27112 --------- ## What is the current behavior? The select does not expose the label or the container for the value/placeholder as a CSS shadow part in order to style it. ## What is the new behavior? - Exposed `label` and `container` parts for custom styling - Added an e2e test to verify the parts are working - Renamed the existing screenshots for the custom tests to fix a typo from "custon" to "custom" ## Does this introduce a breaking change? - [ ] Yes - [x] No --------- Co-authored-by: ionitron --- core/api.txt | 2 + core/src/components/select/select.tsx | 6 ++- .../select/test/custom/select.e2e.ts | 36 +++++++++++++++++- ...stom-diff-ios-ltr-Mobile-Chrome-linux.png} | Bin ...tom-diff-ios-ltr-Mobile-Firefox-linux.png} | Bin ...stom-diff-ios-ltr-Mobile-Safari-linux.png} | Bin ...ustom-diff-md-ltr-Mobile-Chrome-linux.png} | Bin ...stom-diff-md-ltr-Mobile-Firefox-linux.png} | Bin ...ustom-diff-md-ltr-Mobile-Safari-linux.png} | Bin ...parts-diff-ios-ltr-Mobile-Chrome-linux.png | Bin 0 -> 4315 bytes ...arts-diff-ios-ltr-Mobile-Firefox-linux.png | Bin 0 -> 5562 bytes ...parts-diff-ios-ltr-Mobile-Safari-linux.png | Bin 0 -> 3932 bytes ...-parts-diff-md-ltr-Mobile-Chrome-linux.png | Bin 0 -> 3803 bytes ...parts-diff-md-ltr-Mobile-Firefox-linux.png | Bin 0 -> 4725 bytes ...-parts-diff-md-ltr-Mobile-Safari-linux.png | Bin 0 -> 3296 bytes 15 files changed, 41 insertions(+), 3 deletions(-) rename core/src/components/select/test/custom/select.e2e.ts-snapshots/{select-custon-diff-ios-ltr-Mobile-Chrome-linux.png => select-custom-diff-ios-ltr-Mobile-Chrome-linux.png} (100%) rename core/src/components/select/test/custom/select.e2e.ts-snapshots/{select-custon-diff-ios-ltr-Mobile-Firefox-linux.png => select-custom-diff-ios-ltr-Mobile-Firefox-linux.png} (100%) rename core/src/components/select/test/custom/select.e2e.ts-snapshots/{select-custon-diff-ios-ltr-Mobile-Safari-linux.png => select-custom-diff-ios-ltr-Mobile-Safari-linux.png} (100%) rename core/src/components/select/test/custom/select.e2e.ts-snapshots/{select-custon-diff-md-ltr-Mobile-Chrome-linux.png => select-custom-diff-md-ltr-Mobile-Chrome-linux.png} (100%) rename core/src/components/select/test/custom/select.e2e.ts-snapshots/{select-custon-diff-md-ltr-Mobile-Firefox-linux.png => select-custom-diff-md-ltr-Mobile-Firefox-linux.png} (100%) rename core/src/components/select/test/custom/select.e2e.ts-snapshots/{select-custon-diff-md-ltr-Mobile-Safari-linux.png => select-custom-diff-md-ltr-Mobile-Safari-linux.png} (100%) create mode 100644 core/src/components/select/test/custom/select.e2e.ts-snapshots/select-custom-parts-diff-ios-ltr-Mobile-Chrome-linux.png create mode 100644 core/src/components/select/test/custom/select.e2e.ts-snapshots/select-custom-parts-diff-ios-ltr-Mobile-Firefox-linux.png create mode 100644 core/src/components/select/test/custom/select.e2e.ts-snapshots/select-custom-parts-diff-ios-ltr-Mobile-Safari-linux.png create mode 100644 core/src/components/select/test/custom/select.e2e.ts-snapshots/select-custom-parts-diff-md-ltr-Mobile-Chrome-linux.png create mode 100644 core/src/components/select/test/custom/select.e2e.ts-snapshots/select-custom-parts-diff-md-ltr-Mobile-Firefox-linux.png create mode 100644 core/src/components/select/test/custom/select.e2e.ts-snapshots/select-custom-parts-diff-md-ltr-Mobile-Safari-linux.png diff --git a/core/api.txt b/core/api.txt index ef311f982b..7ba90bf116 100644 --- a/core/api.txt +++ b/core/api.txt @@ -1267,7 +1267,9 @@ ion-select,css-prop,--padding-top ion-select,css-prop,--placeholder-color ion-select,css-prop,--placeholder-opacity ion-select,css-prop,--ripple-color +ion-select,part,container ion-select,part,icon +ion-select,part,label ion-select,part,placeholder ion-select,part,text diff --git a/core/src/components/select/select.tsx b/core/src/components/select/select.tsx index 2cd3db9040..1050749ca7 100644 --- a/core/src/components/select/select.tsx +++ b/core/src/components/select/select.tsx @@ -35,6 +35,8 @@ import type { SelectChangeEventDetail, SelectInterface, SelectCompareFn } from ' * @part placeholder - The text displayed in the select when there is no value. * @part text - The displayed value of the select. * @part icon - The select icon container. + * @part container - The container for the selected text or placeholder. + * @part label - The label text describing the select. */ @Component({ tag: 'ion-select', @@ -701,7 +703,7 @@ export class Select implements ComponentInterface { } return ( -
+
{this.label}
); @@ -776,7 +778,7 @@ export class Select implements ComponentInterface { >