Skip to content

Commit ba1f50f

Browse files
committed
feat(select): add ionic theme styles
1 parent a5a7bee commit ba1f50f

File tree

7 files changed

+133
-77
lines changed

7 files changed

+133
-77
lines changed

core/src/components/select/select.scss renamed to core/src/components/select/select.common.scss

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use "../../themes/mixins" as mixins;
12
@import "./select.vars";
23

34
// Select
@@ -31,7 +32,6 @@
3132
--padding-bottom: 0px;
3233
--padding-start: 0px;
3334
--placeholder-color: currentColor;
34-
--placeholder-opacity: #{$placeholder-opacity};
3535
--background: transparent;
3636
--border-style: solid;
3737
--highlight-color-focused: #{ion-color(primary, base)};
@@ -52,12 +52,9 @@
5252
width: 100%;
5353
min-height: 44px;
5454

55-
font-family: $font-family-base;
56-
5755
white-space: nowrap;
5856

5957
cursor: pointer;
60-
z-index: $z-index-item-input;
6158
}
6259

6360
/**
@@ -115,15 +112,13 @@
115112
}
116113

117114
button {
118-
@include visually-hidden();
115+
@include mixins.visually-hidden();
119116
}
120117

121118
// Select Icon
122119
// --------------------------------------------------
123120

124121
.select-icon {
125-
@include margin(0, 0, 0, $select-icon-margin-start);
126-
127122
position: relative;
128123

129124
/**
@@ -193,9 +188,6 @@ button {
193188
// --------------------------------------------------
194189

195190
.select-wrapper {
196-
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
197-
@include border-radius(var(--border-radius));
198-
199191
display: flex;
200192

201193
position: relative;
@@ -389,15 +381,6 @@ button {
389381
flex-direction: row;
390382
}
391383

392-
:host(.select-label-placement-start) .label-text-wrapper {
393-
/**
394-
* The margin between the label and
395-
* the select should be on the end
396-
* when the label sits at the start.
397-
*/
398-
@include margin(0, $form-control-label-margin, 0, 0);
399-
}
400-
401384
// Select Label Placement - End
402385
// ----------------------------------------------------------------
403386

@@ -409,27 +392,6 @@ button {
409392
flex-direction: row-reverse;
410393
}
411394

412-
/**
413-
* The margin between the label and
414-
* the select should be on the start
415-
* when the label sits at the end.
416-
*/
417-
:host(.select-label-placement-end) .label-text-wrapper {
418-
@include margin(0, 0, 0, $form-control-label-margin);
419-
}
420-
421-
// Select Label Placement - Fixed
422-
// ----------------------------------------------------------------
423-
424-
:host(.select-label-placement-fixed) .label-text-wrapper {
425-
/**
426-
* The margin between the label and
427-
* the select should be on the end
428-
* when the label sits at the start.
429-
*/
430-
@include margin(0, $form-control-label-margin, 0, 0);
431-
}
432-
433395
/**
434396
* Label is on the left of the select in LTR and
435397
* on the right in RTL. Label also has a fixed width.
@@ -488,28 +450,11 @@ button {
488450
*/
489451
:host(.select-label-placement-stacked) .native-wrapper,
490452
:host(.select-label-placement-floating) .native-wrapper {
491-
@include margin(1px, 0, 0, 0);
492-
493453
flex-grow: 1;
494454

495455
width: 100%;
496456
}
497457

498-
/**
499-
* This makes the label sit over the select
500-
* when the select is blurred and has no value.
501-
* The label should not sit over the select if the
502-
* select has a placeholder.
503-
* Note: This is different from what ion-input does
504-
* because the activating the select causes an overlay
505-
* to appear. This makes it hard to read the placeholder.
506-
* With ion-input, the input just focuses and the placeholder
507-
* is still easy to read.
508-
*/
509-
:host(.select-label-placement-floating) .label-text-wrapper {
510-
@include transform(translateY(100%), scale(1));
511-
}
512-
513458
/**
514459
* The placeholder should be hidden when the label
515460
* is on top of the select. This prevents the label
@@ -537,19 +482,6 @@ button {
537482
opacity: 1;
538483
}
539484

540-
/**
541-
* This makes the label sit above the input.
542-
*/
543-
:host(.label-floating) .label-text-wrapper {
544-
@include transform(translateY(50%), scale(#{$form-control-label-stacked-scale}));
545-
546-
/**
547-
* Label text should not extend
548-
* beyond the bounds of the input.
549-
*/
550-
max-width: calc(100% / #{$form-control-label-stacked-scale});
551-
}
552-
553485
// Start/End Slots
554486
// ----------------------------------------------------------------
555487

@@ -564,11 +496,9 @@ button {
564496
}
565497

566498
::slotted([slot="start"]:last-of-type) {
567-
margin-inline-end: $form-control-label-margin;
568499
margin-inline-start: 0;
569500
}
570501

571502
::slotted([slot="end"]:first-of-type) {
572-
margin-inline-start: $form-control-label-margin;
573503
margin-inline-end: 0;
574504
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@use "../../themes/ionic/ionic.globals.scss" as globals;
2+
@use "./select.common";
3+
4+
// Ionic Select
5+
// -------------------------------------------------
6+
7+
// Select Label
8+
// ----------------------------------------------------------------
9+
10+
.label-text-wrapper {
11+
@include globals.typography(globals.$ion-body-sm-medium);
12+
}

core/src/components/select/select.ios.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "./select";
1+
@import "./select.native";
22
@import "./select.ios.vars";
33

44
// iOS Select

core/src/components/select/select.md.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "./select";
1+
@import "./select.native";
22
@import "./select.md.vars";
33
@import "./select.md.solid.scss";
44
@import "./select.md.outline.scss";
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
@import "../../themes/native/native.globals";
2+
@import "./select.common";
3+
4+
// Select: Native
5+
// --------------------------------------------------
6+
7+
:host {
8+
--placeholder-opacity: #{$placeholder-opacity};
9+
10+
font-family: $font-family-base;
11+
12+
z-index: $z-index-item-input;
13+
}
14+
15+
// Select Icon
16+
// --------------------------------------------------
17+
18+
.select-icon {
19+
@include margin(0, 0, 0, $select-icon-margin-start);
20+
}
21+
22+
// Select Wrapper
23+
// --------------------------------------------------
24+
25+
.select-wrapper {
26+
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
27+
@include border-radius(var(--border-radius));
28+
}
29+
30+
// Select Label Placement - Start
31+
// ----------------------------------------------------------------
32+
33+
:host(.select-label-placement-start) .label-text-wrapper {
34+
/**
35+
* The margin between the label and
36+
* the select should be on the end
37+
* when the label sits at the start.
38+
*/
39+
@include margin(0, $form-control-label-margin, 0, 0);
40+
}
41+
42+
// Select Label Placement - End
43+
// ----------------------------------------------------------------
44+
/**
45+
* The margin between the label and
46+
* the select should be on the start
47+
* when the label sits at the end.
48+
*/
49+
:host(.select-label-placement-end) .label-text-wrapper {
50+
@include margin(0, 0, 0, $form-control-label-margin);
51+
}
52+
53+
// Select Label Placement - Fixed
54+
// ----------------------------------------------------------------
55+
56+
:host(.select-label-placement-fixed) .label-text-wrapper {
57+
/**
58+
* The margin between the label and
59+
* the select should be on the end
60+
* when the label sits at the start.
61+
*/
62+
@include margin(0, $form-control-label-margin, 0, 0);
63+
}
64+
65+
// Select Label Placement - Stacked and Floating
66+
// ----------------------------------------------------------------
67+
68+
/**
69+
* Ensures the select does not
70+
* overlap the label.
71+
* Also ensure that the native wrapper
72+
* takes up the remaining available height and width.
73+
*/
74+
:host(.select-label-placement-stacked) .native-wrapper,
75+
:host(.select-label-placement-floating) .native-wrapper {
76+
@include margin(1px, 0, 0, 0);
77+
}
78+
79+
/**
80+
* This makes the label sit over the select
81+
* when the select is blurred and has no value.
82+
* The label should not sit over the select if the
83+
* select has a placeholder.
84+
* Note: This is different from what ion-input does
85+
* because the activating the select causes an overlay
86+
* to appear. This makes it hard to read the placeholder.
87+
* With ion-input, the input just focuses and the placeholder
88+
* is still easy to read.
89+
*/
90+
:host(.select-label-placement-floating) .label-text-wrapper {
91+
@include transform(translateY(100%), scale(1));
92+
}
93+
94+
/**
95+
* This makes the label sit above the input.
96+
*/
97+
:host(.label-floating) .label-text-wrapper {
98+
@include transform(translateY(50%), scale(#{$form-control-label-stacked-scale}));
99+
100+
/**
101+
* Label text should not extend
102+
* beyond the bounds of the input.
103+
*/
104+
max-width: calc(100% / #{$form-control-label-stacked-scale});
105+
}
106+
107+
// Start/End Slots
108+
// ----------------------------------------------------------------
109+
110+
::slotted([slot="start"]:last-of-type) {
111+
margin-inline-end: $form-control-label-margin;
112+
}
113+
114+
::slotted([slot="end"]:first-of-type) {
115+
margin-inline-start: $form-control-label-margin;
116+
}

core/src/components/select/select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import type { SelectChangeEventDetail, SelectInterface, SelectCompareFn } from '
4949
styleUrls: {
5050
ios: 'select.ios.scss',
5151
md: 'select.md.scss',
52-
ionic: 'select.md.scss',
52+
ionic: 'select.ionic.scss',
5353
},
5454
shadow: true,
5555
})
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
@import "../../themes/native/native.globals";
2-
31
/// @prop - Margin start of the select icon
42
$select-icon-margin-start: 4px;

0 commit comments

Comments
 (0)