Skip to content

Commit 3d88c5e

Browse files
authored
Merge branch 'main' into feat/369
2 parents b52d361 + f56b8b4 commit 3d88c5e

File tree

9 files changed

+133
-663
lines changed

9 files changed

+133
-663
lines changed

.github/workflows/cypress-run.yml

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

.github/workflows/tests.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node: ['12', '14']
18+
node: ["12", "14"]
1919
name: Tests (Node.js ${{ matrix.node }})
2020
steps:
2121
- uses: actions/checkout@v2
2222
- name: Setup node
23-
uses: actions/setup-node@v1
23+
uses: actions/setup-node@v2
2424
with:
2525
node-version: ${{ matrix.node }}
2626
- name: Install dependencies
@@ -39,3 +39,39 @@ jobs:
3939
run: yarn install
4040
- name: Run linter
4141
run: yarn run lint
42+
43+
cypress-run:
44+
runs-on: ubuntu-latest
45+
# Browser on which the tests are run
46+
container: cypress/browsers:node12.18.3-chrome87-ff82
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v2
50+
- name: Cache dependencies
51+
uses: actions/cache@v2
52+
with:
53+
path: |
54+
./node_modules
55+
key: ${{ hashFiles('yarn.lock') }}
56+
- name: Setup node
57+
uses: actions/setup-node@v2
58+
with:
59+
node-version: "14.x"
60+
- name: Install dependencies
61+
run: yarn --dev && yarn --cwd ./playgrounds/html
62+
- name: Browser tests
63+
uses: cypress-io/github-action@v2
64+
with:
65+
# Your starting script
66+
start: yarn playground
67+
# Creates and uploads GitHub artifacts in case of failure
68+
- uses: actions/upload-artifact@v2
69+
if: failure()
70+
with:
71+
name: cypress-screenshots
72+
path: cypress/screenshots
73+
- uses: actions/upload-artifact@v2
74+
if: failure()
75+
with:
76+
name: cypress-videos
77+
path: cypress/videos

bors.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
status = [
22
'linter-check',
33
'Tests (Node.js 12)',
4-
'Tests (Node.js 14)'
4+
'Tests (Node.js 14)',
5+
'cypress-run'
56
]
67
# 1 hour timeout
78
timeout-sec = 3600

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"eslint-plugin-prettier": "^3.3.0",
5555
"jest": "^26.6.3",
5656
"jsdom": "^17.0.0",
57-
"node-sass": "^6.0.1",
57+
"sass": "^1.43.2",
5858
"postcss-cli": "^7.1.2",
5959
"prettier": "^2.0.5",
6060
"pretty-bytes-cli": "^2.0.0",

scripts/build-css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mkdir -p "$DIST_DIR"
1414

1515
# ./dist/cdn/docs-searchbar.css
1616
echo "$LICENSE" > "$DIST_FILE";
17-
node-sass --output-style expanded ./src/styles/main.scss \
17+
sass --style expanded ./src/styles/main.scss \
1818
| postcss --use autoprefixer -o "$DIST_FILE"
1919

2020
# copy styles

src/lib/DocsSearchBar.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ class DocsSearchBar {
135135
},
136136
])
137137

138+
// We remove the inline styles of the wrapper element for left / right
139+
$(`.${this.autocompleteOptions.cssClasses.root} > [role='listbox']`).css({
140+
left: false,
141+
right: false,
142+
})
143+
138144
const customHandleSelected = handleSelected
139145
this.handleSelected = customHandleSelected || this.handleSelected
140146

src/styles/_dropdown.scss

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Detect lightness
2+
@use "sass:math";
3+
24
@function detectLightness($color) {
35
@if (lightness($color) > 60) {
46
@return mix($color, #000, 90%);
@@ -50,17 +52,17 @@
5052
// Alignment type
5153
@mixin alignment-type($type) {
5254
@if $type == 'left' {
53-
left: 0 !important;
54-
right: inherit !important;
55+
left: 0;
56+
right: inherit;
5557
}
5658
@if $type == 'right' {
57-
right: 0 !important;
58-
left: inherit !important;
59+
right: 0;
60+
left: inherit;
5961
}
6062
@if $type == 'center' {
61-
left: 0 !important;
62-
right: 0 !important;
63-
margin: auto !important;
63+
left: 0;
64+
right: 0;
65+
margin: auto;
6466
}
6567
}
6668

@@ -177,7 +179,7 @@
177179
.dsb-suggestions {
178180
position: relative;
179181
z-index: 1000;
180-
margin-top: $padding/2;
182+
margin-top: $padding*0.5;
181183
& a:hover {
182184
text-decoration: none;
183185
}
@@ -205,7 +207,7 @@
205207
background: $background-color;
206208
border-radius: $border-radius + px;
207209
overflow: auto;
208-
padding: 0 $padding/2 $padding/2;
210+
padding: 0 $padding*0.5 $padding*0.5;
209211
}
210212

211213
// Inner-grid setup
@@ -218,7 +220,7 @@
218220
.docs-searchbar-suggestion {
219221
display: block;
220222
position: relative;
221-
padding: 0 $padding/2;
223+
padding: 0 $padding*0.5;
222224
background: $background-color;
223225
color: $title-color;
224226
overflow: hidden;
@@ -262,7 +264,7 @@
262264
display: block;
263265
width: 70%;
264266
position: relative;
265-
padding: $padding/3 0 $padding/3 $padding/1.5;
267+
padding: math.div($padding, 3) 0 math.div($padding, 3) math.div($padding, 1.5);
266268
cursor: pointer;
267269

268270
&:before {
@@ -281,8 +283,8 @@
281283
position: relative;
282284
border-bottom: 1px solid #ddd;
283285
display: none;
284-
margin-top: $padding/2;
285-
padding: $padding/4 0;
286+
margin-top: $padding*0.5;
287+
padding: $padding*0.25 0;
286288
font-size: $header-size;
287289
color: $header-color;
288290
@if $dark-mode {
@@ -294,15 +296,15 @@
294296
width: 100%;
295297
display: flex;
296298
align-items: flex-start;
297-
padding: $padding/2 0 0 0;
299+
padding: $padding*0.5 0 0 0;
298300
}
299301

300302
&--subcategory-column {
301303
width: 30%;
302304
padding-left: 0;
303305
text-align: right;
304306
position: relative;
305-
padding: $padding/3 $padding/1.5;
307+
padding: math.div($padding, 3) math.div($padding, 1.5);
306308
color: $subtitle-color;
307309
font-size: $subtitle-size;
308310
word-wrap: break-word;
@@ -324,7 +326,7 @@
324326
}
325327

326328
&--title {
327-
margin-bottom: $padding/4;
329+
margin-bottom: $padding*0.25;
328330
color: $title-color;
329331
font-size: $title-size;
330332
font-weight: bold;
@@ -339,7 +341,7 @@
339341

340342
&--no-results {
341343
width: 100%;
342-
padding: $padding/2 0;
344+
padding: $padding*0.5 0;
343345
text-align: center;
344346
font-size: 1.2em;
345347

@@ -415,7 +417,7 @@
415417
.suggestion-layout-simple {
416418
&.docs-searchbar-suggestion {
417419
border-bottom: solid 1px #eee;
418-
padding: $padding/2;
420+
padding: $padding*0.5;
419421
margin: 0;
420422
@if $dark-mode {
421423
border-bottom: solid 1px lighten($border-color, 10%);
@@ -471,7 +473,7 @@
471473

472474
&--duplicate-content,
473475
&--subcategory-inline {
474-
display: none !important;
476+
display: none;
475477
}
476478

477479
&--title {
@@ -495,10 +497,10 @@
495497
}
496498

497499
&--text {
498-
margin: $padding/4 0 0;
500+
margin: $padding*0.25 0 0;
499501
display: desc($include-desc);
500502
line-height: 1.4em;
501-
padding: $padding/3 $padding/2;
503+
padding: math.div($padding, 3) $padding*0.5;
502504
background: $suggestion-background-color;
503505
font-size: $text-size;
504506
opacity: 0.8;
@@ -520,7 +522,7 @@
520522
width: 180px;
521523
height: 20px;
522524
z-index: 2000;
523-
margin-top: $padding/1.5;
525+
margin-top: math.div($padding, 1.5);
524526
color: $text-color;
525527
margin-left: auto;
526528
}

src/styles/_searchbox.scss

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
@use "sass:math";
2+
13
@function even-px($value) {
24
@if type-of($value) == 'number' {
35
@if (unitless($value)) {
46
$value: $value * 1px;
57
} @else if unit($value) == 'em' {
6-
$value: ($value / 1em * 16px);
8+
$value: (math.div($value, 1em) * 16px);
79
} @else if unit($value) == 'pts' {
810
$value: $value * 1.3333 * 1px;
911
} @else if unit($value) == '%' {
10-
$value: $value * 16 / 100% * 1px;
12+
$value: math.div($value * 16, 100%) * 1px;
1113
}
1214
$value: round($value);
13-
@if ($value % 2 != 0) {
15+
@if ($value % 2 != 0px) {
1416
$value: $value + 1;
1517
}
1618
@return $value;
@@ -23,30 +25,30 @@
2325
$input-height: $font-size * 2.4,
2426
$border-width: 1px,
2527
$text-color: #555,
26-
$border-radius: $input-height / 2,
28+
$border-radius: $input-height * 0.5,
2729
$input-border-color: #ccc,
2830
$input-focus-border-color: #1ec9ea,
2931
$input-background: #f8f8f8,
3032
$input-focus-background: #fff,
3133
$placeholder-color: #aaa,
3234
$icon: 'sbx-icon-search-1',
33-
$icon-size: $input-height / 1.6,
35+
$icon-size: math.div($input-height, 1.6),
3436
$icon-position: left,
3537
$icon-color: #888,
3638
$icon-background: $input-focus-border-color,
3739
$icon-background-opacity: 0.1,
3840
$icon-clear: 'sbx-icon-clear-1',
39-
$icon-clear-size: $font-size / 1.1,
41+
$icon-clear-size: math.div($font-size, 1.1),
4042
$dark-mode: false
4143
) {
4244
.searchbox {
4345
display: inline-block;
4446
position: relative;
4547
width: $input-width;
46-
height: even-px($input-height) !important;
48+
height: even-px($input-height);
4749
white-space: nowrap;
4850
box-sizing: border-box;
49-
visibility: visible !important;
51+
visibility: visible;
5052

5153
.meilisearch-autocomplete {
5254
display: block;
@@ -69,7 +71,7 @@
6971
border: 0;
7072
border-radius: even-px($border-radius);
7173
box-shadow: inset 0 0 0 $border-width $input-border-color;
72-
background: $input-background !important;
74+
background: $input-background;
7375
padding: 0;
7476
padding-right: if(
7577
$icon-position == 'right',
@@ -78,7 +80,7 @@
7880
) + if($icon-background-opacity == 0, 0, even-px($font-size));
7981
padding-left: if(
8082
$icon-position == 'right',
81-
even-px($font-size / 2) + even-px($border-radius / 2),
83+
even-px($font-size * 0.5) + even-px($border-radius * 0.5),
8284
even-px($input-height) +
8385
if($icon-background-opacity == 0, 0, even-px($font-size * 1.2))
8486
);
@@ -133,7 +135,7 @@
133135
background-color: rgba($icon-background, $icon-background-opacity);
134136
padding: 0;
135137
width: even-px($input-height) +
136-
if($icon-background-opacity == 0, 0, even-px($font-size / 2));
138+
if($icon-background-opacity == 0, 0, even-px($font-size * 0.5));
137139
height: 100%;
138140
vertical-align: middle;
139141
text-align: center;
@@ -176,12 +178,12 @@
176178
&__reset {
177179
display: block;
178180
position: absolute;
179-
top: (even-px($input-height) - even-px($icon-clear-size)) / 2 - 4px;
181+
top: (even-px($input-height) - even-px($icon-clear-size)) * 0.5 - 4px;
180182
right: if(
181183
$icon-position == 'right',
182184
even-px($input-height) +
183185
if($icon-background-opacity == 0, 0, even-px($font-size)),
184-
(even-px($input-height) - even-px($icon-clear-size)) / 2 - 4px
186+
(even-px($input-height) - even-px($icon-clear-size)) * 0.5 - 4px
185187
);
186188
margin: 0;
187189
border: 0;

0 commit comments

Comments
 (0)