Skip to content

Build your personal knowledge base with Trilium Notes

client: fix some issues

Adorian Doran06beb9fa2fab
diff --git a/apps/client/src/widgets/collections/board/card.spec.tsx b/apps/client/src/widgets/collections/board/card.spec.tsx
index 2a7d826069..2dd0fb6df6 100644
--- a/apps/client/src/widgets/collections/board/card.spec.tsx
+++ b/apps/client/src/widgets/collections/board/card.spec.tsx
@@ -31,7 +31,14 @@ const draws = vi.hoisted(() => new Map<string, number>());
vi.mock("../../attribute_widgets/UserAttributesList", () => ({
default: ({ note }: { note: { noteId: string } }) => {
draws.set(note.noteId, (draws.get(note.noteId) ?? 0) + 1);
- return null;
+ // What a relation draws: a link to the note it points at, and beside it one to a page of
+ // its own, which is not the card's to open.
+ return (
+ <span className="user-attributes">
+ <a className="relation-link" href="#root/targetNote">Target</a>
+ <a className="outside-link" href="https://example.invalid">Elsewhere</a>
+ </span>
+ );
}
}));
@@ -122,6 +129,39 @@ describe("Board card", () => {
.toHaveBeenCalledWith("openInPopup", { noteIdOrPath: first });
});
+ /**
+ * A relation on a card is drawn as a link to the note it points at. The page's own link handler
+ * would open that in a tab, and the card underneath would open itself over the top of it.
+ */
+ it("opens what a link inside it points at, and only that", async () => {
+ const { first } = await renderBoard();
+ const opened = vi.spyOn(appContext, "triggerCommand").mockReturnValue(undefined);
+ const link = card(first).querySelector<HTMLElement>(".relation-link");
+ if (!link) throw new Error("expected the relation link");
+
+ const press = new MouseEvent("click", { bubbles: true, cancelable: true, detail: 1 });
+ await act(async () => { link.dispatchEvent(press); });
+
+ expect(opened).toHaveBeenCalledTimes(1);
+ expect(opened).toHaveBeenCalledWith("openInPopup", { noteIdOrPath: "root/targetNote" });
+ // Taken here, so the page's own handler never sees it and no tab is opened.
+ expect(press.defaultPrevented).toBe(true);
+ expect(press.cancelBubble).toBe(true);
+ });
+
+ /** A link out of Trilium is the browser's to follow, and opens no card over it. */
+ it("leaves a link that names no note alone", async () => {
+ const { first } = await renderBoard();
+ const opened = vi.spyOn(appContext, "triggerCommand").mockReturnValue(undefined);
+ opened.mockClear();
+
+ await act(async () => {
+ card(first).querySelector<HTMLElement>(".outside-link")?.click();
+ });
+
+ expect(opened).not.toHaveBeenCalled();
+ });
+
/**
* Enter opens the field a card is named in where a spreadsheet would add a row, and Shift puts
* it above instead. The card itself is made by that field, once it has been given a title.
diff --git a/apps/client/src/widgets/collections/board/card.tsx b/apps/client/src/widgets/collections/board/card.tsx
index 4adccad7f8..6bc37d140c 100644
--- a/apps/client/src/widgets/collections/board/card.tsx
+++ b/apps/client/src/widgets/collections/board/card.tsx
@@ -10,6 +10,7 @@ import { ContextMenuEvent } from "../../../menus/context_menu";
import { openNoteContextMenu } from "./context_menu";
import { t } from "../../../services/i18n";
import UserAttributesDisplay from "../../attribute_widgets/UserAttributesList";
+import { parseNavigationStateFromUrl } from "../../../services/link";
import { FLIP_SETTLE_MS } from "../../react/flip";
import {
useNoteColorClass, useNoteIcon, useNoteLabel, useNoteLabelBoolean, useTriliumEvent
@@ -90,6 +91,20 @@ function Card({
// popup already standing is taken as the one to stack on, and closing that leaves neither.
if (e.detail > 1) return;
+ // A link the card draws, such as the target of a relation, names a note of its own. It is
+ // opened in the popup like any other card, and the press is taken here so that neither the
+ // page's own link handler (which would open a tab) nor the card below it acts on it too.
+ const link = (e.target as HTMLElement | null)?.closest<HTMLAnchorElement>("a[href]");
+ if (link) {
+ const { notePath } = parseNavigationStateFromUrl(link.getAttribute("href") ?? undefined);
+ e.preventDefault();
+ e.stopPropagation();
+ if (notePath) {
+ api.openNote(notePath);
+ }
+ return;
+ }
+
api.openNote(note.noteId);
}, [ api, note ]);
diff --git a/apps/client/src/widgets/collections/board/properties.css b/apps/client/src/widgets/collections/board/properties.css
index b72a16d9a5..781f9d6db9 100644
--- a/apps/client/src/widgets/collections/board/properties.css
+++ b/apps/client/src/widgets/collections/board/properties.css
@@ -1,8 +1,8 @@
-/* The dialog stacks its cards, so the space between them is the dialog's rather than each card's. */
+/* The dialog stacks its cards, so the space between them is its own rather than each card's. */
.modal.board-properties-dialog .modal-body {
- display: flex;
- flex-direction: column;
- gap: 24px;
- padding-inline: 25px;
- padding-block-end: 25px;
+ display: flex;
+ flex-direction: column;
+ gap: 24px;
+ padding-inline: 25px;
+ padding-block-end: 25px;
}
diff --git a/apps/client/src/widgets/dialogs/item_picker.css b/apps/client/src/widgets/dialogs/item_picker.css
index f6aea6a94d..8c86c80157 100644
--- a/apps/client/src/widgets/dialogs/item_picker.css
+++ b/apps/client/src/widgets/dialogs/item_picker.css
@@ -1,192 +1,192 @@
:where(:root) {
- /* The colour the quick search marks its terms in. */
- --item-picker-mark-color: var(--quick-search-result-highlight-color);
- --item-picker-inline-padding: 40px;
- /* One line of caption plus the card's padding. Exact, so the collapse animates. */
- --item-picker-item-height: calc(1.4em + 2 * var(--card-padding-block));
- --item-picker-fold-duration: 0.15s;
+ /* The colour the quick search marks its terms in. */
+ --item-picker-mark-color: var(--quick-search-result-highlight-color);
+ --item-picker-inline-padding: 40px;
+ /* One line of caption plus the card's padding. Exact, so the collapse animates. */
+ --item-picker-item-height: calc(1.4em + 2 * var(--card-padding-block));
+ --item-picker-fold-duration: 0.15s;
}
.modal.item-picker-dialog {
- .modal-body {
- /* A column, so the empty state can take the space the list leaves. */
- display: flex;
- flex-direction: column;
- padding-inline: var(--item-picker-inline-padding);
- }
-
- /* Holds the list. The empty state is positioned over it. */
- .item-picker-results {
- position: relative;
- flex: 1 0 auto;
- }
-
- .modal-dialog {
- /* Half again as wide as a small dialog, to fit the inline padding. */
- max-width: 405px;
- }
-
- .settings-search {
- margin-bottom: 20px;
- }
-
- .item-picker-groups {
- display: flex;
- flex-direction: column;
- }
-
- /* The gap between groups sits on each card, so it collapses with the card. */
- .item-picker-groups > .tn-card {
- margin-block-end: 1em;
- transition: margin var(--item-picker-fold-duration) ease;
- }
-
- .item-picker-groups > .tn-card:last-child {
- margin-block-end: 0;
- }
-
- /* The filter primitive hides an emptied group outright, which cuts the collapse short.
- Overridden in kind, its own rule being `!important`. */
- .tn-card.tn-filter-scope:not(:has(.tn-filter-match)) {
- display: block !important;
- }
-
- .tn-card:not(:has(.item-picker-item:not(.item-picker-folded))) {
- margin-block-end: 0;
- pointer-events: none;
-
- & .tn-card-heading {
- height: 0;
- margin: 0;
- opacity: 0;
- overflow: hidden;
- }
- }
-
- .tn-card-heading {
- height: 1.4em;
- transition: height var(--item-picker-fold-duration) ease,
- margin var(--item-picker-fold-duration) ease,
- opacity calc(var(--item-picker-fold-duration) * 0.7) ease;
- }
-
- .item-picker-item {
- display: flex;
- align-items: center;
- gap: 0.4em;
- /* An exact height, not a max-height ceiling: a ceiling above the real height spends most of
- the transition invisible. */
- height: var(--item-picker-item-height);
- /* The gap sits on the item, so it collapses with it. A flex gap would leave a stripe. */
- margin-block-end: var(--card-section-gap);
- transition: height var(--item-picker-fold-duration) ease,
- margin var(--item-picker-fold-duration) ease,
- padding var(--item-picker-fold-duration) ease,
- border-width var(--item-picker-fold-duration) ease,
- opacity calc(var(--item-picker-fold-duration) * 0.7) ease;
- overflow: hidden;
- cursor: pointer;
- }
-
- .item-picker-item:last-of-type {
- margin-block-end: 0;
- }
-
- .item-picker-folded {
- height: 0;
- margin-block: 0;
- padding-block: 0;
- border-width: 0;
- opacity: 0;
- }
-
- /* Marked by colour alone, as the quick search marks its results. */
- .item-picker-caption {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- /* Bootstrap's Reboot pads `mark`, which would part a matched term from the caption. */
- .item-picker-caption mark {
- margin: 0;
- padding: 0;
- background: none;
- color: var(--item-picker-mark-color);
- font-weight: 600;
- }
-
- /* Laid over the list so it holds still while the list collapses. Faded, not unmounted. */
- .item-picker-empty {
- position: absolute;
- inset: 0;
- opacity: 0;
- visibility: hidden;
- pointer-events: none;
- transition: opacity var(--item-picker-fold-duration) ease,
- visibility 0s linear var(--item-picker-fold-duration);
- }
-
- /* Shown only when the filter leaves nothing. */
- .item-picker-groups:not(:has(.item-picker-item:not(.item-picker-folded))) + .item-picker-empty {
- opacity: 1;
- visibility: visible;
- transition: opacity var(--item-picker-fold-duration) ease;
- }
-
- /* One animation for the whole list, however many items it holds. */
- .item-picker-groups {
- /* Long enough to read as its own animation under the dialog's opening. */
- animation: item-picker-rise 0.4s ease-out;
- }
+ .modal-body {
+ /* A column, so the empty state can take the space the list leaves. */
+ display: flex;
+ flex-direction: column;
+ padding-inline: var(--item-picker-inline-padding);
+ }
+
+ /* Holds the list. The empty state is positioned over it. */
+ .item-picker-results {
+ position: relative;
+ flex: 1 0 auto;
+ }
+
+ .modal-dialog {
+ /* Half again as wide as a small dialog, to fit the inline padding. */
+ max-width: 405px;
+ }
+
+ .settings-search {
+ margin-bottom: 20px;
+ }
+
+ .item-picker-groups {
+ display: flex;
+ flex-direction: column;
+ }
+
+ /* The gap between groups sits on each card, so it collapses with the card. */
+ .item-picker-groups > .tn-card {
+ margin-block-end: 1em;
+ transition: margin var(--item-picker-fold-duration) ease;
+ }
+
+ .item-picker-groups > .tn-card:last-child {
+ margin-block-end: 0;
+ }
+
+ /* The filter primitive hides an emptied group outright, which cuts the collapse short.
+ Overridden in kind, its own rule being `!important`. */
+ .tn-card.tn-filter-scope:not(:has(.tn-filter-match)) {
+ display: block !important;
+ }
+
+ .tn-card:not(:has(.item-picker-item:not(.item-picker-folded))) {
+ margin-block-end: 0;
+ pointer-events: none;
+
+ & .tn-card-heading {
+ height: 0;
+ margin: 0;
+ opacity: 0;
+ overflow: hidden;
+ }
+ }
+
+ .tn-card-heading {
+ height: 1.4em;
+ transition: height var(--item-picker-fold-duration) ease,
+ margin var(--item-picker-fold-duration) ease,
+ opacity calc(var(--item-picker-fold-duration) * 0.7) ease;
+ }
+
+ .item-picker-item {
+ display: flex;
+ align-items: center;
+ gap: 0.4em;
+ /* An exact height, not a max-height ceiling: a ceiling above the real height spends most of
+ the transition invisible. */
+ height: var(--item-picker-item-height);
+ /* The gap sits on the item, so it collapses with it. A flex gap would leave a stripe. */
+ margin-block-end: var(--card-section-gap);
+ transition: height var(--item-picker-fold-duration) ease,
+ margin var(--item-picker-fold-duration) ease,
+ padding var(--item-picker-fold-duration) ease,
+ border-width var(--item-picker-fold-duration) ease,
+ opacity calc(var(--item-picker-fold-duration) * 0.7) ease;
+ overflow: hidden;
+ cursor: pointer;
+ }
+
+ .item-picker-item:last-of-type {
+ margin-block-end: 0;
+ }
+
+ .item-picker-folded {
+ height: 0;
+ margin-block: 0;
+ padding-block: 0;
+ border-width: 0;
+ opacity: 0;
+ }
+
+ /* Marked by colour alone, as the quick search marks its results. */
+ .item-picker-caption {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ /* Bootstrap's Reboot pads `mark`, which would part a matched term from the caption. */
+ .item-picker-caption mark {
+ margin: 0;
+ padding: 0;
+ background: none;
+ color: var(--item-picker-mark-color);
+ font-weight: 600;
+ }
+
+ /* Laid over the list so it holds still while the list collapses. Faded, not unmounted. */
+ .item-picker-empty {
+ position: absolute;
+ inset: 0;
+ opacity: 0;
+ visibility: hidden;
+ pointer-events: none;
+ transition: opacity var(--item-picker-fold-duration) ease,
+ visibility 0s linear var(--item-picker-fold-duration);
+ }
+
+ /* Shown only when the filter leaves nothing. */
+ .item-picker-groups:not(:has(.item-picker-item:not(.item-picker-folded))) + .item-picker-empty {
+ opacity: 1;
+ visibility: visible;
+ transition: opacity var(--item-picker-fold-duration) ease;
+ }
+
+ /* One animation for the whole list, however many items it holds. */
+ .item-picker-groups {
+ /* Long enough to read as its own animation under the dialog's opening. */
+ animation: item-picker-rise 0.4s ease-out;
+ }
}
.tn-card-body > .item-picker-item {
- /* The card lays its own segments out with a gap; these carry their own so they can fold. */
- margin-block-start: 0;
+ /* The card lays its own segments out with a gap; these carry their own so they can fold. */
+ margin-block-start: 0;
}
.modal.item-picker-dialog .tn-card-body {
- gap: 0;
+ gap: 0;
}
/* One height whatever it holds, the list scrolling inside it.
The height goes on `.modal-content`: a scrollable modal only caps that box, which is otherwise
- sized by its contents and shrinks as the filter narrows the list. `.modal-dialog` then fills the
- viewport and centres it, as `.modal-dialog-centered` does. */
+ sized by its contents and shrinks as the filter narrows the list. `.modal-dialog` then fills
+ the viewport and centres it, as `.modal-dialog-centered` does. */
body:not(.mobile) .modal.item-picker-dialog {
- .modal-dialog {
- display: flex;
- align-items: center;
- height: 100%;
- margin-block: 0;
- }
+ .modal-dialog {
+ display: flex;
+ align-items: center;
+ height: 100%;
+ margin-block: 0;
+ }
- .modal-content {
- height: 60vh;
- max-height: 100%;
- }
+ .modal-content {
+ height: 60vh;
+ max-height: 100%;
+ }
}
/* A phone fills the screen instead, together with `isFullPageOnMobile`. */
body.mobile .modal.item-picker-dialog .modal-content {
- height: 100%;
+ height: 100%;
}
@keyframes item-picker-rise {
- from { opacity: 0; transform: translateY(50px); }
- to { opacity: 1; transform: translateY(0); }
+ from { opacity: 0; transform: translateY(50px); }
+ to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
- .modal.item-picker-dialog {
- .item-picker-groups {
- animation: none;
- }
-
- .item-picker-item {
- transition: none;
+ .modal.item-picker-dialog {
+ .item-picker-groups {
+ animation: none;
+ }
+
+ .item-picker-item {
+ transition: none;
+ }
}
- }
}
diff --git a/apps/client/src/widgets/react/PromotedAttributesCard.css b/apps/client/src/widgets/react/PromotedAttributesCard.css
index 3c93351d61..768e4842d7 100644
--- a/apps/client/src/widgets/react/PromotedAttributesCard.css
+++ b/apps/client/src/widgets/react/PromotedAttributesCard.css
@@ -1,25 +1,25 @@
.tn-card.promoted-attributes-card {
- /* The name takes the free space, pushing the edit button and the toggle to the trailing edge. */
- .promoted-attribute-name {
- flex-grow: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
+ /* The name takes the free space, pushing the buttons and the toggle to the trailing edge. */
+ .promoted-attribute-name {
+ flex-grow: 1;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ 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;
- }
+ /* 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;
+ }
- .promoted-attribute-edit,
- .promoted-attribute-delete {
- flex-shrink: 0;
- }
+ .promoted-attribute-edit,
+ .promoted-attribute-delete {
+ flex-shrink: 0;
+ }
- .switch-widget {
- flex-shrink: 0;
- }
+ .switch-widget {
+ flex-shrink: 0;
+ }
}
diff --git a/apps/client/src/widgets/react/SortableCard.css b/apps/client/src/widgets/react/SortableCard.css
index 4ea9db209c..08a2d55706 100644
--- a/apps/client/src/widgets/react/SortableCard.css
+++ b/apps/client/src/widgets/react/SortableCard.css
@@ -1,191 +1,191 @@
:where(:root) {
- --sortable-grip-color: var(--muted-text-color);
- --sortable-grip-hover-color: var(--main-text-color);
- --sortable-selected-color: var(--main-text-color);
- /* Above and below, so a dragged segment reads as raised. The lower one is heavier. */
- --sortable-dragging-shadow: 0 -3px 8px rgba(0, 0, 0, 0.3),
- 0 5px 8px rgba(0, 0, 0, 0.3);
- /* Enough to read as lifted without washing out the text. */
- --sortable-dragging-opacity: 0.90;
+ --sortable-grip-color: var(--muted-text-color);
+ --sortable-grip-hover-color: var(--main-text-color);
+ --sortable-selected-color: var(--main-text-color);
+ /* Above and below, so a dragged segment reads as raised. The lower one is heavier. */
+ --sortable-dragging-shadow: 0 -3px 8px rgba(0, 0, 0, 0.3),
+ 0 5px 8px rgba(0, 0, 0, 0.3);
+ /* Enough to read as lifted without washing out the text. */
+ --sortable-dragging-opacity: 0.90;
}
.tn-card.tn-sortable-card {
- .tn-sortable-list {
- display: flex;
- /* Must be the dragged segment's offsetParent: it is positioned against this. */
- position: relative;
- flex-direction: column;
- gap: var(--card-section-gap);
- }
-
- .tn-sortable-segment {
- display: flex;
- align-items: center;
- gap: 0.5em;
- /* useFlip transforms a segment back for one frame and lets this transition carry it to its
- new position. Must match FLIP_DURATION_MS. */
- transition: transform 200ms ease;
- }
-
- /* A touch drags from anywhere on the segment, and a press that long raises the iOS callout and
- magnifier. Not applied to a mouse, which drags by the grip and can select the caption. */
- @media (pointer: coarse) {
+ .tn-sortable-list {
+ display: flex;
+ /* Must be the dragged segment's offsetParent: it is positioned against this. */
+ position: relative;
+ flex-direction: column;
+ gap: var(--card-section-gap);
+ }
+
.tn-sortable-segment {
- -webkit-touch-callout: none;
- user-select: none;
- }
- }
-
- .tn-sortable-segment:focus-visible {
- outline: 2px solid var(--sortable-selected-color);
- outline-offset: -2px;
- }
-
- /* Inset, so a selected segment takes no more room than the rest. Painted only while an entry
- has the focus, not the creation row and not once the focus leaves the card. */
- .tn-sortable-list:has(.tn-sortable-segment:focus-within) .tn-sortable-selected {
- box-shadow: inset 0 0 0 1px var(--sortable-selected-color);
- }
-
- .tn-sortable-content {
- display: flex;
- flex-grow: 1;
- align-items: center;
- gap: 0.5em;
- min-width: 0;
- }
-
- .tn-sortable-caption {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .tn-sortable-grip {
- display: flex;
- flex-shrink: 0;
- align-items: center;
- padding: 0.2em 0.1em;
- color: var(--sortable-grip-color);
- cursor: grab;
- /* The page still scrolls from here. A drag is what calls preventDefault on touchmove. */
- touch-action: pan-y;
- -webkit-touch-callout: none;
- user-select: none;
-
- & svg {
- width: 1.1em;
- height: 1.1em;
- stroke: currentColor;
- stroke-width: 1.5;
- stroke-linecap: round;
- }
-
- &:hover {
- color: var(--sortable-grip-hover-color);
- }
- }
-
- /* A touch target wider than the icon. The negative margin cancels the padding, so the segment
- keeps its height. */
- @media (pointer: coarse) {
+ display: flex;
+ align-items: center;
+ gap: 0.5em;
+ /* useFlip transforms a segment back for one frame and lets this transition carry it to its
+ new position. Must match FLIP_DURATION_MS. */
+ transition: transform 200ms ease;
+ }
+
+ /* A touch drags from anywhere on the segment, and a press that long raises the iOS callout and
+ magnifier. Not applied to a mouse, which drags by the grip and can select the caption. */
+ @media (pointer: coarse) {
+ .tn-sortable-segment {
+ -webkit-touch-callout: none;
+ user-select: none;
+ }
+ }
+
+ .tn-sortable-segment:focus-visible {
+ outline: 2px solid var(--sortable-selected-color);
+ outline-offset: -2px;
+ }
+
+ /* Inset, so a selected segment takes no more room than the rest. Painted only while an entry
+ has the focus, not the creation row and not once the focus leaves the card. */
+ .tn-sortable-list:has(.tn-sortable-segment:focus-within) .tn-sortable-selected {
+ box-shadow: inset 0 0 0 1px var(--sortable-selected-color);
+ }
+
+ .tn-sortable-content {
+ display: flex;
+ flex-grow: 1;
+ align-items: center;
+ gap: 0.5em;
+ min-width: 0;
+ }
+
+ .tn-sortable-caption {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
.tn-sortable-grip {
- margin-block: -0.5em;
- margin-inline-end: calc(var(--card-padding-inline) / -2);
- padding: 0.7em calc(var(--card-padding-inline) / 2);
- }
-
- /* Placed first, the grip extends into the leading padding instead. */
- .tn-sortable-grip:first-child {
- margin-inline-start: calc(var(--card-padding-inline) / -2);
- margin-inline-end: 0;
- }
- }
-
- /* Follows the pointer directly: the sliding transition would leave it a frame behind. */
- .tn-sortable-dragging {
- z-index: 1;
- box-shadow: var(--sortable-dragging-shadow);
- opacity: var(--sortable-dragging-opacity);
- transition: none;
-
- & .tn-sortable-grip {
- cursor: grabbing;
- }
- }
-
- /* Transparent: each button paints itself, and the gaps show the card through. */
- .tn-sortable-adders {
- display: flex;
- gap: var(--card-section-gap);
- border: none;
- padding: 0;
- background: transparent;
- }
-
- /* Painted as a segment rather than a button, all of one width, undoing what Bootstrap and the
- theme give a button. */
- button.tn-sortable-adder.btn {
- display: flex;
- flex: 1 1 0;
- justify-content: center;
- align-items: center;
- gap: 0.3em;
- min-width: 0;
- box-shadow: none;
- border: 1px solid var(--card-border-color, var(--main-border-color));
- border-radius: 0;
- padding: var(--card-padding-block) var(--card-padding-inline);
- background: var(--card-background-color);
- color: var(--muted-text-color);
- font: inherit;
- letter-spacing: normal;
- text-transform: none;
- cursor: pointer;
-
- &:hover {
- background-color: var(--card-background-hover-color);
- color: var(--main-text-color);
- }
-
- &:active {
- background-color: var(--card-background-hover-color);
- }
- }
-
- /* The row is transparent, so its buttons carry the card's corners. */
- .tn-sortable-adders:first-of-type button.tn-sortable-adder:first-child {
- border-start-start-radius: var(--card-border-radius);
- }
-
- .tn-sortable-adders:first-of-type button.tn-sortable-adder:last-child {
- border-start-end-radius: var(--card-border-radius);
- }
-
- .tn-sortable-adders:last-of-type button.tn-sortable-adder:first-child {
- border-end-start-radius: var(--card-border-radius);
- }
-
- .tn-sortable-adders:last-of-type button.tn-sortable-adder:last-child {
- border-end-end-radius: var(--card-border-radius);
- }
-
- .tn-sortable-appearing {
- animation: tn-sortable-appear 400ms ease-out;
- }
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ padding: 0.2em 0.1em;
+ color: var(--sortable-grip-color);
+ cursor: grab;
+ /* The page still scrolls from here. A drag is what calls preventDefault on touchmove. */
+ touch-action: pan-y;
+ -webkit-touch-callout: none;
+ user-select: none;
+
+ & svg {
+ width: 1.1em;
+ height: 1.1em;
+ stroke: currentColor;
+ stroke-width: 1.5;
+ stroke-linecap: round;
+ }
+
+ &:hover {
+ color: var(--sortable-grip-hover-color);
+ }
+ }
+
+ /* A touch target wider than the icon. The negative margin cancels the padding, so the segment
+ keeps its height. */
+ @media (pointer: coarse) {
+ .tn-sortable-grip {
+ margin-block: -0.5em;
+ margin-inline-end: calc(var(--card-padding-inline) / -2);
+ padding: 0.7em calc(var(--card-padding-inline) / 2);
+ }
+
+ /* Placed first, the grip extends into the leading padding instead. */
+ .tn-sortable-grip:first-child {
+ margin-inline-start: calc(var(--card-padding-inline) / -2);
+ margin-inline-end: 0;
+ }
+ }
+
+ /* Follows the pointer directly: the sliding transition would leave it a frame behind. */
+ .tn-sortable-dragging {
+ z-index: 1;
+ box-shadow: var(--sortable-dragging-shadow);
+ opacity: var(--sortable-dragging-opacity);
+ transition: none;
+
+ & .tn-sortable-grip {
+ cursor: grabbing;
+ }
+ }
+
+ /* Transparent: each button paints itself, and the gaps show the card through. */
+ .tn-sortable-adders {
+ display: flex;
+ gap: var(--card-section-gap);
+ border: none;
+ padding: 0;
+ background: transparent;
+ }
+
+ /* Painted as a segment rather than a button, all of one width, undoing what Bootstrap and the
+ theme give a button. */
+ button.tn-sortable-adder.btn {
+ display: flex;
+ flex: 1 1 0;
+ justify-content: center;
+ align-items: center;
+ gap: 0.3em;
+ min-width: 0;
+ box-shadow: none;
+ border: 1px solid var(--card-border-color, var(--main-border-color));
+ border-radius: 0;
+ padding: var(--card-padding-block) var(--card-padding-inline);
+ background: var(--card-background-color);
+ color: var(--muted-text-color);
+ font: inherit;
+ letter-spacing: normal;
+ text-transform: none;
+ cursor: pointer;
+
+ &:hover {
+ background-color: var(--card-background-hover-color);
+ color: var(--main-text-color);
+ }
+
+ &:active {
+ background-color: var(--card-background-hover-color);
+ }
+ }
+
+ /* The row is transparent, so its buttons carry the card's corners. */
+ .tn-sortable-adders:first-of-type button.tn-sortable-adder:first-child {
+ border-start-start-radius: var(--card-border-radius);
+ }
+
+ .tn-sortable-adders:first-of-type button.tn-sortable-adder:last-child {
+ border-start-end-radius: var(--card-border-radius);
+ }
+
+ .tn-sortable-adders:last-of-type button.tn-sortable-adder:first-child {
+ border-end-start-radius: var(--card-border-radius);
+ }
+
+ .tn-sortable-adders:last-of-type button.tn-sortable-adder:last-child {
+ border-end-end-radius: var(--card-border-radius);
+ }
+
+ .tn-sortable-appearing {
+ animation: tn-sortable-appear 400ms ease-out;
+ }
}
@keyframes tn-sortable-appear {
- from { opacity: 0; }
- to { opacity: 1; }
+ from { opacity: 0; }
+ to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
- .tn-card.tn-sortable-card .tn-sortable-segment {
- transition: none;
- }
+ .tn-card.tn-sortable-card .tn-sortable-segment {
+ transition: none;
+ }
- .tn-card.tn-sortable-card .tn-sortable-appearing {
- animation: none;
- }
+ .tn-card.tn-sortable-card .tn-sortable-appearing {
+ animation: none;
+ }
}
diff --git a/apps/client/src/widgets/react/TemplateSelectionCard.css b/apps/client/src/widgets/react/TemplateSelectionCard.css
index 71ad9dd4a0..15dce301f2 100644
--- a/apps/client/src/widgets/react/TemplateSelectionCard.css
+++ b/apps/client/src/widgets/react/TemplateSelectionCard.css
@@ -1,15 +1,15 @@
/* The name takes the free space, pushing the buttons to the trailing edge. */
.template-selection-name {
- flex-grow: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+ flex-grow: 1;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
.template-selection-remove {
- flex-shrink: 0;
+ flex-shrink: 0;
}
.template-selection-menu {
- flex-shrink: 0;
+ flex-shrink: 0;
}