Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): name an attribute's type in its icon's tooltip

Elian Doran34f9f9a8c4dd
diff --git a/apps/client/src/widgets/react/PromotedAttributesCard.css b/apps/client/src/widgets/react/PromotedAttributesCard.css
index 31829fc137..9c931c8bfa 100644
--- a/apps/client/src/widgets/react/PromotedAttributesCard.css
+++ b/apps/client/src/widgets/react/PromotedAttributesCard.css
@@ -7,13 +7,6 @@
white-space: nowrap;
}
- /* Reads as a note about the row rather than as something to press. */
- .promoted-attribute-type {
- flex-shrink: 0;
- --color: var(--muted-text-color);
- font-size: 0.8em;
- }
-
/* Shaped like `.shortcut-conflicts-badge`, in the warning color `MfaStatusBadge` uses. */
.promoted-attribute-conflict {
flex-shrink: 0;
diff --git a/apps/client/src/widgets/react/PromotedAttributesCard.spec.tsx b/apps/client/src/widgets/react/PromotedAttributesCard.spec.tsx
index ee5d17c58e..5525d16c03 100644
--- a/apps/client/src/widgets/react/PromotedAttributesCard.spec.tsx
+++ b/apps/client/src/widgets/react/PromotedAttributesCard.spec.tsx
@@ -125,7 +125,8 @@ describe("PromotedAttributesCard", () => {
expect(icons()).toEqual([
"bx bx-calendar", "bx bx-toggle-left", "bx bx-text", "bx bx-transfer"
]);
- // And says which kind it is, in the words the editor lists them under.
+ // Named in the words the editor lists them under, as the icon's tooltip rather than a badge.
+ expect(container.querySelector(".promoted-attribute-type")).toBeNull();
expect(types()).toEqual([
"attribute_detail.date", "attribute_detail.boolean", "attribute_detail.text",
"attribute_detail.relation_type"
@@ -544,7 +545,7 @@ describe("PromotedAttributesCard", () => {
function types() {
return segments().map((segment) =>
- segment.querySelector(".promoted-attribute-type .text")?.textContent);
+ segment.querySelector(".tn-icon")?.getAttribute("aria-label"));
}
function icons() {
diff --git a/apps/client/src/widgets/react/PromotedAttributesCard.tsx b/apps/client/src/widgets/react/PromotedAttributesCard.tsx
index d9de34c10c..68259894ef 100644
--- a/apps/client/src/widgets/react/PromotedAttributesCard.tsx
+++ b/apps/client/src/widgets/react/PromotedAttributesCard.tsx
@@ -21,7 +21,7 @@ import ActionButton from "./ActionButton";
import { Badge } from "./Badge";
import FormToggle from "./FormToggle";
import { useTriliumEvent } from "./hooks";
-import Icon from "./Icon";
+import { TooltipIcon } from "./Icon";
import { type SortableItem, SortableCard } from "./SortableCard";
/** Each kind of definition by name, holding the title and icon `AttributeDetail` lists it with. */
@@ -262,14 +262,14 @@ export default function PromotedAttributesCard({
const attribute = shown.find((candidate) => candidate.name === item.key);
return attribute && (
<>
- {item.icon && <Icon icon={item.icon} />}
- <span className="promoted-attribute-name">{item.caption}</span>
-
- <Badge
- className="promoted-attribute-type"
- text={promotedAttributeType(attribute).title}
- outline
+ <TooltipIcon
+ icon={item.icon}
+ tooltip={promotedAttributeType(attribute).title}
+ tooltipClass="tooltip-top"
+ role="img"
+ aria-label={promotedAttributeType(attribute).title}
/>
+ <span className="promoted-attribute-name">{item.caption}</span>
{attribute.isConflicting && (
<Badge