Skip to content

Commit dfe83f7

Browse files
authored
Add matrix smart constructor (#1096)
Useful for avoiding `MisoString` concatenation.
1 parent 3ecb753 commit dfe83f7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Miso/Style.hs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ module Miso.Style
218218
, ms
219219
-- *** Misc
220220
, url
221+
, matrix
221222
-- *** Animation
222223
, keyframes_
223224
-- *** Media Queries
@@ -272,9 +273,31 @@ s x = MS.ms x <> "s"
272273
ms :: Double -> MisoString
273274
ms x = MS.ms x <> "ms"
274275
-----------------------------------------------------------------------------
276+
-- | https://developer.mozilla.org/en-US/docs/Web/CSS/url_function
275277
url :: MisoString -> MisoString
276278
url x = "url(" <> x <> ")"
277279
-----------------------------------------------------------------------------
280+
-- | https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
281+
matrix
282+
:: Double
283+
-> Double
284+
-> Double
285+
-> Double
286+
-> Double
287+
-> Double
288+
-> MisoString
289+
matrix a b c d tx ty = "matrix(" <> values <> ")"
290+
where
291+
values =
292+
MS.intercalate ","
293+
[ MS.ms a
294+
, MS.ms b
295+
, MS.ms c
296+
, MS.ms d
297+
, MS.ms tx
298+
, MS.ms ty
299+
]
300+
-----------------------------------------------------------------------------
278301
-- | https://developer.mozilla.org/en-US/docs/Web/CSS/percentage
279302
pct :: Double -> MisoString
280303
pct x = MS.ms x <> "%"

0 commit comments

Comments
 (0)