Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 81 additions & 41 deletions ui/src/components/stickies/StickyNoteCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TaskItem } from '@tiptap/extension-task-item';
import { TaskList } from '@tiptap/extension-task-list';
import StarterKit from '@tiptap/starter-kit';
import type { StickyApiResponse } from '../../api/types';
import { Tooltip } from '../ui/Tooltip';
import { stickiesService } from '../../services/stickiesService';
import {
STICKY_BACKGROUND_COLORS_DARK,
Expand Down Expand Up @@ -314,6 +315,12 @@ export function StickyNoteCard({

const tb =
'rounded p-1 text-(--txt-icon-tertiary) hover:bg-(--bg-layer-transparent-hover) disabled:opacity-40';
const isMac =
typeof navigator !== 'undefined' && /mac|iphone|ipad|ipod/i.test(navigator.platform);
const modKey = isMac ? 'Cmd' : 'Ctrl';
Comment thread
Rafetikus marked this conversation as resolved.
const boldShortcut = `${modKey} + B`;
const italicShortcut = `${modKey} + I`;
const todoShortcut = `${modKey} + Shift + 9`;
Comment thread
Rafetikus marked this conversation as resolved.

Comment thread
Rafetikus marked this conversation as resolved.
if (!editor) return null;
if (!safeSlug) return null;
Expand All @@ -326,7 +333,7 @@ export function StickyNoteCard({
<div className="min-h-0 text-sm">
<EditorContent
editor={editor}
className="min-h-[4.5rem] min-w-0 max-w-full overflow-hidden text-sm text-(--txt-primary) focus:outline-none [&_p]:my-0.5 [&_p]:break-words [&_ul]:my-1 [&_ol]:my-1 [&_ul[data-type=taskList]]:m-0 [&_ul[data-type=taskList]]:p-0 [&_li[data-type=taskItem]>label]:mt-0.5 [&_li[data-type=taskItem]>label>input]:h-3.5 [&_li[data-type=taskItem]>label>input]:w-3.5 [&_li[data-type=taskItem][data-checked=true]>div]:opacity-60"
className="sticky-note-editor-content min-h-[4.5rem] min-w-0 max-w-full overflow-hidden text-sm text-(--txt-primary) focus:outline-none [&_p]:my-0.5 [&_p]:break-words [&_ul]:my-1 [&_ol]:my-1 [&_ul[data-type=taskList]]:m-0 [&_ul[data-type=taskList]]:p-0 [&_li[data-type=taskItem]>label]:mt-0.5 [&_li[data-type=taskItem]>label>input]:h-3.5 [&_li[data-type=taskItem]>label>input]:w-3.5"
style={{ wordBreak: 'break-word', overflowWrap: 'anywhere' }}
/>
{contentSaveError ? (
Expand All @@ -337,17 +344,19 @@ export function StickyNoteCard({
</div>
<div className="mt-2 flex shrink-0 items-center gap-1 pt-2">
<div className="relative" ref={colorPanelRef}>
<button
type="button"
className={tb}
aria-label="Change color"
aria-expanded={colorOpen}
aria-haspopup="listbox"
aria-controls={colorOpen ? colorListboxId : undefined}
onClick={cycleColor}
>
<IconPalette />
</button>
<Tooltip content="Background color">
<button
type="button"
className={tb}
aria-label="Change color"
aria-expanded={colorOpen}
aria-haspopup="listbox"
aria-controls={colorOpen ? colorListboxId : undefined}
onClick={cycleColor}
Comment thread
Rafetikus marked this conversation as resolved.
>
<IconPalette />
</button>
</Tooltip>
{colorOpen && (
<div
id={colorListboxId}
Expand Down Expand Up @@ -377,38 +386,69 @@ export function StickyNoteCard({
</div>
)}
</div>
<button
type="button"
className={tb}
aria-label="Bold"
onClick={() => editor.chain().focus().toggleBold().run()}
>
<IconBold />
</button>
<button
type="button"
className={tb}
aria-label="Italic"
onClick={() => editor.chain().focus().toggleItalic().run()}
<Tooltip
content={
<div className="text-center">
<p>Bold</p>
<p className="text-(--txt-tertiary)">{boldShortcut}</p>
</div>
}
>
<IconItalic />
</button>
<button
type="button"
className={tb}
aria-label="Todo list"
onClick={() => editor.chain().focus().toggleTaskList().run()}
<button
type="button"
className={tb}
aria-label="Bold"
onClick={() => editor.chain().focus().toggleBold().run()}
>
<IconBold />
</button>
</Tooltip>
<Tooltip
content={
<div className="text-center">
<p>Italic</p>
<p className="text-(--txt-tertiary)">{italicShortcut}</p>
</div>
}
>
<IconTodo />
</button>
<button
type="button"
onClick={() => onDelete(sticky.id)}
className={`${tb} ml-auto hover:text-(--txt-danger-primary)`}
aria-label="Delete"
<button
type="button"
className={tb}
aria-label="Italic"
onClick={() => editor.chain().focus().toggleItalic().run()}
>
<IconItalic />
</button>
</Tooltip>
<Tooltip
content={
<div className="text-center">
<p>To-do list</p>
<p className="text-(--txt-tertiary)">{todoShortcut}</p>
</div>
}
>
<IconTrash />
</button>
<button
type="button"
className={tb}
aria-label="Todo list"
onClick={() => editor.chain().focus().toggleTaskList().run()}
>
<IconTodo />
</button>
</Tooltip>
Comment thread
Rafetikus marked this conversation as resolved.
<div className="ml-auto">
<Tooltip content="Delete sticky note">
<button
type="button"
onClick={() => onDelete(sticky.id)}
className={`${tb} hover:text-(--txt-danger-primary)`}
aria-label="Delete"
>
<IconTrash />
</button>
</Tooltip>
</div>
</div>
</div>
);
Expand Down
41 changes: 40 additions & 1 deletion ui/src/components/ui/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ function computeStyle(el: HTMLElement, placement: TooltipPlacement): CSSProperti
};
}

function mergeDescribedBy(existing: string | null, token: string): string {
const parts = (existing || '')
.split(/\s+/)
.map((s) => s.trim())
.filter(Boolean);
if (!parts.includes(token)) parts.push(token);
return parts.join(' ');
}

function removeDescribedBy(existing: string | null, token: string): string | null {
const next = (existing || '')
.split(/\s+/)
.map((s) => s.trim())
.filter((s) => s && s !== token);
return next.length ? next.join(' ') : null;
}

export function Tooltip({
content,
children,
Expand Down Expand Up @@ -90,7 +107,7 @@ export function Tooltip({
}, [clearDelay]);

const hideIfLeavingTrigger = useCallback(
(e: FocusEvent<HTMLSpanElement>) => {
(e: FocusEvent<HTMLElement>) => {
const next = e.relatedTarget as Node | null;
if (next && e.currentTarget.contains(next)) return;
hide();
Expand All @@ -112,6 +129,28 @@ export function Tooltip({
};
}, [open, updatePosition]);

useEffect(() => {
const root = triggerRef.current;
if (!root) return;
const focusable = root.querySelector<HTMLElement>(
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',
);
if (!focusable) return;

if (open) {
const next = mergeDescribedBy(focusable.getAttribute('aria-describedby'), id);
focusable.setAttribute('aria-describedby', next);
return;
}

const next = removeDescribedBy(focusable.getAttribute('aria-describedby'), id);
if (next) {
focusable.setAttribute('aria-describedby', next);
} else {
focusable.removeAttribute('aria-describedby');
}
}, [open, id]);

return (
<>
<span
Expand Down
10 changes: 10 additions & 0 deletions ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,13 @@
.border-r-column-subtle {
border-right: 1px solid color-mix(in srgb, var(--border-subtle) 45%, transparent);
}

/* Sticky checklist: checked items get placeholder-colored text (matches Plane) */
.sticky-note-editor-content ul[data-type='taskList'] li[data-checked='true'] > div {
color: var(--txt-placeholder);
}

.sticky-note-editor-content ul[data-type='taskList'] li > div,
.sticky-note-editor-content ul[data-type='taskList'] li > div > p {
transition: color 0.2s ease;
}
Loading