mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 22:10:34 +00:00
✨ Show the list style in Inspect
Text paragraphs with list-style-type "disc" now show a "List Style" row in the Inspect Styles and Computed views, after Text Transform. Its copy action gives "list-style-type: disc;". Text without a list shows no row. The list item check lives in common as list-paragraph?, so every place that needs it shares one rule. Refs #12630 AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
0140a31c37
commit
28068f0503
@ -146,6 +146,11 @@
|
||||
"Older paragraphs have no list attrs; read them as no list."
|
||||
{:list-style-type "none"})
|
||||
|
||||
(defn list-paragraph?
|
||||
"True when a paragraph (or its merged style map) is a list item."
|
||||
[node]
|
||||
(= "disc" (:list-style-type node)))
|
||||
|
||||
(def default-text-attrs
|
||||
{:typography-ref-file nil
|
||||
:typography-ref-id nil
|
||||
|
||||
@ -368,3 +368,8 @@
|
||||
|
||||
(t/is (every? #(= % "14") original-font-sizes))
|
||||
(t/is (every? #(= % "32") updated-font-sizes))))
|
||||
|
||||
(t/deftest test-list-paragraph
|
||||
(t/is (true? (cttx/list-paragraph? {:type "paragraph" :list-style-type "disc"})))
|
||||
(t/is (false? (cttx/list-paragraph? {:type "paragraph" :list-style-type "none"})))
|
||||
(t/is (false? (cttx/list-paragraph? {:type "paragraph"}))))
|
||||
|
||||
@ -129,6 +129,14 @@
|
||||
"uppercase" (tr "inspect.attributes.typography.text-transform.uppercase")
|
||||
"unset" (tr "inspect.attributes.typography.text-transform.unset"))]]]])
|
||||
|
||||
(when (types.text/list-paragraph? style)
|
||||
[:div {:class (stl/css :text-row)}
|
||||
[:div {:class (stl/css :global/attr-label)} "List Style"]
|
||||
[:div {:class (stl/css :global/attr-value)}
|
||||
[:> copy-button* {:data (copy-style-data style :list-style-type)}
|
||||
[:div {:class (stl/css :button-children)}
|
||||
(tr "inspect.attributes.typography.list-style-type.disc")]]]])
|
||||
|
||||
[:> copy-button* {:data (str/trim text)
|
||||
:class (stl/css :attributes-content-row)}
|
||||
[:span {:class (stl/css :content)
|
||||
|
||||
@ -180,6 +180,12 @@
|
||||
:property (str "text-transform: " (:text-transform style) ";")
|
||||
:copiable true}]))
|
||||
|
||||
(when (txt/list-paragraph? style)
|
||||
[:> properties-row* {:term "List Style"
|
||||
:detail (:list-style-type style)
|
||||
:property (str "list-style-type: " (:list-style-type style) ";")
|
||||
:copiable true}])
|
||||
|
||||
[:pre {:class (stl/css :text-content-wrapper)
|
||||
:role "presentation"}
|
||||
[:> property-detail-copiable* {:copied copied
|
||||
|
||||
@ -129,6 +129,7 @@
|
||||
[frontend-tests.ui.history-test]
|
||||
[frontend-tests.ui.inspect-geometry-test]
|
||||
[frontend-tests.ui.inspect-stroke-tokens-test]
|
||||
[frontend-tests.ui.inspect-text-list-test]
|
||||
[frontend-tests.ui.jobs-progress-test]
|
||||
[frontend-tests.ui.layout-container-multiple-test]
|
||||
[frontend-tests.ui.mcp-authorize-test]
|
||||
@ -298,6 +299,7 @@
|
||||
'frontend-tests.ui.history-test
|
||||
'frontend-tests.ui.inspect-geometry-test
|
||||
'frontend-tests.ui.inspect-stroke-tokens-test
|
||||
'frontend-tests.ui.inspect-text-list-test
|
||||
'frontend-tests.ui.jobs-progress-test
|
||||
'frontend-tests.ui.layout-container-multiple-test
|
||||
'frontend-tests.ui.measurements-test
|
||||
|
||||
61
frontend/test/frontend_tests/ui/inspect_text_list_test.cljs
Normal file
61
frontend/test/frontend_tests/ui/inspect_text_list_test.cljs
Normal file
@ -0,0 +1,61 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns frontend-tests.ui.inspect-text-list-test
|
||||
(:require
|
||||
["react-dom/server" :as rds]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.main.ui.hooks :as hooks]
|
||||
[app.main.ui.inspect.attributes.text :as attributes-text]
|
||||
[app.main.ui.inspect.styles.panels.text :as styles-text]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[cuerdas.core :as str]
|
||||
[frontend-tests.helpers.mock :as mock]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn- text-shape
|
||||
[paragraph-attrs]
|
||||
{:id (uuid/next)
|
||||
:type :text
|
||||
:content {:type "root"
|
||||
:children [{:type "paragraph-set"
|
||||
:children [(merge {:type "paragraph"
|
||||
:children [{:text "Item"
|
||||
:font-id "sourcesanspro"
|
||||
:font-family "sourcesanspro"
|
||||
:font-size "14"}]}
|
||||
paragraph-attrs)]}]}})
|
||||
|
||||
(defn- render-panel
|
||||
[panel shapes]
|
||||
(rds/renderToStaticMarkup
|
||||
(mf/element panel
|
||||
#js {:shapes shapes
|
||||
:resolvedTokens {}
|
||||
:colorSpace "hex"
|
||||
:onFontShorthand identity})))
|
||||
|
||||
(t/deftest text-panels-show-the-list-style
|
||||
(with-redefs [cf/flags (conj cf/flags :inspect-styles)
|
||||
hooks/use-portal-container (mock/stub (fn [_] nil))]
|
||||
(let [shapes [(text-shape {:list-style-type "disc"})]]
|
||||
(t/testing "styles tab"
|
||||
(let [markup (render-panel styles-text/text-panel* shapes)]
|
||||
(t/is (str/includes? markup "List Style"))
|
||||
(t/is (str/includes? markup ">disc<"))))
|
||||
(t/testing "computed tab"
|
||||
(let [markup (render-panel attributes-text/text-panel* shapes)]
|
||||
(t/is (str/includes? markup "List Style"))
|
||||
(t/is (str/includes? markup "inspect.attributes.typography.list-style-type.disc")))))))
|
||||
|
||||
(t/deftest text-panels-hide-the-list-style-without-a-list
|
||||
(with-redefs [cf/flags (conj cf/flags :inspect-styles)
|
||||
hooks/use-portal-container (mock/stub (fn [_] nil))]
|
||||
(doseq [paragraph-attrs [{} {:list-style-type "none"}]
|
||||
panel [styles-text/text-panel* attributes-text/text-panel*]]
|
||||
(let [markup (render-panel panel [(text-shape paragraph-attrs)])]
|
||||
(t/is (not (str/includes? markup "List Style")))))))
|
||||
@ -2245,6 +2245,10 @@ msgstr "Letter Spacing"
|
||||
msgid "inspect.attributes.typography.line-height"
|
||||
msgstr "Line Height"
|
||||
|
||||
#: src/app/main/ui/inspect/attributes/text.cljs:138
|
||||
msgid "inspect.attributes.typography.list-style-type.disc"
|
||||
msgstr "Disc"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/typography.cljs:594
|
||||
msgid "inspect.attributes.typography.mixed-font-family"
|
||||
msgstr "Mixed Font Families"
|
||||
|
||||
@ -2281,6 +2281,10 @@ msgstr "Espaciado de letras"
|
||||
msgid "inspect.attributes.typography.line-height"
|
||||
msgstr "Interlineado"
|
||||
|
||||
#: src/app/main/ui/inspect/attributes/text.cljs:138
|
||||
msgid "inspect.attributes.typography.list-style-type.disc"
|
||||
msgstr "Disco"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/typography.cljs:594
|
||||
msgid "inspect.attributes.typography.mixed-font-family"
|
||||
msgstr "Varias Familias tipográficas"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user