Skip to content

Commit 9567de1

Browse files
authored
Merge pull request #632 from lalithkarikelli/surf-1900
refactor(text-input): SURF-1900
2 parents e7a76e1 + 7e44233 commit 9567de1

File tree

7 files changed

+134
-136
lines changed

7 files changed

+134
-136
lines changed

docs/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/// load styles needed to test component visuals
66
@import "menu/spec";
77
@import "popover/spec";
8+
@import "text-input/spec";
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
@import (reference) 'components/form/index';
1+
@import "components/form/mixins/textControl";
22

33
.text-input-spec {
44
hx-text-control {
55
/* ----- Pristine --------------- */
66
> input[type="text"].mock-focus {
7-
.TextControl(pristine-focus);
7+
@include hxTextControl($focused: true);
88
}
99

1010
/* ----- Disabled --------------- */
1111
> input[type="text"]:disabled.mock-focus {
12-
.TextControl(disabled-focus);
12+
@include hxTextControl(disabled, $focused: true);
1313
}
1414

1515
/* ----- Changed / Touched --------------- */
1616
&[hx-dirty] {
1717
> input[type="text"]:invalid.mock-focus {
18-
.TextControl(invalid-focus);
18+
@include hxTextControl(invalid, $focused: true);
1919
}
2020
}
2121

2222
/* ----- Styled Invalid --------------- */
2323
&.hxInvalid > input[type="text"]:enabled.mock-focus {
24-
.TextControl(invalid-focus);
24+
@include hxTextControl(invalid, $focused: true);
2525
}
2626
}
2727
}

docs/docs.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ min-version {
319319
@import 'spec/file-input-spec';
320320
@import 'spec/panel-spec';
321321
@import 'spec/radio-spec';
322-
@import 'spec/text-input-spec';
323322
@import 'spec/textarea-spec';
324323

325324
/* ---------------------------------------- *\

src/less/components.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@
2929
@import 'components/dropdown-select/index';
3030
@import 'components/file/index';
3131
@import 'components/form/index';
32-
@import 'components/text-input/index';
3332
@import 'components/textarea/index';

src/less/components/text-input/index.less

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

src/scss/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
@import "toast/index";
2525
@import "table/index";
2626
@import "tabset/index";
27+
@import "text-input/index";
2728
@import "tooltip/index";
2829
@import "typography/index";
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
@import "components/form/config";
2+
3+
// ----- LAYOUT ----------
4+
5+
/// auto* 1fr auto*
6+
/// +----------+---------+----------+
7+
/// | label | label | label | auto
8+
/// +----------+---------+----------+
9+
/// | [prefix] | control | [suffix] | auto
10+
/// +----------+---------+----------+
11+
///
12+
/// * column will collapse if content not present
13+
14+
hx-text-control {
15+
$ctrl-columns: auto 1fr auto;
16+
$ctrl-rows: auto auto;
17+
$ctrl-row-align: center;
18+
19+
-ms-grid-columns: $ctrl-columns;
20+
-ms-grid-rows: $ctrl-rows;
21+
align-items: $ctrl-row-align;
22+
display: -ms-grid;
23+
display: grid;
24+
grid-template-areas:
25+
"label label label"
26+
"prefix control suffix";
27+
grid-template-columns: $ctrl-columns;
28+
grid-template-rows: $ctrl-rows;
29+
30+
// blacklist
31+
> * {
32+
display: none;
33+
}
34+
35+
// whitelist
36+
> label,
37+
> input[type="text"],
38+
> .hxPrefix,
39+
> .hxSuffix {
40+
display: block;
41+
}
42+
43+
> label {
44+
$justify: start;
45+
46+
-ms-grid-column-align: $justify;
47+
-ms-grid-column-span: 3;
48+
-ms-grid-column: 1;
49+
-ms-grid-row: 1;
50+
grid-area: label;
51+
justify-self: $justify;
52+
}
53+
54+
> input[type="text"] {
55+
-ms-grid-column: 2;
56+
-ms-grid-row: 2;
57+
grid-area: control;
58+
height: 2rem;
59+
min-width: 8rem; // ~16 chars
60+
padding: 0 0.75rem;
61+
}
62+
63+
> .hxPrefix {
64+
$justify: end;
65+
66+
-ms-grid-column-align: $justify;
67+
-ms-grid-column: 1;
68+
-ms-grid-row-align: $ctrl-row-align; // because IE
69+
-ms-grid-row: 2;
70+
grid-area: prefix;
71+
justify-self: $justify;
72+
margin-right: 0.25rem;
73+
}
74+
75+
> .hxSuffix {
76+
$justify: start;
77+
78+
-ms-grid-column-align: $justify;
79+
-ms-grid-column: 3;
80+
-ms-grid-row-align: $ctrl-row-align; // because IE
81+
-ms-grid-row: 2;
82+
grid-area: suffix;
83+
justify-self: $justify;
84+
margin-left: 0.25rem;
85+
}
86+
}
87+
88+
// ----- PRISTINE ----------
89+
hx-text-control {
90+
> label {
91+
@include hxFieldName();
92+
}
93+
94+
> input[type="text"] {
95+
@include hxTextControl;
96+
97+
&:focus {
98+
@include hxTextControl($focused: true);
99+
}
100+
}
101+
}
102+
103+
// ----- INVALID ----------
104+
105+
// 1. Prevent IE from incorrectly matching input:disabled:invalid
106+
107+
hx-text-control[hx-dirty] > input[type="text"]:enabled:invalid, // 1
108+
hx-text-control.hxInvalid > input[type="text"]:enabled {
109+
@include hxTextControl(invalid);
110+
111+
&:focus {
112+
@include hxTextControl(invalid, $focused: true);
113+
}
114+
}
115+
116+
// ----- DISABLED ----------
117+
hx-text-control > input[type="text"]:disabled {
118+
@include hxTextControl(disabled);
119+
120+
~ label {
121+
@include hxFieldName(disabled);
122+
}
123+
124+
&:focus {
125+
@include hxTextControl(disabled, $focused: true);
126+
}
127+
}

0 commit comments

Comments
 (0)