summaryrefslogtreecommitdiffstats
path: root/asset/css/search-bar.less
blob: d73cf2750e3d4c3ba901b8a63a254c09ab9f68cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
// Style
.search-bar {
  .rounded-corners(.25em);
  background: var(--searchbar-bg, @searchbar-bg);

  // Reset all input styles
  input, [type="button"] {
    .appearance(none);
    border: none;
    background: none;
  }

  // Submit button styles
  input[type=submit],
  button[type=submit],
  button:not([type]) {
    background: var(--primary-button-bg, @primary-button-bg);
    color: var(--primary-button-color, @primary-button-color);
    border-top-right-radius: .25em;
    border-bottom-right-radius: .25em;
  }

  // General input styles
  input:focus {
    outline-offset: -1px;
  }

  // Hide the submit button, it must exist, but shouldn't be shown to the user
  input[type=submit][value="hidden"] {
    display: none;
  }

  // Left-most search dropdown style
  button.search-options {
    i.icon:before {
      font-size: 1.2em;
      margin-right: 0;
      color: var(--control-color, @control-color);
    }

    &:disabled {
      i.icon:before {
        color: var(--control-disabled-color, @control-disabled-color);
      }
    }
  }

  // Scrollbar style
  .filter-input-area {
    // Firefox
    scrollbar-width: thin;
    scrollbar-color: var(--searchbar-scrollbar-bg, @searchbar-scrollbar-bg) transparent;

    &::-webkit-scrollbar {
      display: none;
      height: .5em;
    }

    &:hover::-webkit-scrollbar {
      display: initial;
    }

    &::-webkit-scrollbar-thumb {
      border-radius: .25em;
      background: var(--searchbar-scrollbar-bg, @searchbar-scrollbar-bg);
    }
  }

  // Term styles
  .filter-condition {
    button {
      border-radius: .4em 0 0 .4em;
      background-color: var(--search-condition-remove-bg, @search-condition-remove-bg);
      color: var(--search-condition-remove-color, @search-condition-remove-color);

      &:after {
        content: "";
        position: absolute;
        width: .4em;
        height: 100%;
        right: 0;
        top: 0;

        background-color: var(--searchbar-bg, @searchbar-bg);
        border: .2em solid var(--search-condition-remove-bg, @search-condition-remove-bg);
        border-width: 0 0 0 .2em;
        border-top-left-radius: .4em;
        border-bottom-left-radius: .4em;
      }
    }

    input {
      background-color: var(--search-term-bg, @search-term-bg);
      color: var(--search-term-color, @search-term-color);
    }
  }

  .terms > .filter-condition:first-child button {
    border-radius: 0 .4em .4em 0;

    &:before {
      content: "";
      position: absolute;
      width: .4em;
      height: 100%;
      left: 0;
      top: 0;

      background-color: var(--searchbar-bg, @searchbar-bg);
      border: .2em solid var(--search-condition-remove-bg, @search-condition-remove-bg);
      border-width: 0 .2em 0 0;
      border-top-right-radius: .4em;
      border-bottom-right-radius: .4em;
    }

    &:after {
      content: none;
    }
  }

  .logical_operator,
  .grouping_operator_open,
  .grouping_operator_close {
    input {
      .rounded-corners();
      background-color: var(--search-logical-operator-bg, @search-logical-operator-bg);
      color: var(--search-logical-operator-color, @search-logical-operator-color);
    }
  }

  .operator,
  .logical_operator,
  .grouping_operator_open,
  .grouping_operator_close {
    input {
      text-align: center;
    }
  }

  [data-index] input:invalid {
    background-color: var(--search-term-invalid-bg, @search-term-invalid-bg);
    color: var(--search-term-invalid-color, @search-term-invalid-color);
  }

  [data-index] input:disabled {
    background-color: var(--search-term-disabled-bg, @search-term-disabled-bg);
  }

  .column input {
    .rounded-corners(.4em);
  }
  .column:not(:last-of-type),
  .column.last-term {
    input {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }
  }

  .operator:last-of-type:not(.last-term) input {
    .rounded-corners(.4em);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .value input {
    .rounded-corners(.4em);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .highlighted input {
    background-color: var(--search-term-highlighted-bg, @search-term-highlighted-bg);
    color: var(--search-term-highlighted-color, @search-term-highlighted-color);
  }

  .selected input {
    background-color: var(--search-term-selected-bg, @search-term-selected-bg);
    color: var(--search-term-selected-color, @search-term-selected-color);
    font-style: italic;
  }

  ul.comma-separated {
    display: inline;
    padding: 0;

    list-style-type: none;

    li {
      display: inline;

      &:not(:first-of-type):before {
        display: inline;
        content: ', ';
      }
    }
  }
}

// Layout
.search-bar {
  height: 2em;
  display: flex;
  position: relative; // Required for the suggestions

  button.search-options {
    line-height: 1em;
  }

  .filter-input-area {
    overflow: auto hidden;
    overflow-x: overlay; // Not invalid, but proprietary feature by chrome/webkit
    display: flex;
    width: 100%;
    height: ~"calc(2em + 10px)"; // Search bar height + approximate scrollbar height
    padding: 2/12em; // 2 (px) desired / default font size (px)

    // Lets inputs grow based on their contents, Inspired by https://css-tricks.com/auto-growing-inputs-textareas/
    label {
      position: relative;
      display: inline-block;
      min-width: 2em;

      &::after,
      input {
        width: auto;
        padding: 0 .5em;
        resize: none;
      }

      input {
        width: 100%;
        position: absolute;
        line-height: 20/12; // 20 (px) desired / default font size (px)
      }

      &::after {
        height: 0;
        content: attr(data-label);
        visibility: hidden;
        white-space: nowrap;
        padding: 0 7/12em; // 7 (px) desired / default font size (px)
      }
    }

    > label {
      flex: 1 0 auto;

      &::after,
      input {
        max-width: none;
        min-width: 8em;
      }
    }
  }

  .terms {
    display: inline;
    flex-shrink: 0;

    .filter-chain,
    .filter-condition {
      display: inline;
    }

    .filter-condition {
      position: relative;

      button {
        display: none;
        z-index: 1;
        width: ~"calc(2em + 2px)";
        padding: .15em .6em .15em .4em;
        position: absolute;
        left: ~"calc(-2em - 2px)"; // That's min-width + margin-right of an operator
        line-height: 16/12; // 16 (px) desired / default font size (px)

        i:before {
          margin-right: 0;
        }
      }

      &:not(._hover_delay):hover button {
        display: inline;
      }
    }

    > .filter-condition:first-child button {
      padding: .15em .4em .15em .6em;
      left: auto;
      right: ~"calc(-2em - 1px)"; // That's min-width + margin-left of an operator
    }

    label {
      margin-right: 1px;

      &.logical_operator,
      &.grouping_operator_open,
      &.grouping_operator_close {
        margin-left: 1px; // adds up to 2px with the previous term
        margin-right: 2px;
      }
    }
  }

  &.disabled {
    .terms .filter-condition:hover button {
      display: none;
    }
  }

  .search-suggestions {
    // 2 (px) desired / default font-size to match .filter-input outline-offset (-1px) + outline-width (3px)
    margin-top: 2/12em;
  }
}