Skip to content

Commit d501126

Browse files
Cathy SillerRyan A. Johnson
authored andcommitted
fix(Search): correct ShadyCSS styles
1 parent 39f92c8 commit d501126

File tree

3 files changed

+39
-32
lines changed

3 files changed

+39
-32
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<label id="wrapper">
2-
<input type="text" role="search" id="search" autocomplete="off" />
3-
<button type="button" id="clear" hidden aria-label="Clear search">
1+
<label id="hxSearch">
2+
<input type="text" role="search" id="hxNativeControl" autocomplete="off" />
3+
<button type="button" id="hxClear" hidden aria-label="Clear search">
44
<hx-icon type="times"></hx-icon>
55
</button>
6-
<div id="icon">
6+
<div id="hxIcon">
77
<hx-icon type="search"></hx-icon>
88
</div>
9-
<div id="customControl"></div>
9+
<div id="hxCustomControl"></div>
1010
</label>

src/helix-ui/elements/HXSearchElement.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ export class HXSearchElement extends HXElement {
6060

6161
constructor () {
6262
super();
63-
this._elSearch = this.shadowRoot.getElementById('search');
64-
this._btnClear = this.shadowRoot.getElementById('clear');
65-
6663
this._clearValue = this._clearValue.bind(this);
6764
this._onInput = this._onInput.bind(this);
6865
}
@@ -162,6 +159,16 @@ export class HXSearchElement extends HXElement {
162159
}
163160
}
164161

162+
/** @private */
163+
get _elSearch () {
164+
return this.shadowRoot.getElementById('hxNativeControl');
165+
}
166+
167+
/** @private */
168+
get _btnClear () {
169+
return this.shadowRoot.getElementById('hxClear');
170+
}
171+
165172
// PRIVATE FUNCTIONS
166173
_onInput (evt) {
167174
this.value = evt.target.value;

src/helix-ui/elements/HXSearchElement.less

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ input::-ms-clear {
1212
height: 2rem;
1313
min-width: 8rem;
1414

15-
#wrapper {
15+
#hxSearch {
1616
display: flex;
1717
height: 100%;
1818
position: relative;
1919
}
2020

21-
#icon {
21+
#hxIcon {
2222
color: @gray-700;
2323
flex-shrink: 0;
2424
line-height: 1;
@@ -27,7 +27,7 @@ input::-ms-clear {
2727
z-index: 1;
2828
}
2929

30-
#search {
30+
#hxNativeControl {
3131
#Mix.placeholder();
3232
#Mix.resetFocus();
3333

@@ -43,18 +43,18 @@ input::-ms-clear {
4343
z-index: 1;
4444

4545
&:focus {
46-
~ #clear {
46+
~ #hxClear {
4747
color: @cyan-700;
4848
}
4949

50-
~ #customControl {
50+
~ #hxCustomControl {
5151
border-color: @cyan-700;
5252
box-shadow: @focus-glow;
5353
}
5454
}
5555
}
5656

57-
#customControl {
57+
#hxCustomControl {
5858
background-color: @gray-0;
5959
border-radius: 2px;
6060
border: 1px solid @gray-500;
@@ -66,7 +66,7 @@ input::-ms-clear {
6666
z-index: 0; // sits behind everything
6767
}
6868

69-
#clear {
69+
#hxClear {
7070
#Mix.resetFocus();
7171

7272
background-color: transparent;
@@ -89,48 +89,48 @@ input::-ms-clear {
8989
color: @cyan-700;
9090
}
9191

92-
~ #customControl {
92+
~ #hxCustomControl {
9393
border-color: @cyan-700;
9494
box-shadow: @focus-glow;
9595
}
9696
}//:focus
97-
}//#clear
97+
}
9898
}//default
9999

100100
:host([invalid]) {
101101
color: @red-900;
102102

103103
// ----- IDLE -----
104104

105-
#icon,
106-
#clear {
105+
#hxIcon,
106+
#hxClear {
107107
color: inherit;
108108
}
109109

110-
#customControl {
110+
#hxCustomControl {
111111
border-color: @red-900;
112112
border-width: 2px;
113113
}
114114

115115
// ----- FOCUS -----
116116

117-
#clear:focus {
117+
#hxClear:focus {
118118
hx-icon {
119119
outline-color: currentColor;
120120
}
121121
}
122122

123-
#search:focus {
124-
~ #clear {
123+
#hxNativeControl:focus {
124+
~ #hxClear {
125125
color: @red-900;
126126
}
127127
}
128128

129129
// make sure that our custom control doesn't lose focus style
130-
// when we tab between #search and #clear
131-
#clear:focus,
132-
#search:focus {
133-
~ #customControl {
130+
// when we tab between #hxSearch and #hxClear
131+
#hxClear:focus,
132+
#hxNativeControl:focus {
133+
~ #hxCustomControl {
134134
box-shadow: @focus-glow-invalid;
135135
border-color: @red-900;
136136
}
@@ -140,26 +140,26 @@ input::-ms-clear {
140140
:host([disabled]) {
141141
color: @gray-400;
142142

143-
#wrapper {
143+
#hxSearch {
144144
color: inherit;
145145
cursor: not-allowed;
146146
}
147147

148-
#icon {
148+
#hxIcon {
149149
color: inherit;
150150
}
151151

152-
#clear {
152+
#hxClear {
153153
display: none;
154154
}
155155

156-
#search {
156+
#hxNativeControl {
157157
#Mix.disabledPlaceholder();
158158

159159
color: inherit;
160160
}
161161

162-
#customControl {
162+
#hxCustomControl {
163163
background-color: @gray-50;
164164
border-color: @gray-300;
165165
border-width: 1px;

0 commit comments

Comments
 (0)