-- | Defines functions to create accompanying .css files for HTML generators.
module Language.Drasil.HTML.CSS where

import Text.PrettyPrint (Doc, text, vcat)

import Language.Drasil hiding (Expr)

-- | Generates the CSS selectors necessary for a document.
makeCSS :: Document -> Doc  
makeCSS :: Document -> Doc
makeCSS Document
_ = [Doc] -> Doc
vcat [
-- TODO: Autogenerate necessary css selectors only, make CSS configurable
  String -> Doc
text String
"body {min-width: 400px; max-width: 1400px;}",
  String -> Doc
text String
".title {text-align: center;}",
  String -> Doc
text String
".author {text-align: center;}",
  String -> Doc
text String
".paragraph {text-align: justify;}",
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".cases {",
    String -> Doc
text String
"  display: inline-block;",
    String -> Doc
text String
"  vertical-align: middle;}"],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".case {",
    String -> Doc
text String
"  float: right;",
    String -> Doc
text String
"  padding-left: 1em;}"],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".cases > span {",
    String -> Doc
text String
"  display: block;",
    String -> Doc
text String
"  padding-top: 0.1em;",
    String -> Doc
text String
"  padding-left: 0em;}"],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".casebr {",
    String -> Doc
text String
"  display: inline-block;",
    String -> Doc
text String
"  vertical-align: middle;",
    String -> Doc
text String
"  margin: 0 0.2em 0.4ex;",
    String -> Doc
text String
"  text-align: center;",
    String -> Doc
text String
"  font-size: 500%;}"],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".caption {",
    String -> Doc
text String
"  text-align: center;",
    String -> Doc
text String
"  font-weight: bold;",
    String -> Doc
text String
"  padding-bottom: 1%;",
    String -> Doc
text String
"  line-height: 0;}"
    ],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".fraction {",
    String -> Doc
text String
"  display: inline-block;",
    String -> Doc
text String
"  vertical-align: middle;",
    String -> Doc
text String
"  margin: 0 0.2em 0.4ex;",
    String -> Doc
text String
"  text-align: center;}"
    ],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".fraction > span {",
    String -> Doc
text String
"  display: block;",
    String -> Doc
text String
"  padding-top: 0.15em;}"
    ],
  String -> Doc
text String
".fdn {border-top: thin solid black;}",
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".table {",
    String -> Doc
text String
"  text-align: left;",
    String -> Doc
text String
"  padding-left: 1%;",
    String -> Doc
text String
"  width: 90%;",
    String -> Doc
text String
"  margin-bottom: 2%;",
    String -> Doc
text String
"  margin-top: 2%}"],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
"table, th, td {",
    String -> Doc
text String
"  border-collapse: collapse;",
    String -> Doc
text String
"  margin-left: auto;",
    String -> Doc
text String
"  margin-right: auto;}"],
  String -> Doc
text String
"th, td {border: 1px solid black; padding: 0.5em;}",
  String -> Doc
text String
".tdefn, .ddefn, .gdefn, .idefn {width: 75%; margin-top: 1%; margin-bottom: 1%;}",
  String -> Doc
text String
".tdefn th, .ddefn th, .gdefn th, .idefn th {width: 15%;}",
  String -> Doc
text String
".section {width: 80%; margin: 0 auto; text-align: left;}",
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".code {",
    String -> Doc
text String
"  display: inline-block;",
    String -> Doc
text String
"  text-align: left;",
    String -> Doc
text (String
"  font-family: Monaco, Consolas, \"Andale Mono\"," String -> String -> String
forall a. [a] -> [a] -> [a]
++
      String
"\"DejaVu Sans Mono\", monospace;"),
    String -> Doc
text String
"  font-size: 95%;",
    String -> Doc
text String
"  line-height: 140%;",
    String -> Doc
text String
"  white-space: pre;",
    String -> Doc
text String
"  white-space: pre-wrap;",
    String -> Doc
text String
"  white-space: -moz-pre-wrap;",
    String -> Doc
text String
"  white-space: -o-pre-wrap;",
    String -> Doc
text String
"  background: #faf8f0;}"],
  String -> Doc
text String
".list {text-align: left;}",
  [Doc] -> Doc
vcat [
    String -> Doc
text String
"figure {",
    String -> Doc
text String
"text-align: center;",
    String -> Doc
text String
"font-weight: bold;",
    String -> Doc
text String
"}"],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
"figure > img {",
    String -> Doc
text String
"max-width: 100%;",
    String -> Doc
text String
"}"],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
".matrix {",
    String -> Doc
text String
"  position: relative;",
    String -> Doc
text String
"  display: inline-table;",
    String -> Doc
text String
"  margin: 10px;",
    String -> Doc
text String
"  vertical-align: middle;}",
    String -> Doc
text String
".matrix:before, .matrix:after {",
    String -> Doc
text String
"  content: \"\";",
    String -> Doc
text String
"  position: absolute;",
    String -> Doc
text String
"  top: 0;",
    String -> Doc
text String
"  border: 1px solid #000;",
    String -> Doc
text String
"  width: 5px;",
    String -> Doc
text String
"  height: 100%;}",
    String -> Doc
text String
".matrix:before {",
    String -> Doc
text String
"  left: -5px;",
    String -> Doc
text String
"  border-right: 0px;}",
    String -> Doc
text String
".matrix:after {",
    String -> Doc
text String
"  right: -5px;",
    String -> Doc
text String
"  border-left: 0px;}",
    String -> Doc
text String
".matrix td {",
    String -> Doc
text String
"  padding: 5px;",
    String -> Doc
text String
"  text-align: center;",
    String -> Doc
text String
"  border: 0px;}"],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
"ul.hide-list-style {",
    String -> Doc
text String
"  list-style-type: none;}"
    ],
  [Doc] -> Doc
vcat [
    String -> Doc
text String
"ul.hide-list-style-no-indent {",
    String -> Doc
text String
"  list-style-type: none;",
    String -> Doc
text String
"padding: 0;}"
    ] 
  ]

-- | Create the link to the necessary CSS file.
linkCSS :: String -> Doc  
linkCSS :: String -> Doc
linkCSS String
fn = 
  String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ String
"<link rel=\"stylesheet\" type=\"text/css\" href=\""String -> String -> String
forall a. [a] -> [a] -> [a]
++String
fnString -> String -> String
forall a. [a] -> [a] -> [a]
++String
".css\">"