Skip to content

Commit

Permalink
value always sounded odd to me
Browse files Browse the repository at this point in the history
  • Loading branch information
fidel committed Mar 22, 2024
1 parent 1af9fab commit f43b1c9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ruby_event_store-browser/elm/src/Search.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type alias Stream =

type alias Model a =
{ streams : List Stream
, value : Stream
, searchedStream : Stream
, onSelectMsg : Stream -> a
, onQueryMsg : Stream -> a
}
Expand All @@ -28,7 +28,7 @@ type Msg
init : (Stream -> a) -> (Stream -> a) -> Model a
init onSelectMsg onQueryMsg =
{ streams = emptyStreams
, value = emptyStreamName
, searchedStream = emptyStreamName
, onSelectMsg = onSelectMsg
, onQueryMsg = onQueryMsg
}
Expand All @@ -39,15 +39,15 @@ update msg model =
case msg of
StreamChanged stream ->
if hasAtLeastThreeChars stream then
( { model | value = stream }
( { model | searchedStream = stream }
, onQueryChangedCmd model.onQueryMsg stream
)

else
( { model | value = stream }, Cmd.none )
( { model | searchedStream = stream }, Cmd.none )

GoToStream stream ->
( { model | value = emptyStreamName }
( { model | searchedStream = emptyStreamName }
, onSelectCmd model.onSelectMsg stream
)

Expand All @@ -56,16 +56,16 @@ view : Model a -> Html Msg
view model =
let
streams_ =
filterStreams model.value model.streams
filterStreams model.searchedStream model.streams
in
form [ onSubmit (GoToStream model.value) ]
form [ onSubmit (GoToStream model.searchedStream) ]
[ div [ class "relative" ]
[ FeatherIcons.search
|> FeatherIcons.withClass "size-4 text-gray-400 absolute pointer-events-none top-3.5 left-2"
|> FeatherIcons.toHtml []
, input
[ class "rounded text-gray-800 cursor-pointer pl-8 pr-12 py-2 w-full appearance-none outline-none focus:ring-2 focus:ring-red-500 focus:ring-opacity-50"
, value model.value
, value model.searchedStream
, onInput StreamChanged
, placeholder "Quick search…"
, autofocus True
Expand Down

0 comments on commit f43b1c9

Please sign in to comment.