{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
module Miso.Lynx.Element
(
lynx_
, page_
, view_
, scrollView_
, image_
, list_
, listItem_
, text_
) where
import Data.Aeson (toJSON)
import Miso.String (MisoString)
import Miso.Types (View, Attribute, node, NS(HTML))
import Miso.Property (textProp, prop)
import Miso.Lynx.Element.List (ListOptions(..))
lynx_ :: MisoString -> [Attribute action] -> [View model action] -> View model action
lynx_ :: forall action model.
MisoString
-> [Attribute action] -> [View model action] -> View model action
lynx_ = NS
-> MisoString
-> [Attribute action]
-> [View model action]
-> View model action
forall action model.
NS
-> MisoString
-> [Attribute action]
-> [View model action]
-> View model action
node NS
HTML
page_ :: [Attribute action] -> [View model action] -> View model action
page_ :: forall action model.
[Attribute action] -> [View model action] -> View model action
page_ = MisoString
-> [Attribute action] -> [View model action] -> View model action
forall action model.
MisoString
-> [Attribute action] -> [View model action] -> View model action
lynx_ MisoString
"page"
scrollView_ :: [Attribute action] -> [View model action] -> View model action
scrollView_ :: forall action model.
[Attribute action] -> [View model action] -> View model action
scrollView_ = MisoString
-> [Attribute action] -> [View model action] -> View model action
forall action model.
MisoString
-> [Attribute action] -> [View model action] -> View model action
lynx_ MisoString
"scroll-view"
view_ :: [Attribute action] -> [View model action] -> View model action
view_ :: forall action model.
[Attribute action] -> [View model action] -> View model action
view_ = MisoString
-> [Attribute action] -> [View model action] -> View model action
forall action model.
MisoString
-> [Attribute action] -> [View model action] -> View model action
lynx_ MisoString
"view"
image_ :: MisoString -> [Attribute action] -> View model action
image_ :: forall action model.
MisoString -> [Attribute action] -> View model action
image_ MisoString
url [Attribute action]
attrs = MisoString
-> [Attribute action] -> [View model action] -> View model action
forall action model.
MisoString
-> [Attribute action] -> [View model action] -> View model action
lynx_ MisoString
"image" (MisoString -> MisoString -> Attribute action
forall action. MisoString -> MisoString -> Attribute action
textProp MisoString
"src" MisoString
url Attribute action -> [Attribute action] -> [Attribute action]
forall a. a -> [a] -> [a]
: [Attribute action]
attrs) []
listItem_ :: [Attribute action] -> [View model action] -> View model action
listItem_ :: forall action model.
[Attribute action] -> [View model action] -> View model action
listItem_ = MisoString
-> [Attribute action] -> [View model action] -> View model action
forall action model.
MisoString
-> [Attribute action] -> [View model action] -> View model action
lynx_ MisoString
"list-item"
list_ :: ListOptions -> [Attribute action] -> [View model action] -> View model action
list_ :: forall action model.
ListOptions
-> [Attribute action] -> [View model action] -> View model action
list_ ListOptions {Int
ListType
ScrollOrientation
listType_ :: ListType
spanCount_ :: Int
scrollOrientation_ :: ScrollOrientation
scrollOrientation_ :: ListOptions -> ScrollOrientation
spanCount_ :: ListOptions -> Int
listType_ :: ListOptions -> ListType
..} [Attribute action]
attrs = MisoString
-> [Attribute action] -> [View model action] -> View model action
forall action model.
MisoString
-> [Attribute action] -> [View model action] -> View model action
lynx_ MisoString
"list" ([Attribute action]
forall {action}. [Attribute action]
defaults [Attribute action] -> [Attribute action] -> [Attribute action]
forall a. Semigroup a => a -> a -> a
<> [Attribute action]
attrs)
where
defaults :: [Attribute action]
defaults =
[ MisoString -> Value -> Attribute action
forall a action. ToJSON a => MisoString -> a -> Attribute action
prop MisoString
"list-type" (ListType -> Value
forall a. ToJSON a => a -> Value
toJSON ListType
listType_)
, MisoString -> Value -> Attribute action
forall a action. ToJSON a => MisoString -> a -> Attribute action
prop MisoString
"span-count" (Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
spanCount_)
, MisoString -> Value -> Attribute action
forall a action. ToJSON a => MisoString -> a -> Attribute action
prop MisoString
"scroll-orientation" (ScrollOrientation -> Value
forall a. ToJSON a => a -> Value
toJSON ScrollOrientation
scrollOrientation_)
]
text_ :: [Attribute action] -> [View model action] -> View model action
text_ :: forall action model.
[Attribute action] -> [View model action] -> View model action
text_ = MisoString
-> [Attribute action] -> [View model action] -> View model action
forall action model.
MisoString
-> [Attribute action] -> [View model action] -> View model action
lynx_ MisoString
"text"