Skip to content

Commit 09a3ce7

Browse files
authored
Merge pull request #648 from lalithkarikelli/surf-1898
refactor(dropdown-select): surf-1898
2 parents ecb177d + 1ece7e5 commit 09a3ce7

File tree

12 files changed

+206
-152
lines changed

12 files changed

+206
-152
lines changed

docs/components/_index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/// load styles needed to test component visuals
66
@import "checkbox/spec";
77
@import "choice-tile/spec";
8+
@import "dropdown-select/spec";
89
@import "menu/spec";
910
@import "popover/spec";
1011
@import "textarea/spec";
1112
@import "text-input/spec";
12-

docs/styles/spec/dropdown-select-spec.less renamed to docs/components/dropdown-select/_spec.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
@import (reference) 'components/dropdown-select/index';
1+
@import "components/dropdown-select/config";
22

33
.dropdown-select-spec {
44
hx-select-control {
55
/* ----- Pristine --------------- */
66
> select.mock-focus {
7-
.SelectControl(pristine-focus);
7+
@include hxSelectControl($focused: true);
88

99
~ hx-select {
10-
.SelectFacade(pristine-focus);
10+
@include hxSelectFacade($focused: true);
1111
}
1212

1313
/* ----- Disabled --------------- */
1414
&:disabled {
15-
.SelectControl(disabled-focus);
15+
@include hxSelectControl(disabled, true);
1616

1717
~ hx-select {
18-
.SelectFacade(disabled-focus);
18+
@include hxSelectFacade(disabled, true);
1919
}
2020
}
2121
}
2222

2323
/* ----- Invalid ---------------*/
2424
&.hxInvalid > select.mock-focus:enabled,
2525
&[hx-dirty] > select.mock-focus:enabled:invalid {
26-
.SelectControl(invalid-focus);
26+
@include hxSelectControl(invalid, true);
2727

2828
~ hx-select {
29-
.SelectFacade(invalid-focus);
29+
@include hxSelectFacade(invalid, true);
3030
}
3131
}
3232
}

docs/docs.less

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ iframe[src*="codepen.io"] {
4444
align-items: center;
4545
align-content: center;
4646
flex-grow: 1;
47-
48-
&:first-child { // brand logo
47+
// brand logo
48+
&:first-child {
4949
flex: 0 0 @app-nav-width;
5050
}
5151

@@ -188,7 +188,6 @@ min-version {
188188
}
189189
}
190190

191-
192191
/* ---------------------------------------- *\
193192
* HELPERS
194193
\* ---------------------------------------- */
@@ -202,7 +201,6 @@ min-version {
202201
@import 'demo/tooltip-docs';
203202
// Spec Styles
204203
@import 'spec/button-spec';
205-
@import 'spec/dropdown-select-spec';
206204
@import 'spec/file-input-spec';
207205
@import 'spec/panel-spec';
208206
@import 'spec/radio-spec';

src/less/components.less

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "vars";
1+
@import 'vars';
22

33
// DEPRECATED! Use SCSS, instead!
44
.hxComponent {
@@ -24,5 +24,4 @@
2424
- NO !important
2525
\* ========== COMPONENTS ========== */
2626
@import 'components/button/index';
27-
@import 'components/dropdown-select/index';
2827
@import 'components/form/index';

src/less/components/dropdown-select/SelectControl.less

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/less/components/dropdown-select/SelectFacade.less

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/scss/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@import "checkbox/index";
77
@import "choice-tile/index";
88
@import "drawer/index";
9+
@import "dropdown-select/index";
910
@import "form/index";
1011
@import "file/index";
1112
@import "grid/index";

src/scss/components/dropdown-select/_config.scss

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,10 @@
33

44

55
/// ========== MIXINS ========== ///
6-
@import "mixins";
7-
8-
// LESS SCSS
9-
// #Reset.select() -> select-reset
10-
@mixin select-reset {
11-
@include appearance(none);
12-
13-
font: inherit;
14-
15-
// Firefox
16-
// TODO: is this still needed?
17-
&:-moz-ui-invalid {
18-
box-shadow: none;
19-
border: 0;
20-
outline: 0;
21-
}
22-
23-
// IE and Edge
24-
&::-ms-value {
25-
background-color: transparent;
26-
color: inherit;
27-
padding: 0;
28-
}
29-
30-
&::-ms-expand {
31-
background-color: transparent;
32-
border: 0;
33-
color: inherit;
34-
margin: 0;
35-
}
36-
}
6+
@import "../form/mixins/fieldName";
7+
@import "./mixins/SelectControl";
8+
@import "./mixins/SelectFacade";
9+
@import "./mixins/SelectReset";
3710

3811

3912
/// ========== PLACEHOLDERS ========== ///
Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
@import (reference) 'vars';
2-
3-
// ===== MIXINS ==========
4-
@import (reference) './SelectControl';
5-
@import (reference) './SelectFacade';
6-
1+
@import "./config";
72

83
// ----- BASE ELEMENTS ---------------
94
hx-select {
@@ -13,31 +8,31 @@ hx-select {
138

149
// ----- RESETS ---------------
1510
hx-select-control > select {
16-
#Reset.select();
11+
@include select-reset();
1712
}
1813

1914
// ----- LAYOUT ---------------
20-
/*
21-
1fr
22-
+------------+
23-
| label | auto
24-
+------------+
25-
| control | 2rem
26-
+------------+
27-
*/
15+
///
16+
/// 1fr
17+
/// +------------+
18+
/// | label | auto
19+
/// +------------+
20+
/// | control | 2rem
21+
/// +------------+
22+
///
2823
hx-select-control {
29-
@ctrl-columns: 1fr;
30-
@ctrl-rows: auto 2rem;
24+
$ctrl-columns: 1fr;
25+
$ctrl-rows: auto 2rem;
3126

32-
-ms-grid-columns: @ctrl-columns;
33-
-ms-grid-rows: @ctrl-rows;
27+
-ms-grid-columns: $ctrl-columns;
28+
-ms-grid-rows: $ctrl-rows;
3429
display: -ms-grid;
3530
display: grid;
3631
grid-template-areas:
37-
'label'
38-
'control';
39-
grid-template-columns: @ctrl-columns;
40-
grid-template-rows: @ctrl-rows;
32+
"label"
33+
"control";
34+
grid-template-columns: $ctrl-columns;
35+
grid-template-rows: $ctrl-rows;
4136

4237
// ----- blacklist -----
4338
> * {
@@ -46,14 +41,14 @@ hx-select-control {
4641

4742
// ----- whitelist -----
4843
> label {
49-
@justify: start; // don't stretch!
44+
$justify: start; // don't stretch!
5045

51-
-ms-grid-column-align: @justify;
46+
-ms-grid-column-align: $justify;
5247
-ms-grid-column: 1;
5348
-ms-grid-row: 1;
5449
display: block;
5550
grid-area: label;
56-
justify-self: @justify;
51+
justify-self: $justify;
5752
}
5853

5954
> select,
@@ -70,74 +65,73 @@ hx-select-control {
7065
border: none;
7166
padding-left: 0.75rem;
7267
width: 100%; // prevent overflow for lengthy option text
73-
7468
// Adjust native trigger for MS browsers (mainly IE)
7569
// Edge will obscure it with <hx-select>.
76-
#MS.set.expand({
70+
&::-ms-expand {
7771
padding: 0 0.75rem;
78-
});
72+
}
7973
}
8074
}
8175

8276
// ----- PRISTINE ---------------
8377
hx-select-control > select {
84-
.SelectControl(pristine);
78+
@include hxSelectControl;
8579

8680
~ label {
87-
.FieldName();
81+
@include hxFieldName;
8882
}
8983

9084
~ hx-select {
91-
.SelectFacade(pristine);
85+
@include hxSelectFacade;
9286
}
9387

9488
&:focus {
95-
.SelectControl(pristine-focus);
89+
@include hxSelectControl($focused: true);
9690

9791
~ hx-select {
98-
.SelectFacade(pristine-focus);
92+
@include hxSelectFacade($focused: true);
9993
}
10094
}
10195
}
10296

10397
// ----- DISABLED ---------------
10498
hx-select-control > select:disabled {
105-
.SelectControl(disabled);
99+
@include hxSelectControl(disabled);
106100

107101
~ label {
108-
.FieldName(disabled);
102+
@include hxFieldName(disabled);
109103
}
110104

111105
~ hx-select {
112-
.SelectFacade(disabled);
106+
@include hxSelectFacade(disabled);
113107
}
114108

115109
&:focus {
116-
.SelectControl(disabled-focus);
110+
@include hxSelectControl(disabled, true);
117111

118112
~ hx-select {
119-
.SelectFacade(disabled-focus);
113+
@include hxSelectFacade(disabled, true);
120114
}
121115
}
122116
}
123117

124118
// ----- INVALID ---------------
125-
/*
126-
1. Prevent IE from incorrectly matching select:disabled:invalid
127-
*/
119+
///
120+
/// 1. Prevent IE from incorrectly matching select:disabled:invalid
121+
///
128122
hx-select-control[hx-dirty] > select:enabled:invalid, /* 1 */
129123
hx-select-control.hxInvalid > select:enabled {
130-
.SelectControl(invalid);
124+
@include hxSelectControl(invalid);
131125

132126
~ hx-select {
133-
.SelectFacade(invalid);
127+
@include hxSelectFacade(invalid);
134128
}
135129

136130
&:focus {
137-
.SelectControl(invalid-focus);
131+
@include hxSelectControl(invalid, true);
138132

139133
~ hx-select {
140-
.SelectFacade(invalid-focus);
134+
@include hxSelectFacade(invalid, true);
141135
}
142136
}
143137
}

0 commit comments

Comments
 (0)