add backdrop for suggestions and show suggestions loading spinner the moment a user starts typing (#129)
fixes #118 fixes #122
This commit is contained in:
parent
a3ed2036cb
commit
71eba22a0e
|
@ -149,7 +149,7 @@ init channel query show from size model =
|
|||
( { channel = Maybe.withDefault defaultChannel channel
|
||||
, queryDebounce =
|
||||
Debouncer.Messages.manual
|
||||
|> Debouncer.Messages.settleWhenQuietFor (Just <| Debouncer.Messages.fromSeconds 0.6)
|
||||
|> Debouncer.Messages.settleWhenQuietFor (Just <| Debouncer.Messages.fromSeconds 0.4)
|
||||
|> Debouncer.Messages.toDebouncer
|
||||
, query = query
|
||||
, querySuggest =
|
||||
|
@ -264,22 +264,7 @@ update path navKey result_type options decodeResultItemSource msg model =
|
|||
(QueryInputDebounce (Debouncer.Messages.provideInput QueryInputSuggestionsSubmit))
|
||||
{ model
|
||||
| query = Just query
|
||||
, querySuggest =
|
||||
case model.querySuggest of
|
||||
RemoteData.Success result ->
|
||||
let
|
||||
suggestions =
|
||||
getSuggestions (Just "XXXX") model.querySuggest
|
||||
|> List.map .text
|
||||
in
|
||||
if List.member (Just query) suggestions then
|
||||
RemoteData.NotAsked
|
||||
|
||||
else
|
||||
model.querySuggest
|
||||
|
||||
_ ->
|
||||
RemoteData.NotAsked
|
||||
, querySuggest = RemoteData.Loading
|
||||
, querySelectedSuggestion = Nothing
|
||||
}
|
||||
|> Tuple.mapSecond
|
||||
|
@ -708,14 +693,25 @@ view path title model viewSuccess outMsg =
|
|||
[ text <| Maybe.withDefault "" x.text ]
|
||||
]
|
||||
in
|
||||
div [ class "search-page" ]
|
||||
div
|
||||
[ classList
|
||||
[ ( "search-page", True )
|
||||
, ( "with-suggestions", RemoteData.isSuccess model.querySuggest && List.length suggestions > 0 )
|
||||
, ( "with-suggestions-loading"
|
||||
, (model.query /= Nothing)
|
||||
&& (model.query /= Just "")
|
||||
&& not (RemoteData.isSuccess model.querySuggest || RemoteData.isNotAsked model.querySuggest)
|
||||
)
|
||||
]
|
||||
]
|
||||
[ h1 [ class "page-header" ] [ text title ]
|
||||
, div
|
||||
[ classList
|
||||
[ ( "search-input", True )
|
||||
, ( "with-suggestions", RemoteData.isSuccess model.querySuggest && List.length suggestions > 0 )
|
||||
, ( "with-suggestions-loading", RemoteData.isLoading model.querySuggest )
|
||||
[ class "search-backdrop"
|
||||
, onClick <| outMsg SuggestionsClose
|
||||
]
|
||||
[]
|
||||
, div
|
||||
[ class "search-input"
|
||||
]
|
||||
[ form [ onSubmit (outMsg QueryInputSubmit) ]
|
||||
[ p
|
||||
|
|
|
@ -29,19 +29,26 @@ header .navbar.navbar-static-top {
|
|||
}
|
||||
}
|
||||
|
||||
.search-page {
|
||||
.search-input.with-suggestions-loading {
|
||||
.search-page.with-suggestions-loading {
|
||||
.input-append div.loader {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
.search-input.with-suggestions {
|
||||
.search-page.with-suggestions {
|
||||
ul.dropdown-menu {
|
||||
display: block;
|
||||
}
|
||||
.input-append input {
|
||||
border-radius: 4px 0 0 0;
|
||||
}
|
||||
.search-backdrop {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 999;
|
||||
}
|
||||
}
|
||||
.search-input {
|
||||
position: relative;
|
||||
|
@ -129,7 +136,7 @@ header .navbar.navbar-static-top {
|
|||
margin-bottom: 1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.loader,
|
||||
.loader:before,
|
||||
|
|
Loading…
Reference in a new issue