git.iko.soy/rowtype-yoga/psfp
on master help sign in
Ronnie's Würstchenbude
commit3664c84350dc90f8db470551ca4932243544d961 authorMark Eibes <mark.eibes@gmail.com> dateMon 30 Mar 2020, 23:17 (7 years ago) parent23914d4
19 files changed+311−66
components/src/React/Basic/Extra/Hooks/UseAffReducer.purs+6−6 components/src/Yoga/Button/Component.purs+2−1 components/src/Yoga/Header/Component.purs−1 components/src/Yoga/Helpers.purs+1−1 components/src/Yoga/InlineCode/Component.purs+4−2 components/src/Yoga/InlineCode/Spec.purs+5−3 components/src/Yoga/InlineCode/Stories.purs+98−2 components/src/Yoga/InlineCode/Styles.purs+59−7 components/src/Yoga/JSS.purs+16−4 components/src/Yoga/Monaco/Editor.purs+1−1 components/src/Yoga/SVG/Image.purs+2−1 components/src/Yoga/Theme.purs+47−5 components/src/Yoga/Theme/CSSBaseline.purs+26−19 components/src/Yoga/Theme/Default.purs+4−1 components/src/Yoga/Theme/Types.purs+31−3 components/src/Yoga/Typography/Header.purs+4−3 components/src/Yoga/Typography/Paragraph.purs−1 server/package-lock.json+3−4 server/package.json+2−1
components/src/React/Basic/Extra/Hooks/UseAffReducer.purs+6−6
@@ -26,12 +26,12 @@ useAffReducer initialState reducer =
2626 coerceHook React.do
2727 state /\ modifyState <- useState initialState
2828 maybeAction /\ modifyAction <- useState Nothing
29+ useAff maybeAction do
30+ for_ maybeAction \action -> do
31+ newState <- reducer state action
32+ liftEffect do
33+ modifyState (const newState)
34+ modifyAction (const Nothing)
2935 let
3036 dispatch = modifyAction <<< const <<< Just
31− useAff maybeAction
32− $ for_ maybeAction \action -> do
33− newState <- reducer state action
34− liftEffect do
35− modifyState (const newState)
36− modifyAction (const Nothing)
3737 pure (state /\ dispatch)
components/src/Yoga/Button/Component.purs+2−1
@@ -3,6 +3,7 @@ module Yoga.Button.Component where
33import Prelude
44import CSS (Color, cssStringRGBA, desaturate)
55import CSS as Color
6+import Data.Array.NonEmpty as NEA
67import Data.Foldable (intercalate)
78import Data.Interpolate (i)
89import Data.Maybe (Maybe)
@@ -106,7 +107,7 @@ styles =
106107 , border: "0"
107108 , height: "calc(var(--s2))"
108109 , fontSize: "calc(var(--s-1))"
109− , fontFamily: theme.textFontFamily
110+ , fontFamily: NEA.head theme.textFontFamily
110111 , fontWeight: "600"
111112 , padding: "0 var(--s0) 0 var(--s0)"
112113 , letterSpacing: "var(--s-5)"
components/src/Yoga/Header/Component.purs−1
@@ -30,7 +30,6 @@ mkHeader = do
3030 , borderRight: "1px solid " <> (theme.backgroundColourLightest # toHexString)
3131 , borderLeft: "1px solid " <> (theme.backgroundColourLightest # toHexString)
3232 , color: theme.textColour # toHexString
33− , fontFamily: theme.textFontFamily
3433 , fontSize: "2em"
3534 , padding: "20px"
3635 , display: "flex"
components/src/Yoga/Helpers.purs+1−1
@@ -6,7 +6,7 @@ import Data.Maybe (Maybe(..), fromMaybe)
66fromMaybeFlipped ∷ ∀ a. Maybe a -> a -> a
77fromMaybeFlipped = flip fromMaybe
88
9−infixr 7 fromMaybeFlipped as ?||
9+infixr 5 fromMaybeFlipped as ?||
1010
1111ifJustTrue ∷ ∀ m. Monoid m => Maybe Boolean -> m -> m
1212ifJustTrue option value = if option == Just true then value else mempty
components/src/Yoga/InlineCode/Component.purs+4−2
@@ -3,9 +3,9 @@ module Yoga.InlineCode.Component where
33import Prelude
44import Data.Foldable (fold, intercalate)
55import Data.Maybe (Maybe)
6+import Data.String (trim)
67import Data.Tuple.Nested ((/\))
78import Effect (Effect)
8−import Effect.Class.Console (log)
99import Foreign.Object as Obj
1010import React.Basic.DOM as R
1111import React.Basic.DOM.Events (preventDefault, targetValue)
@@ -42,9 +42,11 @@ makeComponent = do
4242 classes <- useStyles $ pick props
4343 pure
4444 $ R.form
45− { children:
45+ { className: classes.form
46+ , children:
4647 [ R.input
4748 { className: intercalate " " [ classes.inlinecode, fold className ]
49+ , maxLength: props.width ?|| 10
4850 , value
4951 , onChange:
5052 handler targetValue
components/src/Yoga/InlineCode/Spec.purs+5−3
@@ -8,6 +8,7 @@ import Effect.Aff (Aff)
88import Effect.Class (liftEffect)
99import Effect.Ref (Ref)
1010import Effect.Ref as Ref
11+import Justifill (justifill)
1112import React.Basic.Extra.Hooks (useAffReducer)
1213import React.Basic.Hooks (ReactComponent, component, element, useEffect)
1314import React.Basic.Hooks as React
@@ -57,6 +58,7 @@ mkWrapper = do
5758 useEffect state mempty
5859 pure
5960 $ element inlineCode
60− { dispatch: dispatch <<< InlineCodeAction
61− , className: Nothing
62− }
61+ ( justifill
62+ { dispatch: dispatch <<< InlineCodeAction
63+ }
64+ )
components/src/Yoga/InlineCode/Stories.purs+98−2
@@ -1,20 +1,116 @@
11module Yoga.InlineCode.Stories where
22
33import Prelude hiding (add)
4+import Data.Array (intercalate, length)
5+import Data.Either (Either(..))
46import Data.Maybe (Maybe(..))
7+import Data.String (Pattern(..), split, trim)
8+import Data.String.CodeUnits as String
9+import Data.Tuple.Nested ((/\))
10+import Debug.Trace (spy)
511import Effect (Effect)
12+import Effect.Aff (Aff)
613import Effect.Class.Console (log)
14+import Justifill (justifill)
15+import Milkis as M
16+import Milkis.Impl.Window (windowFetch)
17+import React.Basic (JSX, fragment)
718import React.Basic.DOM as R
19+import React.Basic.Extra.Hooks (useAffReducer)
20+import React.Basic.Helpers (jsx)
21+import React.Basic.Hooks (ReactComponent, component, element)
22+import React.Basic.Hooks as React
823import Storybook.Decorator.FullScreen (fullScreenDecorator)
924import Storybook.React (Storybook, add, addDecorator, storiesOf)
25+import Yoga.CompileEditor.Component (compileAndRun)
26+import Yoga.InlineCode.Component (Action(..))
1027import Yoga.InlineCode.Component as InlineCode
28+import Yoga.Modal.Component as Modal
1129
1230stories ∷ Effect Storybook
1331stories = do
1432 storiesOf "InlineCode" do
1533 addDecorator fullScreenDecorator
1634 add "The InlineCode" InlineCode.makeComponent
17− [ { dispatch: const $ log "hi"
18− , className: Nothing
35+ [ ( justifill
36+ { dispatch: \(_ ∷ InlineCode.Action) -> ((log "hi") ∷ Effect Unit)
37+ }
38+ )
39+ ]
40+ add "The InlineCode with some context" mkWrapper
41+ [ { inside:
42+ \inlineCode ->
43+ [ R.text "hi!"
44+ , element inlineCode (justifill { dispatch: \(_ ∷ InlineCode.Action) -> (log "Hi") ∷ Effect Unit })
45+ , R.text "hello again!"
46+ ]
47+ }
48+ ]
49+ add "The InlineCode with some code" mkWrapper
50+ [ { inside:
51+ \inlineCode ->
52+ [ R.code_ [ R.text "main = logShow \"" ]
53+ , element inlineCode (justifill { dispatch: \(_ ∷ InlineCode.Action) -> (log "Hi") ∷ Effect Unit })
54+ , R.code_ [ R.text "\"" ]
55+ ]
1956 }
2057 ]
58+ add "The InlineCode with some real code" mkRealWrapper
59+ [ {} ]
60+
61+codePrefix =
62+ """module Main where
63+import Batteries
64+
65+main = log """"
66+
67+codeSuffix = "\""
68+
69+renderCode c = intercalate [ R.br {} ] (toJSX <$> lines)
70+ where
71+ toJSX line = [ R.code_ [ R.text line ] ]
72+ lines = split (Pattern "\n") c
73+
74+mkWrapper ∷ Effect (ReactComponent { inside ∷ ReactComponent InlineCode.Props -> Array JSX })
75+mkWrapper = do
76+ inlineCode <- InlineCode.makeComponent
77+ component "InlineCodeWrapper" \{ inside } -> React.do
78+ pure
79+ $ R.div_ (inside inlineCode)
80+
81+type State
82+ = Maybe Boolean
83+
84+data RealAction
85+ = InlineCodeAction InlineCode.Action
86+ | CloseModal
87+
88+derive instance eqRealAction ∷ Eq RealAction
89+mkRealWrapper ∷ Effect (ReactComponent {})
90+mkRealWrapper = do
91+ inlineCode <- InlineCode.makeComponent
92+ modal <- Modal.makeComponent
93+ component "InlineCodeWrapper" \{} -> React.do
94+ state /\ dispatch <- useAffReducer Nothing realReducer
95+ pure
96+ $ R.div_
97+ [ R.h2_ [ R.text "Let's log some 'Magick'" ]
98+ , fragment $ renderCode codePrefix
99+ , element inlineCode (justifill { dispatch: dispatch <<< InlineCodeAction, width: String.length "Magick" })
100+ , fragment $ renderCode codeSuffix
101+ , R.br {}
102+ , case state of
103+ Just true -> element modal $ justifill { title: "Success!", content: R.text "You did it!", onClose: dispatch CloseModal }
104+ Just false -> element modal $ justifill { title: "Oh no!", content: R.text "Try again!", onClose: dispatch CloseModal }
105+ Nothing -> mempty
106+ ]
107+
108+realReducer ∷ State -> RealAction -> Aff State
109+realReducer state = case _ of
110+ CloseModal -> pure Nothing
111+ InlineCodeAction (CompileAndRunCode code) -> do
112+ res <- compileAndRun (M.fetch windowFetch) { code: codePrefix <> code <> codeSuffix }
113+ (pure <<< Just) case spy "res" res of
114+ Right { stdout }
115+ | String.dropRight 1 stdout == "Magick" -> true
116+ _ -> false
components/src/Yoga/InlineCode/Styles.purs+59−7
@@ -1,11 +1,27 @@
11module Yoga.InlineCode.Styles where
22
33import Prelude
4−import JSS (JSSClasses, JSSElem, jssClasses)
5−import Yoga.Theme.Types (YogaTheme)
4+import CSS (GenericFontFamily(..), Selector, TimingFunction(..), animation, background, border, borderBottom, borderBox, borderRadius, boxSizing, color, darken, display, element, focus, fontFamily, fontSize, fromString, inlineBlock, iterationCount, keyframes, lighten, lineHeight, nil, padding, sec, solid, transform, transition, unitless, width, (!*), (!+), (&), (?))
5+import CSS.Animation (forwards, normalAnimationDirection)
6+import CSS.Common (baseline, middle)
7+import CSS.Overflow (hidden, overflow, visible)
8+import CSS.Size (ch)
9+import CSS.Transform (scale3d)
10+import CSS.VerticalAlign (verticalAlign)
11+import Color as Color
12+import Data.Array.NonEmpty as NEA
13+import Data.Int (toNumber)
14+import Data.Maybe (Maybe)
15+import Data.NonEmpty (NonEmpty(..), (:|))
16+import Data.Tuple.Nested ((/\))
17+import JSS (JSSClasses, JSSElem, jss, jssClasses)
18+import Yoga.Helpers ((?||))
19+import Yoga.Theme (withAlpha)
20+import Yoga.Theme.Types (YogaTheme, CSSTheme)
621
722type PropsR
8− = (
23+ = ( regularFont ∷ Maybe Boolean
24+ , width ∷ Maybe Int
925 )
1026
1127type Props
@@ -14,10 +30,46 @@ type Props
1430styles ∷
1531 JSSClasses YogaTheme Props
1632 ( inlinecode ∷ JSSElem Props
33+ , form ∷ JSSElem Props
34+ , "@keyframes plop" ∷ JSSElem Props
1735 )
18−styles =
19− jssClasses \theme ->
20− { inlinecode:
36+styles = jssClasses go
37+ where
38+ go (theme@{ s0, s1, s_1, s_2, s_3, s_4, s_5 } ∷ CSSTheme) =
39+ { form:
40+ do
41+ display inlineBlock
42+ , "@keyframes plop":
43+ keyframes mempty
44+ $ (0.0 /\ transform (scale3d 0.8 0.8 0.8))
45+ :| [ 33.3 /\ transform (scale3d 1.1 1.1 1.1)
46+ , 67.7 /\ transform (scale3d 0.9 0.9 0.9)
47+ , 86.7 /\ transform (scale3d 1.05 1.05 1.05)
48+ , 100.0 /\ transform (scale3d 1.0 1.0 1.0)
49+ ]
50+ , inlinecode:
2151 \props ->
22− {}
52+ jss { outline: "none" }
53+ <> jss do
54+ overflow visible
55+ boxSizing borderBox
56+ verticalAlign baseline
57+ background $ withAlpha 0.15 theme.textColour
58+ border solid s_5 (Color.rgba 0 0 0 0.0)
59+ borderRadius s_2 s_2 s_2 s_2
60+ fontFamily
61+ (NEA.toArray theme.codeFontFamily)
62+ (NonEmpty (GenericFontFamily $ fromString "monospace") [])
63+ fontSize (s0)
64+ lineHeight (s0)
65+ width $ (props.width ?|| 10 # toNumber # ch) !+ (unitless 4.2 !* s_5)
66+ padding nil s_5 nil s_5
67+ color theme.textColour
68+ this & focus
69+ ? do
70+ animation (fromString "$plop") (0.3 # sec) EaseIn (0.0 # sec) (1.0 # iterationCount) normalAnimationDirection forwards
71+ border solid s_5 theme.highlightColourRotatedBackwards
2372 }
73+
74+this ∷ Selector
75+this = element "&"
components/src/Yoga/JSS.purs+16−4
@@ -1,9 +1,11 @@
11module JSS where
22
33import Prelude
4−import CSS (Color, Key(..), Rule(..), StyleM, Value(..), cssStringRGBA, plain, runS)
4+import CSS (App(..), Color, Key(..), Keyframes(..), Path(..), Predicate(..), Refinement(..), Rule(..), Selector(..), StyleM, Value(..), cssStringRGBA, plain, predicate, runS)
55import Data.Foldable (foldMap)
6+import Data.Int (round)
67import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
8+import Data.Tuple (Tuple(..))
79import Debug.Trace (spy)
810import Foreign (unsafeToForeign)
911import Foreign.Object (Object)
@@ -51,6 +53,8 @@ data JSSElem props
5153
5254instance semigroupJssElem ∷ Semigroup (JSSElem props) where
5355 append = case _, _ of
56+ PrimitiveJss p1, PrimitiveJss p2
57+ | p1 == p2 -> PrimitiveJss p1
5458 NestedJss n1, NestedJss n2 -> NestedJss (n1 <> n2)
5559 ArrayJss a1, ArrayJss a2 -> ArrayJss (a1 <> a2)
5660 NestedJss n1, PropsJss fn ->
@@ -59,23 +63,24 @@ instance semigroupJssElem ∷ Semigroup (JSSElem props) where
5963 other -> do
6064 let
6165 _ = spy "other" other
62− unsafeCrashWith "Untreated branch, fix me"
66+ unsafeCrashWith "Untreated branch (1), fix me"
6367 PropsJss fn1, PropsJss fn2 ->
6468 PropsJss \props -> do
6569 case fn1 props, fn2 props of
6670 n1@(NestedJss _), n2@(NestedJss _) -> n1 <> n2
71+ p1@(PrimitiveJss _), p2@(PrimitiveJss _) -> p1 <> p2
6772 x, y -> do
6873 let
6974 _ = spy "x" x
7075
7176 _ = spy "y" y
72− unsafeCrashWith "Untreated branch second, fix me"
77+ unsafeCrashWith "Untreated branch (2), fix me"
7378 x, y -> do
7479 let
7580 _ = spy "x" x
7681
7782 _ = spy "y" y
78− unsafeCrashWith "Untreated branch second, fix me"
83+ unsafeCrashWith "Untreated branch (3), fix me"
7984
8085instance wfJSSElem ∷ WriteForeign (JSSElem props) where
8186 writeImpl = case _ of
@@ -117,6 +122,13 @@ instance jssAbleCss ∷ JSSAble p (StyleM Unit) where
117122 rules = runS someCss
118123 ruleToObject = case _ of
119124 Property (Key k) (Value v) -> Object.singleton (plain k) (jss (plain v))
125+ Nested (Sub (Selector (Refinement preds) (Elem el))) rules -> Object.singleton (el <> foldMap predicate preds) (jss (foldMap ruleToObject rules))
126+ Keyframe (Keyframes name frames) ->
127+ frames
128+ # foldMap \(Tuple pos rules) ->
129+ Object.singleton
130+ (show (round pos) <> "%")
131+ (NestedJss (foldMap ruleToObject rules))
120132 x ->
121133 unsafeCrashWith do
122134 let
components/src/Yoga/Monaco/Editor.purs+1−1
@@ -114,7 +114,7 @@ mkEditor = do
114114 eddy <- monacoEditor
115115 liftEffect $ modifyEditor (const (Just eddy))
116116 theme <- useTheme
117− useEffect theme do
117+ useEffect theme.backgroundColour do
118118 for_ maybeMonaco (initEditor theme)
119119 pure mempty
120120 let
components/src/Yoga/SVG/Image.purs+2−1
@@ -3,6 +3,7 @@ module Yoga.SVG.Image where
33import Prelude
44import Color (toHexString)
55import Data.Array (elem, foldl, head, intercalate, snoc, uncons, zip, (:))
6+import Data.Array.NonEmpty as NEA
67import Data.Int (round, toNumber)
78import Data.Maybe (Maybe(..), maybe)
89import Data.String (codePointFromChar)
@@ -45,7 +46,7 @@ mkLandingPageBackground = do
4546 { fill: if theme.isLight then "url(#_Linear9)" else "url(#_Linear12)"
4647 }
4748 , screenText:
48− { fontFamily: theme.codeFontFamily
49+ { fontFamily: NEA.head theme.codeFontFamily
4950 , fontSize: "0.85em"
5051 , fill: theme.textColour # toHexString
5152 }
components/src/Yoga/Theme.purs+47−5
@@ -1,10 +1,10 @@
11module Yoga.Theme where
22
33import Prelude
4−import CSS (contrast, darken, isLight, lighten, rotateHue)
4+import CSS (CSSVariable, Size, contrast, darken, isLight, lighten, reference, rotateHue, unitless, variable, (!*))
5+import CSS.Size (Calc, (!/))
56import Color (Color)
67import Color as Color
7−import Data.Foldable (intercalate)
88import Data.Maybe (fromMaybe)
99import Data.Symbol (SProxy(..))
1010import Record.Builder as RB
@@ -85,14 +85,56 @@ fromTheme theme =
8585 (theme.altHighlightColour # darken 0.2)
8686 -- fonts
8787
88− >>> RB.modify (f ∷ _ "textFontFamily") (intercalate ",")
89− >>> RB.modify (f ∷ _ "headingFontFamily") (intercalate ",")
90− >>> RB.modify (f ∷ _ "codeFontFamily") (intercalate ",")
88+ -- >>> RB.modify (f ∷ _ "textFontFamily") (intercalate ",")
89+
90+ -- >>> RB.modify (f ∷ _ "headingFontFamily") (intercalate ",")
91+
92+ -- >>> RB.modify (f ∷ _ "codeFontFamily") (intercalate ",")
93+
9194 >>> RB.insert (f ∷ _ "isLight") isLightTheme
95+ -- variables
96+
9297 >>> RB.insert (f ∷ _ "fontWeightBold") "300"
98+ >>> RB.insert (f ∷ _ "ratioVar") (ratio)
99+ >>> RB.insert (f ∷ _ "s0Var") (s0)
100+ >>> RB.modify (f ∷ _ "s0") (const $ reference s0)
101+ >>> RB.modify (f ∷ _ "ratio") (const $ reference ratio)
102+ >>> RB.insert (f ∷ _ "s1Var") s1
103+ >>> RB.insert (f ∷ _ "s2Var") s2
104+ >>> RB.insert (f ∷ _ "s3Var") s3
105+ >>> RB.insert (f ∷ _ "s4Var") s4
106+ >>> RB.insert (f ∷ _ "s5Var") s5
107+ >>> RB.insert (f ∷ _ "s_1Var") s_1
108+ >>> RB.insert (f ∷ _ "s_2Var") s_2
109+ >>> RB.insert (f ∷ _ "s_3Var") s_3
110+ >>> RB.insert (f ∷ _ "s_4Var") s_4
111+ >>> RB.insert (f ∷ _ "s_5Var") s_5
112+ >>> RB.insert (f ∷ _ "s1") (reference s1)
113+ >>> RB.insert (f ∷ _ "s2") (reference s2)
114+ >>> RB.insert (f ∷ _ "s3") (reference s3)
115+ >>> RB.insert (f ∷ _ "s4") (reference s4)
116+ >>> RB.insert (f ∷ _ "s5") (reference s5)
117+ >>> RB.insert (f ∷ _ "s_1") (reference s_1)
118+ >>> RB.insert (f ∷ _ "s_2") (reference s_2)
119+ >>> RB.insert (f ∷ _ "s_3") (reference s_3)
120+ >>> RB.insert (f ∷ _ "s_4") (reference s_4)
121+ >>> RB.insert (f ∷ _ "s_5") (reference s_5)
93122 )
94123 theme
95124 where
125+ ratio ∷ CSSVariable (Size Calc)
126+ ratio = variable "ratio" (unitless theme.ratio !* unitless 1.0)
127+ s5 = variable "s5" (reference s4 !* reference ratio)
128+ s4 = variable "s4" (reference s3 !* reference ratio)
129+ s3 = variable "s3" (reference s2 !* reference ratio)
130+ s2 = variable "s2" (reference s1 !* reference ratio)
131+ s1 = variable "s1" (reference s0 !* reference ratio)
132+ s0 = variable "s0" (theme.s0)
133+ s_1 = variable "s-1" (reference s0 !/ reference ratio)
134+ s_2 = variable "s-2" (reference s_1 !/ reference ratio)
135+ s_3 = variable "s-3" (reference s_2 !/ reference ratio)
136+ s_4 = variable "s-4" (reference s_3 !/ reference ratio)
137+ s_5 = variable "s-5" (reference s_4 !/ reference ratio)
96138 isLightTheme = isLight theme.backgroundColour
97139 lighter ∷ Color -> Color
98140 lighter = if isLightTheme then lighten 0.04 else lighten 0.02
components/src/Yoga/Theme/CSSBaseline.purs+26−19
@@ -1,7 +1,9 @@
11module Yoga.Theme.CSSBaseline where
22
33import Prelude hiding (add)
4+import CSS (declare)
45import Color (toHexString)
6+import Data.Array.NonEmpty as NEA
57import Effect (Effect)
68import JSS (JSSClasses, JSSElem, jss, jssClasses)
79import React.Basic (ReactComponent)
@@ -10,7 +12,7 @@ import React.Basic.Hooks as React
1012import Yoga.Font.Rubik as Rubik
1113import Yoga.Font.VictorMono as VictorMono
1214import Yoga.Theme.Styles (makeStylesJSS)
13−import Yoga.Theme.Types (YogaTheme)
15+import Yoga.Theme.Types (YogaTheme, CSSTheme)
1416
1517mkCssBaseline ∷
1618 Effect (ReactComponent { kids ∷ Array JSX })
@@ -29,22 +31,21 @@ html =
2931 , boxSizing: "border-box"
3032 }
3133
32−root ∷ JSSElem {}
33−root =
34− jss
35− { "--ratio": "1.5"
36− , "--s-5": "calc(var(--s-4) / var(--ratio))"
37− , "--s-4": "calc(var(--s-3) / var(--ratio))"
38− , "--s-3": "calc(var(--s-2) / var(--ratio))"
39− , "--s-2": "calc(var(--s-1) / var(--ratio))"
40− , "--s-1": "calc(var(--s0) / var(--ratio))"
41− , "--s0": "1rem"
42− , "--s1": "calc(var(--s0) * var(--ratio))"
43− , "--s2": "calc(var(--s1) * var(--ratio))"
44− , "--s3": "calc(var(--s2) * var(--ratio))"
45− , "--s4": "calc(var(--s3) * var(--ratio))"
46− , "--s5": "calc(var(--s4) * var(--ratio))"
47− }
34+root ∷ CSSTheme -> JSSElem {}
35+root theme =
36+ jss do
37+ declare theme.ratioVar
38+ declare theme.s_5Var
39+ declare theme.s_4Var
40+ declare theme.s_3Var
41+ declare theme.s_2Var
42+ declare theme.s_1Var
43+ declare theme.s0Var
44+ declare theme.s1Var
45+ declare theme.s2Var
46+ declare theme.s3Var
47+ declare theme.s4Var
48+ declare theme.s5Var
4849
4950styles ∷ JSSClasses YogaTheme {} ( "@global" ∷ JSSElem {} )
5051styles =
@@ -53,7 +54,7 @@ styles =
5354 jss
5455 { html
5556 , "@font-face": jss (Rubik.fontFamilies <> VictorMono.fontFamilies)
56− , ":root": root
57+ , ":root": root theme
5758 , "*":
5859 { maxWidth: theme.measure
5960 }
@@ -73,7 +74,7 @@ styles =
7374 { margin: 0
7475 , backgroundColor: theme.backgroundColour # toHexString
7576 , color: theme.textColour # toHexString
76− , fontFamily: theme.textFontFamily
77+ , fontFamily: NEA.head theme.textFontFamily
7778 , "&::backdrop":
7879 { backgroundColor: theme.backgroundColour # toHexString
7980 }
@@ -98,5 +99,11 @@ styles =
9899 { "font-size": "var(--s1)"
99100 , "text-transform": "uppercase"
100101 }
102+ , "code, pre":
103+ { fontFamily: NEA.head theme.codeFontFamily
104+ , lineHeight: "var(--ratio)"
105+ , fontSize: "var(--s0)"
106+ , fontSmooth: "never"
107+ }
101108 }
102109 }
components/src/Yoga/Theme/Default.purs+4−1
@@ -1,6 +1,7 @@
11module Yoga.Theme.Default where
22
33import Prelude
4+import CSS (rem)
45import Color as Color
56import Data.Array.NonEmpty (cons')
67import Data.Maybe (fromMaybe')
@@ -23,7 +24,7 @@ darkTheme =
2324 , altHighlightColour: Color.hsl 84.0 0.617 0.631
2425 , textFontFamily: cons' "Rubik" systemFontStack
2526 , headingFontFamily: cons' "Rubik" systemFontStack
26− , codeFontFamily: cons' "'VictorMono'" [ "monospace" ]
27+ , codeFontFamily: cons' "VictorMono" []
2728 , yellow: Color.rgb 255 235 149
2829 , green: Color.hsl 84.0 0.617 0.631
2930 , pink: Color.hsl 276.0 0.677 0.745
@@ -35,6 +36,8 @@ darkTheme =
3536 , white: Color.rgb 250 250 250
3637 , measure: "60ch"
3738 , borderThin: "0.125rem"
39+ , ratio: 1.5
40+ , s0: 1.0 # rem
3841 }
3942
4043lightTheme ∷ Theme
components/src/Yoga/Theme/Types.purs+31−3
@@ -1,5 +1,7 @@
11module Yoga.Theme.Types where
22
3+import CSS (CSSVariable, Rel, Size)
4+import CSS.Size (Calc)
35import Color (Color)
46import Data.Array.NonEmpty (NonEmptyArray)
57
@@ -23,6 +25,8 @@ type Theme
2325 , grey ∷ Color
2426 , measure ∷ String
2527 , borderThin ∷ String
28+ , ratio ∷ Number
29+ , s0 ∷ Size Rel
2630 }
2731
2832type YogaTheme
@@ -48,9 +52,9 @@ type YogaTheme
4852 , altHighlightColour ∷ Color
4953 , altHighlightColourDark ∷ Color
5054 , isLight ∷ Boolean
51− , textFontFamily ∷ String
52− , headingFontFamily ∷ String
53− , codeFontFamily ∷ String
55+ , textFontFamily ∷ NonEmptyArray String
56+ , headingFontFamily ∷ NonEmptyArray String
57+ , codeFontFamily ∷ NonEmptyArray String
5458 , yellow ∷ Color
5559 , green ∷ Color
5660 , pink ∷ Color
@@ -63,6 +67,30 @@ type YogaTheme
6367 , fontWeightBold ∷ String
6468 , measure ∷ String
6569 , borderThin ∷ String
70+ , ratioVar ∷ CSSVariable (Size Calc)
71+ , s_5Var ∷ CSSVariable (Size Calc)
72+ , s_4Var ∷ CSSVariable (Size Calc)
73+ , s_3Var ∷ CSSVariable (Size Calc)
74+ , s_2Var ∷ CSSVariable (Size Calc)
75+ , s_1Var ∷ CSSVariable (Size Calc)
76+ , s0Var ∷ CSSVariable (Size Rel)
77+ , s1Var ∷ CSSVariable (Size Calc)
78+ , s2Var ∷ CSSVariable (Size Calc)
79+ , s3Var ∷ CSSVariable (Size Calc)
80+ , s4Var ∷ CSSVariable (Size Calc)
81+ , s5Var ∷ CSSVariable (Size Calc)
82+ , s0 ∷ Size Rel
83+ , ratio ∷ Size Calc
84+ , s_5 ∷ Size Calc
85+ , s_4 ∷ Size Calc
86+ , s_3 ∷ Size Calc
87+ , s_2 ∷ Size Calc
88+ , s_1 ∷ Size Calc
89+ , s1 ∷ Size Calc
90+ , s2 ∷ Size Calc
91+ , s3 ∷ Size Calc
92+ , s4 ∷ Size Calc
93+ , s5 ∷ Size Calc
6694 )
6795
6896type CSSTheme
components/src/Yoga/Typography/Header.purs+4−3
@@ -3,6 +3,7 @@ module Yoga.Typography.Header where
33import Prelude
44import Color (toHexString)
55import Data.Array as Array
6+import Data.Array.NonEmpty as NEA
67import Data.Foldable (intercalate)
78import Data.Maybe (Maybe)
89import Effect (Effect)
@@ -28,7 +29,7 @@ mkH = do
2829 $ jssClasses \(theme ∷ CSSTheme) ->
2930 { common:
3031 { color: theme.textColour # toHexString
31− , fontFamily: theme.headingFontFamily
32+ , fontFamily: NEA.head theme.headingFontFamily
3233 }
3334 , h1:
3435 { textTransform: "uppercase"
@@ -45,8 +46,8 @@ mkH = do
4546 , padding: 0
4647 }
4748 , h3:
48− { -- fontSize: "2.2em"
49− margin: 0
49+ { fontSize: "2.2em"
50+ , margin: 0
5051 , padding: 0
5152 }
5253 , h4:
components/src/Yoga/Typography/Paragraph.purs−1
@@ -17,7 +17,6 @@ mkP = do
1717 $ jssClasses \(theme ∷ CSSTheme) ->
1818 { p:
1919 { color: theme.textColour # toHexString
20− , fontFamily: theme.textFontFamily
2120 , fontSize: "1em"
2221 , margin: "0.67em 0 0.33em 0"
2322 , padding: "0.67em 0 0.33em 0"
server/package-lock.json+3−4
@@ -945,10 +945,9 @@
945945 }
946946 },
947947 "minimist": {
948− "version": "1.2.0",
949− "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
950− "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
951− "dev": true
948+ "version": "1.2.5",
949+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
950+ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
952951 },
953952 "minipass": {
954953 "version": "2.9.0",
server/package.json+2−1
@@ -17,7 +17,8 @@
1717 "express": "^4.17.1",
1818 "fs-extra": "^9.0.0",
1919 "json-parser": "^3.1.2",
20− "uuid": "^7.0.2"
20+ "uuid": "^7.0.2",
21+ "minimist": "^1.2.2"
2122 },
2223 "devDependencies": {
2324 "purescript": "^0.13.6",