Skip to content

Commit ed7f265

Browse files
committed
Add support for tags with classnames
1 parent aedb50a commit ed7f265

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/UI/Tag.elm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type alias Tag msg =
2626
, text : String
2727
, rightText : Maybe String
2828
, action : TagAction msg
29+
, className : Maybe String
2930
, size : TagSize
3031
}
3132

@@ -42,6 +43,7 @@ tag text_ =
4243
, rightText = Nothing
4344
, action = NoAction
4445
, size = Medium
46+
, className = Nothing
4547
}
4648

4749

@@ -54,6 +56,11 @@ withIcon icon t =
5456
{ t | icon = Just icon }
5557

5658

59+
withClassName : String -> Tag msg -> Tag msg
60+
withClassName className t =
61+
{ t | className = Just className }
62+
63+
5764
withClick : Click msg -> Tag msg -> Tag msg
5865
withClick click t =
5966
{ t | action = TagClick click }
@@ -120,6 +127,7 @@ map toMsg t =
120127
, leftText = t.leftText
121128
, text = t.text
122129
, rightText = t.rightText
130+
, className = t.className
123131
, action = mapAction toMsg t.action
124132
, size = t.size
125133
}
@@ -164,6 +172,10 @@ view t =
164172

165173
attrs =
166174
[ class "tag", sizeClass ]
175+
++ (t.className
176+
|> Maybe.map (\cn -> [ class cn ])
177+
|> Maybe.withDefault []
178+
)
167179

168180
content =
169181
MaybeE.values [ icon, Just tagText ]

0 commit comments

Comments
 (0)