Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
style(attributes): count a run at its name rather than ahead of it
Elian Doran078c5736b633
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 495a0405d7..7b683ff65e 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -803,19 +803,14 @@},"attribute_list_panel": {"no_attributes": "No attributes",- "owned_one": "{{count}} owned attribute",- "owned_other": "{{count}} owned attributes",- "inherited_one": "{{count}} inherited attribute",- "inherited_other": "{{count}} inherited attributes",- "definitions_one": "{{count}} definition",- "definitions_other": "{{count}} definitions",- "internal_one": "{{count}} internal system attribute",- "internal_other": "{{count}} internal system attributes",+ "section_owned": "Owned",+ "section_inherited": "Inherited",+ "section_definitions": "Definitions",+ "section_internal": "Internal","back": "Back to the attributes","inheritable": "Inheritable: applies to this note and to its whole subtree","delete": "Delete this attribute","delete_confirm": "Delete the attribute \"{{name}}\"?",- "add_definition": "Add a new definition","no_target": "No target note","no_value": "No value","change_target": "Change the target note",diff --git a/apps/client/src/widgets/sidebar/AttributeList.css b/apps/client/src/widgets/sidebar/AttributeList.cssindex 25e7f3ebec..039e9507ef 100644--- a/apps/client/src/widgets/sidebar/AttributeList.css+++ b/apps/client/src/widgets/sidebar/AttributeList.css@@ -284,6 +284,22 @@white-space: nowrap;}+/* How many the run holds, beside its name rather than away at the trailing edge: it is read as part+ of what the run is called, not as a column of its own. Sized and worn as the note tree wears the+ count of a node's hidden children (see note_tree.css) — the same wash, a shade of the ink over the+ page rather than a colour, and small enough to be answered rather than announced. */+.attribute-list-panel .attribute-group-count {+ flex-shrink: 0;+ /* The heading's own gap sets it off; the base badge's margin would set it adrift of the name. */+ margin-inline-start: 0;+ padding: 0.1em 0.5em;+ border-radius: 0.5em;+ color: var(--muted-text-color);+ font-size: 0.7rem;+ font-weight: normal;+ letter-spacing: 0;+}+/* What separates the note's own vocabulary from the names Trilium reads for itself. Quiet: the sortis what carries the split, the rule only marks where it falls — and quieter still than the linethe run hangs from, which it crosses: a split within a branch, not a cut through it. Held off thediff --git a/apps/client/src/widgets/sidebar/AttributeList.tsx b/apps/client/src/widgets/sidebar/AttributeList.tsxindex 1492596d02..440b323232 100644--- a/apps/client/src/widgets/sidebar/AttributeList.tsx+++ b/apps/client/src/widgets/sidebar/AttributeList.tsx@@ -20,6 +20,7 @@ import { getErrorMessage, isMobile } from "../../services/utils";import { AttributeDetail, AttributeDetailOpts, AttributeForm, AttrType, DEFINITION_TYPES, getAttrType, RELATION_DEFINITION_TYPE } from "../attribute_widgets/attribute_detail";import { ColorChip, renderLabelValue } from "../attribute_widgets/label_value_display";import ActionButton from "../react/ActionButton";+import SimpleBadge from "../react/Badge";import { FormListItem } from "../react/FormList";import HelpButton from "../react/HelpButton";import { useActiveNoteContext, useTriliumEvent, useTriliumOptionJson } from "../react/hooks";@@ -703,7 +704,8 @@ export default function AttributeList() {inherited ones' do — the two runs of plain attributes reading as one ledger. */}<AttributeGroupid="attributes-owned"- title={t("attribute_list_panel.owned", { count: sections.owned.length })}+ title={t("attribute_list_panel.section_owned")}+ count={sections.owned.length}>{sections.owned.length > 0 ? (<AttributeRowList rows={sections.owned} alignValuesEnd {...rowProps} />@@ -721,7 +723,8 @@ export default function AttributeList() {{sections.inherited.length > 0 && (<AttributeGroupid="attributes-inherited"- title={t("attribute_list_panel.inherited", { count: sections.inherited.length })}+ title={t("attribute_list_panel.section_inherited")}+ count={sections.inherited.length}><AttributeRowList rows={sections.inherited} alignValuesEnd {...rowProps} /></AttributeGroup>@@ -732,7 +735,8 @@ export default function AttributeList() {// rather than a value, so there is no column of values for it to line up in.<AttributeGroupid="attributes-definitions"- title={t("attribute_list_panel.definitions", { count: sections.definitions.length })}+ title={t("attribute_list_panel.section_definitions")}+ count={sections.definitions.length}><AttributeRowList rows={sections.definitions} {...rowProps} /></AttributeGroup>@@ -741,7 +745,8 @@ export default function AttributeList() {{internalRows.length > 0 && (<AttributeGroupid="attributes-internal"- title={t("attribute_list_panel.internal", { count: internalRows.length })}+ title={t("attribute_list_panel.section_internal")}+ count={internalRows.length}><AttributeRowList rows={internalRows} readOnly {...rowProps} /></AttributeGroup>@@ -843,7 +848,13 @@ function AttributeSection({ id, title, children, buttons, grow }: AttributeSecti* inherited attributes can still be put away — and what it is remembered under, so a pane that had* them put away has them put away still.*/-function AttributeGroup({ id, title, children }: { id: string; title: string; children: ComponentChildren }) {+function AttributeGroup({ id, title, count, children }: {+ id: string;+ title: string;+ /** How many rows the run holds, shown beside its name rather than read ahead of it. */+ count: number;+ children: ComponentChildren;+}) {const [ collapsedItems, setCollapsedItems ] = useTriliumOptionJson<string[]>("rightPaneCollapsedItems");const [ collapsed, setCollapsed ] = useState(collapsedItems.includes(id));@@ -873,6 +884,12 @@ function AttributeGroup({ id, title, children }: { id: string; title: string; ch><Icon className="attribute-group-chevron" icon="bx bx-chevron-down" /><span class="attribute-group-title">{title}</span>++ {/* Beside the name rather than away at the trailing edge: it is read as part of what+ the run is called. The plain badge, as the note tree counts a node's hidden+ children with and as the checkbox tree counts its leaves — a bare figure, the+ heading beside it saying what is being counted. */}+ <SimpleBadge className="attribute-group-count" title={count} /></div>{/* The rows hang together under the heading rather than each standing on its own, so that