Skip to content

Commit 0a5fdb4

Browse files
committed
updated to 0.10
1 parent 35fa5f7 commit 0a5fdb4

File tree

9 files changed

+77
-96
lines changed

9 files changed

+77
-96
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
language: node_js
2-
node_js:
3-
- 0.12.7
2+
node_js: stable
43
install:
5-
- npm install gulp bower -g
4+
- npm install bower -g
65
- npm install
76
- bower install
87
script:
9-
- gulp
8+
- npm run build

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ An adapter between the `purescript-halogen` and `purescript-css` libraries.
77
## Module documentation
88

99
- [Halogen.HTML.CSS](docs/Halogen/HTML/CSS.md)
10+
- [Halogen.HTML.CSS.Indexed](docs/Halogen/HTML/CSS/Indexed.md)

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test"
2121
],
2222
"dependencies": {
23-
"purescript-css": "^0.4.0",
24-
"purescript-halogen": "^0.5.3"
23+
"purescript-css": "^2.0.0",
24+
"purescript-halogen": "^0.12.0"
2525
}
2626
}

docs/Halogen/HTML/CSS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ This module defines an adapter between the `purescript-halogen` and
66
#### `style`
77

88
``` purescript
9-
style :: forall i. Css -> Prop i
9+
style :: forall i. CSS -> Prop i
1010
```
1111

1212
Render a set of rules as an inline style.
1313

1414
For example:
1515

1616
```purescript
17-
H.div [ Css.style do color red
17+
HH.div [ CSS.style do color red
1818
display block ]
1919
[ ... ]
2020
```
2121

2222
#### `stylesheet`
2323

2424
``` purescript
25-
stylesheet :: forall p i. Css -> HTML p i
25+
stylesheet :: forall p i. CSS -> HTML p i
2626
```
2727

2828
Render a set of rules as a `style` element.

docs/Halogen/HTML/CSS/Indexed.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Module Halogen.HTML.CSS.Indexed
2+
3+
#### `style`
4+
5+
``` purescript
6+
style :: forall i r. CSS -> IProp (style :: I | r) i
7+
```
8+
9+
#### `stylesheet`
10+
11+
``` purescript
12+
stylesheet :: forall p i. CSS -> NoninteractiveNode (media :: I, onError :: I, onLoad :: I, scoped :: I, mediaType :: I) p i
13+
```
14+
15+

gulpfile.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"name": "purescript-halogen-css",
33
"private": true,
44
"license": "Apache-2.0",
5+
"scripts": {
6+
"clean": "rm -rf output .pulp-cache docs",
7+
"build": "pulp build --censor-lib --strict"
8+
},
59
"devDependencies": {
6-
"gulp": "^3.8.11",
7-
"gulp-jscs": "^1.6.0",
8-
"gulp-jshint": "^1.11.2",
9-
"gulp-purescript": "^0.7.0",
10-
"purescript": "0.7.4",
11-
"rimraf": "^2.4.1"
10+
"pulp": "^9.0.1",
11+
"purescript": "0.10.1",
12+
"purescript-psa": "^0.3.9"
1213
}
1314
}

src/Halogen/HTML/CSS.purs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,65 @@ module Halogen.HTML.CSS
77

88
import Prelude
99

10-
import Data.Array (mapMaybe)
11-
import Data.Either (Either(), either)
12-
import Data.List (fromList, toList)
10+
import Data.Array (mapMaybe, concatMap, singleton)
11+
import Data.Either (Either)
12+
import Data.Foldable (foldMap)
1313
import Data.Maybe (Maybe(..), fromMaybe)
14+
import Data.Newtype (class Newtype)
1415
import Data.String (joinWith)
1516
import Data.Tuple (Tuple(..))
16-
import qualified Data.StrMap as SM
17+
import Data.StrMap as SM
1718

18-
import Css.Property (Key(), Value())
19-
import Css.Render (render, renderedSheet, collect)
20-
import Css.Stylesheet (Css(), Rule(..), runS)
19+
import CSS.Property (Key, Value)
20+
import CSS.Render (render, renderedSheet, collect)
21+
import CSS.Stylesheet (CSS, Rule(..), runS)
2122

22-
import Halogen.HTML.Core (HTML(), Prop(), IsProp, prop, propName, attrName)
23-
import qualified Halogen.HTML as H
24-
import qualified Halogen.HTML.Elements as H
25-
import qualified Halogen.HTML.Properties as P
23+
import Halogen.HTML.Core (HTML, Prop, class IsProp, prop, propName, attrName)
24+
import Halogen.HTML as HH
25+
import Halogen.HTML.Elements as HE
26+
import Halogen.HTML.Properties as P
2627

2728
-- | A newtype for CSS styles
2829
newtype Styles = Styles (SM.StrMap String)
2930

30-
-- | Unpack CSS styles
31-
runStyles :: Styles -> SM.StrMap String
32-
runStyles (Styles m) = m
31+
derive instance newtypeStylesNewtype Styles _
3332

34-
instance stylesIsProp :: IsProp Styles where
35-
toPropString _ _ (Styles m) = joinWith "; " $ (\(Tuple key value) -> key <> ": " <> value) <$> fromList (SM.toList m)
33+
instance stylesIsPropIsProp Styles where
34+
toPropString _ _ (Styles m) =
35+
joinWith "; " $ SM.foldMap (\key value → [key <> ": " <> value]) m
3636

3737
-- | Render a set of rules as an inline style.
3838
-- |
3939
-- | For example:
4040
-- |
4141
-- | ```purescript
42-
-- | H.div [ Css.style do color red
42+
-- | HH.div [ CSS.style do color red
4343
-- | display block ]
4444
-- | [ ... ]
4545
-- | ```
46-
style :: forall i. Css -> Prop i
47-
style = prop (propName "style") (Just $ attrName "style") <<< Styles <<< rules <<< runS
46+
style i. CSS Prop i
47+
style =
48+
prop (propName "style") (Just $ attrName "style")
49+
<<< Styles
50+
<<< rules
51+
<<< runS
4852
where
49-
rules :: Array Rule -> SM.StrMap String
50-
rules rs = SM.fromList (toList properties)
53+
rules Array Rule SM.StrMap String
54+
rules rs = SM.fromFoldable properties
5155
where
52-
properties :: Array (Tuple String String)
56+
properties Array (Tuple String String)
5357
properties = mapMaybe property rs >>= collect >>> rights
5458

55-
property :: Rule -> Maybe (Tuple (Key Unit) Value)
59+
property Rule Maybe (Tuple (Key Unit) Value)
5660
property (Property k v) = Just (Tuple k v)
5761
property _ = Nothing
5862

59-
rights :: forall a b. Array (Either a b) -> Array b
60-
rights = mapMaybe (either (const Nothing) Just)
63+
rights a b. Array (Either a b) Array b
64+
rights = concatMap $ foldMap singleton
6165

6266
-- | Render a set of rules as a `style` element.
63-
stylesheet :: forall p i. Css -> HTML p i
64-
stylesheet css = H.style [ P.type_ "text/css" ] [ H.text content ]
67+
stylesheet p i. CSS HTML p i
68+
stylesheet css =
69+
HE.style [ P.type_ "text/css" ] [ HH.text content ]
6570
where
6671
content = fromMaybe "" $ renderedSheet $ render css

src/Halogen/HTML/CSS/Indexed.purs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ module Halogen.HTML.CSS.Indexed where
22

33
import Unsafe.Coerce (unsafeCoerce)
44

5-
import Css.Stylesheet (Css())
5+
import CSS.Stylesheet (CSS)
66

7-
import Halogen.HTML.Elements.Indexed (NoninteractiveNode())
8-
import Halogen.HTML.Properties.Indexed (IProp(), I())
9-
import qualified Halogen.HTML.CSS as CSS
7+
import Halogen.HTML.Elements.Indexed (NoninteractiveNode)
8+
import Halogen.HTML.Properties.Indexed (IProp, I)
9+
import Halogen.HTML.CSS as CSS
1010

11-
style :: forall i r. Css -> IProp (style :: I | r) i
12-
style = unsafeCoerce CSS.style
11+
style
12+
i r. CSS IProp (style I | r) i
13+
style =
14+
unsafeCoerce CSS.style
1315

14-
stylesheet :: forall p i. Css -> NoninteractiveNode (media :: I, onError :: I, onLoad :: I, scoped :: I, mediaType :: I) p i
15-
stylesheet = unsafeCoerce CSS.stylesheet
16+
stylesheet
17+
p i
18+
. CSS
19+
NoninteractiveNode (media I, onError I, onLoad I, scoped I, mediaType I) p i
20+
stylesheet =
21+
unsafeCoerce CSS.stylesheet

0 commit comments

Comments
 (0)