mirror of
https://github.com/penpot/penpot.git
synced 2026-11-26 21:00:32 +00:00
♻️ Use DS icon buttons for the Measures toggles (#13278)
* ♻️ Use DS icon buttons for the Measures toggles "Clip content" and "Show in view mode" were labels over hidden checkboxes, styled with the deprecated %button-tertiary. They become ghost icon-button* with aria-pressed: real buttons with a name, the DS tooltip instead of the browser title, and the DS pressed corners. The handlers toggle the current value instead of reading the checkbox, and the two unused refs go away. The ratio lock, already an icon-button*, marks its state with aria-pressed instead of the legacy .selected class; it looks the same. A zero-tolerance visual test shows both toggles at rest, on hover and turned off, and the ratio lock off and on. AI-assisted-by: claude-opus-5-5 * ♻️ Drop the unused button styles of the Measures menu The toggles and the ratio lock no longer use the legacy button styles, so these selectors match nothing and go away: .lock-size-btn, .lock-ratio-icon, .clip-content, .show-in-viewer, .clip-content-input, .clip-content-label, .selected and .checkbox-button. Also .numeric-input-measures, which no module uses. A grep over frontend/src found no other use of any of them. .clip-show takes the DS spacing token. The refactor/ import stays for the presets dropdown and the inputs, which move to the DS with the selects and inputs groups. The visual test shows 0 px against the previous commit. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
9977a4fbc6
commit
6aedbc330e
@ -368,6 +368,50 @@ test.describe("Design tab", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Measures controls", () => {
|
||||
test("Shows the clip content, show in view mode and ratio lock toggles", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = new WorkspacePage(page);
|
||||
await workspace.setupEmptyFile();
|
||||
await workspace.mockRPC(/get\-file\?/, "workspace/get-file-9066.json");
|
||||
await workspace.goToWorkspace({
|
||||
fileId: "e179d9df-de35-80bf-8005-283bbd5516b0",
|
||||
pageId: "e179d9df-de35-80bf-8005-283bbd5516b1",
|
||||
});
|
||||
await workspace.clickLeafLayer("Board");
|
||||
|
||||
const sidebar = workspace.rightSidebar;
|
||||
const toggles = sidebar.locator("[class*='menus_measures__clip-show']");
|
||||
// A label over a hidden checkbox before, a button after.
|
||||
const clip = sidebar
|
||||
.getByTitle("Clip content")
|
||||
.or(sidebar.getByRole("button", { name: "Clip content" }));
|
||||
const shot = { maxDiffPixelRatio: 0, threshold: 0 };
|
||||
|
||||
await expect(toggles).toBeVisible();
|
||||
await page.mouse.move(0, 0);
|
||||
await expect(toggles).toHaveScreenshot("measures-toggles-rest.png", shot);
|
||||
|
||||
await clip.hover();
|
||||
await expect(toggles).toHaveScreenshot("measures-toggles-hover.png", shot);
|
||||
|
||||
// Both start on: one click turns clip content off.
|
||||
await clip.click();
|
||||
await page.mouse.move(0, 0);
|
||||
await expect(toggles).toHaveScreenshot("measures-toggles-off.png", shot);
|
||||
|
||||
const lock = sidebar.getByRole("button", { name: /^(Lock|Unlock) ratio$/ });
|
||||
await expect(lock).toHaveScreenshot("measures-lock-off.png", shot);
|
||||
await lock.click();
|
||||
await page.mouse.move(0, 0);
|
||||
await expect(
|
||||
sidebar.getByRole("button", { name: "Unlock ratio" }),
|
||||
).toBeVisible();
|
||||
await expect(lock).toHaveScreenshot("measures-lock-on.png", shot);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Component options", () => {
|
||||
test("Shows the component pill of a copy", async ({ page }) => {
|
||||
const workspace = new WorkspacePage(page);
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
[app.main.ui.components.radio-buttons :refer [radio-button radio-buttons]]
|
||||
[app.main.ui.components.search-bar :refer [search-bar*]]
|
||||
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
|
||||
[app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
|
||||
[app.main.ui.ds.foundations.assets.icon :as i]
|
||||
[app.main.ui.icons :as deprecated-icon]
|
||||
[app.main.ui.workspace.sidebar.options.menus.border-radius :refer [border-radius-menu*]]
|
||||
[app.main.ui.workspace.sidebar.options.menus.input-wrapper-tokens :refer [numeric-input-wrapper*]]
|
||||
@ -322,11 +322,11 @@
|
||||
proportion-lock
|
||||
(get values :proportion-lock)
|
||||
|
||||
clip-content-ref
|
||||
(mf/use-ref nil)
|
||||
clip-content?
|
||||
(not (:show-content values))
|
||||
|
||||
show-in-viewer-ref
|
||||
(mf/use-ref nil)
|
||||
show-in-viewer?
|
||||
(not (:hide-in-viewer values))
|
||||
|
||||
;; PRESETS
|
||||
preset-state*
|
||||
@ -460,16 +460,16 @@
|
||||
;; CLIP CONTENT AND SHOW IN VIEWER
|
||||
on-change-clip-content
|
||||
(mf/use-fn
|
||||
(mf/deps ids)
|
||||
(fn [event]
|
||||
(let [value (-> event dom/get-target dom/checked?)]
|
||||
(mf/deps ids clip-content?)
|
||||
(fn []
|
||||
(let [value (not clip-content?)]
|
||||
(st/emit! (dwsh/update-shapes ids (fn [shape] (assoc shape :show-content (not value))))))))
|
||||
|
||||
on-change-show-in-viewer
|
||||
(mf/use-fn
|
||||
(mf/deps ids)
|
||||
(fn [event]
|
||||
(let [value (-> event dom/get-target dom/checked?)
|
||||
(mf/deps ids show-in-viewer?)
|
||||
(fn []
|
||||
(let [value (not show-in-viewer?)
|
||||
undo-id (js/Symbol)]
|
||||
(st/emit! (dwu/start-undo-transaction undo-id)
|
||||
(dwsh/update-shapes ids (fn [shape] (cls/change-show-in-viewer shape (not value)))))
|
||||
@ -610,7 +610,7 @@
|
||||
[:> icon-button* {:variant "ghost"
|
||||
:tooltip-placement "top-left"
|
||||
:icon (if proportion-lock "lock" "unlock")
|
||||
:class (stl/css-case :selected (true? proportion-lock))
|
||||
:aria-pressed (true? proportion-lock)
|
||||
:disabled (= proportion-lock :multiple)
|
||||
:aria-label (if proportion-lock (tr "workspace.options.size.unlock") (tr "workspace.options.size.lock"))
|
||||
:on-click on-proportion-lock-change}]])
|
||||
@ -708,31 +708,14 @@
|
||||
(when (or (options :clip-content) (options :show-in-viewer))
|
||||
[:div {:class (stl/css :clip-show)}
|
||||
(when (options :clip-content)
|
||||
[:div {:class (stl/css :clip-content)}
|
||||
[:input {:type "checkbox"
|
||||
:id "clip-content"
|
||||
:ref clip-content-ref
|
||||
:class (stl/css :clip-content-input)
|
||||
:checked (not (:show-content values))
|
||||
:on-change on-change-clip-content}]
|
||||
|
||||
[:label {:for "clip-content"
|
||||
:title (tr "workspace.options.clip-content")
|
||||
:class (stl/css-case :clip-content-label true
|
||||
:selected (not (:show-content values)))}
|
||||
|
||||
[:> icon* {:icon-id i/clip-content}]]])
|
||||
[:> icon-button* {:variant "ghost"
|
||||
:aria-label (tr "workspace.options.clip-content")
|
||||
:aria-pressed (boolean clip-content?)
|
||||
:on-click on-change-clip-content
|
||||
:icon i/clip-content}])
|
||||
(when (options :show-in-viewer)
|
||||
[:div {:class (stl/css :show-in-viewer)}
|
||||
[:input {:type "checkbox"
|
||||
:id "show-in-viewer"
|
||||
:ref show-in-viewer-ref
|
||||
:class (stl/css :clip-content-input)
|
||||
:checked (not (:hide-in-viewer values))
|
||||
:on-change on-change-show-in-viewer}]
|
||||
|
||||
[:label {:for "show-in-viewer"
|
||||
:title (tr "workspace.options.show-in-viewer")
|
||||
:class (stl/css-case :clip-content-label true
|
||||
:selected (not (:hide-in-viewer values)))}
|
||||
[:> icon* {:icon-id i/play}]]])])]))
|
||||
[:> icon-button* {:variant "ghost"
|
||||
:aria-label (tr "workspace.options.show-in-viewer")
|
||||
:aria-pressed (boolean show-in-viewer?)
|
||||
:on-click on-change-show-in-viewer
|
||||
:icon i/play}])])]))
|
||||
|
||||
@ -4,6 +4,9 @@
|
||||
//
|
||||
// Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
// Only for the presets dropdown (%asset-element, %dropdown-*) and the
|
||||
// inputs (%input-element, %disabled-input): they move to the DS with the
|
||||
// selects and inputs groups.
|
||||
@use "refactor/common-refactor.scss" as deprecated;
|
||||
@use "../../../sidebar/common/sidebar.scss" as sidebar;
|
||||
@use "ds/_utils.scss" as *;
|
||||
@ -182,55 +185,9 @@
|
||||
grid-column: 2/-1;
|
||||
}
|
||||
|
||||
.lock-size-btn {
|
||||
@extend %button-tertiary;
|
||||
|
||||
border-radius: deprecated.$br-8;
|
||||
height: deprecated.$s-32;
|
||||
width: deprecated.$s-28;
|
||||
|
||||
&.selected {
|
||||
@extend %button-icon-selected;
|
||||
}
|
||||
}
|
||||
|
||||
.lock-ratio-icon {
|
||||
@extend %button-icon;
|
||||
|
||||
stroke: var(--icon-foreground);
|
||||
}
|
||||
|
||||
.clip-show {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: deprecated.$s-4;
|
||||
}
|
||||
|
||||
.clip-content,
|
||||
.show-in-viewer {
|
||||
.clip-content-input {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.clip-content-label {
|
||||
@extend %button-tertiary;
|
||||
|
||||
height: var(--sp-xxxl);
|
||||
width: var(--sp-xxxl);
|
||||
border-radius: deprecated.$br-8;
|
||||
}
|
||||
|
||||
.selected {
|
||||
@extend %button-icon-selected;
|
||||
}
|
||||
|
||||
.checkbox-button {
|
||||
@extend %button-icon;
|
||||
}
|
||||
|
||||
// TODO: Add a proper variable to this sizing
|
||||
.numeric-input-measures {
|
||||
--dropdown-width: var(--seven-columns-width);
|
||||
gap: var(--sp-xs);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user