Skip to content

Finish PR 44 - Remove Nested Tuple usage #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ New features:
Bugfixes:

Other improvements:
- Remove ending space in css output (e.g. `padding: 1 2 3 4 `) (#135 by @chexxor and @JordanMartinez)

## [v5.0.1](https://github.com/purescript-contrib/purescript-css/releases/tag/v5.0.1) - 2021-04-19

Expand Down
4 changes: 2 additions & 2 deletions src/CSS/Animation.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CSS.Stylesheet (CSS, key)
import CSS.Time (Time)
import CSS.Transition (TimingFunction)
import Data.Foldable (for_)
import Data.Tuple.Nested (tuple7)
import Data.Tuple (Tuple(..))

newtype AnimationDirection = AnimationDirection Value

Expand Down Expand Up @@ -60,7 +60,7 @@ backwards = FillMode $ fromString "backwards"
animation :: AnimationName -> Time -> TimingFunction -> Time -> IterationCount -> AnimationDirection -> FillMode -> CSS
animation p de f du i di fm = do
for_ animationKeys \k ->
key (fromString k) (tuple7 p de f du i di fm)
key (fromString k) (Tuple (Tuple (Tuple p de) (Tuple f du)) (Tuple (Tuple i di) fm))
where
animationKeys =
[ "animation"
Expand Down
15 changes: 7 additions & 8 deletions src/CSS/Border.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ module CSS.Border where

import Prelude

import Data.Tuple.Nested (tuple3, tuple4)

import CSS.Color (Color)
import CSS.Property (class Val, Value)
import CSS.Size (Size, Abs)
import CSS.String (fromString)
import CSS.Stylesheet (CSS, key)
import Data.Tuple (Tuple(..))

newtype Stroke = Stroke Value

Expand Down Expand Up @@ -46,25 +45,25 @@ outset :: Stroke
outset = Stroke $ fromString "outset"

border :: Stroke -> Size Abs -> Color -> CSS
border a b c = key (fromString "border") $ tuple3 a b c
border a b c = key (fromString "border") (Tuple a (Tuple b c))

borderTop :: Stroke -> Size Abs -> Color -> CSS
borderTop a b c = key (fromString "border-top") $ tuple3 a b c
borderTop a b c = key (fromString "border-top") (Tuple a (Tuple b c))

borderBottom :: Stroke -> Size Abs -> Color -> CSS
borderBottom a b c = key (fromString "border-bottom") $ tuple3 a b c
borderBottom a b c = key (fromString "border-bottom") (Tuple a (Tuple b c))

borderLeft :: Stroke -> Size Abs -> Color -> CSS
borderLeft a b c = key (fromString "border-left") $ tuple3 a b c
borderLeft a b c = key (fromString "border-left") (Tuple a (Tuple b c))

borderRight :: Stroke -> Size Abs -> Color -> CSS
borderRight a b c = key (fromString "border-right") $ tuple3 a b c
borderRight a b c = key (fromString "border-right") (Tuple a (Tuple b c))

borderColor :: Color -> CSS
borderColor = key $ fromString "border-color"

borderRadius :: forall a. Size a -> Size a -> Size a -> Size a -> CSS
borderRadius a b c d = key (fromString "border-radius") (tuple4 a b c d)
borderRadius a b c d = key (fromString "border-radius") (Tuple (Tuple a b) (Tuple c d))

borderSpacing :: forall a. Size a -> CSS
borderSpacing = key $ fromString "border-spacing"
9 changes: 4 additions & 5 deletions src/CSS/Geometry.purs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module CSS.Geometry where

import Data.Function (($))
import Data.Tuple.Nested (tuple4)

import CSS.Size (Size)
import CSS.String (fromString)
import CSS.Stylesheet (CSS, key)
import Data.Function (($))
import Data.Tuple (Tuple(..))

width :: forall a. Size a -> CSS
width = key $ fromString "width"
Expand Down Expand Up @@ -38,7 +37,7 @@ right :: forall a. Size a -> CSS
right = key $ fromString "right"

padding :: forall a. Size a -> Size a -> Size a -> Size a -> CSS
padding a b c d = key (fromString "padding") $ tuple4 a b c d
padding a b c d = key (fromString "padding") (Tuple (Tuple a b) (Tuple c d))

paddingTop :: forall a. Size a -> CSS
paddingTop = key $ fromString "padding-top"
Expand All @@ -53,7 +52,7 @@ paddingRight :: forall a. Size a -> CSS
paddingRight = key $ fromString "padding-right"

margin :: forall a. Size a -> Size a -> Size a -> Size a -> CSS
margin a b c d = key (fromString "margin") $ tuple4 a b c d
margin a b c d = key (fromString "margin") (Tuple (Tuple a b) (Tuple c d))

marginTop :: forall a. Size a -> CSS
marginTop = key $ fromString "margin-top"
Expand Down
4 changes: 2 additions & 2 deletions src/CSS/ListStyle.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import CSS.ListStyle.Type (ListStyleType)
import CSS.Property (class Val, value)
import CSS.String (fromString)
import CSS.Stylesheet (CSS, key)
import Data.Tuple.Nested (tuple3)
import Data.Tuple (Tuple(..))

data ListStyle = ListStyle ListStyleType ListStylePosition ListStyleImage

instance valueListStyle :: Val ListStyle where
value (ListStyle t p i) = value (tuple3 t p i)
value (ListStyle t p i) = value (Tuple t (Tuple p i))

listStyle :: ListStyleType -> ListStylePosition -> ListStyleImage -> CSS
listStyle t p i = key (fromString "list-style") (ListStyle t p i)
2 changes: 0 additions & 2 deletions src/CSS/Property.purs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ instance valString :: Val String where
instance valUnit :: Val Unit where
value _ = fromString ""

-- When `b` is Unit, the rendered value will have an extra
-- space appended to end. Shouldn't hurt. I'd fix if I knew how.
instance valTuple :: (Val a, Val b) => Val (Tuple a b) where
value (Tuple a b) = value a <> fromString " " <> value b

Expand Down
4 changes: 2 additions & 2 deletions src/CSS/Text/Shadow.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CSS.Property (class Val, value)
import CSS.Size (Size)
import CSS.String (fromString)
import CSS.Stylesheet (CSS, key)
import Data.Tuple.Nested (tuple4)
import Data.Tuple (Tuple(..))

data TextShadow :: Type -> Type
data TextShadow a
Expand All @@ -16,7 +16,7 @@ data TextShadow a
| Inherit

instance valTextShadow :: Val (TextShadow a) where
value (TextShadow h v b c) = value (tuple4 h v b c)
value (TextShadow h v b c) = value (Tuple (Tuple h v) (Tuple b c))
value (None) = fromString "none"
value (Initial) = fromString "initial"
value (Inherit) = fromString "inherit"
Expand Down
4 changes: 2 additions & 2 deletions src/CSS/Transform.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CSS.Property (class Val, Value, noCommas, value)
import CSS.Size (Angle, Size)
import CSS.String (fromString)
import CSS.Stylesheet (CSS, key)
import Data.Tuple.Nested (tuple3)
import Data.Tuple (Tuple(..))

newtype Transformation = Transformation Value

Expand Down Expand Up @@ -124,7 +124,7 @@ instance valTransformOriginOffset :: Val (TransformOriginOffset a) where
value (OffsetCenter) = fromString "center"

instance valTransformOrigin :: Val (TransformOrigin a) where
value (TransformOrigin x y z) = value (tuple3 x y z)
value (TransformOrigin x y z) = value (Tuple (Tuple x y) z)
value (Initial) = fromString "initial"
value (Inherit) = fromString "inherit"
value (Unset) = fromString "unset"
Expand Down
2 changes: 1 addition & 1 deletion test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ main :: Effect Unit
main = do
renderedInline example1 `assertEqual` Just "color: hsl(0.0, 100.0%, 50.0%); display: block"
renderedInline example2 `assertEqual` Just "display: inline-block"
renderedInline example3 `assertEqual` Just "border: dashed 2.0px hsl(240.0, 100.0%, 50.0%) "
renderedInline example3 `assertEqual` Just "border: dashed 2.0px hsl(240.0, 100.0%, 50.0%)"

selector (Selector (Refinement [Id "test"]) Star) `assertEqual` "#test"

Expand Down