Skip to content

Introduce purs-tidy formatter #138

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
Nov 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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:

- name: Set up a PureScript toolchain
uses: purescript-contrib/setup-purescript@main
with:
purs-tidy: "latest"

- name: Cache PureScript dependencies
uses: actions/cache@v2
Expand All @@ -32,3 +34,6 @@ jobs:

- name: Run tests
run: spago test --no-install

- name: Check formatting
run: purs-tidy check src test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!.gitignore
!.github
!.editorconfig
!.tidyrc.json

output
generated-docs
Expand Down
10 changes: 10 additions & 0 deletions .tidyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"importSort": "source",
"importWrap": "source",
"indent": 2,
"operatorsFile": null,
"ribbon": 1,
"typeArrowPlacement": "first",
"unicode": "never",
"width": null
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ New features:
Bugfixes:

Other improvements:
- Added `purs-tidy` formatter (#138 by @thomashoneyman)
- 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
2 changes: 1 addition & 1 deletion packages.dhall
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210722/packages.dhall sha256:1ceb43aa59436bf5601bac45f6f3781c4e1f0e4c2b8458105b018e5ed8c30f8c
https://github.com/purescript/package-sets/releases/download/psc-0.14.5-20211116/packages.dhall sha256:7ba810597a275e43c83411d2ab0d4b3c54d0b551436f4b1632e9ff3eb62e327a

in upstream
25 changes: 15 additions & 10 deletions src/CSS/Background.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module CSS.Background
(
-- * Generic background property.
-- * Generic background property.
class Background
, background

Expand All @@ -18,16 +18,21 @@ module CSS.Background
, BackgroundSize
, backgroundSize
, backgroundSizes
, contain, cover
, contain
, cover
, by

-- * The background-repeat.
, BackgroundRepeat
, backgroundRepeat
, backgroundRepeats
, repeat, space, round, noRepeat
, repeat
, space
, round
, noRepeat
, xyRepeat
, repeatX, repeatY
, repeatX
, repeatY

-- * The background-origin.
, BackgroundOrigin
Expand All @@ -45,7 +50,8 @@ module CSS.Background
, BackgroundAttachment
, backgroundAttachment
, backgroundAttachments
, attachFixed, attachScroll
, attachFixed
, attachScroll

-- * The background-image.
, BackgroundImage
Expand All @@ -70,8 +76,7 @@ module CSS.Background
, Location
, class Loc
, location
)
where
) where

import Prelude

Expand All @@ -95,8 +100,7 @@ class Val a <= Background a where
instance backgroundArray :: (Background a) => Background (Array a) where
background = key $ fromString "background"

instance backgroundTuple
:: (Background a, Background b) => Background (Tuple a b) where
instance backgroundTuple :: (Background a, Background b) => Background (Tuple a b) where
background = key $ fromString "background"

instance backgroundColor' :: Background Color where
Expand All @@ -118,7 +122,8 @@ instance backgroundBackgroundClip :: Background BackgroundClip where
background = key $ fromString "background"

instance backgroundBackgroundAttachment :: Background BackgroundAttachment
where background = key $ fromString "background"
where
background = key $ fromString "background"

instance backgroundBackgroundImage :: Background BackgroundImage where
background = key $ fromString "background"
Expand Down
10 changes: 5 additions & 5 deletions src/CSS/Box.purs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module CSS.Box
( BoxType
, paddingBox, borderBox, contentBox
, paddingBox
, borderBox
, contentBox
, boxSizing
, boxShadow
, insetBoxShadow
)
where
) where

import Prelude

Expand Down Expand Up @@ -56,6 +57,5 @@ boxShadow x y w c =

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

insetBoxShadow ::
forall a. Stroke -> Size a -> Size a -> Size a -> Color -> CSS
insetBoxShadow :: forall a. Stroke -> Size a -> Size a -> Size a -> Color -> CSS
insetBoxShadow x y w c z = prefixed (browsers <> fromString "box-shadow") (x ! y ! w ! c ! z)
135 changes: 98 additions & 37 deletions src/CSS/Common.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,114 @@ import Data.Tuple (Tuple(..))
import CSS.Property (Prefixed(..), Value)
import CSS.String (class IsString, fromString)

class All a where all :: a
class Auto a where auto :: a
class Baseline a where baseline :: a
class Center a where center :: a
class Inherit a where inherit :: a
class None a where none :: a
class Normal a where normal :: a
class Visible a where visible :: a
class Hidden a where hidden :: a
class Initial a where initial :: a
class Unset a where unset :: a
class Top a where top :: a
class Middle a where middle :: a
class Bottom a where bottom :: a
class URL a where url :: String -> a
class All a where
all :: a

class Auto a where
auto :: a

class Baseline a where
baseline :: a

class Center a where
center :: a

class Inherit a where
inherit :: a

class None a where
none :: a

class Normal a where
normal :: a

class Visible a where
visible :: a

class Hidden a where
hidden :: a

class Initial a where
initial :: a

class Unset a where
unset :: a

class Top a where
top :: a

class Middle a where
middle :: a

class Bottom a where
bottom :: a

class URL a where
url :: String -> a

-- | The other type class is used to escape from the type safety introduced by
-- | embedding CSS properties into the typed world of purescript-css.
-- | `Other` allows you to cast any `Value` to a specific value type.
class Other a where other :: Value -> a

instance allValue :: All Value where all = fromString "all"
instance autoValue :: Auto Value where auto = fromString "auto"
instance baselineValue :: Baseline Value where baseline = fromString "baseline"
instance centerValue :: Center Value where center = fromString "center"
instance inheritValue :: Inherit Value where inherit = fromString "inherit"
instance normalValue :: Normal Value where normal = fromString "normal"
instance noneValue :: None Value where none = fromString "none"
instance visibleValue :: Visible Value where visible = fromString "visible"
instance hiddenValue :: Hidden Value where hidden = fromString "hidden"
instance otherValue :: Other Value where other = identity
instance initialValue :: Initial Value where initial = fromString "initial"
instance unsetValue :: Unset Value where unset = fromString "unset"
instance topValue :: Top Value where top = fromString "top"
instance middleValue :: Middle Value where middle = fromString "middle"
instance bottomValue :: Bottom Value where bottom = fromString "bottom"
instance urlValue :: URL Value where url s = fromString ("url(\"" <> s <> "\")")
class Other a where
other :: Value -> a

instance allValue :: All Value where
all = fromString "all"

instance autoValue :: Auto Value where
auto = fromString "auto"

instance baselineValue :: Baseline Value where
baseline = fromString "baseline"

instance centerValue :: Center Value where
center = fromString "center"

instance inheritValue :: Inherit Value where
inherit = fromString "inherit"

instance normalValue :: Normal Value where
normal = fromString "normal"

instance noneValue :: None Value where
none = fromString "none"

instance visibleValue :: Visible Value where
visible = fromString "visible"

instance hiddenValue :: Hidden Value where
hidden = fromString "hidden"

instance otherValue :: Other Value where
other = identity

instance initialValue :: Initial Value where
initial = fromString "initial"

instance unsetValue :: Unset Value where
unset = fromString "unset"

instance topValue :: Top Value where
top = fromString "top"

instance middleValue :: Middle Value where
middle = fromString "middle"

instance bottomValue :: Bottom Value where
bottom = fromString "bottom"

instance urlValue :: URL Value where
url s = fromString ("url(\"" <> s <> "\")")

-- | Common list browser prefixes to make
-- | experimental properties work in different browsers.
browsers :: Prefixed
browsers = Prefixed
[ Tuple "-webkit-" ""
, Tuple "-moz-" ""
, Tuple "-ms-" ""
, Tuple "-o-" ""
, Tuple "" ""
, Tuple "-moz-" ""
, Tuple "-ms-" ""
, Tuple "-o-" ""
, Tuple "" ""
]

-- | Syntax for CSS function call.
Expand Down
30 changes: 15 additions & 15 deletions src/CSS/Cursor.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data Cursor
= Default
| Help
| Pointer
| Progress
| Progress
| Wait
| Cell
| Crosshair
Expand All @@ -19,13 +19,13 @@ data Cursor
| Alias
| Copy
| Move
| NoDrop
| NoDrop
| NotAllowed
| Grab
| Grabbing
| AllScroll
| ColResize
| RowResize
| RowResize
| NResize
| EResize
| SResize
Expand All @@ -45,29 +45,29 @@ derive instance eqCursor :: Eq Cursor
derive instance ordCursor :: Ord Cursor

instance valCursor :: Val Cursor where
value Default = fromString "default"
value Default = fromString "default"
value Help = fromString "help"
value Pointer = fromString "pointer"
value Pointer = fromString "pointer"
value Progress = fromString "progress"
value Wait = fromString "wait"
value Cell = fromString "cell"
value Crosshair = fromString "crosshair"
value Crosshair = fromString "crosshair"
value Text = fromString "text"
value VerticalText = fromString "vertical-text"
value Alias = fromString "alias"
value Alias = fromString "alias"
value Copy = fromString "copy"
value Move = fromString "move"
value NoDrop = fromString "no-drop"
value NotAllowed = fromString "not-allowed"
value Grab = fromString "grab"
value Grabbing = fromString "grabbing"
value AllScroll = fromString "all-scroll"
value ColResize = fromString "col-resize"
value RowResize = fromString "row-resize"
value NResize = fromString "n-resize"
value EResize = fromString "e-resize"
value SResize = fromString "s-resize"
value WResize = fromString "w-resize"
value AllScroll = fromString "all-scroll"
value ColResize = fromString "col-resize"
value RowResize = fromString "row-resize"
value NResize = fromString "n-resize"
value EResize = fromString "e-resize"
value SResize = fromString "s-resize"
value WResize = fromString "w-resize"
value NEResize = fromString "ne-resize"
value NWResize = fromString "nw-resize"
value SEResize = fromString "se-resize"
Expand All @@ -77,7 +77,7 @@ instance valCursor :: Val Cursor where
value NESWResize = fromString "nesw-resize"
value NWSEResize = fromString "nwse-resize"
value ZoomIn = fromString "zoom-in"
value ZoomOut = fromString "zoom-out"
value ZoomOut = fromString "zoom-out"

cursor :: Cursor -> CSS
cursor = key $ fromString "cursor"
Expand Down
Loading