Module

Turbine.HTML

Package
purescript-turbine
Repository
funkia/purescript-turbine

This module contains Turbines DSL for constructing HTML.

This module is typically imported qualified as.

import Turbine.HTML as H

#Attributes' Source

type Attributes' r = (class :: Behavior String, classes :: ClassDescription, id :: Behavior String | r)

This type describes the attributes that all HTML elements accepts.

#Output' Source

type Output' r = (blur :: Stream FocusEvent, click :: Stream MouseEvent, dblclick :: Stream MouseEvent, keydown :: Stream KeyboardEvent, keyup :: Stream KeyboardEvent | r)

This type describes the output that all HTML elements output.

#h1 Source

h1 :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#div Source

div :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#br Source

br :: Component Unit (Record ())

A br element. Note that this is a constant and not a function since a br elements takes neither attributes nor children.

#p Source

p :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#text Source

text :: String -> Component Unit (Record ())

Creates a static text node based on the given string.

For a dynamic version see textB.

#textB Source

textB :: Behavior String -> Component Unit (Record ())

Creates a dynamic text node based on the given string valued behavior. The value of the text node is always equal to the value of the behavior.

#ul Source

ul :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#li Source

li :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#span Source

span :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#InputAttrs' Source

type InputAttrs' r = (autofocus :: Behavior Boolean, placeholder :: Behavior String, type :: Behavior String, value :: Behavior String | Attributes' + r)

#InputAttrs Source

#InputOut' Source

type InputOut' r = (input :: Stream InputEvent, keyup :: Stream KeyboardEvent, value :: Behavior String | Output' + r)

#InputOut Source

#input Source

input :: forall r. Subrow r InputAttrs => Record r -> Component InputOut (Record ())

#checkbox Source

checkbox :: forall r. Subrow r CheckboxAttrs => Record r -> Component CheckboxOutput (Record ())

An input element with the type attribute set to checkbox.

Most notably a checkbox outputs a behavior named checked denoting whether or not the checkbox is currently checked.

#inputRange Source

inputRange :: forall r. Subrow r (InputRangeAttrs' ()) => Record r -> Component (Record (InputRangeOut' ())) (Record ())

An input element with the type attribute set to range. Compared to a normal a normal input element this variant accepts three additional attributes all of which are numbers: max, min, and step. Additionally the value output is a Number and not a String.

#textarea Source

textarea :: forall r. Subrow r TextareaAttrs => Record r -> Component InputOut (Record ())

A textarea element. Accepts rows and cols attributes.

#button Source

button :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component ButtonOut o

#label Source

label :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#section Source

section :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#header Source

header :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#footer Source

footer :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#table Source

table :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#th Source

th :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#tr Source

tr :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#td Source

td :: forall o a r. Subrow r Attributes => Record r -> Component a o -> Component Output o

#progress Source

progress :: forall o a r. Subrow r ProgressAttrs => Record r -> Component a o -> Component Output o

A progress element. At accepts value and max both of which must be Number valued.

#empty Source

empty :: Component Unit (Record ())

An empty component corresponding to no HTML nor effects.

#Subrow Source

class Subrow (r :: Row Type) (s :: Row Type) 

Instances

#RecordOf Source

class RecordOf a (row :: Row Type) | row -> a where

Members

Instances

#RecordOfGo Source

class RecordOfGo (xs :: RowList) (row :: Row Type) a | xs -> row a where

Members

Instances

#ClassDescription Source

newtype ClassDescription

Instances

  • Semigroup ClassDescription

    Class descriptions form a semigroup. This makes it convenient to combine several types of description and add them to the same element.

    E.div { classes: staticClass "foo"
                     <> dynamicClass beh
                     <> toggleClass "selected" isSelected
          }
    

#ClassElement Source

#staticClass Source

staticClass :: String -> ClassDescription

Creates a static class from a string of space separated class names.

staticClass "foo bar baz"

#dynamicClass Source

dynamicClass :: Behavior String -> ClassDescription

Creates a dynamic class from a string valued behavior. At any point in time the element will have the class named in the behavior at that point in time.

dynamicClass stringValuedBehavior

#toggleClass Source

toggleClass :: String -> Behavior Boolean -> ClassDescription

Takes a class name and a boolean valued behavior. When the behavior is true the element has the class and when the behavior is false the element does not have the class.

toggleClass "active" isActiveBehavior
<> toggleClass "selected" isSelectedBehavior