@@ -0,0 +1,175 @@
1+module Main exposing (main)
3+{-| Line Height as its specified through CSS doesn't make a whole lot of sense typographically.
5+We also run into issues with sizing a font. The font size generally refers to the full type size (from the top of ascendors to the bottom of descenders)
7+However, sometimes we might want to size things from the top of the Capital to the baseline.
9+Or from the top of the x-height to the baseline.
11+The main place this shows up is for dropped capitals, and for text on buttons.
16+import Element exposing (..)
17+import Element.Background as Background
18+import Element.Border as Border
19+import Element.Font as Font
20+import Element.Input as Input
22+import Html.Attributes
25+type alias FontAdjustment =
26+ { capital : Adjustment
27+ , lowercase : Adjustment
28+ , baseline : Adjustment
29+ , descender : Adjustment
33+type alias Adjustment =
38+ = UpdateAdjustment FontAdjustment
42+ { top = 0, right = 0, bottom = 0, left = 0 }
57+ UpdateAdjustment adj ->
58+ { model | adjustment = adj }
71+ [ Background.color (rgba 1 1 1 1)
72+ , Font.color (rgba 0 0 0 1)
75+ { url = "https://fonts.googleapis.com/css?family=EB+Garamond"
76+ , name = "EB Garamond"
82+ adjustor 240 model.adjustment
85+fontSize pixels lineHeight up =
88+ -- , htmlAttribute (Html.Attributes.style "line-height" lineHeight)
89+ -- , Background.color (rgb 0 0.8 0.9)
92+ -- [ Background.color (rgb 0 0 0)
94+ -- , height (px pixels)
106+viewAdjustment label adjustment size left updateWith =
108+ (el [ moveLeft left, moveUp (0.25 * toFloat size), height (px (round (toFloat size * 1.5))) ] <|
111+ , Element.behindContent
113+ [ Element.width (Element.px 1)
114+ , Element.height Element.fill
116+ , Background.color charcoal
121+ , height (px (round (toFloat size * 1.5)))
123+ , Background.color charcoal
124+ , below (el [ centerX ] (text (String.fromFloat adjustment)))
126+ { label = Input.labelAbove [ Font.size 18 ] (text "")
136+ [ Element.width (Element.px 16)
137+ , Element.height (Element.px 16)
140+ , Border.color (Element.rgb 0.5 0.5 0.5)
141+ , Background.color (Element.rgb 1 1 1)
147+ , Border.color charcoal
159+ , value = adjustment
164+adjustor size adjustment =
167+ [ viewAdjustment "Type Height" adjustment.capital size 180 (\capital -> { adjustment | capital = capital })
168+ , viewAdjustment "Lowercase Height" adjustment.lowercase size 60 (\lowercase -> { adjustment | lowercase = lowercase })
169+ , viewAdjustment "Baseline" adjustment.baseline size 120 (\baseline -> { adjustment | baseline = baseline })
170+ , viewAdjustment "Descender" adjustment.descender size 0 (\descender -> { adjustment | descender = descender })
174+ ([ centerX, centerY ] ++ labels ++ fontSize size "1.0" 0)