Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyday567 committed Dec 29, 2023
1 parent 6a05f6f commit 30029b0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
0.12
0.12.1
===
* Changed the order of Page elements, so that inline css over-rides libraries.
* Added cssColorScheme to API

0.12
===
* markupInput replaces inputToHtml as per markup-parse
* ToByteString introduced
* upgrade to box-socket-0.5
Expand Down
1 change: 1 addition & 0 deletions src/Web/Rep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Web.Rep
-- * Css
Css (..),
renderCss,
cssColorScheme,

-- * JS
Js (..),
Expand Down
22 changes: 22 additions & 0 deletions src/Web/Rep/Page.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Web.Rep.Page
PageStructure (..),
Css (..),
renderCss,
cssColorScheme,
Js (..),
onLoad,
)
Expand Down Expand Up @@ -132,6 +133,27 @@ renderCss :: RenderStyle -> Css -> ByteString
renderCss Compact = C.filter (\c -> c /= ' ' && c /= '\n') . cssByteString
renderCss _ = cssByteString

-- | Css snippet for reponsiveness to preferred color-scheme.
cssColorScheme :: Css
cssColorScheme =
Css
[i|
{
color-scheme: light dark;
}
{
body {
background-color: rgb(92%, 92%, 92%);
color: rgb(5%, 5%, 5%);
}
}
@media (prefers-color-scheme:dark) {
body {
background-color: rgb(5%, 5%, 5%);
color: rgb(92%, 92%, 92%);
}
}|]

-- | Javascript as string
newtype Js = Js {jsByteString :: ByteString} deriving (Eq, Show, Generic, Semigroup, Monoid)

Expand Down
6 changes: 3 additions & 3 deletions src/Web/Rep/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ renderPageWith pc p =
"head"
[]
(element_ "meta" [Attr "charset" "utf-8"])
<> cssInline
<> libsCss'
<> cssInline
<> view #htmlHeader p
)
<> element
Expand All @@ -71,8 +71,8 @@ renderPageWith pc p =
<> libsJs'
<> jsInline
Snippet ->
libsCss'
<> cssInline
cssInline
<> libsCss'
<> view #htmlHeader p
<> view #htmlBody p
<> libsJs'
Expand Down
1 change: 1 addition & 0 deletions src/Web/Rep/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ defaultSocketPage :: Page
defaultSocketPage =
bootstrapPage
<> socketPage
& set #cssBody cssColorScheme
& set
#htmlBody
( element
Expand Down
2 changes: 1 addition & 1 deletion web-rep.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: web-rep
version: 0.12.0.0
version: 0.12.1.0
license: BSD-3-Clause
license-file: LICENSE
copyright: Tony Day (c) 2015
Expand Down

0 comments on commit 30029b0

Please sign in to comment.