diff --git a/frontend/src/app/main/ui/ds/foundations/heading.cljs b/frontend/src/app/main/ui/ds/foundations/heading.cljs index 4d0545dbc..59c8e3dde 100644 --- a/frontend/src/app/main/ui/ds/foundations/heading.cljs +++ b/frontend/src/app/main/ui/ds/foundations/heading.cljs @@ -9,7 +9,7 @@ [app.common.data.macros :as dm] [app.main.style :as stl]) (:require - [app.main.ui.ds.foundations.typography :refer [typography-list]] + [app.main.ui.ds.foundations.typography :as t] [rumext.v2 :as mf])) (defn- valid-level? [value] @@ -17,7 +17,7 @@ (contains? number-set (dm/str value)))) (defn- valid-typography? [value] - (contains? typography-list value)) + (contains? t/typography-list value)) (mf/defc heading* {::mf/props :obj} @@ -31,17 +31,17 @@ (let [level (or level "1") tag (dm/str "h" level) - class (dm/str (or class "") " " (stl/css-case :display-typography (= typography "display") - :title-large-typography (= typography "title-large") - :title-medium-typography (= typography "title-medium") - :title-small-typography (= typography "title-small") - :headline-large-typography (= typography "headline-large") - :headline-medium-typography (= typography "headline-medium") - :headline-small-typography (= typography "headline-small") - :body-large-typography (= typography "body-large") - :body-medium-typography (= typography "body-medium") - :body-small-typography (= typography "body-small") - :code-font-typography (= typography "code-font"))) + class (dm/str (or class "") " " (stl/css-case :display-typography (= typography t/display) + :title-large-typography (= typography t/title-large) + :title-medium-typography (= typography t/title-medium) + :title-small-typography (= typography t/title-small) + :headline-large-typography (= typography t/headline-large) + :headline-medium-typography (= typography t/headline-medium) + :headline-small-typography (= typography t/headline-small) + :body-large-typography (= typography t/body-large) + :body-medium-typography (= typography t/body-medium) + :body-small-typography (= typography t/body-small) + :code-font-typography (= typography t/code-font))) props (mf/spread-props props {:class class})] [:> tag props children])) diff --git a/frontend/src/app/main/ui/ds/foundations/heading.mdx b/frontend/src/app/main/ui/ds/foundations/heading.mdx index 85380a760..52e3bb120 100644 --- a/frontend/src/app/main/ui/ds/foundations/heading.mdx +++ b/frontend/src/app/main/ui/ds/foundations/heading.mdx @@ -16,7 +16,6 @@ This components accepts to props: You can check passed props to renderized components on hover `level / typography`; - ### Using typography IDs There are typography ID definitions you can use in your code rather than typing the diff --git a/frontend/src/app/main/ui/ds/foundations/text.cljs b/frontend/src/app/main/ui/ds/foundations/text.cljs index 3b74ba853..180ee703f 100644 --- a/frontend/src/app/main/ui/ds/foundations/text.cljs +++ b/frontend/src/app/main/ui/ds/foundations/text.cljs @@ -9,29 +9,31 @@ [app.common.data.macros :as dm] [app.main.style :as stl]) (:require - [app.main.ui.ds.foundations.typography :refer [typography-list]] + [app.main.ui.ds.foundations.typography :as t] [rumext.v2 :as mf])) (defn- valid-typography? [value] - (contains? typography-list value)) + (contains? t/typography-list value)) (mf/defc text* {::mf/props :obj} - [{:keys [tag typography children] :rest props}] + [{:keys [tag typography children class] :rest props}] (assert (valid-typography? (dm/str typography)) (dm/str typography " is an unknown typography")) - (let [props (mf/spread-props props {:class (stl/css-case :display-typography (= typography "display") - :title-large-typography (= typography "title-large") - :title-medium-typography (= typography "title-medium") - :title-small-typography (= typography "title-small") - :headline-large-typography (= typography "headline-large") - :headline-medium-typography (= typography "headline-medium") - :headline-small-typography (= typography "headline-small") - :body-large-typography (= typography "body-large") - :body-medium-typography (= typography "body-medium") - :body-small-typography (= typography "body-small") - :code-font-typography (= typography "code-font"))})] + (let [tag (or tag "p") + class (dm/str (or class "") " " (stl/css-case :display-typography (= typography t/display) + :title-large-typography (= typography t/title-large) + :title-medium-typography (= typography t/title-medium) + :title-small-typography (= typography t/title-small) + :headline-large-typography (= typography t/headline-large) + :headline-medium-typography (= typography t/headline-medium) + :headline-small-typography (= typography t/headline-small) + :body-large-typography (= typography t/body-large) + :body-medium-typography (= typography t/body-medium) + :body-small-typography (= typography t/body-small) + :code-font-typography (= typography t/code-font))) + props (mf/spread-props props {:class class})] [:> tag props children])) diff --git a/frontend/src/app/main/ui/ds/foundations/text.mdx b/frontend/src/app/main/ui/ds/foundations/text.mdx new file mode 100644 index 000000000..0f526cf27 --- /dev/null +++ b/frontend/src/app/main/ui/ds/foundations/text.mdx @@ -0,0 +1,48 @@ +import { Canvas, Meta } from "@storybook/blocks"; +import * as TextStories from "./text.stories"; + + + +# Texts +This component will add a text element to our code that will match the tag prop. + +## Technical notes + +This components accepts to props: + +- `tag` (default value: `p`) : Give a proper tag name (i.e. `p`, `span`, etc.). +- `typography` (mandatory): Any of the [supported typography IDs](?path=/docs/foundations-typography--docs). + +You can check passed props to renderized components on hover `tag / typography` + + +### Using typography IDs + +There are typography ID definitions you can use in your code rather than typing the +typography ID by hand. + +**Using these IDs is recommended**. + +Assuming the namespace of the typography is required as `t`: + +```clj +(ns app.main.ui.foo + (:require + [app.main.ui.ds.foundations.text :refer [text*]] + [app.main.ui.ds.foundations.typography :as t])) +``` + +You can now use the typography IDs defined in the namespace: + +```clj +[:> text* {:typography t/title-large :tag "p"} "Welcome to Penpot"] +``` + +## Accesibility + +There should only be one level 1 heading `