Safe Haskell | None |
---|
Synopsis
- data FormField = FormField {
- fieldType :: !InputType
- fieldName :: !Text
- fieldLabel :: !Text
- fieldValue :: !Text
- fieldInputId :: !Text
- validatorResult :: !(Maybe Violation)
- additionalAttributes :: [(Text, Text)]
- fieldClass :: !Text
- labelClass :: !Text
- disabled :: !Bool
- disableLabel :: !Bool
- disableGroup :: !Bool
- disableValidationResult :: !Bool
- cssFramework :: CSSFramework
- helpText :: !Text
- placeholder :: !Text
- required :: Bool
- autofocus :: Bool
- data SubmitButton = SubmitButton {
- label :: Html
- buttonClass :: Text
- buttonDisabled :: Bool
- cssFramework :: CSSFramework
- data FormContext model = FormContext {
- model :: model
- formAction :: !Text
- formMethod :: !Text
- cssFramework :: !CSSFramework
- formClass :: !Text
- formId :: !Text
- disableJavascriptSubmission :: !Bool
- customFormAttributes :: ![(Text, Text)]
- fieldNamePrefix :: !Text
- data InputType
- data CSSFramework = CSSFramework {
- styledFlashMessage :: CSSFramework -> FlashMessage -> Html
- styledFlashMessages :: CSSFramework -> [FlashMessage] -> Html
- styledFormField :: CSSFramework -> FormField -> Html
- styledTextFormField :: CSSFramework -> Text -> FormField -> Html -> Html
- styledTextareaFormField :: CSSFramework -> FormField -> Html -> Html
- styledCheckboxFormField :: CSSFramework -> FormField -> Html -> Html
- styledSelectFormField :: CSSFramework -> FormField -> Html -> Html
- styledRadioFormField :: CSSFramework -> FormField -> Html -> Html
- styledFormGroup :: CSSFramework -> Text -> Html -> Html
- styledSubmitButton :: CSSFramework -> SubmitButton -> Html
- styledSubmitButtonClass :: Text
- styledFormFieldHelp :: CSSFramework -> FormField -> Html
- styledInputClass :: CSSFramework -> FormField -> Text
- styledInputInvalidClass :: CSSFramework -> FormField -> Text
- styledFormGroupClass :: Text
- styledValidationResult :: CSSFramework -> FormField -> Html
- styledValidationResultClass :: Text
- styledPagination :: CSSFramework -> PaginationView -> Html
- styledPaginationLinkPrevious :: CSSFramework -> Pagination -> ByteString -> Html
- styledPaginationLinkNext :: CSSFramework -> Pagination -> ByteString -> Html
- styledPaginationPageLink :: CSSFramework -> Pagination -> ByteString -> Int -> Html
- styledPaginationDotDot :: CSSFramework -> Pagination -> Html
- styledPaginationItemsPerPageSelector :: CSSFramework -> Pagination -> (Int -> ByteString) -> Html
- styledBreadcrumb :: CSSFramework -> [BreadcrumbItem] -> BreadcrumbsView -> Html
- styledBreadcrumbItem :: CSSFramework -> [BreadcrumbItem] -> BreadcrumbItem -> Bool -> Html
- data BreadcrumbsView = BreadcrumbsView {
- breadcrumbItems :: !Html
- data PaginationView = PaginationView {
- cssFramework :: !CSSFramework
- pagination :: !Pagination
- pageUrl :: Int -> ByteString
- linkPrevious :: !Html
- linkNext :: !Html
- pageDotDotItems :: !Html
- itemsPerPageSelector :: !Html
- type HtmlWithContext context = (?context :: context) => Html
- type Layout = Html -> Html
Documentation
FormField | |
|
Instances
ToHtml FormField | |
Defined in IHP.View.Form |
data SubmitButton Source #
SubmitButton | |
|
Instances
ToHtml SubmitButton | |
Defined in IHP.View.Form toHtml :: SubmitButton -> Html # |
data FormContext model Source #
FormContext | |
|
Instances
data CSSFramework Source #
Render functions to render with Bootstrap, Tailwind CSS etc. We call this functions with the cssFramework passed to have late binding (like from OOP languages). Here's an explanation breaking it down, step by step
renderedHtml = styledPagination theCSSFramework theCSSFramework paginationView
Can also be written using get:
renderedHtml = (theCSSFramework.styledPagination) theCSSFramework paginationView
That's important to understand here. We get a styledPagination
function using 'theCSSFramework.styledPagination'.
Next, we apply theCSSFramework
to that function. We do that so because the styledPagination
function internally
might want to call other functions of the CSSFramework type. But we might want to override some functions of the CSSFramework.
Here's an example of how it would look if we don't pass this a second time, and it's shortcomings.
Let's assume styledPagination
is calling a styledButton
:
data CSSFramework = CSSFramework { styledPagination :: Html, styledButton :: Html } bootstrapCSS = CSSFramework { styledPagination, styledButton } where styledPagination = [hsx|<div>{styledButton}</div>|] styledButton = [hsx|<button style="color: red">button</button>|]] myPage = [hsx|{styledPagination bootstrapCSS}|]
So far all seems fine. But now let's say we would like to override the button styling, and change the button to green instead of red:
customCSS = bootstrapCSS { styledButton = [hsx|<button style="color: green">button</button>|]] } myPage = [hsx|{styledPagination customCSS}|]
Now, when we render the myPage
we will get 'divstyle="color: red"button/button/div' (a red button, while our customCSS specified it should be green).
Our way to fix this is to "late-bind" the calls, by manually passing around a CSSFramework. Here we added that second CSSFramework
to all functions.
Notice how styledPagination
is getting the correct styledButton
by calling 'cssFramework.styledButton':
data CSSFramework = CSSFramework { styledPagination :: CSSFramework -> Html, styledButton :: CSSFramework -> Html } bootstrapCSS = CSSFramework { styledPagination, styledButton } where styledPagination cssFramework = [hsx|<div>{cssFramework.styledButton}</div>|] styledButton cssFramework = [hsx|<button style="color: red">button</button>|]] myPage = [hsx|{styledPagination bootstrapCSS bootstrapCSS}|]
Now, with this second CSSFramework
in place we can customize it again:
customCSS = bootstrapCSS { styledButton = \cssFramework -> [hsx|<button style="color: green">button</button>|]] } myPage = [hsx|{styledPagination customCSS customCSS}|]
CSSFramework | |
|
Instances
Default CSSFramework Source # | Provides an unstyled CSSFramework This way we can later add more properties to the CSSFramework without having to update all the CSS Frameworks manually |
Defined in IHP.View.CSSFramework def :: CSSFramework # | |
SetField "cssFramework" (FormContext record) CSSFramework Source # | |
Defined in IHP.View.Types setField :: CSSFramework -> FormContext record -> FormContext record Source # |
data BreadcrumbsView Source #
BreadcrumbsView | |
|
data PaginationView Source #
PaginationView | |
|
type HtmlWithContext context = (?context :: context) => Html Source #