-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Harvey
committed
Jul 26, 2019
1 parent
1901a7f
commit b3f10f8
Showing
19 changed files
with
1,653 additions
and
539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
module PursUI (module Types, module Internal) where | ||
module Stylesheet (module Types, module Internal) where | ||
|
||
import PursUI.Types.Primitives (CSSSelector(..), CSSText(..), InsertMediaRule(..), InsertRule(..), MediaQueryText(..), StyleSheetId(..), UnpackedMediaRule, UnpackedRule) as Types | ||
import PursUI.Types.VirtualStyleSheet (VirtualStyleSheet(..), getStyleSheetId) as Types | ||
import PursUI.Types.PursUI (PursUI, createBlankStyleSheet, getCSSStyleSheet, readVirtualStyleSheet) as Types | ||
import PursUI.Types.CSSRuleSet (CSSRule(..), CSSRuleSet(..), Props, fun, makeStyle, media, str, testProps) as Types | ||
import PursUI.Types.StyleRuleSet (ClassRule(..), MediaRule(..), RuleType(..), StyleRuleSet(..), classRule, mediaRule, wrapInRuleSet) as Types | ||
import Stylesheet.Types.Primitives (CSSSelector(..), CSSText(..), | ||
InsertMediaRule(..), InsertRule(..), MediaQueryText(..), StylesheetId(..), UnpackedMediaRule, UnpackedRule) as Types | ||
import Stylesheet.Types.VirtualStylesheet (VirtualStylesheet(..), getStylesheetId) as Types | ||
import Stylesheet.Types.Stylesheet (Stylesheet(..), createBlankStylesheet, | ||
getCSSStylesheet, readVirtualStylesheet) as Types | ||
import Stylesheet.Types.CSSRuleSet (CSSRule(..), CSSRuleSet(..), fun, media, str) as Types | ||
import Stylesheet.Types.StyleRuleSet (ClassRule(..), MediaRule(..), RuleType(..), StyleRuleSet(..), classRule, mediaRule, wrapInRuleSet) as Types | ||
|
||
import PursUI.DomActions (createAndReturnCSSMediaRule, createStyleTag, findMediaQueryByQuery, findRuleBySelector, getFilteredRuleList, getMediaRuleMediaText, getStyleRuleDeclarationText, getStyleRuleSelectorText, getUnpackedMediaRules, getUnpackedStyleRules, insertRecursive, insertRule, unpackMediaRule, unpackRule) as Internal | ||
import PursUI.StyleLens (createHashedInsertRule, getClasses, keep, processStyle) as Internal | ||
import PursUI.AddStyle (addStyle) as Internal | ||
import Stylesheet.Internal.DomActions (createAndReturnCSSMediaRule, createStyleTag, findMediaQueryByQuery, findRuleBySelector, getFilteredRuleList, getMediaRuleMediaText, getStyleRuleDeclarationText, getStyleRuleSelectorText, getUnpackedMediaRules, getUnpackedStyleRules, insertRecursive, insertRule, unpackMediaRule, unpackRule) as Internal | ||
import Stylesheet.Internal.ProcessStyles (createHashedInsertRule, getClasses, keep, processStyle) as Internal | ||
import Stylesheet.Internal.AddStyle (addStyle) as Internal |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Stylesheet.Internal.AddStyle where | ||
|
||
import Prelude (discard, pure) | ||
import Effect (Effect) | ||
import Data.Foldable (foldMap) | ||
|
||
import Stylesheet.Types.Stylesheet (Stylesheet(..), addVirtualStylesheet) | ||
import Stylesheet.Types.CSSRuleSet (CSSRuleSet) | ||
import Stylesheet.Types.Primitives (CSSSelector) | ||
import Stylesheet.Types.VirtualStylesheet | ||
|
||
import Stylesheet.Internal.ProcessStyles (getClasses, keep, processStyle) | ||
|
||
-- | This is the top level big dog of a function, as such | ||
-- | We provide the big Stylesheet doing-things-lump | ||
-- | a function from props -> Styles | ||
-- | some props | ||
-- | and we get back a bunch of CSSSelectors (classes) | ||
addStyle | ||
:: forall p props | ||
. Stylesheet p | ||
-> CSSRuleSet props | ||
-> props | ||
-> Effect (Array CSSSelector) | ||
addStyle stylesheet styleRule props = do | ||
let rules = keep (processStyle styleRule props) | ||
virtualStylesheet = foldMap (fromItem) rules | ||
classes = foldMap (getClasses) rules | ||
addVirtualStylesheet stylesheet virtualStylesheet | ||
pure classes |
8 changes: 4 additions & 4 deletions
8
src/PursUI/DomActions.purs → src/Stylesheet/Internal/DomActions.purs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Stylesheet.Types.CSSRuleSet where | ||
|
||
import Prelude (class Monoid, class Semigroup, map, pure, ($), (<<<)) | ||
import Stylesheet.Types.Primitives | ||
|
||
-- | CSSRuleSet is what we build up for a type | ||
newtype CSSRuleSet p | ||
= CSSRuleSet (Array (CSSRule p)) | ||
|
||
derive newtype instance semigroupCSSRuleSet :: Semigroup (CSSRuleSet p) | ||
derive newtype instance monoidCSSRuleSet :: Monoid (CSSRuleSet p) | ||
|
||
data CSSRule p | ||
= Const CSSText | ||
| Lens (p -> CSSText) | ||
| MediaQuery MediaQueryText (CSSRuleSet p) | ||
|
||
str :: forall props. String -> CSSRuleSet props | ||
str = CSSRuleSet <<< pure <<< Const <<< CSSText | ||
|
||
fun :: forall props. (props -> String) -> CSSRuleSet props | ||
fun = CSSRuleSet <<< pure <<< Lens <<< (map CSSText) | ||
|
||
media :: forall props. String -> CSSRuleSet props -> CSSRuleSet props | ||
media queryStr subStyle | ||
= CSSRuleSet <<< pure $ MediaQuery (MediaQueryText queryStr) subStyle | ||
|
Oops, something went wrong.