Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@geraldodev
Last active May 15, 2022 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geraldodev/0333ffe63588a94d98efb8e918dde681 to your computer and use it in GitHub Desktop.
Save geraldodev/0333ffe63588a94d98efb8e918dde681 to your computer and use it in GitHub Desktop.
(ns stitches.componentes.heading
(:require
["lodash.merge" :as js-merge]
["react" :as React]
[applied-science.js-interop :as j]
[crudis.util.helix :refer [defnc]]
[helix.core :refer [$]]
[stitches.componentes.text :refer [Text]]
))
(def default-tag "h1")
(def ^:private textSize
(j/lit
{"1" {"@initial" "4", "@bp2" "5"}
"2" {"@initial" "6", "@bp2" "7"}
"3" {"@initial" "7", "@bp2" "8"}
"4" {"@initial" "8", "@bp2" "9"}
}))
(def ^:private textCss
(j/lit
{"1" {"fontWeight" 500, "lineHeight" "20px", "@bp2" {"lineHeight" "23px"}}
"2" {"fontWeight" 500, "lineHeight" "25px", "@bp2" {"lineHeight" "30px"}}
"3" {"fontWeight" 500, "lineHeight" "33px", "@bp2" {"lineHeight" "41px"}}
"4" {"fontWeight" 500, "lineHeight" "35px", "@bp2" {"lineHeight" "55px"}}
}))
(defnc Heading
[{:keys [size css]
:or {size "1"}
:as props} ref]
{:wrap [(React/forwardRef)]}
(let [css (js-merge
#js {:fontVariantNumeric "proportional-nums"}
(j/get textCss size)
css)]
($ Text
{:as default-tag
:& (dissoc props :size :css)
:ref ref
:size (j/get textSize size)
:css css})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment