on develop help sign in
Merge pull request #278 from reflex-frp/dn-haddock-fixes
8787367Luigy Leon
reflex-dom-core/src/Foreign/JavaScript/Orphans.hs+1
@@ -1,3 +1,4 @@
1+{-# OPTIONS_HADDOCK hide #-}
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE CPP #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
3{-# OPTIONS_GHC -fno-warn-orphans #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
reflex-dom-core/src/Reflex/Dom/Modals/Base.hs+1
@@ -1,3 +1,4 @@
1+{-# OPTIONS_HADDOCK hide #-}
1{-
2{-
2{-# LANGUAGE CPP #-}
3{-# LANGUAGE CPP #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
reflex-dom-core/src/Reflex/Dom/Specializations.hs+1
@@ -1,3 +1,4 @@
1+{-# OPTIONS_HADDOCK hide #-}
1{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE GADTs #-}
3{-# LANGUAGE GADTs #-}
3{-# LANGUAGE Rank2Types #-}
4{-# LANGUAGE Rank2Types #-}
reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs+24−14
@@ -10,11 +10,9 @@
10{-# LANGUAGE ScopedTypeVariables #-}
10{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE TypeFamilies #-}
11{-# LANGUAGE TypeFamilies #-}
12module Reflex.Dom.Widget.Basic
12module Reflex.Dom.Widget.Basic
13− ( partitionMapBySetLT
13+ (
14− , ChildResult (..)
15−
16 -- * Displaying Values
14 -- * Displaying Values
17− , text
15+ text
18 , dynText
16 , dynText
19 , display
17 , display
20 , button
18 , button
@@ -57,6 +55,8 @@ module Reflex.Dom.Widget.Basic
57 , module Data.Map.Misc
55 , module Data.Map.Misc
58 , module Reflex.Collection
56 , module Reflex.Collection
59 , module Reflex.Workflow
57 , module Reflex.Workflow
58+ , partitionMapBySetLT
59+ , ChildResult (..)
60 ) where
60 ) where
61
61
62import Reflex.Class
62import Reflex.Class
@@ -131,7 +131,7 @@ button t = do
131--TODO: Should this be renamed to 'widgetView' for consistency with 'widgetHold'?
131--TODO: Should this be renamed to 'widgetView' for consistency with 'widgetHold'?
132-- | Given a Dynamic of widget-creating actions, create a widget that is recreated whenever the Dynamic updates.
132-- | Given a Dynamic of widget-creating actions, create a widget that is recreated whenever the Dynamic updates.
133-- The returned Event of widget results occurs when the Dynamic does.
133-- The returned Event of widget results occurs when the Dynamic does.
134−-- Note: Often, the type 'a' is an Event, in which case the return value is an Event-of-Events that would typically be flattened (via 'switchPromptly').
134+-- Note: Often, the type @a@ is an 'Event', in which case the return value is an Event-of-Events that would typically be flattened (via 'switchHold').
135dyn :: (DomBuilder t m, PostBuild t m) => Dynamic t (m a) -> m (Event t a)
135dyn :: (DomBuilder t m, PostBuild t m) => Dynamic t (m a) -> m (Event t a)
136dyn = networkView
136dyn = networkView
137
137
@@ -141,7 +141,7 @@ dyn_ = void . dyn
141
141
142-- | Given an initial widget and an Event of widget-creating actions, create a widget that is recreated whenever the Event fires.
142-- | Given an initial widget and an Event of widget-creating actions, create a widget that is recreated whenever the Event fires.
143-- The returned Dynamic of widget results occurs when the Event does.
143-- The returned Dynamic of widget results occurs when the Event does.
144−-- Note: Often, the type 'a' is an Event, in which case the return value is a Dynamic-of-Events that would typically be flattened.
144+-- Note: Often, the type 'a' is an Event, in which case the return value is a Dynamic-of-Events that would typically be flattened (via 'switchDyn').
145widgetHold :: (DomBuilder t m, MonadHold t m) => m a -> Event t (m a) -> m (Dynamic t a)
145widgetHold :: (DomBuilder t m, MonadHold t m) => m a -> Event t (m a) -> m (Dynamic t a)
146widgetHold = networkHold
146widgetHold = networkHold
147
147
@@ -150,43 +150,51 @@ widgetHold_ :: (DomBuilder t m, MonadHold t m) => m a -> Event t (m a) -> m ()
150widgetHold_ z = void . widgetHold z
150widgetHold_ z = void . widgetHold z
151
151
152-- | Create a DOM element
152-- | Create a DOM element
153+--
153−-- > el "div" (text "Hello World")
154+-- >>> el "div" (text "Hello World")
154-- <div>Hello World</div>
155-- <div>Hello World</div>
155{-# INLINABLE el #-}
156{-# INLINABLE el #-}
156el :: forall t m a. DomBuilder t m => Text -> m a -> m a
157el :: forall t m a. DomBuilder t m => Text -> m a -> m a
157el elementTag child = snd <$> el' elementTag child
158el elementTag child = snd <$> el' elementTag child
158
159
159-- | Create a DOM element with attributes
160-- | Create a DOM element with attributes
161+--
160−-- > elAttr "a" ("href" =: "http://google.com") (text "Google!")
162+-- >>> elAttr "a" ("href" =: "https://reflex-frp.org") (text "Reflex-FRP!")
161−-- <a href="http://google.com">Google!</a>
163+-- <a href="https://reflex-frp.org">Reflex-FRP!</a>
162{-# INLINABLE elAttr #-}
164{-# INLINABLE elAttr #-}
163elAttr :: forall t m a. DomBuilder t m => Text -> Map Text Text -> m a -> m a
165elAttr :: forall t m a. DomBuilder t m => Text -> Map Text Text -> m a -> m a
164elAttr elementTag attrs child = snd <$> elAttr' elementTag attrs child
166elAttr elementTag attrs child = snd <$> elAttr' elementTag attrs child
165
167
166-- | Create a DOM element with classes
168-- | Create a DOM element with classes
169+--
167−-- > elClass "div" "row" (return ())
170+-- >>> elClass "div" "row" (return ())
168-- <div class="row"></div>
171-- <div class="row"></div>
169{-# INLINABLE elClass #-}
172{-# INLINABLE elClass #-}
170elClass :: forall t m a. DomBuilder t m => Text -> Text -> m a -> m a
173elClass :: forall t m a. DomBuilder t m => Text -> Text -> m a -> m a
171elClass elementTag c child = snd <$> elClass' elementTag c child
174elClass elementTag c child = snd <$> elClass' elementTag c child
172
175
173-- | Create a DOM element with Dynamic Attributes
176-- | Create a DOM element with Dynamic Attributes
177+--
174−-- > elClass "div" (constDyn ("class" =: "row")) (return ())
178+-- >>> elClass "div" (constDyn ("class" =: "row")) (return ())
175-- <div class="row"></div>
179-- <div class="row"></div>
176{-# INLINABLE elDynAttr #-}
180{-# INLINABLE elDynAttr #-}
177elDynAttr :: forall t m a. (DomBuilder t m, PostBuild t m) => Text -> Dynamic t (Map Text Text) -> m a -> m a
181elDynAttr :: forall t m a. (DomBuilder t m, PostBuild t m) => Text -> Dynamic t (Map Text Text) -> m a -> m a
178elDynAttr elementTag attrs child = snd <$> elDynAttr' elementTag attrs child
182elDynAttr elementTag attrs child = snd <$> elDynAttr' elementTag attrs child
179
183
180-- | Create a DOM element with a Dynamic Class
184-- | Create a DOM element with a Dynamic Class
185+--
181−-- > elDynClass "div" (constDyn "row") (return ())
186+-- >>> elDynClass "div" (constDyn "row") (return ())
182-- <div class="row"></div>
187-- <div class="row"></div>
183{-# INLINABLE elDynClass #-}
188{-# INLINABLE elDynClass #-}
184elDynClass :: forall t m a. (DomBuilder t m, PostBuild t m) => Text -> Dynamic t Text -> m a -> m a
189elDynClass :: forall t m a. (DomBuilder t m, PostBuild t m) => Text -> Dynamic t Text -> m a -> m a
185elDynClass elementTag c child = snd <$> elDynClass' elementTag c child
190elDynClass elementTag c child = snd <$> elDynClass' elementTag c child
186
191
187-- | Create a DOM element and return the element
192-- | Create a DOM element and return the element
193+--
194+-- @
188−-- > do (e, _) <- el' "div" (text "Click")
195+-- do (e, _) <- el' "div" (text "Click")
189−-- > return $ domEvent Click e
196+-- return $ domEvent Click e
197+-- @
190{-# INLINABLE el' #-}
198{-# INLINABLE el' #-}
191el' :: forall t m a. DomBuilder t m => Text -> m a -> m (Element EventResult (DomBuilderSpace m) t, a)
199el' :: forall t m a. DomBuilder t m => Text -> m a -> m (Element EventResult (DomBuilderSpace m) t, a)
192el' elementTag = element elementTag def
200el' elementTag = element elementTag def
@@ -272,6 +280,8 @@ newtype Link t
272 = Link { _link_clicked :: Event t ()
280 = Link { _link_clicked :: Event t ()
273 }
281 }
274
282
283+-- | >>> linkClass "Click here" "link-class"
284+-- > <a class="link-class">Click here</a>
275linkClass :: DomBuilder t m => Text -> Text -> m (Link t)
285linkClass :: DomBuilder t m => Text -> Text -> m (Link t)
276linkClass s c = do
286linkClass s c = do
277 (l,_) <- elAttr' "a" ("class" =: c) $ text s
287 (l,_) <- elAttr' "a" ("class" =: c) $ text s
reflex-dom-core/src/Reflex/Dom/Widget/Resize.hs+1−1
@@ -32,7 +32,7 @@ import GHCJS.DOM.HTMLElement (getOffsetWidth, getOffsetHeight)
32import qualified GHCJS.DOM.Types as DOM
32import qualified GHCJS.DOM.Types as DOM
33
33
34-- | A widget that wraps the given widget in a div and fires an event when resized.
34-- | A widget that wraps the given widget in a div and fires an event when resized.
35−-- Adapted from github.com/marcj/css-element-queries
35+-- Adapted from @github.com\/marcj\/css-element-queries@
36resizeDetector :: (MonadJSM m, DomBuilder t m, PostBuild t m, TriggerEvent t m, PerformEvent t m, MonadHold t m, DomBuilderSpace m ~ GhcjsDomSpace, MonadJSM (Performable m), MonadFix m) => m a -> m (Event t (), a)
36resizeDetector :: (MonadJSM m, DomBuilder t m, PostBuild t m, TriggerEvent t m, PerformEvent t m, MonadHold t m, DomBuilderSpace m ~ GhcjsDomSpace, MonadJSM (Performable m), MonadFix m) => m a -> m (Event t (), a)
37resizeDetector = resizeDetectorWithStyle ""
37resizeDetector = resizeDetectorWithStyle ""
38
38