module Ella.Forms.Widgets where
import Ella.Forms.Base
import qualified Text.XHtml as X
import Text.XHtml ( (<<)
, (+++)
, (!)
)
import qualified Ella.Forms.Widgets.TextInput as TextInput
import qualified Ella.Forms.Widgets.Textarea as Textarea
data Label a = Label {
text :: X.Html
, control :: Maybe a
}
instance (HasId a) => X.HTML (Label a) where
toHtml l = let attrs = case control l of
Nothing -> []
Just c -> case getId c of
"" -> []
theid -> [ X.thefor theid ]
in X.label ! attrs << text l
makeLabel :: (HasId a) => String -> a -> Label a
makeLabel t c = Label { text = X.toHtml t
, control = Just c
}