feat: show most recent 5 cook entries under Record meal button
Build and Deploy / build-and-deploy (push) Failing after 1m17s
Build and Deploy / build-and-deploy (push) Failing after 1m17s
This commit is contained in:
+27
-10
@@ -898,6 +898,21 @@ renderCookLog _filename entries = do
|
||||
H.div ! A.class_ "roux-cook-entries" $ do
|
||||
mapM_ renderEntry entries
|
||||
|
||||
-- | Render the most recent cook entries under the "Record meal" button.
|
||||
renderRecentCookEntries :: [CookLog.CookEntry] -> Html
|
||||
renderRecentCookEntries [] = pure ()
|
||||
renderRecentCookEntries entries = do
|
||||
H.div ! A.style "margin-top: 0.4rem; font-size: 0.75rem; color: rgba(61,44,30,0.5); line-height: 1.5;" $ do
|
||||
H.span "Recent: "
|
||||
mapM_ renderRecentEntry (take 5 entries)
|
||||
|
||||
renderRecentEntry :: CookLog.CookEntry -> Html
|
||||
renderRecentEntry entry = do
|
||||
H.span ! A.style "color: rgba(61,44,30,0.6);" $ H.toHtml (formatDay (CookLog.ceCookedDate entry))
|
||||
unless (T.null (CookLog.ceComment entry)) $
|
||||
H.span ! A.style "color: rgba(61,44,30,0.4);" $ ": " >> H.toHtml (CookLog.ceComment entry)
|
||||
H.span ", "
|
||||
|
||||
-- | Render a single cook log entry.
|
||||
renderEntry :: CookLog.CookEntry -> Html
|
||||
renderEntry entry = do
|
||||
@@ -926,16 +941,18 @@ renderRecipe filename recipe entries = do
|
||||
Nothing -> pure ()
|
||||
H.div ! A.style "display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;" $ do
|
||||
H.h1 ! A.class_ "roux-recipe-title" $ H.toHtml (titleText recipe)
|
||||
H.div ! A.style "display: flex; gap: 0.75rem; align-items: center; flex-shrink: 0;" $ do
|
||||
case metaSource meta of
|
||||
Just url -> H.a ! A.class_ "roux-source-link" ! A.href (H.toValue url) ! A.target "_blank" ! A.rel "noopener noreferrer" $ do
|
||||
"↗ Original"
|
||||
Nothing -> pure ()
|
||||
H.button
|
||||
! A.class_ "roux-record-btn"
|
||||
! A.id "roux-record-btn"
|
||||
! H.dataAttribute "filename" (H.toValue (T.pack filename))
|
||||
$ "+ Record meal"
|
||||
H.div ! A.style "text-align: right;" $ do
|
||||
H.div ! A.style "display: flex; gap: 0.75rem; align-items: center; justify-content: flex-end;" $ do
|
||||
case metaSource meta of
|
||||
Just url -> H.a ! A.class_ "roux-source-link" ! A.href (H.toValue url) ! A.target "_blank" ! A.rel "noopener noreferrer" $ do
|
||||
"↗ Original"
|
||||
Nothing -> pure ()
|
||||
H.button
|
||||
! A.class_ "roux-record-btn"
|
||||
! A.id "roux-record-btn"
|
||||
! H.dataAttribute "filename" (H.toValue (T.pack filename))
|
||||
$ "+ Record meal"
|
||||
renderRecentCookEntries entries
|
||||
H.div ! A.class_ "roux-desc-row" $ do
|
||||
case desc of
|
||||
Just d -> H.p ! A.class_ "roux-desc" $ H.toHtml d
|
||||
|
||||
Reference in New Issue
Block a user