| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Web.View.Types
Synopsis
- data Content
- data Element = Element {
- name :: Name
- attributes :: Attributes
- children :: [Content]
- data Attributes = Attributes {}
- type Attribute = (Name, AttValue)
- type Name = Text
- type AttValue = Text
- type Mod = Attributes -> Attributes
- type CSS = Map Selector Class
- data Class = Class {
- selector :: Selector
- properties :: Styles
- type Styles = Map Name StyleValue
- data Selector = Selector {}
- selector :: ClassName -> Selector
- newtype ClassName = ClassName {}
- class ToClassName a where
- toClassName :: a -> Text
- data Pseudo
- newtype StyleValue = StyleValue String
- class ToStyleValue a where
- toStyleValue :: a -> StyleValue
- data Length
- newtype PxRem = PxRem' Int
- newtype Ms = Ms Int
- data Media
- data Sides a
- newtype FlatAttributes = FlatAttributes {}
- class ToColor a where
- colorValue :: a -> HexColor
- colorName :: a -> Text
- newtype HexColor = HexColor Text
- data Align = Center
Documentation
A single HTML tag. Note that the class attribute is stored separately from the rest of the attributes to make adding styles easier
Constructors
| Element | |
Fields
| |
data Attributes Source #
Instances
| Monoid Attributes Source # | |
Defined in Web.View.Types Methods mempty :: Attributes # mappend :: Attributes -> Attributes -> Attributes # mconcat :: [Attributes] -> Attributes # | |
| Semigroup Attributes Source # | |
Defined in Web.View.Types Methods (<>) :: Attributes -> Attributes -> Attributes # sconcat :: NonEmpty Attributes -> Attributes # stimes :: Integral b => b -> Attributes -> Attributes # | |
Attribute Modifiers
type Mod = Attributes -> Attributes Source #
Element functions expect a Mod function as their first argument that adds attributes and classes.
userEmail :: User -> View c ()
userEmail user = input (fontSize 16 . active) (text user.email)
where
active = isActive user then bold else idAtomic CSS
Atomic classes include a selector and the corresponding styles
Constructors
| Class | |
Fields
| |
The selector to use for the given atomic Class
Constructors
| Selector | |
A class name
Instances
| IsString ClassName Source # | |
Defined in Web.View.Types Methods fromString :: String -> ClassName # | |
| Eq ClassName Source # | |
| Ord ClassName Source # | |
class ToClassName a where Source #
Convert a type into a className segment to generate unique compound style names based on the value
Minimal complete definition
Nothing
Instances
| ToClassName Text Source # | |
Defined in Web.View.Types Methods toClassName :: Text -> Text Source # | |
| ToClassName Align Source # | |
Defined in Web.View.Types Methods toClassName :: Align -> Text Source # | |
| ToClassName Length Source # | |
Defined in Web.View.Types Methods toClassName :: Length -> Text Source # | |
| ToClassName Ms Source # | |
Defined in Web.View.Types Methods toClassName :: Ms -> Text Source # | |
| ToClassName PxRem Source # | |
Defined in Web.View.Types Methods toClassName :: PxRem -> Text Source # | |
| ToClassName Float Source # | |
Defined in Web.View.Types Methods toClassName :: Float -> Text Source # | |
| ToClassName Int Source # | |
Defined in Web.View.Types Methods toClassName :: Int -> Text Source # | |
Psuedos allow for specifying styles that only apply in certain conditions. See hover etc
el (color Primary . hover (color White)) "hello"
newtype StyleValue Source #
The value of a css style property
Constructors
| StyleValue String |
Instances
| IsString StyleValue Source # | |
Defined in Web.View.Types Methods fromString :: String -> StyleValue # | |
| Show StyleValue Source # | |
Defined in Web.View.Types Methods showsPrec :: Int -> StyleValue -> ShowS # show :: StyleValue -> String # showList :: [StyleValue] -> ShowS # | |
class ToStyleValue a where Source #
Use a type as a css style property value
Minimal complete definition
Nothing
Methods
toStyleValue :: a -> StyleValue Source #
default toStyleValue :: Show a => a -> StyleValue Source #
Instances
| ToStyleValue Text Source # | |
Defined in Web.View.Types Methods toStyleValue :: Text -> StyleValue Source # | |
| ToStyleValue Align Source # | |
Defined in Web.View.Types Methods toStyleValue :: Align -> StyleValue Source # | |
| ToStyleValue HexColor Source # | |
Defined in Web.View.Types Methods toStyleValue :: HexColor -> StyleValue Source # | |
| ToStyleValue Length Source # | |
Defined in Web.View.Types Methods toStyleValue :: Length -> StyleValue Source # | |
| ToStyleValue Ms Source # | |
Defined in Web.View.Types Methods toStyleValue :: Ms -> StyleValue Source # | |
| ToStyleValue PxRem Source # | |
Defined in Web.View.Types Methods toStyleValue :: PxRem -> StyleValue Source # | |
| ToStyleValue String Source # | |
Defined in Web.View.Types Methods toStyleValue :: String -> StyleValue Source # | |
| ToStyleValue Float Source # | |
Defined in Web.View.Types Methods toStyleValue :: Float -> StyleValue Source # | |
| ToStyleValue Int Source # | |
Defined in Web.View.Types Methods toStyleValue :: Int -> StyleValue Source # | |
Constructors
| PxRem PxRem | Px, converted to Rem. Allows for the user to change the document font size and have the app scale accordingly. But allows the programmer to code in pixels to match a design |
| Pct Float |
Instances
| Num Length Source # | |
| Show Length Source # | |
| ToClassName Length Source # | |
Defined in Web.View.Types Methods toClassName :: Length -> Text Source # | |
| ToStyleValue Length Source # | |
Defined in Web.View.Types Methods toStyleValue :: Length -> StyleValue Source # | |
Instances
| Enum PxRem Source # | |
| Num PxRem Source # | |
| Integral PxRem Source # | |
| Real PxRem Source # | |
Defined in Web.View.Types Methods toRational :: PxRem -> Rational # | |
| Show PxRem Source # | |
| Eq PxRem Source # | |
| Ord PxRem Source # | |
| ToClassName PxRem Source # | |
Defined in Web.View.Types Methods toClassName :: PxRem -> Text Source # | |
| ToStyleValue PxRem Source # | |
Defined in Web.View.Types Methods toStyleValue :: PxRem -> StyleValue Source # | |
Milliseconds, used for transitions
Instances
| Num Ms Source # | |
| Show Ms Source # | |
| ToClassName Ms Source # | |
Defined in Web.View.Types Methods toClassName :: Ms -> Text Source # | |
| ToStyleValue Ms Source # | |
Defined in Web.View.Types Methods toStyleValue :: Ms -> StyleValue Source # | |
Media allows for responsive designs that change based on characteristics of the window. See Layout Example
Options for styles that support specifying various sides. This has a "fake" Num instance to support literals
border 5 border (X 2) border (TRBL 0 5 0 0)
newtype FlatAttributes Source #
Element's attributes do not include class, which is separated. FlatAttributes generate the class attribute and include it
Constructors
| FlatAttributes | |
Fields | |
Instances
| Generic FlatAttributes Source # | |
Defined in Web.View.Types Associated Types type Rep FlatAttributes :: Type -> Type # Methods from :: FlatAttributes -> Rep FlatAttributes x # to :: Rep FlatAttributes x -> FlatAttributes # | |
| type Rep FlatAttributes Source # | |
Defined in Web.View.Types type Rep FlatAttributes = D1 ('MetaData "FlatAttributes" "Web.View.Types" "web-view-0.4.0-inplace" 'True) (C1 ('MetaCons "FlatAttributes" 'PrefixI 'True) (S1 ('MetaSel ('Just "attributes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Name AttValue)))) | |
Colors
class ToColor a where Source #
ToColor allows you to create a type containing your application's colors:
data AppColor = White | Primary | Dark instance ToColor AppColor where colorValue White = "#FFF" colorValue Dark = "#333" colorValue Primary = "#00F" hello :: View c () hello = el (bg Primary . color White) "Hello"
Minimal complete definition
Methods
colorValue :: a -> HexColor Source #
Hexidecimal Color. Can be specified with or without the leading #. Recommended to use an AppColor type instead of manually using hex colors. See ToColor
Instances
| IsString HexColor Source # | |
Defined in Web.View.Types Methods fromString :: String -> HexColor # | |
| ToColor HexColor Source # | |
| ToStyleValue HexColor Source # | |
Defined in Web.View.Types Methods toStyleValue :: HexColor -> StyleValue Source # | |
Constructors
| Center |
Instances
| Show Align Source # | |
| ToClassName Align Source # | |
Defined in Web.View.Types Methods toClassName :: Align -> Text Source # | |
| ToStyleValue Align Source # | |
Defined in Web.View.Types Methods toStyleValue :: Align -> StyleValue Source # | |