From 985974c264804ff788b3b5242fef707d4b7fa9a6 Mon Sep 17 00:00:00 2001 From: evuez Date: Mon, 1 Apr 2024 15:17:30 +0200 Subject: Initial commit --- src/Html.hs | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/Html.hs (limited to 'src/Html.hs') diff --git a/src/Html.hs b/src/Html.hs new file mode 100644 index 0000000..dd60e16 --- /dev/null +++ b/src/Html.hs @@ -0,0 +1,88 @@ +module Html (span, html, p, hr, div_, iframe, img, main_, ul, li, table, td, th, tr, a) where + +import Data.List (unwords) +import Intro + +type Attr = (String, String) + +html :: [String] -> String +html xs = + concat + [ "" + , "" + , script + [ "function resizeIframe(x) { \ + \ x.style.height = x.contentWindow.document.documentElement.scrollHeight + 'px'; \ + \}" + ] + , "" + , "" + , style + [ ":root { font-size: 16px; }" + , "* { padding: 0; margin: 0; }" + , "body { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; }" + , "hr { height: 0; border: 0; border-top: 1px solid #000; }" + , "table { border-collapse: collapse; width: 100%; }" + , "td, th { border: 1px solid #000; padding: 0.4rem; }" + , "iframe { width: 100%; min-height: 80vh; border: none; }" + , "main { display: flex; flex-direction: column; gap: 1rem; }" + , ".part { background-color: #eee; }" + , ".part-body { padding: 1rem; }" + ] + , concat xs + , "" + ] + +hr :: String +hr = "
" + +style :: [String] -> String +style xs = concat [""] + +script :: [String] -> String +script xs = concat [""] + +iframe :: [Attr] -> [String] -> String +iframe xs ys = concat [""] + +div_ :: [Attr] -> [String] -> String +div_ xs ys = concat ["
", concat ys, "
"] + +main_ :: [String] -> String +main_ xs = concat ["
", concat xs, "
"] + +p :: [String] -> String +p xs = concat ["

", concat xs, "

"] + +span :: [String] -> String +span xs = concat ["", concat xs, ""] + +a :: [Attr] -> [String] -> String +a xs ys = concat ["", concat ys, ""] + +table :: [String] -> String +table xs = concat ["", concat xs, "
"] + +td :: [String] -> String +td xs = concat ["", concat xs, ""] + +th :: [String] -> String +th xs = concat ["", concat xs, ""] + +tr :: [String] -> String +tr xs = concat ["", concat xs, ""] + +ul :: [String] -> String +ul xs = concat [""] + +li :: [String] -> String +li xs = concat ["
  • ", concat xs, "
  • "] + +img :: [Attr] -> String +img xs = concat [""] + +attr :: Attr -> String +attr (k, v) = concat [k, "='", v, "'"] + +attrs :: [Attr] -> String +attrs xs = unwords (attr <$> xs) -- cgit v1.2.3