Skip to content

flex-grow and flex-shrink typed as Number #64

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 1 commit into from
Jan 23, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Notable changes to this project are documented in this file. The format is based

Breaking changes (😱!!!):

- Changed `flex`, `flexGrow`, and `flexShrink` to use `Number` rather than `Int` for the `grow` and `shrink` values - #64 (@andywhite37)

New features:

Bugfixes:
Expand Down
6 changes: 3 additions & 3 deletions src/CSS/Flexbox.purs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ alignSelf = key $ fromString "align-self"

-------------------------------------------------------------------------------

flex :: forall b. Int -> Int -> Size b -> CSS
flex :: forall b. Number -> Number -> Size b -> CSS
flex g s b = key (fromString "flex") (gs ! ss ! value b)
where gs = fromString (show g) :: Value
ss = fromString (show s) :: Value
Expand Down Expand Up @@ -204,10 +204,10 @@ flexFlow d w = key (fromString "flex-flow") (d ! w)

-------------------------------------------------------------------------------

flexGrow :: Int -> CSS
flexGrow :: Number -> CSS
flexGrow i = key (fromString "flex-grow") (fromString (show i) :: Value)

flexShrink :: Int -> CSS
flexShrink :: Number -> CSS
flexShrink i = key (fromString "flex-shrink") (fromString (show i) :: Value)

-------------------------------------------------------------------------------
Expand Down
9 changes: 8 additions & 1 deletion test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import Prelude

import Effect (Effect)
import Effect.Exception (error, throwException)
import CSS (Rendered, Path(..), Predicate(..), Refinement(..), Selector(..), FontFaceSrc(..), FontFaceFormat(..), renderedSheet, renderedInline, fromString, selector, block, display, render, borderBox, boxSizing, contentBox, blue, color, body, a, p, px, dashed, border, inlineBlock, red, (?), (&), (|>), (|*), (|+), byId, byClass, (@=), (^=), ($=), (*=), (~=), (|=), hover, fontFaceSrc, fontStyle, deg, zIndex, textOverflow, opacity, cursor, transform, transition, easeInOut, cubicBezier, ms)
import CSS (Rendered, Path(..), Predicate(..), Refinement(..), Selector(..), FontFaceSrc(..), FontFaceFormat(..), pct, renderedSheet, renderedInline, fromString, selector, block, display, render, borderBox, boxSizing, contentBox, blue, color, body, a, p, px, dashed, border, inlineBlock, red, (?), (&), (|>), (|*), (|+), byId, byClass, (@=), (^=), ($=), (*=), (~=), (|=), hover, fontFaceSrc, fontStyle, deg, zIndex, textOverflow, opacity, cursor, transform, transition, easeInOut, cubicBezier, ms)
import CSS.Cursor as Cursor
import CSS.Flexbox (flex)
import CSS.FontStyle as FontStyle
import CSS.Text.Overflow as TextOverflow
import CSS.Transform as Transform
Expand Down Expand Up @@ -45,6 +46,10 @@ example7 :: Rendered
example7 = render do
zIndex 11
opacity 0.5

example8 :: Rendered
example8 = render do
flex 0.14 1.0 (pct 0.0)

withSelector :: Rendered
withSelector = render do
Expand Down Expand Up @@ -179,6 +184,8 @@ main = do
renderedInline example6 `assertEqual` Just "src: url(\"font.woff\") format(\"woff\")"

renderedInline example7 `assertEqual` Just "z-index: 11; opacity: 0.5"

renderedInline example8 `assertEqual` Just "flex: 0.14 1.0 0.0%"

renderedInline exampleFontStyle1 `assertEqual` Just "font-style: italic"
renderedInline exampleFontStyle2 `assertEqual` Just "font-style: oblique"
Expand Down