1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-02 23:43:01 +03:00

Add css colors ju-comment and ju-judoc (#2321)

This pr adds colors for comments and judoc for the html backend
This commit is contained in:
Jan Mas Rovira 2023-08-30 15:55:15 +02:00 committed by GitHub
parent 15574caf02
commit 92714b8254
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 20 deletions

View File

@ -31,6 +31,14 @@ body {
color: #787b80; color: #787b80;
} }
.ju-comment {
color: #ba919966;
}
.ju-judoc {
color: #8b2252;
}
.ju-var { .ju-var {
color: #5c6166; color: #5c6166;
} }
@ -65,4 +73,4 @@ footer a {
color: gray; color: gray;
font-size: small; font-size: small;
font-weight: bold; font-weight: bold;
} }

View File

@ -39,11 +39,19 @@ body {
color: #a4b4d2 color: #a4b4d2
} }
.ju-comment {
color: #83898d
}
.ju-judoc {
color: #8fbcbb
}
.ju-number { .ju-number {
color: #d8dee9 color: #d8dee9
} }
.ju-defined { .ju-define {
font-weight: bold; font-weight: bold;
} }
@ -65,4 +73,4 @@ footer a {
color: gray; color: gray;
font-size: small; font-size: small;
font-weight: bold; font-weight: bold;
} }

View File

@ -22,6 +22,20 @@ import Text.Blaze.Html.Renderer.Text qualified as Html
import Text.Blaze.Html5 as Html hiding (map) import Text.Blaze.Html5 as Html hiding (map)
import Text.Blaze.Html5.Attributes qualified as Attr import Text.Blaze.Html5.Attributes qualified as Attr
data CssColor
= JuInductive
| JuConstructor
| JuFunction
| JuAxiom
| JuString
| JuKeyword
| JuDelimiter
| JuVar
| JuFixity
| JuNumber
| JuComment
| JuJudoc
kindSuffix :: HtmlKind -> String kindSuffix :: HtmlKind -> String
kindSuffix = \case kindSuffix = \case
HtmlDoc -> "" HtmlDoc -> ""
@ -248,16 +262,34 @@ go sdt = case sdt of
textSpaces :: Int -> Text textSpaces :: Int -> Text
textSpaces n = Text.replicate n (Text.singleton ' ') textSpaces n = Text.replicate n (Text.singleton ' ')
juColor :: CssColor -> Attribute
juColor = Attr.class_ . toStr
where
toStr :: CssColor -> AttributeValue
toStr = \case
JuInductive -> "ju-inductive"
JuConstructor -> "ju-constructor"
JuFunction -> "ju-function"
JuComment -> "ju-comment"
JuJudoc -> "ju-judoc"
JuAxiom -> "ju-axiom"
JuString -> "ju-string"
JuKeyword -> "ju-keyword"
JuDelimiter -> "ju-delimiter"
JuFixity -> "ju-fixity"
JuVar -> "ju-var"
JuNumber -> "ju-number"
putTag :: forall r. (Members '[Reader HtmlOptions] r) => Ann -> Html -> Sem r Html putTag :: forall r. (Members '[Reader HtmlOptions] r) => Ann -> Html -> Sem r Html
putTag ann x = case ann of putTag ann x = case ann of
AnnKind k -> return (tagKind k x) AnnKind k -> return (tagKind k x)
AnnLiteralInteger -> return (Html.span ! Attr.class_ "ju-number" $ x) AnnLiteralInteger -> return (Html.span ! juColor JuNumber $ x)
AnnLiteralString -> return (Html.span ! Attr.class_ "ju-string" $ x) AnnLiteralString -> return (Html.span ! juColor JuString $ x)
AnnKeyword -> return (Html.span ! Attr.class_ "ju-keyword" $ x) AnnKeyword -> return (Html.span ! juColor JuKeyword $ x)
AnnUnkindedSym -> return (Html.span ! Attr.class_ "ju-var" $ x) AnnUnkindedSym -> return (Html.span ! juColor JuVar $ x)
AnnComment -> return (Html.span ! Attr.class_ "ju-var" $ x) -- TODO add comment class AnnComment -> return (Html.span ! juColor JuComment $ x)
AnnJudoc -> return (Html.span ! Attr.class_ "ju-var" $ x) -- TODO add judoc class AnnJudoc -> return (Html.span ! juColor JuJudoc $ x)
AnnDelimiter -> return (Html.span ! Attr.class_ "ju-delimiter" $ x) AnnDelimiter -> return (Html.span ! juColor JuDelimiter $ x)
AnnDef tmp ni -> boldDefine <*> tagDef tmp ni AnnDef tmp ni -> boldDefine <*> tagDef tmp ni
AnnRef tmp ni -> tagRef tmp ni AnnRef tmp ni -> tagRef tmp ni
AnnCode -> return x AnnCode -> return x
@ -285,17 +317,17 @@ putTag ann x = case ann of
tagKind k = tagKind k =
Html.span Html.span
! Attr.class_ ! juColor
( case k of ( case k of
S.KNameConstructor -> "ju-constructor" S.KNameConstructor -> JuConstructor
S.KNameInductive -> "ju-inductive" S.KNameInductive -> JuInductive
S.KNameFunction -> "ju-function" S.KNameFunction -> JuFunction
S.KNameLocal -> "ju-var" S.KNameLocal -> JuVar
S.KNameAxiom -> "ju-axiom" S.KNameAxiom -> JuAxiom
S.KNameLocalModule -> "ju-var" S.KNameLocalModule -> JuVar
S.KNameAlias -> "ju-var" S.KNameAlias -> JuVar
S.KNameTopModule -> "ju-var" S.KNameTopModule -> JuVar
S.KNameFixity -> "ju-fixity" S.KNameFixity -> JuFixity
) )
nameIdAttr :: S.NameId -> AttributeValue nameIdAttr :: S.NameId -> AttributeValue