{-| Module: IHP.View.CSSFramework Description: Adds support for bootstrap, tailwind, etc. to IHP Copyright: (c) digitally induced GmbH, 2020 -} module IHP.View.CSSFramework where import IHP.Prelude import IHP.FlashMessages.Types import qualified Text.Blaze.Html5 as Blaze import IHP.HSX.QQ (hsx) import IHP.HSX.ToHtml () import IHP.View.Types import IHP.View.Classes import IHP.ModelSupport import IHP.Breadcrumb.Types import IHP.Pagination.Helpers import IHP.Pagination.Types -- | Provides an unstyled CSSFramework -- -- This way we can later add more properties to the CSSFramework without having to update all the CSS Frameworks manually instance Default CSSFramework where def = CSSFramework { styledFlashMessage = \cssFramework -> \case SuccessFlashMessage message -> [hsx|
{helpText}
|] styledSubmitButtonClass = "" styledPagination :: CSSFramework -> PaginationView -> Blaze.Html styledPagination _ paginationView = [hsx|{helpText}
|] styledFormGroupClass = "flex flex-col my-6 space-y-2" styledValidationResultClass = "text-red-500 text-xs italic" styledPagination :: CSSFramework -> PaginationView -> Blaze.Html styledPagination _ paginationView@PaginationView {pageUrl, pagination} = let currentPage = pagination.currentPage previousPageUrl = if hasPreviousPage pagination then pageUrl $ currentPage - 1 else "#" nextPageUrl = if hasNextPage pagination then pageUrl $ currentPage + 1 else "#" defaultClass = "relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50" previousClass = classes [ defaultClass , ("disabled", not $ hasPreviousPage pagination) ] nextClass = classes [ defaultClass , ("disabled", not $ hasNextPage pagination) ] previousMobileOnly = [hsx| Previous |] nextMobileOnly = [hsx| Next |] in [hsx|