Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

style(tags): restyle edit/filter btns for tags, add truncation (#5412)

Seamus29358bd828d1
diff --git a/apps/web/src/features/property/tags/EntityRowTags.tsx b/apps/web/src/features/property/tags/EntityRowTags.tsx
index 633850e01d..ee3f8d11cf 100644
--- a/apps/web/src/features/property/tags/EntityRowTags.tsx
+++ b/apps/web/src/features/property/tags/EntityRowTags.tsx
@@ -4,7 +4,7 @@ import FilterIcon from '@phosphor/funnel-simple.svg';
import PencilIcon from '@phosphor/pencil-simple.svg';
import { EntityType } from '@service-properties/generated/schemas/entityType';
import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';
-import { cn, HoverCard, Layer } from '@ui';
+import { Button, cn, HoverCard, Layer } from '@ui';
import { createSignal, For, Match, Show, Switch } from 'solid-js';
import { TagDot } from './TagDot';
import { type EditableTag, TagEditorDialog } from './TagEditorDialog';
@@ -23,6 +23,9 @@ const chipClass = cn(
'px-1.5 py-0.5 leading-tight rounded-full bg-surface text-ink-muted text-xs',
'hover:text-ink'
);
+const hoverMenuLabelClass = 'min-w-0 max-w-[30ch] truncate';
+const hoverMenuIconButtonClass =
+ 'size-5 shrink-0 p-0.5 text-ink-extra-muted [&_:where(svg)]:size-3.5';
function HoverTagRow(props: {
tag: ResolvedTag;
@@ -30,31 +33,47 @@ function HoverTagRow(props: {
onEdit: (tag: ResolvedTag) => void;
}) {
return (
- <div class="flex items-center gap-1 whitespace-nowrap rounded-md px-1.5 py-1 text-ink hover:bg-hover">
- <Show
- when={props.onFilter}
- fallback={
- <span class="flex min-w-0 flex-1 items-center gap-1.5">
- <TagDot color={props.tag.color} />
- <span class="min-w-0 truncate">{props.tag.label}</span>
- </span>
- }
- >
+ <div class="flex min-w-0 items-center gap-1 whitespace-nowrap rounded-md px-1.5 py-1 text-ink hover:bg-hover">
+ <span class="flex min-w-0 flex-1 items-center gap-1.5">
+ <TagDot color={props.tag.color} />
+ <span class={hoverMenuLabelClass}>{props.tag.label}</span>
+ </span>
+ <Show when={props.onFilter}>
{(onFilter) => (
- <button
+ <Button
type="button"
- class="flex min-w-0 flex-1 items-center gap-1.5 text-left"
- onClick={() => onFilter()(props.tag.optionId)}
+ variant="ghost"
+ size="icon-sm"
+ noTouchResize
+ tooltip="Filter by tag"
+ aria-label={`Filter by ${props.tag.label}`}
+ class={hoverMenuIconButtonClass}
+ onMouseDown={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ }}
+ onClick={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ onFilter()(props.tag.optionId);
+ }}
>
- <TagDot color={props.tag.color} />
- <span class="min-w-0 truncate">{props.tag.label}</span>
- </button>
+ <FilterIcon class="size-3.5" />
+ </Button>
)}
</Show>
- <button
+ <Button
type="button"
+ variant="ghost"
+ size="icon-sm"
+ noTouchResize
+ tooltip="Edit tag"
aria-label={`Edit ${props.tag.label}`}
- class="flex size-5 shrink-0 items-center justify-center rounded text-ink-extra-muted hover:bg-hover hover:text-ink"
+ class={hoverMenuIconButtonClass}
+ onMouseDown={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ }}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
@@ -62,7 +81,7 @@ function HoverTagRow(props: {
}}
>
<PencilIcon class="size-3.5" />
- </button>
+ </Button>
</div>
);
}
@@ -73,11 +92,11 @@ function TagHoverContent(props: {
onEdit: (tag: ResolvedTag) => void;
}) {
return (
- <div class="flex items-center gap-1 rounded-md px-1.5 py-1 text-ink hover:bg-hover">
+ <div class="flex flex-col gap-0.5 text-ink">
<Show
when={props.onFilterByTag}
fallback={
- <span class="flex min-w-0 flex-1 items-center gap-1.5">
+ <span class="flex min-w-0 items-center gap-1.5 whitespace-nowrap rounded-md px-2 py-1.5">
<TagDot color={props.tag.color} />
<span class="min-w-0 truncate">{props.tag.label}</span>
</span>
@@ -86,11 +105,11 @@ function TagHoverContent(props: {
{(onFilterByTag) => (
<button
type="button"
- class="flex min-w-0 flex-1 items-center gap-1.5 whitespace-nowrap text-left"
+ class="flex w-full min-w-0 items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left hover:bg-hover"
onClick={() => onFilterByTag()(props.tag.optionId)}
>
<FilterIcon class="size-3.5 shrink-0 text-ink-muted" />
- <span>
+ <span class={hoverMenuLabelClass}>
Filter by <span class="font-medium">{props.tag.label}</span>
</span>
</button>
@@ -99,14 +118,17 @@ function TagHoverContent(props: {
<button
type="button"
aria-label={`Edit ${props.tag.label}`}
- class="flex size-5 shrink-0 items-center justify-center rounded text-ink-extra-muted hover:bg-hover hover:text-ink"
+ class="flex w-full min-w-0 items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left hover:bg-hover"
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
props.onEdit(props.tag);
}}
>
- <PencilIcon class="size-3.5" />
+ <PencilIcon class="size-3.5 shrink-0 text-ink-muted" />
+ <span class={hoverMenuLabelClass}>
+ Edit <span class="font-medium">{props.tag.label}</span>
+ </span>
</button>
</div>
);
diff --git a/apps/web/src/features/property/tags/TagPicker.tsx b/apps/web/src/features/property/tags/TagPicker.tsx
index a959a02946..95fc948736 100644
--- a/apps/web/src/features/property/tags/TagPicker.tsx
+++ b/apps/web/src/features/property/tags/TagPicker.tsx
@@ -1,5 +1,8 @@
+import { useSplitLayout } from '@components/app/split-layout/layout';
+import { useSplitPanel } from '@components/app/split-layout/layoutUtils';
import { Popover } from '@kobalte/core/popover';
import CircleDashedEmpty from '@phosphor/circle-dashed.svg';
+import FilterIcon from '@phosphor/funnel-simple.svg';
import PencilIcon from '@phosphor/pencil-simple.svg';
import PlusIcon from '@phosphor/plus.svg';
import { OptionCheckBox } from '@property/editors/selectors/OptionCheckBox';
@@ -17,7 +20,7 @@ import {
import { useCurrentTeamQuery } from '@queries/team/teams';
import type { PropertyOptionResponse } from '@service-properties/generated/schemas/propertyOptionResponse';
import type { TagScope } from '@service-properties/generated/schemas/tagScope';
-import { Layer } from '@ui';
+import { Button, Layer } from '@ui';
import {
createEffect,
createMemo,
@@ -36,6 +39,7 @@ import {
type TagEditorDialogMode,
} from './TagEditorDialog';
import { DEFAULT_TAG_COLOR, TAG_COLOR_OPTIONS } from './tagColors';
+import { navigateToTag } from './tagNavigation';
import type { ResolvedTag, useDocTags } from './useDocTags';
type DocTags = ReturnType<typeof useDocTags>;
@@ -61,6 +65,8 @@ function nextDisplayOrder(options: PropertyOptionResponse[]): number {
}
const MAX_LIST_HEIGHT = 192;
+const tagActionButtonClass =
+ 'size-5 shrink-0 p-0.5 text-ink-extra-muted opacity-0 group-hover:opacity-100 focus-visible:opacity-100 [&_:where(svg)]:size-3.5';
type TagPickerProps = {
replaceTag?: ResolvedTag;
@@ -310,6 +316,8 @@ function TagPickerBody(props: {
const currentTeamQuery = useCurrentTeamQuery();
const addOption = useAddPropertyOptionMutation();
const ensureTagSet = useEnsureTagSetMutation();
+ const split = useSplitLayout();
+ const panel = useSplitPanel();
let scrollContainerRef: HTMLDivElement | undefined;
const [initialOutsideEventGuard, setInitialOutsideEventGuard] =
createSignal(true);
@@ -487,6 +495,19 @@ function TagPickerBody(props: {
});
};
+ const openTaggedItems = async (item: TagOptionItem) => {
+ if (!(await persistSelection())) return;
+ props.onClose();
+ navigateToTag(
+ split.openWithSplit,
+ {
+ optionId: item.option.id,
+ propertyDefinitionId: item.option.propertyDefinitionId,
+ },
+ { handle: panel?.handle }
+ );
+ };
+
const createTag = async (scope: TagScope) => {
const value = createDraftLabel().trim();
if (!value) return;
@@ -691,6 +712,7 @@ function TagPickerBody(props: {
if (!event.shiftKey) saveAndClose();
}}
onEdit={() => void beginEdit(item)}
+ onOpenTag={() => void openTaggedItems(item)}
onMouseEnter={() => {
if (!dropdown.keyboardMode()) {
dropdown.setSelectedIndex(itemIndex(item));
@@ -725,6 +747,7 @@ function TagPickerBody(props: {
if (!event.shiftKey) saveAndClose();
}}
onEdit={() => void beginEdit(item)}
+ onOpenTag={() => void openTaggedItems(item)}
onMouseEnter={() => {
if (!dropdown.keyboardMode()) {
dropdown.setSelectedIndex(itemIndex(item));
@@ -820,39 +843,70 @@ function TagPickerRow(props: {
selected: boolean;
onSelect: (event: MouseEvent) => void;
onEdit: () => void;
+ onOpenTag: () => void;
onMouseEnter: () => void;
}) {
+ const label = () => optionLabel(props.item.option);
+
return (
<div data-tag-index={props.index}>
<DropdownSelectableRow
isSelected={props.selected}
onClick={props.onSelect}
onMouseEnter={props.onMouseEnter}
+ rightContent={
+ <div class="flex items-center gap-1">
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ noTouchResize
+ tooltip="View tagged items"
+ aria-label={`View all items with tag ${label()}`}
+ class={tagActionButtonClass}
+ onMouseDown={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ }}
+ onClick={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ props.onOpenTag();
+ }}
+ >
+ <FilterIcon class="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ noTouchResize
+ tooltip="Edit tag"
+ aria-label={`Edit ${label()}`}
+ class={tagActionButtonClass}
+ onMouseDown={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ }}
+ onClick={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ props.onEdit();
+ }}
+ >
+ <PencilIcon class="size-3.5" />
+ </Button>
+ </div>
+ }
>
<OptionCheckBox checked={props.checked} multiselect />
<TagDot color={props.item.option.color ?? undefined} />
- <span class="min-w-0 truncate">{optionLabel(props.item.option)}</span>
+ <span class="min-w-0 truncate">{label()}</span>
<Show when={props.item.scope === 'team'}>
<span class="max-w-20 shrink-0 truncate rounded-full border border-ink/5 px-1.5 py-0.5 text-[10px] leading-none text-ink-extra-muted">
{props.teamName}
</span>
</Show>
- <button
- type="button"
- aria-label={`Edit ${optionLabel(props.item.option)}`}
- class="ml-1 flex size-5 shrink-0 items-center justify-center rounded text-ink-extra-muted opacity-0 outline-none hover:bg-hover hover:text-ink group-hover:opacity-100 focus-visible:opacity-100"
- onMouseDown={(event) => {
- event.preventDefault();
- event.stopPropagation();
- }}
- onClick={(event) => {
- event.preventDefault();
- event.stopPropagation();
- props.onEdit();
- }}
- >
- <PencilIcon class="size-3.5" />
- </button>
</DropdownSelectableRow>
</div>
);