UNPKG

5.66 kBSCSSView Raw
1//
2// Copyright IBM Corp. 2016, 2018
3//
4// This source code is licensed under the Apache-2.0 license found in the
5// LICENSE file in the root directory of this source tree.
6//
7
8//-----------------------------
9// Search
10//-----------------------------
11
12@import '../../globals/scss/vars';
13@import '../../globals/scss/helper-mixins';
14@import '../../globals/scss/css--reset';
15@import '../../globals/scss/typography';
16@import '../../globals/scss/import-once';
17
18/// Search styles
19/// @access private
20/// @group search
21@mixin search {
22 .#{$prefix}--search {
23 position: relative;
24 display: flex;
25 align-items: center;
26 width: 100%;
27 }
28
29 .#{$prefix}--search .#{$prefix}--label {
30 @include hidden;
31 }
32
33 .#{$prefix}--search-input {
34 @include reset;
35 @include type-style('body-short-01');
36 @include focus-outline('reset');
37
38 order: 1;
39 width: 100%;
40 padding: 0 $carbon--spacing-08;
41 color: $text-01;
42 text-overflow: ellipsis;
43 background-color: $field-01;
44 border: none;
45 border-bottom: 1px solid $ui-04;
46 transition: background-color $duration--fast-02 motion(standard, productive),
47 outline $duration--fast-02 motion(standard, productive);
48 appearance: none;
49
50 &:focus {
51 @include focus-outline('outline');
52 }
53
54 &::placeholder {
55 color: $text-05;
56 font-weight: 400;
57 }
58
59 &::-ms-clear {
60 display: none;
61 }
62 }
63
64 .#{$prefix}--search-input[disabled] {
65 color: $disabled;
66 background-color: $disabled-background-color;
67 border-bottom: 1px solid transparent;
68 cursor: not-allowed;
69
70 &::placeholder {
71 color: $disabled;
72 font-weight: 400;
73 }
74 }
75
76 .#{$prefix}--search-input[disabled] ~ .#{$prefix}--search-magnifier {
77 fill: $disabled;
78 }
79
80 .#{$prefix}--search--light .#{$prefix}--search-input {
81 background: $field-02;
82 }
83
84 // Small styles
85 .#{$prefix}--search--sm .#{$prefix}--search-input {
86 height: rem(32px);
87 // 8px padding on either side of icon + 16px icon (32px)
88 padding: 0 $spacing-07;
89 }
90
91 .#{$prefix}--search--sm .#{$prefix}--search-magnifier {
92 left: rem(8px);
93 }
94
95 // Large styles
96 .#{$prefix}--search--lg .#{$prefix}--search-input {
97 height: rem(40px);
98 // 12px padding on either side of icon + 16px icon (40px)
99 padding: 0 $spacing-08;
100 }
101
102 .#{$prefix}--search--lg .#{$prefix}--search-magnifier {
103 left: rem(12px);
104 }
105
106 .#{$prefix}--search--xl .#{$prefix}--search-input {
107 height: rem(48px);
108 // 16px padding on either side of icon + 16px icon (48px)
109 padding: 0 $spacing-09;
110 }
111
112 .#{$prefix}--search-magnifier {
113 position: absolute;
114 top: 50%;
115 left: $spacing-05;
116 z-index: 2;
117 width: rem(16px);
118 height: rem(16px);
119 transform: translateY(-50%);
120 pointer-events: none;
121 fill: $icon-02;
122 }
123
124 .#{$prefix}--search-close {
125 @include button-reset(false);
126 @include focus-outline('reset');
127
128 position: absolute;
129 top: 0;
130 right: 0;
131
132 &::before {
133 position: absolute;
134 top: rem(1px);
135 left: 0;
136 display: block;
137 width: 2px;
138 height: calc(100% - 2px);
139 background-color: $field-01;
140 transition: background-color $duration--fast-02
141 motion(standard, productive);
142 content: '';
143 }
144
145 &:hover {
146 border-bottom: 1px solid $ui-04;
147
148 &::before {
149 background-color: $hover-field;
150 }
151 }
152 }
153
154 .#{$prefix}--search-button {
155 flex-shrink: 0;
156 margin-left: $carbon--spacing-01;
157 background-color: $field-01;
158
159 svg {
160 vertical-align: middle;
161 fill: currentColor;
162 }
163 }
164
165 .#{$prefix}--search-close svg {
166 fill: inherit;
167 }
168
169 .#{$prefix}--search-close,
170 .#{$prefix}--search-button {
171 display: flex;
172 align-items: center;
173 justify-content: center;
174 width: rem(40px);
175 height: rem(40px);
176 border-color: transparent;
177 border-style: solid;
178 border-width: 1px 0;
179 visibility: inherit;
180 cursor: pointer;
181 opacity: 1;
182 transition: opacity $duration--fast-02 motion(standard, productive),
183 background-color $duration--fast-02 motion(standard, productive),
184 outline $duration--fast-02 motion(standard, productive),
185 border $duration--fast-02 motion(standard, productive);
186 fill: $icon-01;
187
188 &:hover {
189 background-color: $hover-field;
190 }
191
192 &:focus {
193 @include focus-outline('outline');
194 }
195
196 &:active {
197 @include focus-outline('outline');
198
199 background-color: $selected-ui;
200 }
201 }
202
203 .#{$prefix}--search-close:focus,
204 .#{$prefix}--search-close:active {
205 &::before {
206 background-color: $focus;
207 }
208 }
209
210 .#{$prefix}--search-input:focus ~ .#{$prefix}--search-close:hover {
211 @include focus-outline('outline');
212 }
213
214 .#{$prefix}--search--sm {
215 .#{$prefix}--search-close,
216 ~ .#{$prefix}--search-button {
217 width: rem(32px);
218 height: rem(32px);
219 }
220 }
221
222 .#{$prefix}--search--lg {
223 .#{$prefix}--search-close,
224 ~ .#{$prefix}--search-button {
225 width: rem(40px);
226 height: rem(40px);
227 }
228 }
229
230 .#{$prefix}--search--xl {
231 .#{$prefix}--search-close,
232 ~ .#{$prefix}--search-button {
233 width: rem(48px);
234 height: rem(48px);
235 }
236 }
237
238 .#{$prefix}--search-close--hidden {
239 visibility: hidden;
240 opacity: 0;
241 }
242
243 .#{$prefix}--search--xl.#{$prefix}--skeleton .#{$prefix}--search-input,
244 .#{$prefix}--search--lg.#{$prefix}--skeleton .#{$prefix}--search-input,
245 .#{$prefix}--search--sm.#{$prefix}--skeleton .#{$prefix}--search-input {
246 @include skeleton;
247
248 width: 100%;
249
250 &::placeholder {
251 color: transparent;
252 }
253 }
254}
255
256@include exports('search') {
257 @include search;
258}