Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Commit 4c0cf39

Browse files
committed
Add new Card component
1 parent 20f7882 commit 4c0cf39

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

src/UI/Card.elm

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module UI.Card exposing (..)
2+
3+
import Html exposing (Html, div, text)
4+
import Html.Attributes exposing (class)
5+
6+
7+
type alias Card msg =
8+
{ title : Maybe String, items : List (Html msg) }
9+
10+
11+
card : List (Html msg) -> Card msg
12+
card items =
13+
{ title = Nothing, items = items }
14+
15+
16+
titled : String -> List (Html msg) -> Card msg
17+
titled title items =
18+
{ title = Just title, items = items }
19+
20+
21+
withTitle : String -> Card msg -> Card msg
22+
withTitle title card_ =
23+
{ card_ | title = Just title }
24+
25+
26+
withItems : List (Html msg) -> Card msg -> Card msg
27+
withItems items card_ =
28+
{ card_ | items = items }
29+
30+
31+
withItem : Html msg -> Card msg -> Card msg
32+
withItem item card_ =
33+
{ card_ | items = card_.items ++ [ item ] }
34+
35+
36+
view : Card msg -> Html msg
37+
view card_ =
38+
let
39+
items =
40+
case card_.title of
41+
Just t ->
42+
h3 [ class "card-title" ] [ text t ] :: card_.items
43+
in
44+
div [ class "card" ] items

src/css/card.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.card {
2+
padding: 1rem 1.5rem;
3+
display: flex;
4+
flex-direction: column;
5+
gap: 1rem;
6+
color: var(--color-card-fg);
7+
border-radius: var(--border-radius-base);
8+
background: var(--color-card-bg);
9+
}
10+
11+
.card .card-title {
12+
color: var(--color-card-title);
13+
text-transform: uppercase;
14+
font-size: var(--font-size-medium);
15+
}

src/css/themes/unison/light.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,12 @@
208208
--color-button-danger-hover-fg: var(--color-gray-lighten-100);
209209
--color-button-danger-hover-bg: var(--color-pink-2);
210210

211-
/* Badges */
211+
/* Card */
212+
--color-card-bg: var(--color-gray-lighten-100);
213+
--color-card-fg: var(--color-gray-darken-30);
214+
--color-card-title: var(--color-gray-lighten-30);
215+
216+
/* Badge */
212217
--color-badge-fg: var(--color-gray-base);
213218
--color-badge-bg: var(--color-gray-lighten-60);
214219
--color-badge-border: var(--color-gray-lighten-50);
@@ -220,7 +225,7 @@
220225
--color-option-badge-bg: var(--color-gray-darken-30);
221226
--color-option-badge-border: var(--color-transparent);
222227

223-
/* Tooltips */
228+
/* Tooltip */
224229
--color-tooltip-fg: var(--color-gray-lighten-60);
225230
--color-tooltip-subtle-fg: var(--color-gray-lighten-20);
226231
--color-tooltip-bg: var(--color-gray-darken-30);

0 commit comments

Comments
 (0)