mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-19 23:59:32 +00:00
This drops fomantic-ui as css toolkit and introduces tailwindcss. With tailwind there are no predefined components, but it's very easy to create those. So customizing the look&feel is much simpler, most of the time no additional css is needed. This requires a complete rewrite of the markup + styles. Luckily all logic can be kept as is. The now old ui is not removed, it is still available by using a request header `Docspell-Ui` with a value of `1` for the old ui and `2` for the new ui. Another addition is "dev mode", where docspell serves assets with a no-cache header, to disable browser caching. This makes developing a lot easier.
132 lines
2.7 KiB
Elm
132 lines
2.7 KiB
Elm
module Comp.PasswordInput exposing
|
|
( Model
|
|
, Msg
|
|
, init
|
|
, update
|
|
, view
|
|
, view2
|
|
)
|
|
|
|
import Html exposing (..)
|
|
import Html.Attributes exposing (..)
|
|
import Html.Events exposing (onClick, onInput)
|
|
import Styles as S
|
|
import Util.Maybe
|
|
|
|
|
|
type alias Model =
|
|
{ show : Bool
|
|
}
|
|
|
|
|
|
init : Model
|
|
init =
|
|
{ show = False
|
|
}
|
|
|
|
|
|
type Msg
|
|
= ToggleShow (Maybe String)
|
|
| SetPassword String
|
|
|
|
|
|
update : Msg -> Model -> ( Model, Maybe String )
|
|
update msg model =
|
|
case msg of
|
|
ToggleShow pw ->
|
|
( { model | show = not model.show }
|
|
, pw
|
|
)
|
|
|
|
SetPassword str ->
|
|
let
|
|
pw =
|
|
Util.Maybe.fromString str
|
|
in
|
|
( model, pw )
|
|
|
|
|
|
view : Maybe String -> Model -> Html Msg
|
|
view pw model =
|
|
div [ class "ui left action input" ]
|
|
[ button
|
|
[ class "ui icon button"
|
|
, type_ "button"
|
|
, onClick (ToggleShow pw)
|
|
]
|
|
[ i
|
|
[ classList
|
|
[ ( "ui eye icon", True )
|
|
, ( "slash", model.show )
|
|
]
|
|
]
|
|
[]
|
|
]
|
|
, input
|
|
[ type_ <|
|
|
if model.show then
|
|
"text"
|
|
|
|
else
|
|
"password"
|
|
, onInput SetPassword
|
|
, Maybe.withDefault "" pw |> value
|
|
]
|
|
[]
|
|
]
|
|
|
|
|
|
|
|
--- View2
|
|
|
|
|
|
view2 : Maybe String -> Bool -> Model -> Html Msg
|
|
view2 pw isError model =
|
|
div [ class "relative" ]
|
|
[ div [ class S.inputIcon ]
|
|
[ i
|
|
[ class "fa"
|
|
, if model.show then
|
|
class "fa-lock-open"
|
|
|
|
else
|
|
class "fa-lock"
|
|
]
|
|
[]
|
|
]
|
|
, input
|
|
[ type_ <|
|
|
if model.show then
|
|
"text"
|
|
|
|
else
|
|
"password"
|
|
, name "passw1"
|
|
, autocomplete False
|
|
, onInput SetPassword
|
|
, Maybe.withDefault "" pw |> value
|
|
, class ("pl-10 pr-10 py-2 rounded" ++ S.textInput)
|
|
, class <|
|
|
if isError then
|
|
S.inputErrorBorder
|
|
|
|
else
|
|
""
|
|
, placeholder "Password"
|
|
]
|
|
[]
|
|
, a
|
|
[ class S.inputLeftIconLink
|
|
, class <|
|
|
if isError then
|
|
S.inputErrorBorder
|
|
|
|
else
|
|
""
|
|
, onClick (ToggleShow pw)
|
|
, href "#"
|
|
]
|
|
[ i [ class "fa fa-eye" ] []
|
|
]
|
|
]
|