mirror of
https://github.com/penpot/penpot.git
synced 2025-05-24 00:56:10 +02:00
🐛 Fix text ellipsis on long token names and grouped tokens
This commit is contained in:
parent
6eea633ca9
commit
68a0d74f0e
4 changed files with 61 additions and 14 deletions
|
@ -640,6 +640,13 @@
|
||||||
(let [path-split (split-path path)]
|
(let [path-split (split-path path)]
|
||||||
(merge-path-item (first path-split) name)))
|
(merge-path-item (first path-split) name)))
|
||||||
|
|
||||||
|
(defn split-string-half
|
||||||
|
"Split string in two halfs"
|
||||||
|
[s]
|
||||||
|
(let [len (count s)
|
||||||
|
mid (quot len 2)]
|
||||||
|
[(subs s 0 mid)
|
||||||
|
(subs s mid)]))
|
||||||
|
|
||||||
(defn get-frame-objects
|
(defn get-frame-objects
|
||||||
"Retrieves a new objects map only with the objects under frame-id (with frame-id)"
|
"Retrieves a new objects map only with the objects under frame-id (with frame-id)"
|
||||||
|
|
|
@ -70,7 +70,7 @@ test.describe("Tokens: Tokens Tab", () => {
|
||||||
await expect(submitButton).toBeEnabled();
|
await expect(submitButton).toBeEnabled();
|
||||||
await submitButton.click();
|
await submitButton.click();
|
||||||
|
|
||||||
await expect(tokensTabPanel.getByText("color.primary")).toBeEnabled();
|
await expect(tokensTabPanel.getByLabel("primary")).toBeEnabled();
|
||||||
|
|
||||||
// Create token referencing the previous one with keyboard
|
// Create token referencing the previous one with keyboard
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ test.describe("Tokens: Tokens Tab", () => {
|
||||||
await expect(submitButton).toBeEnabled();
|
await expect(submitButton).toBeEnabled();
|
||||||
await nameField.press("Enter");
|
await nameField.press("Enter");
|
||||||
|
|
||||||
const referenceToken = tokensTabPanel.getByText("color.secondary");
|
const referenceToken = tokensTabPanel.getByLabel("color.secondary");
|
||||||
await expect(referenceToken).toBeEnabled();
|
await expect(referenceToken).toBeEnabled();
|
||||||
|
|
||||||
// Tokens tab panel should have two tokens with the color red / #ff0000
|
// Tokens tab panel should have two tokens with the color red / #ff0000
|
||||||
|
@ -105,6 +105,35 @@ test.describe("Tokens: Tokens Tab", () => {
|
||||||
}),
|
}),
|
||||||
).toHaveAttribute("aria-checked", "true");
|
).toHaveAttribute("aria-checked", "true");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("User creates grouped color token", async ({ page }) => {
|
||||||
|
const { workspacePage, tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||||
|
await setupFileWithTokens(page);
|
||||||
|
|
||||||
|
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||||
|
await tokensTabPanel.getByTitle("Add token: Color").click();
|
||||||
|
|
||||||
|
// Create grouped color token with mouse
|
||||||
|
|
||||||
|
await expect(tokensUpdateCreateModal).toBeVisible();
|
||||||
|
|
||||||
|
const nameField = tokensUpdateCreateModal.getByLabel("Name");
|
||||||
|
const valueField = tokensUpdateCreateModal.getByLabel("Value");
|
||||||
|
|
||||||
|
await nameField.click();
|
||||||
|
await nameField.fill("color.dark.primary");
|
||||||
|
|
||||||
|
await valueField.click();
|
||||||
|
await valueField.fill("red");
|
||||||
|
|
||||||
|
const submitButton = tokensUpdateCreateModal.getByRole("button", {
|
||||||
|
name: "Save",
|
||||||
|
});
|
||||||
|
await expect(submitButton).toBeEnabled();
|
||||||
|
await submitButton.click();
|
||||||
|
|
||||||
|
await expect(tokensTabPanel.getByLabel("color.dark.primary")).toBeEnabled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe("Tokens: Sets Tab", () => {
|
test.describe("Tokens: Sets Tab", () => {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns app.main.ui.workspace.tokens.token-pill
|
(ns app.main.ui.workspace.tokens.token-pill
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.files.helpers :as cfh]
|
||||||
[app.common.types.tokens-lib :as ctob]
|
[app.common.types.tokens-lib :as ctob]
|
||||||
[app.main.ui.components.color-bullet :refer [color-bullet]]
|
[app.main.ui.components.color-bullet :refer [color-bullet]]
|
||||||
[app.main.ui.ds.foundations.assets.icon :refer [icon*]]
|
[app.main.ui.ds.foundations.assets.icon :refer [icon*]]
|
||||||
|
@ -17,10 +18,10 @@
|
||||||
[{:keys [on-click token theme-token full-applied on-context-menu half-applied]}]
|
[{:keys [on-click token theme-token full-applied on-context-menu half-applied]}]
|
||||||
(let [{:keys [name value resolved-value errors]} token
|
(let [{:keys [name value resolved-value errors]} token
|
||||||
errors? (or (nil? theme-token) (and (seq errors) (seq (:errors theme-token))))
|
errors? (or (nil? theme-token) (and (seq errors) (seq (:errors theme-token))))
|
||||||
|
|
||||||
color (when (seq (ctob/find-token-value-references value))
|
color (when (seq (ctob/find-token-value-references value))
|
||||||
(wtt/resolved-value-hex theme-token))
|
(wtt/resolved-value-hex theme-token))
|
||||||
|
contains-path? (str/includes? name ".")
|
||||||
|
splitted-name (cfh/split-string-half name)
|
||||||
color (or color (wtt/resolved-value-hex token))
|
color (or color (wtt/resolved-value-hex token))
|
||||||
on-click
|
on-click
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
@ -64,4 +65,13 @@
|
||||||
[:> token-status-icon*
|
[:> token-status-icon*
|
||||||
{:icon-id token-status-id
|
{:icon-id token-status-id
|
||||||
:class (stl/css :token-pill-icon)}])
|
:class (stl/css :token-pill-icon)}])
|
||||||
name]))
|
(if contains-path?
|
||||||
|
[:span {:class (stl/css :divided-name-wrapper)
|
||||||
|
:aria-label name}
|
||||||
|
[:span {:class (stl/css :first-name-wrapper)}
|
||||||
|
(first splitted-name)]
|
||||||
|
[:span {:class (stl/css :last-name-wrapper)}
|
||||||
|
(last splitted-name)]]
|
||||||
|
[:span {:class (stl/css :name-wrapper)
|
||||||
|
:aria-label name}
|
||||||
|
name])]))
|
|
@ -60,22 +60,23 @@
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-name-wrapper::before, span::after {
|
.divided-name-wrapper {
|
||||||
vertical-align: middle;
|
height: $s-16;
|
||||||
|
}
|
||||||
|
|
||||||
|
.first-name-wrapper {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
max-width: 50%;
|
max-width: 50%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
}
|
|
||||||
|
|
||||||
.group-name-wrapper::before {
|
|
||||||
content: attr(data-content-start);
|
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-name-wrapper::after {
|
.last-name-wrapper {
|
||||||
content: attr(data-content-end);
|
display: inline-block;
|
||||||
text-overflow: '';
|
max-width: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: pre;
|
||||||
direction: rtl;
|
direction: rtl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue