Skip to content

Commit f19d1a3

Browse files
bors[bot]mdubus
andauthored
Merge #146
146: Add layout option and style r=bidoubiwa a=mdubus ## What's wrong ? **Problem 1:** [docs-searchbar](https://github.com/meilisearch/docs-searchbar.js) provides an option to choose between 2 layouts : "simple" and "columns". But the plugin `vuepress-plugin-meilisearch` doesn't provide access to this existing option. **Problem 2:** After making this option available, the design looks horrific: ![before simple layout](https://user-images.githubusercontent.com/30866152/120343835-54c87280-c2f9-11eb-8cb8-0748c3c1c4ff.png) ## What's inside this PR This PR makes the `layout` option available. It also adapts the style to match the existing one in docs-searchbar. Style in `docs-searchbar` (simple layout): ![reference docs searchbar](https://user-images.githubusercontent.com/30866152/120344347-caccd980-c2f9-11eb-8412-4837569338f7.png) Style in `vuepress-plugin-meilisearch` after this PR (simple layout): ![after simple layout](https://user-images.githubusercontent.com/30866152/120345811-1af86b80-c2fb-11eb-8119-c12529a2248f.png) ## How to test Go to the file `playground/.vuepress/config.js` and add `"layout": "simple"` in the options: ![Capture d’écran 2021-06-01 à 16 55 06](https://user-images.githubusercontent.com/30866152/120344750-28f9bc80-c2fa-11eb-9d65-7b1e8c8ff62c.png) Note that you might need to restart your server. Please make sure to test that it doesn't break the "columns" layout 🙏 Co-authored-by: Morgane Dubus <[email protected]> Co-authored-by: Morgane Dubus <[email protected]>
2 parents 5e78f2d + e0b9686 commit f19d1a3

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ module.exports = {
1717
MAX_SUGGESTIONS: 'readonly',
1818
CROP_LENGTH: 'readonly',
1919
HOT_KEYS: 'readonly',
20-
PLACEHOLDER: 'readonly'
20+
PLACEHOLDER: 'readonly',
21+
LAYOUT: 'readonly'
2122
},
2223
parserOptions: {
2324
parser: 'babel-eslint',

MeiliSearchBox.vue

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export default {
3636
},
3737
autocompleteOptions: {
3838
keyboardShortcuts: HOT_KEYS
39-
}
39+
},
40+
layout: LAYOUT
4041
}
4142
this.initialize(options)
4243
this.placeholder = PLACEHOLDER || this.$site.themeConfig.searchPlaceholder || ''
@@ -101,11 +102,11 @@ export default {
101102
.meilisearch-search-wrapper
102103
& > span
103104
vertical-align middle
105+
.dsb-cursor
106+
background rgba($accentColor, 0.05)
104107
.meilisearch-autocomplete
105108
line-height 2
106-
.docs-searchbar-suggestion--highlight
107-
color darken($accentColor, 20%)
108-
.docs-searchbar-suggestion
109+
.docs-searchbar-suggestion:not(.suggestion-layout-simple)
109110
border-color $borderColor
110111
.docs-searchbar-suggestion--category-header
111112
background #f1f3f5
@@ -115,10 +116,12 @@ export default {
115116
font-weight 600
116117
color #fff
117118
.docs-searchbar-suggestion--highlight
118-
background rgba(255, 255, 255, 0.6)
119119
box-shadow none
120+
background lighten($accentColor, 70%)
120121
.docs-searchbar-suggestion--wrapper
121122
padding 0
123+
.docs-searchbar-suggestion--highlight
124+
color darken($accentColor, 20%)
122125
.docs-searchbar-suggestion--title
123126
margin-bottom 0
124127
color $textColor
@@ -129,6 +132,22 @@ export default {
129132
.docs-searchbar-suggestion--text
130133
.docs-searchbar-suggestion--highlight
131134
box-shadow inset 0 -2px 0 0 lighten($accentColor, 20%)
135+
color: inherit
136+
.suggestion-layout-simple
137+
.docs-searchbar-suggestion--title
138+
color: $accentColor
139+
&:before
140+
color: darken($accentColor, 20%)
141+
.docs-searchbar-suggestion--category-header
142+
.docs-searchbar-suggestion--highlight
143+
box-shadow unset
144+
color: darken($accentColor, 20%)
145+
background-color rgba($accentColor, 0.05)
146+
.docs-searchbar-suggestion--category-header-lvl0, .docs-searchbar-suggestion--category-header-lvl1
147+
.docs-searchbar-suggestion--highlight
148+
background-color: transparent
149+
box-shadow inset 0 -2px 0 0 lighten($accentColor, 20%)
150+
color inherit
132151
.docs-searchbar-footer
133152
display flex !important
134153
justify-content space-between !important

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ module.exports = {
110110
"placeholder": "Search as you type...", // Default: ""
111111
"maxSuggestions": 10, // Default: 5
112112
"hotKeys": [], // Default: ['s', '/']
113-
"cropLength": 50 // Default: 30
113+
"cropLength": 50, // Default: 30
114+
"layout": "simple" // Default: "columns"
114115
}
115116
],
116117
],

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = (options) => {
1212
PLACEHOLDER: options.placeholder || null,
1313
MAX_SUGGESTIONS: options.maxSuggestions || null,
1414
HOT_KEYS: options.hotKeys || ['s', '/'],
15-
CROP_LENGTH: options.cropLength || 30
15+
CROP_LENGTH: options.cropLength || 30,
16+
LAYOUT: options.layout || 'columns'
1617
}
1718
}
1819
}

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
PLACEHOLDER: null,
1111
MAX_SUGGESTIONS: null,
1212
HOT_KEYS: ['s', '/'],
13-
CROP_LENGTH: 30
13+
CROP_LENGTH: 30,
14+
LAYOUT: 'columns'
1415
}
1516
}

0 commit comments

Comments
 (0)