Skip to content

update 1.0.0 #15

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
Feb 7, 2017
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: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
],
"dependencies": {
"purescript-css": "^2.0.0",
"purescript-halogen": "^0.12.0"
"purescript-halogen": "1.0.0-rc.2"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"license": "Apache-2.0",
"scripts": {
"clean": "rm -rf output .pulp-cache",
"build": "pulp build --censor-lib --strict"
"build": "pulp build -- --censor-lib --strict"
},
"devDependencies": {
"pulp": "^9.0.1",
"purescript": "0.10.1",
"purescript-psa": "^0.3.9"
"pulp": "^10.0.0",
"purescript": "0.10.5",
"purescript-psa": "^0.4.0"
}
}
28 changes: 11 additions & 17 deletions src/Halogen/HTML/CSS.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,15 @@ import Data.Array (mapMaybe, concatMap, singleton)
import Data.Either (Either)
import Data.Foldable (foldMap)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Newtype (class Newtype)
import Data.MediaType (MediaType(..))
import Data.StrMap as SM
import Data.String (joinWith)
import Data.Tuple (Tuple(..))

import Halogen.HTML as HH
import Halogen.HTML.Core (HTML, Prop, class IsProp, prop, propName, attrName)
import Halogen.HTML.Elements as HE
import Halogen.HTML.Properties as P

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

derive instance newtypeStyles ∷ Newtype Styles _

instance stylesIsProp ∷ IsProp Styles where
toPropString _ _ (Styles m) =
joinWith "; " $ SM.foldMap (\key value → [key <> ": " <> value]) m
import Halogen.HTML.Properties as HP
import Halogen.HTML.Core as HC

-- | Render a set of rules as an inline style.
-- |
Expand All @@ -43,13 +34,16 @@ instance stylesIsProp ∷ IsProp Styles where
-- | display block ]
-- | [ ... ]
-- | ```
style ∷ ∀ i. CSS → Prop i
style ∷ ∀ i r. CSS → HP.IProp (style ∷ String|r) i
style =
prop (propName "style") (Just $ attrName "style")
<<< Styles
HP.prop (HC.PropName "style")
<<< toString
<<< rules
<<< runS
where
toString ∷ SM.StrMap String → String
toString = joinWith "; " <<< SM.foldMap (\key val → [ key <> ": " <> val])

rules ∷ Array Rule → SM.StrMap String
rules rs = SM.fromFoldable properties
where
Expand All @@ -64,8 +58,8 @@ style =
rights = concatMap $ foldMap singleton

-- | Render a set of rules as a `style` element.
stylesheet ∷ ∀ p i. CSS → HTML p i
stylesheet ∷ ∀ p i. CSS → HC.HTML p i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use HTMLstyle from DOM.HTML.Indexed for the p here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was my initial intention. But Node and Leaf from Halogen.HTML.Elements are functions from Array (IProp _) now and this thing doesn't use any props

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good point!

stylesheet css =
HE.style [ P.type_ "text/css" ] [ HH.text content ]
HE.style [ HP.type_ $ MediaType "text/css" ] [ HH.text content ]
where
content = fromMaybe "" $ renderedSheet $ render css
21 changes: 0 additions & 21 deletions src/Halogen/HTML/CSS/Indexed.purs

This file was deleted.