Skip to content

Commit f33bab0

Browse files
committed
maxWidth, maxHeight
1 parent 9137dd9 commit f33bab0

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

src/Web/Atomic/CSS/Layout.hs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ import Web.Atomic.Types
3838
> el " - " ~ grow
3939
> el "Bottom"
4040
-}
41-
42-
4341
flexCol :: (Styleable h) => CSS h -> CSS h
4442
flexCol =
4543
utility
@@ -48,6 +46,7 @@ flexCol =
4846
, "flex-direction" :. style Column
4947
]
5048

49+
5150
{- | Lay out children in a row. See 'Web.Atomic.Html.Tag.row'
5251
5352
> el ~ flexRow $ do
@@ -64,8 +63,6 @@ flexRow =
6463
]
6564

6665

67-
68-
6966
-- | Grow to fill the available space in the parent 'flexRow' or 'flexCol'
7067
grow :: (Styleable h) => CSS h -> CSS h
7168
grow = utility "grow" ["flex-grow" :. "1"]
@@ -226,21 +223,22 @@ data Visibility
226223
deriving (Show, ToClassName, ToStyle)
227224

228225

229-
visibility :: Styleable h => Visibility -> CSS h -> CSS h
226+
visibility :: (Styleable h) => Visibility -> CSS h -> CSS h
230227
visibility v = utility ("vis" -. v) ["visibility" :. style v]
231228

229+
232230
{- | Set to specific width
233231
234232
> el ~ width 100 $ "100px"
235233
> el ~ width (PxRem 100) $ "100px"
236234
> el ~ width (Pct 50) $ "50pct"
237235
-}
238236
width :: (Styleable h) => Length -> CSS h -> CSS h
239-
width n = utility ("w" -. n) [ "width" :. style n ]
237+
width n = utility ("w" -. n) ["width" :. style n]
240238

241239

242240
height :: (Styleable h) => Length -> CSS h -> CSS h
243-
height n = utility ("h" -. n) [ "height" :. style n ]
241+
height n = utility ("h" -. n) ["height" :. style n]
244242

245243

246244
-- | Allow width to grow to contents but not shrink any smaller than value
@@ -249,12 +247,22 @@ minWidth n =
249247
utility ("mw" -. n) ["min-width" :. style n]
250248

251249

250+
maxWidth :: (Styleable h) => Length -> CSS h -> CSS h
251+
maxWidth n =
252+
utility ("mxw" -. n) ["max-width" :. style n]
253+
254+
252255
-- | Allow height to grow to contents but not shrink any smaller than value
253256
minHeight :: (Styleable h) => Length -> CSS h -> CSS h
254257
minHeight n =
255258
utility ("mh" -. n) ["min-height" :. style n]
256259

257260

261+
maxHeight :: (Styleable h) => Length -> CSS h -> CSS h
262+
maxHeight n =
263+
utility ("mxh" -. n) ["max-height" :. style n]
264+
265+
258266
data Overflow
259267
= Scroll
260268
| Clip
@@ -264,6 +272,6 @@ instance PropertyStyle Overflow Auto
264272
instance PropertyStyle Overflow Visibility
265273

266274

267-
-- | Control how an element clips content that exceeds its bounds
275+
-- | Control how an element clips content that exceeds its bounds
268276
overflow :: (PropertyStyle Overflow o, ToClassName o, Styleable h) => o -> CSS h -> CSS h
269277
overflow o = utility ("over" -. o) ["overflow" :. propertyStyle @Overflow o]

0 commit comments

Comments
 (0)