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.

feat(tasks): restyle and improve task compose modal (#3466)

Seamus2c1a7d20159b
diff --git a/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx b/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx
index 53c677c5d3..22eeee5ffb 100644
--- a/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx
+++ b/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx
@@ -1,7 +1,7 @@
import { SoupContextProvider } from '@app/component/next-soup/soup-context';
import clickOutside from '@core/directive/clickOutside';
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
-import { Dialog, Surface } from '@ui';
+import { Dialog, Panel } from '@ui';
import { createMemo, createSignal, For, Show } from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { SplitPanelContext, type SplitPanelContextType } from '../context';
@@ -130,17 +130,17 @@ function PopoverSplitModal(props: {
bindHotKeyDom(r);
}}
>
- <Surface depth={2} active class="rounded-xl">
- <div class="*:max-h-[75vh]">
- <SplitPanelContext.Provider value={stubPanelContext}>
- <SoupContextProvider>
- <Show when={props.popover.mount}>
+ <Panel depth={2} active class="rounded-xl">
+ <SplitPanelContext.Provider value={stubPanelContext}>
+ <SoupContextProvider>
+ <Show when={props.popover.mount}>
+ <Panel.Body>
<Dynamic component={props.popover.mount.element} />
- </Show>
- </SoupContextProvider>
- </SplitPanelContext.Provider>
- </div>
- </Surface>
+ </Panel.Body>
+ </Show>
+ </SoupContextProvider>
+ </SplitPanelContext.Provider>
+ </Panel>
</Dialog>
);
}
diff --git a/js/app/packages/block-md/component/ComposeTask.tsx b/js/app/packages/block-md/component/ComposeTask.tsx
index e330e0d71c..90572bd132 100644
--- a/js/app/packages/block-md/component/ComposeTask.tsx
+++ b/js/app/packages/block-md/component/ComposeTask.tsx
@@ -1,16 +1,14 @@
import { useSplitLayout } from '@app/component/split-layout/layout';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
-import { CircleSpinner } from '@core/component/CircleSpinner';
-import { EntityIcon } from '@core/component/EntityIcon';
import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';
import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';
+import { addMediaFromFile } from '@core/component/LexicalMarkdown/plugins/media';
import { initializeEditorEmpty } from '@core/component/LexicalMarkdown/utils';
import {
propertyApiValuesToNormalized,
propertyValueToApi,
} from '@core/component/Properties/api/converters';
import { Modals } from '@core/component/Properties/component/modal';
-import { PropertyGrid } from '@core/component/Properties/component/panel';
import {
PROPERTY_OPTION_IDS,
SYSTEM_PROPERTY_IDS,
@@ -29,11 +27,11 @@ import { useUserId } from '@core/context/user';
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
import { createTask } from '@core/util/create';
import { filterMap } from '@core/util/list';
-
import { buildSimpleEntityUrl } from '@core/util/url';
import ArrowSquareOutIcon from '@phosphor/arrow-square-out.svg';
+import ArrowsOutIcon from '@phosphor/arrows-out.svg';
+import PaperclipIcon from '@phosphor/paperclip.svg';
import SplitIcon from '@phosphor/square-half.svg';
-import TrashIcon from '@phosphor/trash.svg';
import XIcon from '@phosphor/x.svg';
import { useUpsertToHistoryMutation } from '@queries/history/history';
import { refetchSoupEntity } from '@queries/soup/cache';
@@ -41,9 +39,16 @@ import { propertiesServiceClient } from '@service-properties/client';
import type { PropertyDefinition } from '@service-properties/generated/schemas/propertyDefinition';
import { debounce } from '@solid-primitives/scheduled';
import { useQuery } from '@tanstack/solid-query';
-import { Button, Hotkey, ToggleSwitch } from '@ui';
+import { Button, Hotkey, Scroll, ToggleSwitch } from '@ui';
import type { LexicalEditor } from 'lexical';
-import { createEffect, createSignal, onMount, Show, Suspense } from 'solid-js';
+import {
+ createEffect,
+ createSignal,
+ For,
+ onMount,
+ Show,
+ Suspense,
+} from 'solid-js';
import { createStore, reconcile, type Store, unwrap } from 'solid-js/store';
import { tabbable } from 'tabbable';
import {
@@ -52,13 +57,14 @@ import {
saveTaskComposerDraft,
updateDraftTimestamp,
} from '../util/taskComposerStorage';
+import { InlinePropertyValue } from './InlinePropertyValue';
-// Show these props in the composer.
+// Show these props in the composer (Linear-style left-to-right order).
const COMPOSER_PROPERTIES = [
- SYSTEM_PROPERTY_IDS.ASSIGNEES,
SYSTEM_PROPERTY_IDS.STATUS,
- SYSTEM_PROPERTY_IDS.DUE_DATE,
SYSTEM_PROPERTY_IDS.PRIORITY,
+ SYSTEM_PROPERTY_IDS.ASSIGNEES,
+ SYSTEM_PROPERTY_IDS.DUE_DATE,
];
/**
@@ -247,6 +253,19 @@ export function ComposeTask(props: ComposeTaskProps) {
const [createMore, setCreateMore] = createSignal(false);
const [errorMessage, setErrorMessage] = createSignal<string>('');
const [isCreating, setIsCreating] = createSignal(false);
+ let attachInputRef: HTMLInputElement | undefined;
+
+ const handleAttachFiles = async (event: Event) => {
+ const input = event.currentTarget as HTMLInputElement;
+ const files = Array.from(input.files ?? []);
+ input.value = '';
+ const editor = bodyEditor();
+ if (!editor || files.length === 0) return;
+ for (const file of files) {
+ const mediaType = file.type.startsWith('video/') ? 'video' : 'image';
+ await addMediaFromFile(editor, file, mediaType);
+ }
+ };
const [propertyValues, setPropertyValues] = createStore<
Record<string, PropertyApiValues>
@@ -262,7 +281,11 @@ export function ComposeTask(props: ComposeTaskProps) {
createEffect(() => {
const currentTitle = title();
const currentContent = content();
- const currentProperties = { ...unwrap(propertyValues) };
+ // Deeply read propertyValues so this effect subscribes to any property
+ // change (e.g. setting a due date). unwrap()'d access doesn't subscribe,
+ // so without this the draft only saved when title/content changed.
+ JSON.stringify(propertyValues);
+ const currentProperties = structuredClone(unwrap(propertyValues));
if (hasInitializedFromDraft) {
hasInitializedFromDraft = false;
@@ -486,6 +509,64 @@ export function ComposeTask(props: ComposeTaskProps) {
}
};
+ const handleContinueInSplit = async () => {
+ if (isCreating()) return;
+
+ const taskTitle = title().trim();
+ const taskContent = content().trim();
+
+ setErrorMessage('');
+ setIsCreating(true);
+
+ const properties = structuredClone(Object.entries(unwrap(propertyValues)));
+ const draftSnapshot = {
+ title: taskTitle,
+ content: taskContent,
+ propertyValues: structuredClone(unwrap(propertyValues)),
+ };
+ clearTaskComposerDraft();
+
+ splitPanel.handle.close();
+ props.onClose?.();
+
+ const split = openWithSplit(
+ { type: 'component', id: 'loading' },
+ { referredFrom: 'launcher', preferNewSplit: true }
+ );
+
+ const documentId = await createTaskWithProperties(
+ taskTitle,
+ taskContent,
+ properties,
+ definitions(),
+ (params) => upsertToHistoryMutation.mutate(params)
+ );
+
+ setIsCreating(false);
+
+ if (!documentId) {
+ split?.goBack();
+ saveTaskComposerDraft(draftSnapshot);
+ popoverSplit({ type: 'component', id: 'task-compose' });
+ return;
+ }
+
+ if (split) {
+ split.replace({
+ next: { type: 'task', id: documentId },
+ mergeHistory: true,
+ referredFrom: 'launcher',
+ });
+ } else {
+ openWithSplit(
+ { type: 'task', id: documentId },
+ { referredFrom: 'launcher', preferNewSplit: true }
+ );
+ }
+
+ props.onCreateTask?.(taskTitle, taskContent);
+ };
+
const handleClose = () => {
const currentTitle = title();
const currentContent = content();
@@ -563,38 +644,53 @@ export function ComposeTask(props: ComposeTaskProps) {
return (
<div
- class="flex flex-col relative h-full max-h-full min-h-0"
+ class="flex flex-col relative h-full max-h-full min-h-0 p-4 gap-4"
tabIndex={-1}
ref={setContainerRef}
>
- <div class="flex items-center gap-1 p-2">
+ <div class="flex items-center gap-1">
+ <div class="flex-1 flex items-center">
+ <Show when={splitPanel?.handle.isPopover()}>
+ <Button
+ onMouseDown={handleContinueInSplit}
+ disabled={isCreating()}
+ tabIndex={-1}
+ tooltip="Continue editing in split"
+ size="icon-sm"
+ >
+ <ArrowsOutIcon />
+ </Button>
+ </Show>
+ </div>
+ <Show when={content().trim() || title()}>
+ <Button
+ onMouseDown={handleClearDraft}
+ tabIndex={-1}
+ tooltip="Clear Draft"
+ size="sm"
+ variant="base"
+ depth={3}
+ class="bg-surface px-3"
+ >
+ Clear Draft
+ </Button>
+ </Show>
<Show when={splitPanel?.handle.isPopover()}>
- <Button onMouseDown={handleClose} tabIndex={-1} size="icon-sm">
+ <Button
+ onMouseDown={handleClose}
+ tabIndex={-1}
+ tooltip="Close"
+ size="icon-sm"
+ >
<XIcon />
</Button>
</Show>
- <div class="flex items-center gap-2 flex-1">
- <span class="text-sm font-medium text-ink-disabled/50">
- Create Task
- </span>
- </div>
- <Button
- onMouseDown={handleClearDraft}
- tabIndex={-1}
- tooltip="Clear Draft"
- size="icon-sm"
- disabled={!(content().trim() || title())}
- >
- <TrashIcon />
- </Button>
</div>
- <div class="border-b border-edge-muted" />
- <div class="p-2 flex-1 min-h-0 flex flex-col">
- <div class="shrink-0 flex p-2 gap-2 items-center">
- <EntityIcon targetType="task" size="sm" />
+ <div class="flex-1 min-h-0 flex flex-col overflow-hidden">
+ <div class="shrink-0 flex gap-2 items-center px-2">
<input
type="text"
- placeholder="Task Title"
+ placeholder="New task"
value={title()}
onInput={(e) => {
setTitle(e.currentTarget.value);
@@ -603,7 +699,7 @@ export function ComposeTask(props: ComposeTaskProps) {
}
}}
disabled={isCreating()}
- class="w-full py-2 text-xl font-medium placeholder-ink-placeholder disabled:opacity-50"
+ class="w-full py-2 text-xl font-medium placeholder-ink-placeholder disabled:opacity-50 truncate focus:overflow-visible"
on:keydown={(e) => {
if (e.key === 'Escape') {
const container = containerRef();
@@ -625,20 +721,23 @@ export function ComposeTask(props: ComposeTaskProps) {
/>
</div>
- <MarkdownShell
- config={editorConfig}
- initialState={initialState.editorState}
- initialValue={
- initialState.editorState
- ? undefined
- : initialState.content || undefined
- }
- placeholder={props.placeholder ?? 'Add description...'}
- portalScope={splitPanel.handle.isPopover() ? 'local' : 'block'}
- class="shrink min-h-0 h-[unset] text-base px-2 overflow-y-auto"
- />
+ <div class="overflow-auto scrollbar-hidden mb-6 min-h-24 grow px-2">
+ <Scroll>
+ <MarkdownShell
+ config={editorConfig}
+ initialState={initialState.editorState}
+ initialValue={
+ initialState.editorState
+ ? undefined
+ : initialState.content || undefined
+ }
+ placeholder={props.placeholder ?? 'Add description...'}
+ portalScope={splitPanel.handle.isPopover() ? 'local' : 'block'}
+ />
+ </Scroll>
+ </div>
- <Suspense>
+ <Suspense fallback={<div class="h-7" />}>
<PropertiesProvider
entityType="TASK"
canEdit={true}
@@ -648,15 +747,17 @@ export function ComposeTask(props: ComposeTaskProps) {
onPropertyDeleted={() => {}}
saveHandler={saveHandler}
>
- <div class="text-sm">
- <PropertyGrid
- properties={properties()}
- columns={2}
- withDelete={false}
- withPin={false}
- ></PropertyGrid>
- <Modals />
+ <div class="flex min-h-7 flex-row flex-wrap items-center gap-2 text-sm m-px">
+ <For each={properties()}>
+ {(property) => (
+ <InlinePropertyValue
+ property={property}
+ emptyLabel={property.displayName}
+ />
+ )}
+ </For>
</div>
+ <Modals />
</PropertiesProvider>
</Suspense>
</div>
@@ -668,31 +769,43 @@ export function ComposeTask(props: ComposeTaskProps) {
</div>
</Show>
- <div class="w-full border-b border-edge-muted" />
- <div class="shrink-0 flex justify-between items-center p-2 gap-2">
- <ToggleSwitch
- labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"
- onChange={setCreateMore}
- checked={createMore()}
- label="Create More"
+ <div class="shrink-0 flex justify-between items-end gap-2">
+ <input
+ ref={(el) => {
+ attachInputRef = el;
+ }}
+ type="file"
+ class="hidden"
+ multiple
+ accept="image/*,video/*"
+ onChange={handleAttachFiles}
/>
<Button
- onClick={handleCreateTask}
- class="px-3 pr-2"
- disabled={title().trim().length === 0 || isCreating()}
- variant="base"
+ onMouseDown={() => attachInputRef?.click()}
+ tabIndex={-1}
+ tooltip="Attach image or video"
+ size="icon-sm"
>
- <Show
- when={isCreating()}
- fallback={<EntityIcon targetType="task" theme="monochrome" />}
- >
- <CircleSpinner width={16} height={16} />
- </Show>
- Create Task
- <div class="text-xxs text-ink-extra-muted ml-auto border border-edge-muted px-1.5 py-1 font-sans rounded-xs">
- <Hotkey shortcut="cmd+enter" />
- </div>
+ <PaperclipIcon />
</Button>
+ <div class="flex items-center gap-3">
+ <ToggleSwitch
+ labelClass="text-xs text-ink-muted font-normal whitespace-nowrap"
+ onChange={setCreateMore}
+ checked={createMore()}
+ label="Create More"
+ />
+ <Button
+ onClick={handleCreateTask}
+ disabled={title().trim().length === 0 || isCreating()}
+ variant={title().trim().length === 0 ? 'ghost' : 'active'}
+ depth={3}
+ class="gap-3 rounded-lg border-0"
+ >
+ Create Task
+ <Hotkey shortcut="cmd+enter" theme="current" />
+ </Button>
+ </div>
</div>
</div>
);
diff --git a/js/app/packages/block-md/component/InlinePropertyValue.tsx b/js/app/packages/block-md/component/InlinePropertyValue.tsx
index 127f1804c8..44755d0fd3 100644
--- a/js/app/packages/block-md/component/InlinePropertyValue.tsx
+++ b/js/app/packages/block-md/component/InlinePropertyValue.tsx
@@ -5,10 +5,12 @@ import { Property } from '@property';
import type { Property as PropertyT } from '@property/types';
import { Layer } from '@ui';
import { cn } from '@ui/utils/classname';
-import { type Component, Match, Switch } from 'solid-js';
+import { type Component, type JSX, Match, Switch } from 'solid-js';
type InlinePropertyValueProps = {
property: PropertyT;
+ /** Label rendered when the property is empty. Defaults to "None". */
+ emptyLabel?: JSX.Element;
};
/**
@@ -49,7 +51,7 @@ export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
'bg-surface',
{
'hover:bg-hover': !isReadOnly(),
- 'text-ink-extra-muted/50': isEmpty(),
+ 'text-ink-extra-muted': isEmpty(),
}
)}
>
@@ -70,7 +72,7 @@ export const InlinePropertyValue: Component<InlinePropertyValueProps> = (
</Switch>
<Property.Text
property={props.property}
- fallback={<Property.Empty label="None" />}
+ fallback={<Property.Empty label={props.emptyLabel ?? 'None'} />}
/>
<Property.Caret />
</Property.EditTrigger>
diff --git a/js/app/packages/block-md/util/taskComposerStorage.ts b/js/app/packages/block-md/util/taskComposerStorage.ts
index acf99d9c25..c09f791648 100644
--- a/js/app/packages/block-md/util/taskComposerStorage.ts
+++ b/js/app/packages/block-md/util/taskComposerStorage.ts
@@ -49,6 +49,7 @@ export function loadTaskComposerDraft(): TaskComposerDraft | null {
return null;
}
+ draft.propertyValues = rehydratePropertyValues(draft.propertyValues);
return draft;
} catch (error) {
console.warn('Failed to load task composer draft:', error);
@@ -57,6 +58,27 @@ export function loadTaskComposerDraft(): TaskComposerDraft | null {
}
}
+// JSON.stringify serializes Date as an ISO string, and JSON.parse won't turn
+// it back into a Date. propertyApiValuesToNormalized requires `value instanceof
+// Date`, so without this step DATE properties round-trip as EMPTY.
+function rehydratePropertyValues(
+ values: Record<string, PropertyApiValues>
+): Record<string, PropertyApiValues> {
+ const result: Record<string, PropertyApiValues> = {};
+ for (const [key, value] of Object.entries(values)) {
+ if (value.valueType === 'DATE') {
+ const raw = (value as { value: unknown }).value;
+ result[key] = {
+ valueType: 'DATE',
+ value: typeof raw === 'string' ? new Date(raw) : (raw as Date | null),
+ };
+ } else {
+ result[key] = value;
+ }
+ }
+ return result;
+}
+
/**
* Clear task composer draft from local storage
*/
diff --git a/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx b/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
index 55ddac3872..2fa370ae2b 100644
--- a/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
@@ -188,7 +188,10 @@ export const MarkdownShell: Component<
return (
<LexicalWrapperContext.Provider value={lexicalWrapper}>
<div
- class={cn('relative h-full overflow-y-auto min-h-8', props.class)}
+ class={cn(
+ 'relative h-full overflow-y-auto min-h-8 scrollbar-hidden',
+ props.class
+ )}
on:keydown={(e) => e.stopPropagation()}
on:click={(e) => {
e.stopPropagation();
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/misc/DragInsertIndicator.tsx b/js/app/packages/core/component/LexicalMarkdown/component/misc/DragInsertIndicator.tsx
index 60cd329aea..c42ad77e43 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/misc/DragInsertIndicator.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/misc/DragInsertIndicator.tsx
@@ -40,7 +40,7 @@ export function DragInsertIndicator(props: {
<Show when={props.active}>
<Portal>
<div
- class="invisible fixed bg-accent/60 pointer-events-none rounded-full ring-6 ring-accent/10 transition-all duration-100 ease-in-out"
+ class="z-tool-tip invisible fixed bg-accent/60 pointer-events-none rounded-full ring-6 ring-accent/10 transition-all duration-100 ease-in-out"
classList={{
visible: props.state.visible,
}}
diff --git a/js/app/packages/property/src/editors/popover/EditorPopover.tsx b/js/app/packages/property/src/editors/popover/EditorPopover.tsx
index 45b9e730c5..789e9a14fb 100644
--- a/js/app/packages/property/src/editors/popover/EditorPopover.tsx
+++ b/js/app/packages/property/src/editors/popover/EditorPopover.tsx
@@ -30,7 +30,7 @@ export function EditorPopover(props: EditorPopoverProps) {
return (
<Dropdown.Content
class={cn(
- 'max-h-96 overflow-hidden flex flex-col w-full max-w-60 p-0',
+ 'max-h-96 overflow-hidden flex flex-col w-full max-w-70 p-0 text-xs',
props.class
)}
onInteractOutside={close}
diff --git a/js/app/packages/property/src/editors/selectors/PropertyDateSelector.tsx b/js/app/packages/property/src/editors/selectors/PropertyDateSelector.tsx
index dd348bdc39..add8015eff 100644
--- a/js/app/packages/property/src/editors/selectors/PropertyDateSelector.tsx
+++ b/js/app/packages/property/src/editors/selectors/PropertyDateSelector.tsx
@@ -5,7 +5,6 @@ import { useDateSearch } from '@core/util/dateSearch/useDateSearch';
import { useKeyPressed } from '@core/util/useKeyPressed';
import SearchIcon from '@phosphor/magnifying-glass.svg';
import { cn } from '@ui';
-import { format } from 'date-fns';
import {
createEffect,
createMemo,
@@ -40,10 +39,21 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
showTimeInResults: false,
});
- const totalOptions = createMemo(() => dateOptions().length + 1); // +1 for calendar button
+ const hasClear = () => props.selectedDate != null;
+ // When a date is set, replace the last suggestion with the Clear row so
+ // the section height stays the same.
+ const visibleDateOptions = createMemo(() => {
+ const all = dateOptions();
+ return hasClear() && all.length > 0 ? all.slice(0, -1) : all;
+ });
+ const calendarOptionIndex = () => visibleDateOptions().length;
+ const clearOptionIndex = () => visibleDateOptions().length + 1;
+ const totalOptions = createMemo(
+ () => visibleDateOptions().length + 1 + (hasClear() ? 1 : 0)
+ );
createEffect(
- on(dateOptions, (options) => {
+ on(visibleDateOptions, (options) => {
if (options.length === 0) {
setSelectedIndex(0);
} else {
@@ -67,7 +77,7 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
};
const scrollSelectedIntoView = () => {
- const options = dateOptions();
+ const options = visibleDateOptions();
const currentIndex = selectedIndex();
if (currentIndex >= 0 && currentIndex < options.length) {
const element = document.querySelector(
@@ -80,7 +90,7 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
};
const handleKeyDown = (e: KeyboardEvent) => {
- const options = dateOptions();
+ const options = visibleDateOptions();
const total = totalOptions();
if (
@@ -104,8 +114,10 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
e.preventDefault();
const currentIndex = selectedIndex();
- if (currentIndex === options.length) {
+ if (currentIndex === calendarOptionIndex()) {
setMode('calendar');
+ } else if (hasClear() && currentIndex === clearOptionIndex()) {
+ handleClearDate();
} else {
const selectedOption = options[currentIndex];
if (selectedOption) {
@@ -128,22 +140,13 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
() => true
);
- const currentDateDisplay = createMemo(() => {
- if (!props.selectedDate) return 'No date set';
- try {
- return format(props.selectedDate, "MMMM d, yyyy 'at' h:mm a");
- } catch {
- return 'Invalid date';
- }
- });
-
const handleCalendarChange = (date: Date) => {
handleSelectDate(date);
};
return (
<div class="relative">
- <div class="flex w-full items-center py-1 gap-2 px-2 border-b border-edge-muted">
+ <div class="flex w-full items-center py-2 gap-2 px-2 border-b border-edge-muted">
<SearchIcon class="size-4 text-ink-muted" />
<input
class="w-full caret-accent"
@@ -166,36 +169,19 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
</div>
<Switch>
<Match when={mode() === 'search'}>
- <Show when={props.selectedDate}>
- <div class="px-3 py-2 border-b border-edge-muted">
- <div class="flex items-center justify-between">
- <div class="flex items-center gap-2">
- <span class="text-xs text-ink-muted">Current:</span>
- <span class="text-xs font-medium">
- {currentDateDisplay()}
- </span>
- </div>
- <button
- onClick={() => handleClearDate(true)}
- class="text-xs text-ink-muted hover:text-ink underline"
- >
- Clear
- </button>
- </div>
- </div>
- </Show>
-
- <div class="p-1">
+ <div class="p-1.5">
<div class="max-h-50 overflow-y-auto overflow-x-hidden scrollbar-hidden">
<Show
- when={dateOptions().length > 0}
+ when={visibleDateOptions().length > 0}
fallback={
<Show
when={searchQuery().trim()}
fallback={
- <div class="text-center py-2 text-ink-muted text-sm">
- Enter a date or duration
- </div>
+ <Show when={!hasClear()}>
+ <div class="text-center py-2 text-ink-muted text-sm">
+ Enter a date or duration
+ </div>
+ </Show>
}
>
<div class="text-center py-2 text-ink-muted text-sm">
@@ -204,12 +190,12 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
</Show>
}
>
- <For each={dateOptions()}>
+ <For each={visibleDateOptions()}>
{(option, index) => (
<div
data-date-index={index()}
class={cn(
- 'flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2',
+ 'flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 rounded-md',
index() === selectedIndex() && 'bg-hover'
)}
onClick={() => handleSelectDate(option.date)}
@@ -220,9 +206,7 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
}}
>
<div class="flex items-center gap-2 flex-1 min-w-0">
- <p class="text-sm font-medium truncate">
- {option.displayText}
- </p>
+ <p class="truncate">{option.displayText}</p>
</div>
<span class="text-xs text-ink-muted">
@@ -235,21 +219,21 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
<div class="border-t border-edge-muted mt-1 pt-1">
<div
- data-date-index={dateOptions().length}
+ data-date-index={calendarOptionIndex()}
class={cn(
- 'flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2',
- selectedIndex() === dateOptions().length && 'bg-hover'
+ 'flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 rounded-md',
+ selectedIndex() === calendarOptionIndex() && 'bg-hover'
)}
onClick={() => setMode('calendar')}
onMouseEnter={() => {
if (!keyboardMode()) {
- setSelectedIndex(dateOptions().length);
+ setSelectedIndex(calendarOptionIndex());
}
}}
>
<div class="flex items-center gap-2 flex-1 min-w-0">
<div class="flex-1 min-w-0">
- <p class="text-sm font-medium truncate">Custom date...</p>
+ <p class="truncate">Custom date...</p>
</div>
</div>
<div class="flex items-center gap-2 shrink-0">
@@ -258,6 +242,25 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
</span>
</div>
</div>
+ <Show when={hasClear()}>
+ <div
+ data-date-index={clearOptionIndex()}
+ class={cn(
+ 'flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 rounded-md',
+ selectedIndex() === clearOptionIndex() && 'bg-hover'
+ )}
+ onClick={() => handleClearDate()}
+ onMouseEnter={() => {
+ if (!keyboardMode()) {
+ setSelectedIndex(clearOptionIndex());
+ }
+ }}
+ >
+ <div class="flex items-center gap-2 flex-1 min-w-0">
+ <p class="truncate text-ink-muted">Clear date</p>
+ </div>
+ </div>
+ </Show>
</div>
</div>
</div>
diff --git a/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx b/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
index e8ee4537c9..1d499137e2 100644
--- a/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
+++ b/js/app/packages/property/src/editors/selectors/PropertyOptionSelector.tsx
@@ -324,7 +324,7 @@ export const PropertyOptionSelector = (props: SelectOptionsProps) => {
<PlusIcon class="size-3" />
</Show>
</div>
- <p class="text-sm font-medium">Add "{dropdown.searchQuery().trim()}"</p>
+ <p>Add "{dropdown.searchQuery().trim()}"</p>
</div>
</div>
);
@@ -362,7 +362,7 @@ export const PropertyOptionSelector = (props: SelectOptionsProps) => {
<Show
when={isValidNewOption() && props.onAddOption}
fallback={
- <div class="text-center py-6 text-ink-muted text-sm">
+ <div class="text-center py-6 text-ink-muted">
No options available
</div>
}
@@ -383,7 +383,7 @@ export const PropertyOptionSelector = (props: SelectOptionsProps) => {
<Show
when={selectableItems().length > 0}
fallback={
- <div class="text-center py-4 text-ink-muted text-sm">
+ <div class="text-center py-4 text-ink-muted">
No options match your search
</div>
}
@@ -432,7 +432,7 @@ export const PropertyOptionSelector = (props: SelectOptionsProps) => {
optionId={optionItem().option.id}
/>
<div class="flex-1 min-w-0 text-left">
- <p class="text-sm font-medium truncate">
+ <p class="truncate">
{optionItem().option.label}
</p>
</div>
@@ -460,7 +460,7 @@ export const PropertyOptionSelector = (props: SelectOptionsProps) => {
>
<CircleDashedEmpty class="size-3 shrink-0 text-ink-extra-muted" />
<div class="flex-1 min-w-0 text-left">
- <p class="text-sm font-medium text-ink-muted truncate">
+ <p class="text-ink-muted truncate">
{clear().label}
</p>
</div>
diff --git a/js/app/packages/ui/components/Hotkey.tsx b/js/app/packages/ui/components/Hotkey.tsx
index 3230e9ba4c..e96fbecf92 100644
--- a/js/app/packages/ui/components/Hotkey.tsx
+++ b/js/app/packages/ui/components/Hotkey.tsx
@@ -48,7 +48,7 @@ const hotkeyStyles: Record<Theme, { label: string; hotkey: string }> = {
label: 'bg-accent border border-accent/30 text-surface',
},
current: {
- hotkey: 'bg-surface border border-current text-current',
+ hotkey: 'border border-current/30 text-current',
label: 'bg-current border border-current text-surface',
},
accentFill: {
diff --git a/js/app/packages/ui/components/ToggleSwitch.tsx b/js/app/packages/ui/components/ToggleSwitch.tsx
index 4fa78d0a3d..c016bf304e 100644
--- a/js/app/packages/ui/components/ToggleSwitch.tsx
+++ b/js/app/packages/ui/components/ToggleSwitch.tsx
@@ -1,5 +1,5 @@
import { Switch as KobalteSwitch } from '@kobalte/core/switch';
-import { Show } from 'solid-js';
+import { Show, createSignal, onCleanup, splitProps } from 'solid-js';
import { cn } from '../utils/classname';
import type { JSX } from 'solid-js';
@@ -14,29 +14,58 @@ export type ToggleSwitchProps = {
};
export const ToggleSwitch = (props: ToggleSwitchProps): JSX.Element => {
+ const [local, others] = splitProps(props, [
+ 'defaultChecked',
+ 'labelClass',
+ 'onChange',
+ 'disabled',
+ 'checked',
+ 'class',
+ 'label',
+ ]);
+ const [isStretched, setIsStretched] = createSignal(false);
+ let stretchTimeout: ReturnType<typeof setTimeout> | undefined;
+
+ const triggerStretch = () => {
+ setIsStretched(true);
+ if (stretchTimeout) clearTimeout(stretchTimeout);
+ stretchTimeout = setTimeout(() => setIsStretched(false), 75);
+ };
+
+ const handleChange = (checked: boolean) => {
+ triggerStretch();
+ local.onChange?.(checked);
+ };
+
+ onCleanup(() => {
+ if (stretchTimeout) clearTimeout(stretchTimeout);
+ });
+
return (
<KobalteSwitch
- class={cn(
- 'inline-flex items-center gap-2 font-medium text-[14px]',
- props.disabled && 'opacity-50 cursor-not-allowed',
- props.class
- )}
- checked={props.checked}
- defaultChecked={props.defaultChecked}
- onChange={props.onChange}
- disabled={props.disabled}
+ class={cn('inline-flex items-center gap-2', local.class)}
+ defaultChecked={local.defaultChecked}
+ onChange={handleChange}
+ disabled={local.disabled}
+ checked={local.checked}
+ {...others}
>
<KobalteSwitch.Input class="sr-only" />
- <Show when={props.label != null}>
- <KobalteSwitch.Label
- class={cn('whitespace-nowrap', props.labelClass)}
- >
- {props.label}
+ <KobalteSwitch.Control class="relative h-4 w-6 rounded-full bg-edge transition-colors duration-100 data-checked:bg-accent">
+ <KobalteSwitch.Thumb
+ class={cn(
+ 'absolute top-0.5 left-0.5 h-3 rounded-full bg-surface transition-all duration-100 ease-in-out',
+ isStretched()
+ ? 'w-4 data-checked:translate-x-1'
+ : 'w-3 data-checked:translate-x-2',
+ )}
+ />
+ </KobalteSwitch.Control>
+ <Show when={local.label != null}>
+ <KobalteSwitch.Label class={cn(local.labelClass)}>
+ {local.label}
</KobalteSwitch.Label>
</Show>
- <KobalteSwitch.Control class="relative w-8 h-3 touch:w-12 touch:h-8 rounded-full bg-edge transition-colors duration-80 data-[checked]:bg-accent">
- <KobalteSwitch.Thumb class="absolute top-0.5 size-2 touch:size-7 rounded-full bg-surface transition-transform duration-200 ease-out translate-x-0.5 data-[checked]:translate-x-5.5 touch:data-[checked]:translate-x-4.5" />
- </KobalteSwitch.Control>
</KobalteSwitch>
);
};