mirror of
https://github.com/penpot/penpot.git
synced 2026-11-10 03:50:33 +00:00
Since stroke widths can be set per side, stroke width tokens are stored in the four per-side attributes, not in :stroke-width. The inspect stroke panel still read :stroke-width for Border width and had no token lookup for the per-side widths, so it showed the raw value instead of the token. Read the token of each side for the per-side widths, and the token shared by every side for Border width. Files that are not migrated yet keep the token in :stroke-width, so Border width still falls back to it. Closes #12029 AI-assisted-by: claude-opus-5-5
44 lines
2.0 KiB
Clojure
44 lines
2.0 KiB
Clojure
;; 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-stroke-tokens-test
|
|
(:require
|
|
[app.common.types.token :as cto]
|
|
[app.main.ui.inspect.styles.panels.stroke :as stroke]
|
|
[cljs.test :as t :include-macros true]))
|
|
|
|
(def ^:private all-sides-sw-3
|
|
(zipmap cto/per-side-stroke-width-keys (repeat "sw-3")))
|
|
|
|
(t/deftest border-width-shows-the-token-applied-to-every-side
|
|
(t/is (= "sw-3" (stroke/stroke-property-token-name all-sides-sw-3 :border-width))))
|
|
|
|
(t/deftest border-width-shows-no-token-when-the-sides-differ
|
|
(t/is (nil? (stroke/stroke-property-token-name
|
|
(assoc all-sides-sw-3 :stroke-width-top "sw-10") :border-width)))
|
|
(t/is (nil? (stroke/stroke-property-token-name
|
|
{:stroke-width-top "sw-3"} :border-width))))
|
|
|
|
(t/deftest border-width-reads-the-legacy-key-of-unmigrated-files
|
|
(t/is (= "sw-3" (stroke/stroke-property-token-name {:stroke-width "sw-3"} :border-width))))
|
|
|
|
(t/deftest per-side-widths-show-the-token-of-each-side
|
|
(let [applied {:stroke-width-top "sw-10"
|
|
:stroke-width-right "sw-3"
|
|
:stroke-width-bottom "sw-3"
|
|
:stroke-width-left "sw-4"}]
|
|
(t/is (= "sw-10" (stroke/stroke-property-token-name applied :border-block-start-width)))
|
|
(t/is (= "sw-3" (stroke/stroke-property-token-name applied :border-inline-end-width)))
|
|
(t/is (= "sw-3" (stroke/stroke-property-token-name applied :border-block-end-width)))
|
|
(t/is (= "sw-4" (stroke/stroke-property-token-name applied :border-inline-start-width)))))
|
|
|
|
(t/deftest per-side-widths-without-a-token-show-none
|
|
(t/is (nil? (stroke/stroke-property-token-name
|
|
{:stroke-width-top "sw-10"} :border-inline-end-width))))
|
|
|
|
(t/deftest border-color-keeps-the-stroke-color-token
|
|
(t/is (= "red" (stroke/stroke-property-token-name {:stroke-color "red"} :border-color))))
|