Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change input selector to id #264

Merged
merged 5 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 57 additions & 27 deletions MeiliSearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
id="search-form"
class="meilisearch-search-wrapper search-box"
role="search"
:class="'theme-' + theme"
>
<input
id="meilisearch-search-input"
Expand All @@ -17,6 +18,7 @@ export default {
name: 'MeiliSearchBox',
data() {
return {
theme: false,
placeholder: undefined
}
},
Expand All @@ -43,6 +45,7 @@ export default {
debug: DEBUG,
enableDarkMode: ENABLE_DARK_MODE
}
this.updateTheme(options)
this.initialize(options)
this.placeholder =
PLACEHOLDER || this.$site.themeConfig.searchPlaceholder || ''
Expand Down Expand Up @@ -72,9 +75,14 @@ export default {
},

update(options) {
this.updateTheme(options)
this.$el.innerHTML =
'<input id="meilisearch-search-input" class="search-query">'
this.initialize(options)
},

updateTheme(options) {
this.theme = options.enableDarkMode === true ? 'dark' : options.enableDarkMode === false ? 'light' : 'auto'
bidoubiwa marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand All @@ -83,6 +91,55 @@ export default {
<style lang="stylus">
@require './styles/palette.styl'

light-input()
color lighten($textColor, 25%)
border 1px solid darken($borderColor, 10%)
background-color #fff
&:focus
border-color $accentColor

dark-input()
color $textDarkColor
border 1px solid $borderDarkColor
background-color $inputDarkBgColor
&:focus
border-color $accentDarkColor

// Searchbox
#meilisearch-search-input
cursor text
width 10rem
height: 2rem
display inline-block
border-radius 2rem
font-size 0.9rem
line-height 2rem
padding 0 0.5rem 0 2rem
outline none
transition border .2s ease
background: url(assets/search.svg) 0.6rem 0.5rem no-repeat
&:focus
cursor auto
background-size 1rem

.meilisearch-search-wrapper.theme-light
#meilisearch-search-input
light-input()

.meilisearch-search-wrapper.theme-dark
#meilisearch-search-input
dark-input()

@media (prefers-color-scheme: dark)
.meilisearch-search-wrapper.theme-auto
#meilisearch-search-input
dark-input()

@media (prefers-color-scheme: light)
.meilisearch-search-wrapper.theme-auto
#meilisearch-search-input
light-input()

.meilisearch-search-wrapper
display: inline-block;
position: relative;
Expand All @@ -93,25 +150,6 @@ export default {
background rgba($accentColor, 0.05)
.meilisearch-autocomplete
line-height: 2
// Searchbox
input
cursor text
width 10rem
height: 2rem
color lighten($textColor, 25%)
display inline-block
border 1px solid darken($borderColor, 10%)
border-radius 2rem
font-size 0.9rem
line-height 2rem
padding 0 0.5rem 0 2rem
outline none
transition all .2s ease
&:focus
cursor auto
border-color $accentColor
background #fff url(assets/search.svg) 0.6rem 0.5rem no-repeat
background-size 1rem

// Layout "columns"
.docs-searchbar-suggestion:not(.suggestion-layout-simple)
Expand Down Expand Up @@ -177,14 +215,6 @@ export default {
.dsb-dropdown-menu [class^=dsb-dataset-], .docs-searchbar-suggestion
background $dropdownBgDarkColor

// Searchbox
input
color $textDarkColor
border 1px solid $borderDarkColor
background-color $inputDarkBgColor
&:focus
border-color $accentDarkColor

// Layout "columns"
.docs-searchbar-suggestion:not(.suggestion-layout-simple)
border-color $borderDarkColor
Expand Down
2 changes: 1 addition & 1 deletion tests/MeiliSearchBoxTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('MeiliSearchBox', () => {

it('renders default form and input', () => {
expect(wrapper.html()).toContain(
'<form id="search-form" role="search" class="meilisearch-search-wrapper search-box">'
'<form id="search-form" role="search" class="meilisearch-search-wrapper search-box theme-light">'
)
expect(wrapper.html()).toContain(
'<input id="meilisearch-search-input" class="search-query" placeholder="">'
Expand Down