summaryrefslogtreecommitdiff
path: root/Hero/Look/Typography.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-04-15 09:54:10 -0700
committerBen Sima <ben@bsima.me>2020-04-15 10:06:56 -0700
commitf4b8c0df041b063c0b47d2ec6c818a9c202fd833 (patch)
tree01ad246a83fda29c079847b3397ca6509a7f6106 /Hero/Look/Typography.hs
parent6ed475ca94209ce92e75f48764cb9d361029ea26 (diff)
Re-namespacing
Moving away from the DNS-driven namespacing toward more condensed names, mostly because I don't like typing so much.
Diffstat (limited to 'Hero/Look/Typography.hs')
-rw-r--r--Hero/Look/Typography.hs79
1 files changed, 79 insertions, 0 deletions
diff --git a/Hero/Look/Typography.hs b/Hero/Look/Typography.hs
new file mode 100644
index 0000000..4d4f976
--- /dev/null
+++ b/Hero/Look/Typography.hs
@@ -0,0 +1,79 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+module Hero.Look.Typography where
+
+import Alpha
+import Clay
+import Clay.Stylesheet ( key )
+import qualified Hero.Assets as Assets
+import Data.Semigroup ( (<>) )
+
+main :: Css
+main = fonts
+
+-- font modifiers
+
+euro, slim, wide, thicc, thinn, norm, lean, smol, lower, upper :: Css
+
+euro = fontFamily ["Eurostile"] [sansSerif]
+
+-- | stretch
+slim = fontStretch condensed
+wide = fontStretch expanded
+
+-- | weight
+thicc = fontWeight bold
+thinn = fontWeight normal
+
+-- | style
+norm = fontStyle normal
+lean = fontStyle italic
+
+-- | "smallcaps" is already taken by Clay
+smol = fontVariant smallCaps
+
+lower = textTransform lowercase
+upper = textTransform uppercase
+
+-- | font sizing
+
+-- | apparently "coat" is a synonym for "size"
+coat :: Double -> Css
+coat = fontSize . Clay.rem
+
+fontRoot :: Text
+fontRoot = Assets.cdnEdge <> "/old-assets/fonts/eurostile/Eurostile"
+
+-- | font faces
+fonts :: Css
+fonts =
+ mconcat
+ $ mkEuro
+ </ [ ("-Reg.otf" , OpenType, fontWeight normal <> fontStyle normal)
+ , ("LTStd-Bold.otf" , OpenType, thicc <> norm)
+ , ("LTStd-Cn.otf" , OpenType, slim <> norm)
+ , ("LTStd-Ex2.otf" , OpenType, wide <> norm)
+ , ("LTStd-BoldCn.otf" , OpenType, slim <> thicc)
+ , ("LTStd-BoldEx2.otf", OpenType, wide <> thicc)
+ ]
+ where
+ mkEuro :: (Text, FontFaceFormat, Css) -> Css
+ mkEuro (sufx, fmt, extra) = fontFace $ do
+ fontFamily ["Eurostile"] []
+ fontFaceSrc [FontFaceSrcUrl (fontRoot <> sufx) $ Just fmt]
+ extra
+
+-- TODO: add the below to Clay.Font upstream
+
+newtype FontStretch = FontStretch Value
+ deriving (Val, Inherit, Normal, Other)
+
+expanded :: FontStretch
+expanded = FontStretch "expanded"
+
+condensed :: FontStretch
+condensed = FontStretch "condensed"
+
+fontStretch :: FontStretch -> Css
+fontStretch = key "font-stretch"