mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
First version of new ui based on tailwind
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.
This commit is contained in:
@ -1,4 +1,9 @@
|
||||
module Util.CustomField exposing (nameOrLabel, renderValue, renderValue1)
|
||||
module Util.CustomField exposing
|
||||
( nameOrLabel
|
||||
, renderValue
|
||||
, renderValue1
|
||||
, renderValue2
|
||||
)
|
||||
|
||||
import Api.Model.ItemFieldValue exposing (ItemFieldValue)
|
||||
import Data.CustomFieldType
|
||||
@ -52,3 +57,41 @@ renderValue1 classes tagger cv =
|
||||
text cv.value
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
renderValue2 : List ( String, Bool ) -> Maybe msg -> ItemFieldValue -> Html msg
|
||||
renderValue2 classes tagger cv =
|
||||
let
|
||||
renderBool =
|
||||
if cv.value == "true" then
|
||||
i [ class "fa fa-check" ] []
|
||||
|
||||
else
|
||||
i [ class "fa fa-minus" ] []
|
||||
|
||||
el : List (Html msg) -> Html msg
|
||||
el =
|
||||
case tagger of
|
||||
Just t ->
|
||||
a
|
||||
[ classList classes
|
||||
, onClick t
|
||||
, href "#"
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
div [ classList classes ]
|
||||
in
|
||||
el
|
||||
[ Icons.customFieldTypeIconString2 "" cv.ftype
|
||||
, span [ class "ml-1 mr-2" ]
|
||||
[ nameOrLabel cv |> text
|
||||
]
|
||||
, div [ class "detail" ]
|
||||
[ if Data.CustomFieldType.fromString cv.ftype == Just Data.CustomFieldType.Boolean then
|
||||
renderBool
|
||||
|
||||
else
|
||||
text cv.value
|
||||
]
|
||||
]
|
||||
|
@ -1,11 +1,14 @@
|
||||
module Util.ExpandCollapse exposing
|
||||
( collapseToggle
|
||||
, collapseToggle2
|
||||
, expandToggle
|
||||
, expandToggle2
|
||||
)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
import Styles as S
|
||||
|
||||
|
||||
expandToggle : Int -> Int -> msg -> List (Html msg)
|
||||
@ -48,3 +51,47 @@ collapseToggle max all m =
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
|
||||
--- View2
|
||||
|
||||
|
||||
expandToggle2 : Int -> Int -> msg -> List (Html msg)
|
||||
expandToggle2 max all m =
|
||||
if max >= all then
|
||||
[]
|
||||
|
||||
else
|
||||
[ a
|
||||
[ class S.link
|
||||
, class "flex flex-row items-center"
|
||||
, onClick m
|
||||
, href "#"
|
||||
]
|
||||
[ i [ class "fa fa-angle-down" ] []
|
||||
, div [ class "font-italics text-sm ml-2" ]
|
||||
[ text "Show More …"
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
collapseToggle2 : Int -> Int -> msg -> List (Html msg)
|
||||
collapseToggle2 max all m =
|
||||
if max >= all then
|
||||
[]
|
||||
|
||||
else
|
||||
[ a
|
||||
[ class S.link
|
||||
, class "flex flex-row items-center"
|
||||
, onClick m
|
||||
, href "#"
|
||||
]
|
||||
[ i [ class "fa fa-angle-up" ] []
|
||||
, div [ class "font-italics text-sm ml-2" ]
|
||||
[ text "Show Less …"
|
||||
]
|
||||
]
|
||||
]
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Util.Html exposing
|
||||
( KeyCode(..)
|
||||
, checkbox
|
||||
, checkbox2
|
||||
, classActive
|
||||
, intToKeyCode
|
||||
, onClickk
|
||||
@ -40,6 +41,15 @@ checkbox flag =
|
||||
checkboxUnchecked
|
||||
|
||||
|
||||
checkbox2 : Bool -> Html msg
|
||||
checkbox2 flag =
|
||||
if flag then
|
||||
i [ class "fa fa-check-square font-thin" ] []
|
||||
|
||||
else
|
||||
i [ class "fa fa-minus-square font-thin" ] []
|
||||
|
||||
|
||||
type KeyCode
|
||||
= Up
|
||||
| Down
|
||||
|
@ -2,6 +2,7 @@ module Util.Tag exposing
|
||||
( getCategories
|
||||
, makeCatDropdownModel
|
||||
, makeDropdownModel
|
||||
, makeDropdownModel2
|
||||
)
|
||||
|
||||
import Api.Model.Tag exposing (Tag)
|
||||
@ -24,6 +25,23 @@ makeDropdownModel =
|
||||
}
|
||||
|
||||
|
||||
makeDropdownModel2 : Comp.Dropdown.Model Tag
|
||||
makeDropdownModel2 =
|
||||
Comp.Dropdown.makeModel
|
||||
{ multiple = True
|
||||
, searchable = \n -> n > 0
|
||||
, makeOption = \tag -> { value = tag.id, text = tag.name, additional = "" }
|
||||
, labelColor =
|
||||
\tag ->
|
||||
\settings ->
|
||||
Data.UiSettings.tagColorString2 tag settings
|
||||
++ -- legacy colors
|
||||
" basic "
|
||||
++ Data.UiSettings.tagColorString tag settings
|
||||
, placeholder = "Choose a tag…"
|
||||
}
|
||||
|
||||
|
||||
makeCatDropdownModel : Comp.Dropdown.Model String
|
||||
makeCatDropdownModel =
|
||||
Comp.Dropdown.makeModel
|
||||
|
Reference in New Issue
Block a user