mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 18:31:24 +02:00
feat: add possibility to set search input placeholder
This commit is contained in:
parent
ac7f3805d4
commit
8ad7d4be0a
@ -871,6 +871,7 @@ Preview:
|
|||||||
| search-engine | string | no | duckduckgo |
|
| search-engine | string | no | duckduckgo |
|
||||||
| new-tab | boolean | no | false |
|
| new-tab | boolean | no | false |
|
||||||
| autofocus | boolean | no | false |
|
| autofocus | boolean | no | false |
|
||||||
|
| placeholder | string | no | Type here to search… |
|
||||||
| bangs | array | no | |
|
| bangs | array | no | |
|
||||||
|
|
||||||
##### `search-engine`
|
##### `search-engine`
|
||||||
@ -887,6 +888,9 @@ When set to `true`, swaps the shortcuts for showing results in the same or new t
|
|||||||
##### `autofocus`
|
##### `autofocus`
|
||||||
When set to `true`, automatically focuses the search input on page load.
|
When set to `true`, automatically focuses the search input on page load.
|
||||||
|
|
||||||
|
##### `placeholder`
|
||||||
|
When set, modifies the text displayed in the input field before typing.
|
||||||
|
|
||||||
##### `bangs`
|
##### `bangs`
|
||||||
What now? [Bangs](https://duckduckgo.com/bangs). They're shortcuts that allow you to use the same search box for many different sites. Assuming you have it configured, if for example you start your search input with `!yt` you'd be able to perform a search on YouTube:
|
What now? [Bangs](https://duckduckgo.com/bangs). They're shortcuts that allow you to use the same search box for many different sites. Assuming you have it configured, if for example you start your search input with `!yt` you'd be able to perform a search on YouTube:
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input class="search-input" type="text" placeholder="Type here to search…" autocomplete="off"{{ if .Autofocus }} autofocus{{ end }}>
|
<input class="search-input" type="text" placeholder="{{ .Placeholder }}" autocomplete="off"{{ if .Autofocus }} autofocus{{ end }}>
|
||||||
|
|
||||||
<div class="search-bang"></div>
|
<div class="search-bang"></div>
|
||||||
<kbd class="hide-on-mobile" title="Press [S] to focus the search input">S</kbd>
|
<kbd class="hide-on-mobile" title="Press [S] to focus the search input">S</kbd>
|
||||||
|
@ -21,6 +21,7 @@ type searchWidget struct {
|
|||||||
Bangs []SearchBang `yaml:"bangs"`
|
Bangs []SearchBang `yaml:"bangs"`
|
||||||
NewTab bool `yaml:"new-tab"`
|
NewTab bool `yaml:"new-tab"`
|
||||||
Autofocus bool `yaml:"autofocus"`
|
Autofocus bool `yaml:"autofocus"`
|
||||||
|
Placeholder string `yaml:"placeholder"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertSearchUrl(url string) string {
|
func convertSearchUrl(url string) string {
|
||||||
@ -41,6 +42,10 @@ func (widget *searchWidget) initialize() error {
|
|||||||
widget.SearchEngine = "duckduckgo"
|
widget.SearchEngine = "duckduckgo"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if widget.Placeholder == "" {
|
||||||
|
widget.Placeholder = "Type here to search…"
|
||||||
|
}
|
||||||
|
|
||||||
if url, ok := searchEngines[widget.SearchEngine]; ok {
|
if url, ok := searchEngines[widget.SearchEngine]; ok {
|
||||||
widget.SearchEngine = url
|
widget.SearchEngine = url
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user