Skip to content

Build your personal knowledge base with Trilium Notes

feat(attributes): a red trash, and marks where the summary had words

Elian Doranefe0173df11c
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 7b6ef24ba6..bca6a29edb 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -816,7 +816,7 @@
"no_target": "No target note",
"no_value": "No value",
"change_target": "Change the target note",
- "inverse_of": "inverse of {{name}}",
+ "inverse_hint": "Inverse of \"{{name}}\": the target note is automatically given a \"{{name}}\" relation pointing back",
"type_label": "Label",
"type_relation": "Relation",
"type_label_definition": "Label definition",
diff --git a/apps/client/src/widgets/sidebar/AttributeList.css b/apps/client/src/widgets/sidebar/AttributeList.css
index 84ee83c715..ce8b4c1646 100644
--- a/apps/client/src/widgets/sidebar/AttributeList.css
+++ b/apps/client/src/widgets/sidebar/AttributeList.css
@@ -171,16 +171,23 @@
margin-inline-start: auto;
}
-/* The settings of a definition, which are a summary and not a value — worn at the size every value
- preview now shares. Lowercased, the settings being sentence-cased words of Trilium's own read as a
- list where they read as a sentence otherwise. */
+/* A definition's summary: its marks at the leading end, and the alias — the one part the user
+ wrote — at the trailing edge, where the other cards keep their values. */
.attribute-list-panel .attribute-value.definition {
- text-transform: lowercase;
+ display: flex;
+ align-items: center;
+ gap: 4px;
+}
+
+.attribute-list-panel .definition-marker {
+ flex-shrink: 0;
}
-/* The one part of the summary the user wrote, so it is shown as they capitalised it. */
.attribute-list-panel .definition-display-name {
- text-transform: none;
+ margin-inline-start: auto;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
.attribute-list-panel .attribute-marker,
@@ -227,11 +234,19 @@
padding-inline-end: 27px;
}
-/* The pencil at the compact size the theme gives the delete cross (`.icon-action.bx-x`). */
-.attribute-list-panel .attribute-edit-button {
+/* Both at the compact size the theme reserves for close crosses (`.icon-action.bx-x`), which the
+ trash and the pencil do not get by name. */
+.attribute-list-panel .attribute-row-actions .icon-action {
--icon-button-size: 24px;
--icon-button-icon-ratio: 0.8;
border-radius: 50%;
}
+/* The red the menus give their trash: deleting is the one destructive press on the row. Stated
+ from `:root` and with the button's own class doubled on, so as to outweigh the theme's blanket
+ icon colour (`:root .icon-action:not(...)`) whichever way the stylesheets are ordered. */
+:root .attribute-list-panel .attribute-delete-button.icon-action {
+ color: var(--dropdown-item-icon-destructive-color);
+}
+
diff --git a/apps/client/src/widgets/sidebar/AttributeList.spec.tsx b/apps/client/src/widgets/sidebar/AttributeList.spec.tsx
index 7cff712d23..e5a9467166 100644
--- a/apps/client/src/widgets/sidebar/AttributeList.spec.tsx
+++ b/apps/client/src/widgets/sidebar/AttributeList.spec.tsx
@@ -213,9 +213,11 @@ describe("AttributeList", () => {
// Only what the note may edit is deletable, whichever card it is in.
expect(cards[2].querySelectorAll(".attribute-delete-button")).toHaveLength(1);
- // An inheritable attribute is marked, and every definition previews what it sets up.
+ // An inheritable attribute is marked, and every definition previews what it sets up — a
+ // set-holding one (label:status, "multi") by a mark of its own rather than by words.
expect(cards[1].querySelectorAll(".attribute-marker")).toHaveLength(2);
expect(cards[2].querySelectorAll(".attribute-value.definition")).toHaveLength(2);
+ expect(cards[2].querySelectorAll(".definition-marker")).toHaveLength(1);
});
it("keeps to one card, collapsing and all, for a note with nothing but its own attributes", () => {
diff --git a/apps/client/src/widgets/sidebar/AttributeList.tsx b/apps/client/src/widgets/sidebar/AttributeList.tsx
index 6724838bce..9c87d2ba31 100644
--- a/apps/client/src/widgets/sidebar/AttributeList.tsx
+++ b/apps/client/src/widgets/sidebar/AttributeList.tsx
@@ -653,7 +653,9 @@ function AttributeRow({ attribute, note, active, valueEditor, isSystem, showOwne
{onDelete && (
<ActionButton
className="attribute-delete-button"
- icon="bx bx-x"
+ // The trash the menus mark deletion with, worn red as they wear it —
+ // a cross beside an editor reads as "close", and this is not that.
+ icon="bx bx-trash"
text={t("attribute_list_panel.delete")}
onClick={(e) => {
e.stopPropagation();
@@ -850,34 +852,41 @@ function AttributeValue({ attribute, note, attrType, onEdit }: {
/**
* What a definition sets up, beyond the two things its icon and its badge already say — the type of
- * field it defines, and whether that field is promoted. First the name that field goes by, if it was
- * given one of its own; then its settings, which are quiet enough that a plain single-value definition
- * summarises to the display name alone, or to nothing at all.
+ * field it defines, and whether that field is promoted: a mark for a field holding a set, the inverse
+ * a relation declares, and at the trailing edge — as the other cards keep their values — the name the
+ * field was given of its own, the nearest thing a definition has to a value. A plain single-value
+ * definition summarises to that alone, or to nothing at all.
*/
function DefinitionSummary({ attribute }: { attribute: Attribute }) {
const definition = promotedAttributeDefinitionParser.parse(attribute.value ?? "");
const displayName = definition.promotedAlias?.trim();
- const settings: string[] = [];
-
- if (definition.multiplicity === "multi") {
- settings.push(t("attribute_detail.multi_value"));
- }
-
- if (definition.inverseRelation) {
- settings.push(t("attribute_list_panel.inverse_of", { name: definition.inverseRelation }));
- }
return (
<span class="attribute-value definition">
+ {definition.multiplicity === "multi" && (
+ <Icon
+ className="definition-marker"
+ icon="bx bx-layer"
+ title={t("attribute_detail.multi_value")}
+ />
+ )}
+
+ {definition.inverseRelation && (
+ // A returning arrow rather than words; the tooltip names the inverse and what it does.
+ <Icon
+ className="definition-marker"
+ icon="bx bx-reply"
+ title={t("attribute_list_panel.inverse_hint", { name: definition.inverseRelation })}
+ />
+ )}
+
{displayName && (
- // Written by hand and shown as written, unlike the settings beside it, which are words
- // of Trilium's own (see AttributeList.css).
+ // Written by hand and shown as written, unlike the words of Trilium's own beside it
+ // (see AttributeList.css).
<span class="definition-display-name" title={t("attribute_detail.promoted_alias")}>
{displayName}
</span>
)}
- {displayName && settings.length > 0 && SUMMARY_SEPARATOR}
- {settings.join(SUMMARY_SEPARATOR)}
</span>
);
}