Skip to content

Commit

Permalink
update Home template
Browse files Browse the repository at this point in the history
  • Loading branch information
sigrdrifa committed Jul 2, 2024
1 parent 717e7dc commit 6fe8d78
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ help: ## print make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: ghcid-devel
ghcid-devel: ## Run the server in fast development mode. See lib/DevelMain.hs for details.
ghcid-devel: tailwind-build ## Run the server in fast development mode. See lib/DevelMain.hs for details.
ghcid \
--command "cabal repl hastl" \
--test DevelMain.update \
Expand Down
6 changes: 0 additions & 6 deletions lib/Api/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ module Api.Base where

import Lucid (
Html,
a_,
body_,
br_,
class_,
div_,
doctypehtml_,
h1_,
href_,
id_,
p_,
target_,
)
import Servant (
Get,
Expand Down
71 changes: 46 additions & 25 deletions lib/Api/Templates/Base/Home.hs
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
module Api.Templates.Base.Home where

import Api.Templates.Helpers.Htmx
import Api.Templates.Helpers.Htmx (hxGet_, hxSwap_, hxTrigger_)
import Api.Templates.User.User (renderAddUserForm)
import Lucid
import Data.Text (Text)
import Lucid (
Html,
a_,
b_,
br_,
class_,
div_,
h1_,
href_,
img_,
p_,
src_,
target_,
)

renderHome :: Lucid.Html ()
renderHome =
div_ [class_ "mt-4"] $ do
div_
[class_ "max-w-screen-xl mx-auto"]
Lucid.div_ [Lucid.class_ "mt-4"] $ do
Lucid.div_
[Lucid.class_ "max-w-screen-xl mx-auto"]
$ do
h1_ [class_ "text-3xl font-bold text-gray-900"] "Welcome to hastl"
p_ [class_ "text-gray-600"] $ do
Lucid.h1_ [Lucid.class_ "text-3xl font-bold text-gray-900"] "Welcome to hastl"
Lucid.p_ [Lucid.class_ "text-gray-600"] $ do
"hastl is a modern "
a_ [href_ "haskell.org", target_ "_blank"] "Haskell"
Lucid.a_ [Lucid.href_ "haskell.org", Lucid.target_ "_blank"] "Haskell"
" web application using "
b_ "(H)tmx, "
b_ "(A)lpine.js, "
b_ "(S)ervant, "
b_ "(T)ailwind-css "
Lucid.b_ "(H)tmx, "
Lucid.b_ "(A)lpine.js, "
Lucid.b_ "(S)ervant, "
Lucid.b_ "(T)ailwind-css "
"and"
b_ "(L)ucid. "
Lucid.b_ "(L)ucid. "
"It is licensed under MIT and is entirely free and open source."
br_ []
Lucid.br_ []
renderBadges
p_ [class_ "text-gray-600 mt-5"] "Try it out below by adding guests to your awesome party!"
Lucid.p_ [Lucid.class_ "text-gray-600 mt-5"] "Try it out below by adding guests to your awesome party!"
renderAddUserForm
p_ [class_ "text-xs text-gray-500 mt-2 mx-auto text-center"] "* Don't worry, we won't actually send anything!"
div_ [hxGet_ "/users", hxSwap_ "innerHTML", hxTrigger_ "load"] $ p_ "Loading..."
Lucid.p_ [Lucid.class_ "text-xs text-gray-500 mt-2 mx-auto text-center"] "* Don't worry, we won't actually send anything!"
Lucid.div_ [hxGet_ "/users", hxSwap_ "innerHTML", hxTrigger_ "load"] $ Lucid.p_ "Loading..."

renderBadges :: Html ()
renderBadge :: Text -> Lucid.Html ()
renderBadge src = Lucid.img_ [Lucid.class_ "col-span-1 inline", Lucid.src_ src]

renderBadges :: Lucid.Html ()
renderBadges =
div_ [class_ "mx-auto max-w-screen-xl"] $ do
img_ [class_ "col-span-1 inline", src_ "https://img.shields.io/badge/haskell-5D4F85?style=for-the-badge&logo=haskell&logoColor=white"]
img_ [class_ "col-span-1 inline", src_ "https://img.shields.io/badge/htmxjs-3366CC?style=for-the-badge&logo=htmx&logoColor=white"]
img_ [class_ "col-span-1 inline", src_ "https://img.shields.io/badge/alpinejs-8BC0D0?style=for-the-badge&logo=alpine.js&logoColor=white"]
img_ [class_ "col-span-1 inline", src_ "https://img.shields.io/badge/Servant-5D4F85?style=for-the-badge&logo=haskell&logoColor=white"]
img_ [class_ "col-span-1 inline", src_ "https://img.shields.io/badge/Tailwind-06B6D4?style=for-the-badge&logo=tailwindcss&logoColor=white"]
img_ [class_ "col-span-1 inline", src_ "https://img.shields.io/badge/Lucid-5D4F85?style=for-the-badge&logo=haskell&logoColor=white"]
Lucid.div_ [Lucid.class_ "mx-auto max-w-screen-xl"] $ do
mapM_ renderBadge badges
where
badges =
[ "https://img.shields.io/badge/haskell-5D4F85?style=for-the-badge&logo=haskell&logoColor=white"
, "https://img.shields.io/badge/htmxjs-3366CC?style=for-the-badge&logo=htmx&logoColor=white"
, "https://img.shields.io/badge/alpinejs-8BC0D0?style=for-the-badge&logo=alpine.js&logoColor=white"
, "https://img.shields.io/badge/Servant-5D4F85?style=for-the-badge&logo=haskell&logoColor=white"
, "https://img.shields.io/badge/Tailwind-06B6D4?style=for-the-badge&logo=tailwindcss&logoColor=white"
, "https://img.shields.io/badge/Lucid-5D4F85?style=for-the-badge&logo=haskell&logoColor=white"
]
3 changes: 2 additions & 1 deletion lib/Api/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ singleUser str = do
logDebugNS "web" "singleUser"
maybeUser <- runDb (selectFirst [Md.UserName ==. str] [])
case maybeUser of
Nothing ->
Nothing -> do
logDebugNS "web" "failed to find user"
throwError err404
Just person ->
return person
Expand Down

0 comments on commit 6fe8d78

Please sign in to comment.