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(style): Google Drivemaxx share menu (#2182)

Aidan Holloway-Bidwelldfce82633aa6
diff --git a/js/app/packages/core/component/CustomScrollbar.tsx b/js/app/packages/core/component/CustomScrollbar.tsx
index b2a1bd8cc7..ecb37d843c 100644
--- a/js/app/packages/core/component/CustomScrollbar.tsx
+++ b/js/app/packages/core/component/CustomScrollbar.tsx
@@ -10,6 +10,7 @@ interface CustomScrollbarProps {
labelClass?: string;
enabled?: boolean;
reverse?: boolean;
+ horizontal?: boolean;
}
export function CustomScrollbar(props: CustomScrollbarProps) {
@@ -21,11 +22,13 @@ export function CustomScrollbar(props: CustomScrollbarProps) {
}
function InnerCustomScrollbar(props: CustomScrollbarProps) {
- const [scrollTop, setScrollTop] = createSignal(0);
- const [scrollHeight, setScrollHeight] = createSignal(0);
- const [clientHeight, setClientHeight] = createSignal(0);
+ const horiz = () => props.horizontal ?? false;
+
+ const [scrollPos, setScrollPos] = createSignal(0);
+ const [scrollSize, setScrollSize] = createSignal(0);
+ const [clientSize, setClientSize] = createSignal(0);
const [isDragging, setIsDragging] = createSignal(false);
- const [scrollStartTop, setScrollStartTop] = createSignal(0);
+ const [scrollStart, setScrollStart] = createSignal(0);
const [isScrolling, setIsScrolling] = createSignal(false);
const [isHovering, setIsHovering] = createSignal(false);
@@ -43,59 +46,46 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {
const updateScrollMetrics = () => {
const container = props.scrollContainer();
if (!container) return;
-
- const { scrollTop, scrollHeight, clientHeight } = container;
-
- setScrollTop(scrollTop);
- setScrollHeight(scrollHeight);
- setClientHeight(clientHeight);
+ if (horiz()) {
+ setScrollPos(container.scrollLeft);
+ setScrollSize(container.scrollWidth);
+ setClientSize(container.clientWidth);
+ } else {
+ setScrollPos(container.scrollTop);
+ setScrollSize(container.scrollHeight);
+ setClientSize(container.clientHeight);
+ }
};
- const maxScroll = () => Math.max(0, scrollHeight() - clientHeight());
-
- /**
- * Maps the container's scroll position to an offset measured from the top of
- * the content in the normal (non-reversed) coordinate space.
- *
- * When using reverse layouts (e.g. `flex-direction: column-reverse`), many
- * browsers report `scrollTop` in the range `[-maxScroll..0]`. In that case:
- * - at visual top: scrollTop === -maxScroll
- * - at visual bottom: scrollTop === 0
- *
- * We map that into [0..maxScroll] so the thumb can correctly reach the top.
- */
- const scrollOffsetFromTop = () => {
+ const maxScroll = () => Math.max(0, scrollSize() - clientSize());
+
+ const scrollOffset = () => {
const max = maxScroll();
if (max <= 0) return 0;
-
- if (!props.reverse) {
- return Math.max(0, Math.min(max, scrollTop()));
+ if (!props.reverse || horiz()) {
+ return Math.max(0, Math.min(max, scrollPos()));
}
+ return Math.max(0, Math.min(max, max + scrollPos()));
+ };
- // For reversed scrollTop in [-max..0], this converts to [0..max]
- return Math.max(0, Math.min(max, max + scrollTop()));
+ const thumbSize = () => {
+ const cSize = clientSize();
+ const sSize = scrollSize();
+ if (sSize <= cSize) return 0;
+ return Math.max(20, (cSize / sSize) * cSize);
};
- // Calculate scrollbar metrics
- function thumbHeight() {
- const containerHeight = clientHeight();
- const contentHeight = scrollHeight();
- if (contentHeight <= containerHeight) return 0;
- return Math.max(20, (containerHeight / contentHeight) * containerHeight);
- }
- const thumbTop = () => {
- const containerHeight = clientHeight();
+ const thumbOffset = () => {
+ const cSize = clientSize();
const max = maxScroll();
if (max <= 0) return 0;
- const thumbH = thumbHeight();
- const trackSpace = Math.max(0, containerHeight - thumbH);
- const offset = scrollOffsetFromTop();
- return (offset / max) * trackSpace;
+ const tSize = thumbSize();
+ const trackSpace = Math.max(0, cSize - tSize);
+ return (scrollOffset() / max) * trackSpace;
};
- const isVisible = () => scrollHeight() > clientHeight();
+ const isVisible = () => scrollSize() > clientSize();
- // Handle scroll events
createEffect(() => {
const container = props.scrollContainer();
if (!container) return;
@@ -103,26 +93,17 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {
updateScrollMetrics();
const handleScroll = () => {
- if (!isDragging()) {
- updateScrollMetrics();
- }
-
- // Show scrollbar while scrolling, hide after delay
+ if (!isDragging()) updateScrollMetrics();
setIsScrolling(true);
debouncedHideScrollbar();
-
if (props.labelVisibilityDebounceMs !== Infinity) {
setScrollLabelVisible(true);
debouncedHideScrollLabel();
}
};
- const handleResize = () => {
- updateScrollMetrics();
- };
-
container.addEventListener('scroll', handleScroll, { passive: true });
- const resizeObserver = new ResizeObserver(handleResize);
+ const resizeObserver = new ResizeObserver(updateScrollMetrics);
resizeObserver.observe(container);
onCleanup(() => {
@@ -131,7 +112,6 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {
});
});
- // Handle mouse drag
const handleMouseDown = (e: MouseEvent) => {
e.preventDefault();
e.stopPropagation();
@@ -140,35 +120,37 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {
if (!container) return;
setIsDragging(true);
- // Store "offset from top" so dragging works consistently in reverse mode.
- setScrollStartTop(scrollOffsetFromTop());
+ setScrollStart(scrollOffset());
let isDraggingLocal = true;
const handleMouseMove = (moveEvent: MouseEvent) => {
if (!isDraggingLocal) return;
- const deltaY = moveEvent.clientY - e.clientY;
- const trackH = clientHeight();
+ const delta = horiz()
+ ? moveEvent.clientX - e.clientX
+ : moveEvent.clientY - e.clientY;
+ const trackSize = clientSize();
const max = maxScroll();
if (max <= 0) return;
- const thumbH = thumbHeight();
- const trackSpace = trackH - thumbH;
+ const tSize = thumbSize();
+ const trackSpace = trackSize - tSize;
if (trackSpace <= 0) return;
- const scrollRatio = deltaY / trackSpace;
- let newScrollTop = Math.max(
+ const scrollRatio = delta / trackSpace;
+ let newPos = Math.max(
0,
- Math.min(max, scrollStartTop() + scrollRatio * max)
+ Math.min(max, scrollStart() + scrollRatio * max)
);
- if (props.reverse) {
- // Convert [0..max] back into [-max..0] for reversed layouts.
- newScrollTop = newScrollTop - max;
- }
+ if (props.reverse && !horiz()) newPos = newPos - max;
- container.scrollTop = newScrollTop;
- setScrollTop(newScrollTop);
+ if (horiz()) {
+ container.scrollLeft = newPos;
+ } else {
+ container.scrollTop = newPos;
+ }
+ setScrollPos(newPos);
};
const handleMouseUp = () => {
@@ -182,26 +164,27 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {
document.addEventListener('mouseup', handleMouseUp);
};
- // Handle track click
const handleTrackClick = (e: MouseEvent) => {
const container = props.scrollContainer();
if (!container) return;
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
- const clickY = e.clientY - rect.top;
- const trackH = clientHeight();
+ const clickPos = horiz() ? e.clientX - rect.left : e.clientY - rect.top;
+ const trackSize = horiz() ? rect.width : rect.height;
const max = maxScroll();
if (max <= 0) return;
- const scrollRatio = clickY / trackH;
- let newScrollTop = Math.max(0, Math.min(max, scrollRatio * max));
+ const scrollRatio = clickPos / trackSize;
+ let newPos = Math.max(0, Math.min(max, scrollRatio * max));
- if (props.reverse) {
- newScrollTop = newScrollTop - max;
- }
+ if (props.reverse && !horiz()) newPos = newPos - max;
- container.scrollTop = newScrollTop;
- setScrollTop(newScrollTop);
+ if (horiz()) {
+ container.scrollLeft = newPos;
+ } else {
+ container.scrollTop = newPos;
+ }
+ setScrollPos(newPos);
};
const getThumbOpacity = () => {
@@ -212,6 +195,12 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {
};
const getThumbScale = () => {
+ if (horiz()) {
+ if (isDragging()) return 'scaleY(4)';
+ if (isHovering()) return 'scaleY(2)';
+ if (isScrolling()) return 'scaleY(2)';
+ return 'scaleY(1)';
+ }
if (isDragging()) return 'scaleX(4)';
if (isHovering()) return 'scaleX(2)';
if (isScrolling()) return 'scaleX(2)';
@@ -221,7 +210,7 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {
return (
<Show when={isVisible()}>
<div
- class={`absolute right-0 top-0 bottom-0 w-[1px] pointer-events-auto overflow-visible bg-transparent ${props.class || ''}`}
+ class={`absolute pointer-events-auto overflow-visible bg-transparent ${horiz() ? 'bottom-0 left-0 right-0 h-[1px]' : 'right-0 top-0 bottom-0 w-[1px]'} ${props.class || ''}`}
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
>
@@ -232,28 +221,45 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {
/>
{/* Thumb */}
<div
- class="absolute right-0 cursor-grab active:cursor-grabbing"
- style={{
- top: `${thumbTop()}px`,
- height: `${thumbHeight()}px`,
- width: '1px',
- 'background-color': 'var(--color-accent)',
- 'transform-origin': 'right center',
- opacity: getThumbOpacity(),
- transform: getThumbScale(),
- transition: 'opacity 200ms ease-out, transform 200ms ease-out',
- }}
+ class="absolute cursor-grab active:cursor-grabbing"
+ style={
+ horiz()
+ ? {
+ left: `${thumbOffset()}px`,
+ width: `${thumbSize()}px`,
+ height: '1px',
+ bottom: '0',
+ 'background-color': 'var(--color-accent)',
+ 'transform-origin': 'center bottom',
+ opacity: getThumbOpacity(),
+ transform: getThumbScale(),
+ transition:
+ 'opacity 200ms ease-out, transform 200ms ease-out',
+ }
+ : {
+ top: `${thumbOffset()}px`,
+ height: `${thumbSize()}px`,
+ width: '1px',
+ right: '0',
+ 'background-color': 'var(--color-accent)',
+ 'transform-origin': 'right center',
+ opacity: getThumbOpacity(),
+ transform: getThumbScale(),
+ transition:
+ 'opacity 200ms ease-out, transform 200ms ease-out',
+ }
+ }
onMouseDown={handleMouseDown}
/>
<Show when={props.getLabel}>
<div
class={`absolute right-[calc(100%+8px)] -translate-y-1/2 whitespace-nowrap font-mono text-sm text-accent pointer-events-none select-none drop-shadow transition-opacity duration-200 ease-out ${props.labelClass || ''}`}
style={{
- top: `${thumbTop() + thumbHeight() / 2}px`,
+ top: `${thumbOffset() + thumbSize() / 2}px`,
opacity: scrollLabelVisible() ? 1 : 0,
}}
>
- {props.getLabel?.(scrollOffsetFromTop())}
+ {props.getLabel?.(scrollOffset())}
</div>
</Show>
</div>
diff --git a/js/app/packages/core/component/EntityIcon.tsx b/js/app/packages/core/component/EntityIcon.tsx
index 0eda8df579..f23901f743 100644
--- a/js/app/packages/core/component/EntityIcon.tsx
+++ b/js/app/packages/core/component/EntityIcon.tsx
@@ -34,6 +34,7 @@ import WideCsv from '@macro-icons/wide/csv.svg';
import WideDiagram from '@macro-icons/wide/diagram.svg';
import WideDocx from '@macro-icons/wide/docx.svg';
import WideCalendar from '@macro-icons/wide/calendar.svg';
+import WideGlobe from '@macro-icons/wide/globe.svg';
import WideEmail from '@macro-icons/wide/email.svg';
import WideFileCode from '@macro-icons/wide/file-code.svg';
import WideFileImage from '@macro-icons/wide/file-image.svg';
@@ -270,7 +271,7 @@ export const WIDE_ICONS: Record<EntityWithValidIcon, Component> = {
canvas: WideDiagram,
html: WideFileCode,
channel: WideChannel,
- public: GlobeIcon,
+ public: WideGlobe,
organization: Building,
private: WideChannel,
direct_message: WideChat,
diff --git a/js/app/packages/core/component/FormControls/MiniToggleSwitch.tsx b/js/app/packages/core/component/FormControls/MiniToggleSwitch.tsx
index 9f0daef9b4..3ff6c57ca7 100644
--- a/js/app/packages/core/component/FormControls/MiniToggleSwitch.tsx
+++ b/js/app/packages/core/component/FormControls/MiniToggleSwitch.tsx
@@ -92,7 +92,7 @@ export const MiniToggleSwitch: Component<
<div
class="relative w-8 h-3 transition-colors duration-80"
classList={{
- 'bg-edge-muted': !checked(),
+ 'bg-edge': !checked(),
'bg-accent': checked(),
}}
aria-hidden
diff --git a/js/app/packages/core/component/ForwardToChannel.tsx b/js/app/packages/core/component/ForwardToChannel.tsx
index f27a17c595..dba41b1039 100644
--- a/js/app/packages/core/component/ForwardToChannel.tsx
+++ b/js/app/packages/core/component/ForwardToChannel.tsx
@@ -8,14 +8,13 @@ import {
type BlockName,
type BlockAlias,
} from '@core/block';
-import { DeprecatedTextButton } from '@core/component/DeprecatedTextButton';
import { RecipientSelector } from '@core/component/RecipientSelector';
import { ShareOptions } from '@core/component/TopBar/ShareButton';
import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';
import type { WithCustomUserInput } from '@core/user';
import { useSendMessageToPeople } from '@core/util/channels';
import CheckIcon from '@icon/bold/check-bold.svg?component-solid';
-import PaperPlaneRight from '@phosphor-icons/core/fill/paper-plane-right-fill.svg?component-solid';
+import PaperPlane from '@macro-icons/wide/paper-plane-cutout.svg';
import { blockNameToItemType } from '@service-storage/client';
import type { AccessLevel } from '@service-storage/generated/schemas/accessLevel';
import type { SharePermissionV2ChannelSharePermissions } from '@service-storage/generated/schemas/sharePermissionV2ChannelSharePermissions';
@@ -26,6 +25,8 @@ import {
onMount,
Show,
} from 'solid-js';
+import { Button } from '@ui/components/Button';
+import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { getDestinationFromOptions } from './NewMessage';
import { Permissions } from './SharePermissions';
import { toast } from './Toast/Toast';
@@ -41,6 +42,7 @@ interface ForwardToChannelProps {
userPermissions: Permissions;
};
onSubmit?: () => void;
+ onCancel?: () => void;
refetch?: () => void;
projectId?: string;
name: string;
@@ -99,19 +101,15 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
});
const { sendToUsers, sendToChannel } = useSendMessageToPeople();
- const [submitAccessLevel, setSubmitAccessLevel] =
- createSignal<AccessLevel | null>(props.initialAccessLevel ?? null);
-
const blockBaseName = useMaybeBlockName() ?? props.blockName;
-
+ const [submitAccessLevel, setSubmitAccessLevel] =
+ createSignal<AccessLevel | null>(
+ props.initialAccessLevel ?? (blockBaseName === 'md' ? 'edit' : 'view')
+ );
createEffect(() => {
const channelPermissions_ = channelPermissions();
if (channelPermissions_) {
- setSubmitAccessLevel(channelPermissions_?.access_level);
- } else {
- setSubmitAccessLevel(
- ['md'].includes(blockBaseName as string) ? 'edit' : 'view'
- );
+ setSubmitAccessLevel(channelPermissions_.access_level);
}
});
@@ -283,39 +281,65 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
return (
<Show when={isAuthenticated()}>
- <div class="grow-1 shrink-0 p-2 min-h-11">
- <RecipientSelector<'user' | 'contact' | 'channel'>
- placeholder="To: Email Or Group"
- setSelectedOptions={setSelectedOptions}
- selectedOptions={selectedOptions()}
- triedToSubmit={triedToSubmit}
- options={destinationOptions}
- triggerMode="input"
- noBrackets
- hideBorder
- noPadding
- focusOnMount
- />
+ {/* Row 1: Recipient input + ShareOptions */}
+ <div class="flex items-center">
+ <div class="min-w-0 flex-1 px-1 py-2 min-h-11">
+ <RecipientSelector<'user' | 'contact' | 'channel'>
+ placeholder="To: Email or group"
+ setSelectedOptions={setSelectedOptions}
+ selectedOptions={selectedOptions()}
+ triedToSubmit={triedToSubmit}
+ options={destinationOptions}
+ triggerMode="input"
+ noBrackets
+ hideBorder
+ noPadding
+ focusOnMount
+ mobileHorizontalScroll
+ />
+ </div>
+ <Show
+ when={
+ props.submitPermissionInfo?.userPermissions === Permissions.OWNER &&
+ !props.hideAccessLevelSelector
+ }
+ >
+ <div class="shrink-0 pr-2 flex items-center">
+ <Show when={selectedOptions().length > 0}>
+ <span class="text-sm text-ink-muted pr-2">can</span>
+ </Show>
+ <ShareOptions
+ setPermissions={(accessLevel) =>
+ setSubmitAccessLevel(accessLevel)
+ }
+ permissions={submitAccessLevel()}
+ label="Permission"
+ hideNoAccess
+ noBorder
+ />
+ </div>
+ </Show>
</div>
+
+ {/* Row 2: Optional message */}
<div class="grow-1 shrink-1 min-h-0 flex flex-col w-full border-t-1 border-edge-muted/50">
<div class="relative grow-1 shrink-1 min-h-0 flex flex-col">
<ScrollIndicators scrollRef={mdScrollRef} noBorderStart />
+ <CustomScrollbar scrollContainer={mdScrollRef} />
<div
- class="grow-1 shrink-1 min-h-20 overflow-y-auto scrollbar-hidden px-[12px] py-[6px] w-full text-sm"
+ class="grow-1 shrink-1 min-h-20 max-h-40 overflow-y-auto scrollbar-hidden px-[12px] py-[6px] w-full text-sm"
onClick={() => focusMarkdownArea()}
ref={setMdScrollRef}
>
<MarkdownArea
- placeholder="Optional: Message"
+ placeholder="Optional message"
onEnter={(e: KeyboardEvent) => {
handleSubmit();
e.preventDefault();
return true;
}}
initialValue={markdownState()}
- onTab={() => {
- return true;
- }}
+ onTab={() => false}
useBlockBoundary={false}
portalScope="local"
dontFocusOnMount
@@ -323,6 +347,7 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
</div>
</div>
+ {/* Row 3: Send As Group (optional) + Cancel + Send */}
<div class="shrink-0 flex w-full items-center p-3 gap-3 flex-wrap">
<Show when={canSendAsGroup()}>
<label
@@ -365,37 +390,29 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
</label>
</Show>
- <div class="flex flex-auto min-w-0 gap-3">
- <div class="flex-auto min-w-0" />
-
- <DeprecatedTextButton
+ <div class="flex flex-auto items-center justify-end gap-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => props.onCancel?.()}
+ >
+ Cancel
+ </Button>
+ <Button
+ variant={selectedOptions().length > 0 ? 'accent' : 'secondary'}
+ size="sm"
+ class="pl-2 pr-2 rounded-xs flex items-center gap-1"
+ disabled={selectedOptions().length === 0}
onClick={() => {
const options = selectedOptions();
if (options && options.length > 0) {
handleSubmit();
}
}}
- theme={selectedOptions().length > 0 ? 'accent' : 'disabled'}
- icon={PaperPlaneRight}
- height="h-[22px]"
- text="Share"
- />
-
- <Show
- when={
- props.submitPermissionInfo?.userPermissions ===
- Permissions.OWNER && !props.hideAccessLevelSelector
- }
>
- <ShareOptions
- setPermissions={(accessLevel) => {
- setSubmitAccessLevel(accessLevel);
- }}
- permissions={submitAccessLevel()}
- label="Permission"
- hideNoAccess
- />
- </Show>
+ <PaperPlane class="size-4" />
+ Share
+ </Button>
</div>
</div>
</div>
diff --git a/js/app/packages/core/component/RecipientSelector.tsx b/js/app/packages/core/component/RecipientSelector.tsx
index 4e0392be6b..f985b5c2c2 100644
--- a/js/app/packages/core/component/RecipientSelector.tsx
+++ b/js/app/packages/core/component/RecipientSelector.tsx
@@ -1,3 +1,4 @@
+import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { EntityIcon } from '@core/component/EntityIcon';
import { toast } from '@core/component/Toast/Toast';
import { Tooltip } from '@core/component/Tooltip';
@@ -11,7 +12,6 @@ import {
recipientEntityMapper,
type WithCustomUserInput,
} from '@core/user';
-import { isMobileWidth } from '@core/mobile/mobileWidth';
import { matches } from '@core/util/match';
import { clamp } from '@core/util/math';
import { truncateString } from '@core/util/string';
@@ -53,14 +53,14 @@ function RecipientChip(props: {
}) {
return (
<div
- class="flex flex-row py-1 pl-2 gap-1 pr-0.5 overflow-hidden items-center bg-hover"
+ class="flex flex-row flex-shrink-0 py-1 pl-2 gap-1 pr-0.5 overflow-hidden items-center bg-hover"
classList={{ 'cursor-grab active:cursor-grabbing': props.draggable }}
draggable={props.draggable}
onDragStart={props.onDragStart}
onDragEnd={props.onDragEnd}
>
<Show when={props.icon}>{props.icon}</Show>
- <p class="text-sm">{truncateString(props.label, 20)}</p>
+ <p class="text-sm whitespace-nowrap">{truncateString(props.label, 20)}</p>
<XIcon
class="w-5 h-5 cursor-pointer hover:bg-hover hover-transition-bg p-1"
onClick={props.onRemove}
@@ -239,6 +239,7 @@ type RecipientSelectorProps<K extends CombinedRecipientKind> = {
disabled?: boolean;
onChipDragStart?: (option: WithCustomUserInput<K>, e: DragEvent) => void;
onChipDragEnd?: (e: DragEvent) => void;
+ mobileHorizontalScroll?: boolean;
};
export function RecipientSelector<K extends CombinedRecipientKind>(
@@ -483,162 +484,177 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
<Combobox.Control<CombinedRecipientItem>>
{(state) => {
const context = useComboboxContext();
+ const [chipsScrollRef, setChipsScrollRef] =
+ createSignal<HTMLElement>();
return (
- <div class="flex flex-wrap gap-1.5 max-h-[150px] overflow-y-auto text-ink">
- <For each={state.selectedOptions()}>
- {(option) => {
- return (
- <Switch>
- <Match
- when={matches(
- option,
- (o) => o.kind === 'user' || o.kind === 'contact'
- )}
- >
- {(userOrContactOption) => {
- const opt = userOrContactOption();
- const name = getRecipientOptionName(opt);
- const email = getRecipientOptionEmail(opt);
-
- const displayText = () => name || email;
-
- return (
- <Tooltip
- placement="bottom"
- unstyled
- tooltip={
- <UserTooltip
- displayName={name || ''}
- email={email}
- id={opt.id}
- isDeleted={false}
- />
- }
- >
- <RecipientChip
- icon={
- !isMobileWidth() ? (
+ <div class="relative">
+ <div
+ ref={
+ props.mobileHorizontalScroll ? setChipsScrollRef : undefined
+ }
+ class={`flex gap-1.5 text-ink scrollbar-hidden ${props.mobileHorizontalScroll ? 'flex-nowrap overflow-x-auto sm:flex-wrap sm:overflow-x-hidden sm:max-h-[150px] sm:overflow-y-auto pb-[2px] sm:pb-0' : 'flex-wrap max-h-[150px] overflow-y-auto'}`}
+ >
+ <For each={state.selectedOptions()}>
+ {(option) => {
+ return (
+ <Switch>
+ <Match
+ when={matches(
+ option,
+ (o) => o.kind === 'user' || o.kind === 'contact'
+ )}
+ >
+ {(userOrContactOption) => {
+ const opt = userOrContactOption();
+ const name = getRecipientOptionName(opt);
+ const email = getRecipientOptionEmail(opt);
+
+ const displayText = () => name || email;
+
+ return (
+ <Tooltip
+ placement="bottom"
+ unstyled
+ tooltip={
+ <UserTooltip
+ displayName={name || ''}
+ email={email}
+ id={opt.id}
+ isDeleted={false}
+ />
+ }
+ >
+ <RecipientChip
+ icon={
<UserIcon
id={opt.id}
size="xs"
isDeleted={false}
showTooltip={false}
/>
- ) : undefined
+ }
+ label={displayText() ?? ''}
+ onRemove={() => state.remove(option)}
+ draggable={!!props.onChipDragStart}
+ onDragStart={(e) =>
+ props.onChipDragStart?.(
+ option as WithCustomUserInput<K>,
+ e
+ )
+ }
+ onDragEnd={props.onChipDragEnd}
+ />
+ </Tooltip>
+ );
+ }}
+ </Match>
+ <Match
+ when={matches(option, (o) => o.kind === 'channel')}
+ >
+ {(channelOption) => {
+ return (
+ <RecipientChip
+ icon={<HashIcon class="w-4 h-4" />}
+ label={
+ channelOption().data.name ??
+ channelOption().id
}
- label={displayText() ?? ''}
onRemove={() => state.remove(option)}
- draggable={!!props.onChipDragStart}
- onDragStart={(e) =>
- props.onChipDragStart?.(
- option as WithCustomUserInput<K>,
- e
- )
- }
- onDragEnd={props.onChipDragEnd}
/>
- </Tooltip>
- );
- }}
- </Match>
- <Match
- when={matches(option, (o) => o.kind === 'channel')}
- >
- {(channelOption) => {
- return (
- <RecipientChip
- icon={<HashIcon class="w-4 h-4" />}
- label={
- channelOption().data.name ?? channelOption().id
- }
- onRemove={() => state.remove(option)}
- />
- );
- }}
- </Match>
- <Match when={matches(option, (o) => o.kind === 'custom')}>
- {(customOption) => {
- const email = customOption().data.email;
-
- return (
- <Tooltip
- placement="bottom"
- unstyled
- tooltip={
- <UserTooltip
- displayName={email}
- email={email}
- isDeleted={false}
- />
- }
- >
- <RecipientChip
- icon={
- !isMobileWidth() ? (
+ );
+ }}
+ </Match>
+ <Match
+ when={matches(option, (o) => o.kind === 'custom')}
+ >
+ {(customOption) => {
+ const email = customOption().data.email;
+
+ return (
+ <Tooltip
+ placement="bottom"
+ unstyled
+ tooltip={
+ <UserTooltip
+ displayName={email}
+ email={email}
+ isDeleted={false}
+ />
+ }
+ >
+ <RecipientChip
+ icon={
<UserIcon
id={email}
size="xs"
isDeleted={false}
showTooltip={false}
/>
- ) : undefined
- }
- label={email}
- onRemove={() => state.remove(option)}
- draggable={!!props.onChipDragStart}
- onDragStart={(e) =>
- props.onChipDragStart?.(
- option as WithCustomUserInput<K>,
- e
- )
- }
- onDragEnd={props.onChipDragEnd}
- />
- </Tooltip>
- );
- }}
- </Match>
- </Switch>
- );
- }}
- </For>
- <Combobox.Input
- disabled={disabled()}
- ref={(el) => {
- setInputRef(el);
- props.inputRef?.(el);
- }}
- class="flex-1 min-h-7 p-1 min-w-[200px] outline-none placeholder:text-ink-placeholder"
- classList={{ 'ml-1': selectedLen() === 0 }}
- onKeyDown={(e) => {
- if (
- (e.key === 'a' && e.ctrlKey) ||
- (e.key === 'a' && e.metaKey)
- ) {
- setDisabled(true);
- queueMicrotask(() => setDisabled(false));
- }
- if (e.key === 'Escape') {
- if (inputValue().length === 0) {
- inputRef()?.blur();
- }
- }
- }}
- // use a non-delegated event here so that we can process it before Kobalte
- on:keydown={(e: KeyboardEvent) => {
- if (e.key === 'Tab' && context.isOpen()) {
- e.preventDefault();
- e.stopPropagation();
- inputRef()?.dispatchEvent(
- // We need to send `bubbles: true` because otherwise Kobalte ignores the event
- new KeyboardEvent('keydown', {
- bubbles: true,
- key: 'Enter',
- })
+ }
+ label={email}
+ onRemove={() => state.remove(option)}
+ draggable={!!props.onChipDragStart}
+ onDragStart={(e) =>
+ props.onChipDragStart?.(
+ option as WithCustomUserInput<K>,
+ e
+ )
+ }
+ onDragEnd={props.onChipDragEnd}
+ />
+ </Tooltip>
+ );
+ }}
+ </Match>
+ </Switch>
);
- }
- }}
- />
+ }}
+ </For>
+ <Combobox.Input
+ disabled={disabled()}
+ ref={(el) => {
+ setInputRef(el);
+ props.inputRef?.(el);
+ }}
+ class="flex-1 min-h-7 p-1 min-w-[200px] outline-none placeholder:text-ink-placeholder"
+ classList={{ 'ml-1': selectedLen() === 0 }}
+ onKeyDown={(e) => {
+ if (
+ (e.key === 'a' && e.ctrlKey) ||
+ (e.key === 'a' && e.metaKey)
+ ) {
+ setDisabled(true);
+ queueMicrotask(() => setDisabled(false));
+ }
+ if (e.key === 'Escape') {
+ if (inputValue().length === 0) {
+ inputRef()?.blur();
+ }
+ }
+ }}
+ // use a non-delegated event here so that we can process it before Kobalte
+ on:keydown={(e: KeyboardEvent) => {
+ if (e.key === 'Tab' && context.isOpen()) {
+ e.preventDefault();
+ e.stopPropagation();
+ inputRef()?.dispatchEvent(
+ // We need to send `bubbles: true` because otherwise Kobalte ignores the event
+ new KeyboardEvent('keydown', {
+ bubbles: true,
+ key: 'Enter',
+ })
+ );
+ }
+ }}
+ />
+ </div>
+ <Show when={props.mobileHorizontalScroll}>
+ <CustomScrollbar
+ scrollContainer={chipsScrollRef}
+ horizontal
+ class="sm:hidden"
+ />
+ </Show>
</div>
);
}}
diff --git a/js/app/packages/core/component/TopBar/ShareButton.tsx b/js/app/packages/core/component/TopBar/ShareButton.tsx
index 803717385b..188126720a 100644
--- a/js/app/packages/core/component/TopBar/ShareButton.tsx
+++ b/js/app/packages/core/component/TopBar/ShareButton.tsx
@@ -9,7 +9,7 @@ import {
useBlockId,
useBlockName,
} from '@core/block';
-import { DropdownMenuContent, MenuItem } from '@core/component/Menu';
+import { DropdownMenuContent } from '@core/component/Menu';
import { UserIcon } from '@core/component/UserIcon';
import { ENABLE_MARKDOWN_COMMENTS } from '@core/constant/featureFlags';
import clickOutside from '@core/directive/clickOutside';
@@ -33,11 +33,16 @@ import {
type MaybeResult,
} from '@core/util/maybeResult';
import { buildSimpleEntityUrl } from '@core/util/url';
+import CheckIcon from '@icon/bold/check-bold.svg';
import IconLink from '@icon/regular/link.svg';
+import UserCircle from '@macro-icons/wide/user-circle.svg';
+import WideCopy from '@macro-icons/wide/copy.svg';
+import WideUsers from '@macro-icons/wide/users.svg';
+import IconX from '@icon/bold/x-bold.svg';
import IconShared from '@macro-icons/wide/share.svg';
-import User from '@icon/regular/user.svg';
-import IconUsers from '@icon/regular/users.svg';
-import CloseIcon from '@icon/regular/x.svg';
+import IconComment from '@macro-icons/wide/comment.svg';
+import IconEdit from '@macro-icons/wide/edit.svg';
+import IconEye from '@macro-icons/wide/eye.svg';
import { Dialog } from '@kobalte/core/dialog';
import { DropdownMenu } from '@kobalte/core/dropdown-menu';
import { cognitionApiServiceClient } from '@service-cognition/client';
@@ -67,13 +72,17 @@ import {
useContext,
} from 'solid-js';
import { match } from 'ts-pattern';
-import { DialogWrapper } from '../DialogWrapper';
+import { EntityIcon } from '@core/component/EntityIcon';
+import { MiniToggleSwitch } from '@core/component/FormControls/MiniToggleSwitch';
+import { ClippedPanel } from '../ClippedPanel';
+import { CustomScrollbar } from '../CustomScrollbar';
import { ForwardToChannel } from '../ForwardToChannel';
import { Permissions } from '../SharePermissions';
import { toast } from '../Toast/Toast';
import { Tooltip } from '../Tooltip';
import { openLoginModal } from './LoginButton';
import { ScrollIndicators } from '../VerticalScrollIndicators';
+import { useChannelParticipants } from '@channel/use-channel-participants';
import { useAnalytics } from '@app/component/analytics-context';
import { Button } from '@ui/components/Button';
import { Dynamic } from 'solid-js/web';
@@ -144,7 +153,7 @@ const accessLevelText = (accessLevel?: AccessLevel | null) => {
case 'owner':
return 'Owner';
default:
- return 'No Access';
+ return 'Remove Access';
}
};
@@ -169,6 +178,77 @@ interface ShareModalProps {
id: string;
}
+function DmRecipientIcon(props: { channelId: string }) {
+ const currentUserId = useUserId();
+ const { ids } = useChannelParticipants(() => props.channelId);
+ const dmPartnerId = createMemo(() =>
+ ids().find((id) => id !== currentUserId())
+ );
+ return (
+ <Show
+ when={dmPartnerId()}
+ fallback={<UserCircle class="flex-shrink-0 w-4 h-4" />}
+ >
+ {(id) => (
+ <UserIcon id={id()} size="xs" isDeleted={false} showTooltip={false} />
+ )}
+ </Show>
+ );
+}
+
+function shortName(user: { name: string; email: string }): string {
+ const display = user.name || user.email;
+ if (display.includes('@')) return display.split('@')[0];
+ return display.split(' ')[0];
+}
+
+function GroupChannelLabel(props: { channelId: string; fallbackName: string }) {
+ const currentUserId = useUserId();
+ const { users } = useChannelParticipants(() => props.channelId);
+ const others = createMemo(() =>
+ users().filter((u) => u.id !== currentUserId())
+ );
+
+ const label = createMemo(() => {
+ const rest = others();
+ if (rest.length === 0) return props.fallbackName;
+
+ const MAX_CHARS = 20;
+ const names: string[] = [];
+ let charsUsed = 0;
+
+ for (const user of rest) {
+ const name = shortName(user);
+ const separator = names.length > 0 ? ', ' : '';
+ if (charsUsed + separator.length + name.length > MAX_CHARS) break;
+ names.push(name);
+ charsUsed += separator.length + name.length;
+ }
+
+ const remaining = rest.length - names.length;
+ const base = names.join(', ');
+ if (remaining === 0) return base;
+ return `${base} +${remaining} ${remaining === 1 ? 'other' : 'others'}`;
+ });
+
+ const tooltipContent = createMemo(() =>
+ others()
+ .map((u) => u.name || u.email)
+ .join('\n')
+ );
+
+ return (
+ <Show when={others().length > 0} fallback={props.fallbackName}>
+ <Tooltip
+ placement="bottom"
+ tooltip={<div class="text-xs whitespace-pre">{tooltipContent()}</div>}
+ >
+ <span>{label()}</span>
+ </Tooltip>
+ </Show>
+ );
+}
+
export function ShareModal(props: ShareModalProps) {
const navigate = useNavigate();
const analytics = useAnalytics();
@@ -554,161 +634,246 @@ export function ShareModal(props: ShareModalProps) {
open={props.isSharePermOpen}
>
<Dialog.Portal>
- <DialogWrapper>
- <div class="text-ink flex flex-col">
- <div class="shrink-0 flex flex-row items-center justify-between px-2 h-[40px] gap-2 border-b-1 border-b-edge-muted">
- <div class="flex flex-row items-center gap-2">
- <Dialog.CloseButton>
- <Button tooltip="Close" variant="ghost" size="icon-sm">
- <CloseIcon />
- </Button>
- </Dialog.CloseButton>
- <Dialog.Title>{`Share: ${props.name}`}</Dialog.Title>
+ <Dialog.Overlay class="z-modal fixed inset-0 bg-modal-overlay pattern-edge-muted pattern-diagonal-4 pointer-events-none" />
+ <div class="z-modal fixed inset-0 flex flex-col items-center justify-center py-8">
+ <Dialog.Content
+ class="max-w-[calc(100vw-16px)] max-h-[calc(100vh-64px)] overflow-y-auto scrollbar-hidden mx-auto portal-scope flex flex-col gap-2"
+ style={{ width: '533px' }}
+ >
+ {/* Card 1: Share form — gradient border */}
+ <ClippedPanel active cornerRadius="4px">
+ <div class="text-ink flex flex-col">
+ <div class="shrink-0 flex flex-row items-center justify-between px-3 h-[40px] gap-2 border-b border-edge-muted">
+ <div class="flex-1 flex flex-row items-center gap-2 min-w-0">
+ <Dialog.Title class="flex items-center gap-1.5 min-w-0 overflow-hidden whitespace-nowrap w-full text-sm font-medium">
+ <span class="shrink-0">Share:</span>
+ <EntityIcon
+ targetType={props.blockAlias}
+ size="sm"
+ class="shrink-0"
+ />
+ <span class="truncate">{props.name}</span>
+ </Dialog.Title>
+ </div>
+ </div>
+ <ForwardToChannel
+ submitPermissionInfo={{
+ setChannelPermissions: (id, accessLevel) =>
+ setChannelPermissions(id, accessLevel, true),
+ userPermissions: props.userPermissions,
+ channelSharePermissions: recipients(),
+ }}
+ onSubmit={() => props.setIsSharePermOpen(false)}
+ onCancel={() => props.setIsSharePermOpen(false)}
+ refetch={refetch}
+ name={props.name}
+ hideAccessLevelSelector={props.itemType === 'email'}
+ initialAccessLevel={
+ props.itemType === 'email' ? 'view' : null
+ }
+ blockId={props.id}
+ blockName={props.blockAlias}
+ />
</div>
+ </ClippedPanel>
- <div class="flex flex-row items-center gap-2"></div>
- </div>
-
- <ForwardToChannel
- submitPermissionInfo={{
- setChannelPermissions: (id, accessLevel) =>
- setChannelPermissions(id, accessLevel, true),
- userPermissions: props.userPermissions,
- channelSharePermissions: recipients(),
- }}
- onSubmit={() => props.setIsSharePermOpen(false)}
- refetch={refetch}
- name={props.name}
- hideAccessLevelSelector={props.itemType === 'email'}
- initialAccessLevel={props.itemType === 'email' ? 'view' : null}
- blockId={props.id}
- blockName={props.blockAlias}
- />
-
- <Show when={(recipients()?.length ?? 0) > 0}>
- <div class="grow-2 shrink-1 min-h-[118px] flex flex-col border-t-1 border-edge-muted relative">
- <ScrollIndicators
- scrollRef={recipientScrollRef}
- noBorderStart
- noBorderEnd
- />
- <div
- class="overflow-y-auto scrollbar-hidden"
- ref={setRecipientScrollRef}
- >
- <div
- class="sticky shrink-0 top-0 left-0 border-b border-edge-muted/50 bg-panel w-full h-[40px] flex items-center z-1"
- style="transform: translateX(12px); width: calc(100% - 24px);"
- >
- Share Recipients
+ {/* Card 2: Recipients — plain border */}
+ <Show when={(recipients()?.length ?? 0) > 0 || !!props.owner}>
+ <ClippedPanel cornerRadius="4px">
+ <div class="text-ink flex flex-col">
+ <div class="shrink-0 h-[40px] flex items-center px-3 border-b border-edge-muted text-sm font-medium">
+ People with access to this{' '}
+ {props.itemType === 'email'
+ ? 'email thread'
+ : props.itemType}
</div>
- <div class="grid gap-3 text-ink text-sm select-none py-3 px-3 relative">
- <Show when={props.owner}>
- <div class="flex justify-between bg-panel">
- <div class="flex items-center gap-2 overflow-hidden">
- <UserIcon
- isDeleted={false}
- id={props.owner!}
- size="xs"
- />
- <div class="font-medium truncate">
- {formattedOwner()}
- </div>
- </div>
- <div class="flex items-center">
- <div class="font-medium text-ink-muted text-xs">
- Owner
- </div>
- </div>
- </div>
- </Show>
-
- <For each={recipients() || []}>
- {(recipient) => (
- <div class="flex justify-between bg-panel">
- <div
- class="flex items-center gap-2 overflow-hidden cursor-pointer"
- onClick={() =>
- navigateToChannel(recipient.channel_id)
- }
- >
- <Switch>
- <Match
- when={channelNameMap().get(
- recipient.channel_id
- )}
- >
- <User class="flex-shrink-0 w-4 h-4" />
- </Match>
- <Match when={true}>
- <IconUsers class="flex-shrink-0 w-4 h-4" />
- </Match>
- </Switch>
- <div class="font-medium truncate">
- {channelNameMap().get(recipient.channel_id)
- ?.name || recipient.channel_id}
+ <div class="relative">
+ <ScrollIndicators
+ scrollRef={recipientScrollRef}
+ noBorderStart
+ noBorderEnd
+ />
+ <CustomScrollbar scrollContainer={recipientScrollRef} />
+ <div
+ class="overflow-y-auto scrollbar-hidden max-h-[calc(27vh-40px)]"
+ ref={setRecipientScrollRef}
+ >
+ <div class="grid gap-3 text-ink text-sm select-none py-3 px-3">
+ <Show when={props.owner}>
+ <div class="flex justify-between">
+ <div class="flex items-center gap-2 overflow-hidden">
+ <UserIcon
+ isDeleted={false}
+ id={props.owner!}
+ size="xs"
+ />
+ <div class="font-medium truncate">
+ {formattedOwner()}
+ </div>
+ </div>
+ <div class="flex items-center">
+ <div class="font-medium text-ink-muted text-xs">
+ Owner
+ </div>
</div>
</div>
- <div class="flex items-center">
- <div class="font-medium text-ink-muted text-xs">
- <ShareOptions
- permissions={recipient.access_level}
- setPermissions={(accessLevel) => {
- if (accessLevel === null) {
- removeChannelAccess(recipient.channel_id);
- } else if (
- accessLevel !== recipient.access_level
- ) {
- setChannelPermissions(
- recipient.channel_id,
- accessLevel
- );
+ </Show>
+ <For each={recipients() || []}>
+ {(recipient) => (
+ <div class="flex justify-between">
+ <div
+ class="flex items-center gap-2 overflow-hidden cursor-pointer"
+ onClick={() =>
+ navigateToChannel(recipient.channel_id)
+ }
+ >
+ <Switch
+ fallback={
+ <WideUsers class="flex-shrink-0 w-4 h-4" />
}
- }}
- />
+ >
+ <Match
+ when={
+ channelNameMap().get(recipient.channel_id)
+ ?.type === 'direct_message'
+ }
+ >
+ <DmRecipientIcon
+ channelId={recipient.channel_id}
+ />
+ </Match>
+ <Match
+ when={channelNameMap().get(
+ recipient.channel_id
+ )}
+ >
+ <WideUsers class="flex-shrink-0 w-4 h-4" />
+ </Match>
+ </Switch>
+ <div class="font-medium truncate">
+ <Show
+ when={
+ channelNameMap().get(recipient.channel_id)
+ ?.type !== 'direct_message'
+ }
+ fallback={
+ channelNameMap().get(recipient.channel_id)
+ ?.name || recipient.channel_id
+ }
+ >
+ <GroupChannelLabel
+ channelId={recipient.channel_id}
+ fallbackName={
+ channelNameMap().get(
+ recipient.channel_id
+ )?.name || recipient.channel_id
+ }
+ />
+ </Show>
+ </div>
+ </div>
+ <div class="flex items-center">
+ <ShareOptions
+ permissions={recipient.access_level}
+ setPermissions={(accessLevel) => {
+ if (accessLevel === null) {
+ removeChannelAccess(recipient.channel_id);
+ } else if (
+ accessLevel !== recipient.access_level
+ ) {
+ setChannelPermissions(
+ recipient.channel_id,
+ accessLevel
+ );
+ }
+ }}
+ />
+ </div>
</div>
- </div>
- </div>
- )}
- </For>
+ )}
+ </For>
+ </div>
+ </div>
</div>
</div>
- </div>
+ </ClippedPanel>
</Show>
+ {/* Card 3: Public link — plain border */}
<Show
when={
props.userPermissions === Permissions.OWNER &&
props.itemType !== 'email'
}
>
- <div class="border-t-1 border-edge-muted flex flex-col">
- <div
- class="border-b border-edge-muted/50 bg-panel w-full h-[40px] flex items-center"
- style="transform: translateX(12px); left: 12px; width: calc(100% - 24px);"
- >
- Public Link
- </div>
- <div class="flex items-center p-3 justify-between">
- <Button
- variant="secondary"
- size="sm"
- class="flex items-center gap-1 rounded-xs px-2"
- onClick={copyPublicLink}
+ <ClippedPanel cornerRadius="4px">
+ <div class="text-ink flex flex-col">
+ <div
+ class="h-[40px] flex items-center justify-between px-3 text-sm font-medium"
+ classList={{
+ 'border-b border-edge-muted': publicAccessLevel() != null,
+ }}
>
- <IconLink class="size-4" />
- Copy Link
- </Button>
- <ShareOptions
- permissions={publicAccessLevel() ?? null}
- hideNoAccess={props.itemType === 'chat'}
- setPermissions={setPublicPermissions}
- />
+ <div class="flex items-center gap-2">
+ Public link
+ <div
+ class="px-2 rounded-xl border-1 py-0.5 flex justify-center items-center"
+ classList={{
+ 'border-accent/30 bg-accent/10':
+ publicAccessLevel() != null,
+ 'border-edge-muted bg-edge-muted/20':
+ publicAccessLevel() == null,
+ }}
+ >
+ <span
+ class="text-xs font-medium whitespace-nowrap"
+ classList={{
+ 'text-accent-ink': publicAccessLevel() != null,
+ 'text-ink-extra-muted': publicAccessLevel() == null,
+ }}
+ >
+ {publicAccessLevel() != null ? 'ENABLED' : 'DISABLED'}
+ </span>
+ </div>
+ </div>
+ <MiniToggleSwitch
+ size="Base"
+ label="Enable public link"
+ checked={publicAccessLevel() != null}
+ onChange={(on) =>
+ setPublicPermissions(on ? 'view' : null)
+ }
+ />
+ </div>
+ <Show when={publicAccessLevel() != null}>
+ <div class="flex items-center p-3 justify-between">
+ <Button
+ variant="secondary"
+ size="sm"
+ class="flex items-center gap-1 rounded-xs px-2"
+ onClick={copyPublicLink}
+ >
+ <WideCopy class="size-4" />
+ <span class="hidden sm:inline">Copy Link</span>
+ </Button>
+ <span class="text-sm text-ink-muted flex items-center">
+ <span class="px-2 hidden sm:inline">
+ Anyone with the link can
+ </span>
+ <span class="px-2 sm:hidden">Permissions:</span>
+ <ShareOptions
+ permissions={publicAccessLevel() ?? null}
+ hideNoAccess={true}
+ setPermissions={setPublicPermissions}
+ />
+ </span>
+ </div>
+ </Show>
</div>
- </div>
+ </ClippedPanel>
</Show>
- </div>
- </DialogWrapper>
+ </Dialog.Content>
+ </div>
</Dialog.Portal>
</Dialog>
);
@@ -864,12 +1029,19 @@ export function ShareBlockModal(props: {
);
}
+const PERMISSION_ICONS = {
+ comment: IconComment,
+ view: IconEye,
+ edit: IconEdit,
+} as const;
+
export function ShareOptions(props: {
setPermissions: (accessLevel: AccessLevel | null) => void;
permissions?: AccessLevel | null;
hideNoAccess?: boolean;
label?: string | '';
disabled?: boolean;
+ noBorder?: boolean;
}) {
const editPermissionEnabled = isInBlock()
? blockEditPermissionEnabledSignal()
@@ -879,24 +1051,24 @@ export function ShareOptions(props: {
const options = createMemo(() => {
const optionsList: { value: string; label: string }[] = [];
- // Add no access option if not hidden
- if (!props.hideNoAccess) {
- optionsList.push({ value: 'none', label: accessLevelText(null) });
- }
+ // Always add view option
+ optionsList.push({ value: 'view', label: accessLevelText('view') });
// Add comment option if applicable
if (blockName !== 'md' || ENABLE_MARKDOWN_COMMENTS) {
optionsList.push({ value: 'comment', label: accessLevelText('comment') });
}
- // Always add view option
- optionsList.push({ value: 'view', label: accessLevelText('view') });
-
// Add edit option if enabled
if (editPermissionEnabled) {
optionsList.push({ value: 'edit', label: accessLevelText('edit') });
}
+ // Add no access option if not hidden
+ if (!props.hideNoAccess) {
+ optionsList.push({ value: 'none', label: accessLevelText(null) });
+ }
+
return optionsList;
});
@@ -911,7 +1083,10 @@ export function ShareOptions(props: {
return accessLevelText(value as AccessLevel);
});
+ const [isOpen, setIsOpen] = createSignal(false);
+
const handleChange = (value: string) => {
+ setIsOpen(false);
if (value === 'none') {
props.setPermissions(null);
} else {
@@ -920,11 +1095,11 @@ export function ShareOptions(props: {
};
return (
- <DropdownMenu>
+ <DropdownMenu open={isOpen()} onOpenChange={setIsOpen}>
<DropdownMenu.Trigger disabled={props.disabled}>
<Button
disabled={props.disabled}
- class="min-w-[67px] h-[22px] py-2 pl-2 pr-1 rounded-xs flex items-center gap-1"
+ class={`min-w-[67px] h-[22px] py-2 pl-2 pr-1 rounded-xs flex items-center gap-1 ${props.noBorder ? 'border-0 sm:border' : ''}`}
variant="secondary"
>
{currentValueText()}
@@ -937,16 +1112,43 @@ export function ShareOptions(props: {
value={currentValue()}
onChange={handleChange}
>
- <For each={options()}>
- {(option) => (
- <MenuItem
- groupValue={currentValue()}
- value={option.value}
- selectorType="radio"
- text={option.label}
- />
- )}
+ <For each={options().filter((o) => o.value !== 'none')}>
+ {(option) => {
+ const Icon =
+ PERMISSION_ICONS[
+ option.value as keyof typeof PERMISSION_ICONS
+ ];
+ return (
+ <DropdownMenu.RadioItem
+ value={option.value}
+ class="flex items-center gap-2 w-full py-1 pl-2 pr-2 text-sm font-medium rounded-xs cursor-pointer hover:bg-hover hover-transition-bg focus-bracket"
+ >
+ <div class="w-4 h-4 shrink-0">
+ {Icon && <Icon class="w-full h-full" />}
+ </div>
+ <div class="flex-1 truncate">{option.label}</div>
+ <Show when={currentValue() === option.value}>
+ <CheckIcon class="w-3 h-3 text-accent" />
+ </Show>
+ </DropdownMenu.RadioItem>
+ );
+ }}
</For>
+ <Show when={!props.hideNoAccess}>
+ <div class="my-1 border-t border-edge-muted w-full" />
+ <DropdownMenu.RadioItem
+ value="none"
+ class="flex items-center gap-2 w-full py-1 pl-2 pr-2 text-sm font-medium rounded-xs cursor-pointer hover:bg-hover hover-transition-bg focus-bracket"
+ >
+ <div class="w-4 h-4 shrink-0">
+ <IconX class="w-full h-full" />
+ </div>
+ <div class="flex-1 truncate">{accessLevelText(null)}</div>
+ <Show when={currentValue() === 'none'}>
+ <CheckIcon class="w-3 h-3 text-accent" />
+ </Show>
+ </DropdownMenu.RadioItem>
+ </Show>
</DropdownMenu.RadioGroup>
</DropdownMenuContent>
</DropdownMenu.Portal>
diff --git a/js/app/packages/macro-icons/wide/comment.svg b/js/app/packages/macro-icons/wide/comment.svg
new file mode 100644
index 0000000000..5e09947c16
--- /dev/null
+++ b/js/app/packages/macro-icons/wide/comment.svg
@@ -0,0 +1,4 @@
+<svg width="100%" height="100%" viewBox="0 -3 18 18" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
+<path d="M17.25,0H1.5v1.5h15v9h1.5V.75c0-.41-.34-.75-.75-.75Z"/>
+<path d="M9.85,10.5l-.85.85-.85-.85H1.5V1.5H0v9.75c0,.41.34.75.75.75h6.75l1.5,1.5,1.5-1.5h6v-1.5h-6.65Z"/>
+</svg>
diff --git a/js/app/packages/macro-icons/wide/edit.svg b/js/app/packages/macro-icons/wide/edit.svg
new file mode 100644
index 0000000000..15cc7625be
--- /dev/null
+++ b/js/app/packages/macro-icons/wide/edit.svg
@@ -0,0 +1,5 @@
+<svg width="100%" height="100%" viewBox="0 -3 18 18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-miterlimit="10" xmlns="http://www.w3.org/2000/svg">
+<path d="M8.18.78L.75,8.2v2.9c0,.05.04.1.1.1h2.9l7.43-7.43s.04-.1,0-.14l-2.86-2.86s-.1-.04-.14,0Z"/>
+<line x1="1.5" y1="11.21" x2="18" y2="11.21"/>
+<line x1="6.07" y1="2.88" x2="9.14" y2="5.94"/>
+</svg>
diff --git a/js/app/packages/macro-icons/wide/eye.svg b/js/app/packages/macro-icons/wide/eye.svg
new file mode 100644
index 0000000000..8c57282963
--- /dev/null
+++ b/js/app/packages/macro-icons/wide/eye.svg
@@ -0,0 +1,4 @@
+<svg width="100%" height="100%" viewBox="0 -3 18 18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-miterlimit="10" xmlns="http://www.w3.org/2000/svg">
+<path d="M9.12.75C3.93.75.87,6,.87,6c0,0,3.07,5.25,8.25,5.25s8.25-5.25,8.25-5.25c0,0-3.07-5.25-8.25-5.25Z"/>
+<circle cx="9.12" cy="6" r="2.25"/>
+</svg>
diff --git a/js/app/packages/macro-icons/wide/globe.svg b/js/app/packages/macro-icons/wide/globe.svg
new file mode 100644
index 0000000000..8e1a9b550b
--- /dev/null
+++ b/js/app/packages/macro-icons/wide/globe.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 12" fill="currentColor" width="100%" height="100%"><path d="M9,0C3.95,0,0,2.64,0,6s3.95,6,9,6,9-2.64,9-6S14.05,0,9,0ZM16.38,5.25h-2.43c-.12-1.17-.52-2.23-1.12-3.09,1.83.67,3.16,1.79,3.54,3.09ZM8.25,1.61v3.64h-2.69c.24-1.81,1.31-3.25,2.69-3.64ZM8.25,6.75v3.64c-1.38-.39-2.45-1.83-2.69-3.64h2.69ZM9.75,10.39v-3.64h2.69c-.24,1.81-1.31,3.25-2.69,3.64ZM9.75,5.25V1.61c1.38.39,2.45,1.83,2.69,3.64h-2.69ZM5.16,2.16c-.6.86-1,1.92-1.12,3.09H1.62c.38-1.29,1.72-2.42,3.54-3.09ZM1.62,6.75h2.43c.12,1.17.52,2.23,1.12,3.09-1.83-.67-3.16-1.79-3.54-3.09ZM12.84,9.84c.6-.86,1-1.92,1.12-3.09h2.43c-.38,1.29-1.72,2.42-3.54,3.09Z"/></svg>
diff --git a/js/app/packages/macro-icons/wide/user-circle.svg b/js/app/packages/macro-icons/wide/user-circle.svg
new file mode 100644
index 0000000000..f4409164fe
--- /dev/null
+++ b/js/app/packages/macro-icons/wide/user-circle.svg
@@ -0,0 +1,4 @@
+<svg width="100%" height="100%" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
+<path d="M6,0C2.69,0,0,2.69,0,6c0,.22.01.45.04.66,0,.07.02.13.03.2.02.15.05.3.08.45.02.07.04.14.06.21.04.14.08.28.12.42.02.07.05.13.07.2.05.14.11.28.18.42.02.05.05.11.08.16.08.16.17.31.26.45.02.03.03.06.05.09.36.55.8,1.04,1.31,1.45.31.25.65.46,1.01.64h0c.19.1.39.18.6.26.03.01.05.02.08.03.18.06.35.12.54.17.05.01.09.03.14.04.17.04.34.07.52.09.05,0,.11.02.16.02.22.03.45.04.68.04s.46-.02.68-.04c.06,0,.11-.02.16-.02.17-.03.35-.05.52-.09.05-.01.09-.02.14-.04.18-.05.36-.1.54-.17.03,0,.05-.02.08-.03.2-.08.4-.16.6-.26h0c.36-.18.69-.4,1.01-.64.51-.41.96-.9,1.31-1.45.02-.03.04-.06.05-.09.09-.15.18-.3.26-.45.03-.05.05-.1.08-.16.06-.14.12-.28.18-.42.02-.07.05-.13.07-.2.05-.14.09-.28.12-.42.02-.07.04-.14.06-.21.03-.15.06-.3.08-.45,0-.07.02-.13.03-.2.02-.22.04-.44.04-.66,0-3.31-2.69-6-6-6ZM6,11c-.97,0-1.86-.29-2.63-.77.33-1.14,1.38-1.98,2.63-1.98s2.29.84,2.63,1.98c-.77.48-1.66.77-2.63.77ZM9.47,9.59c-.56-1.37-1.9-2.34-3.47-2.34s-2.91.97-3.47,2.34c-.94-.91-1.53-2.18-1.53-3.59C1,3.24,3.24,1,6,1s5,2.24,5,5c0,1.41-.59,2.68-1.53,3.59Z"/>
+<path d="M8.25,5c0-1.24-1.01-2.25-2.25-2.25s-2.25,1.01-2.25,2.25,1.01,2.25,2.25,2.25,2.25-1.01,2.25-2.25ZM6,6.25c-.69,0-1.25-.56-1.25-1.25s.56-1.25,1.25-1.25,1.25.56,1.25,1.25-.56,1.25-1.25,1.25Z"/>
+</svg>
diff --git a/js/app/packages/ui/components/Button.tsx b/js/app/packages/ui/components/Button.tsx
index 84cb3ff85a..de44b36ac3 100644
--- a/js/app/packages/ui/components/Button.tsx
+++ b/js/app/packages/ui/components/Button.tsx
@@ -41,7 +41,7 @@ const variantStyles: Record<ButtonVariant, string> = {
'bg-transparent text-ink-muted not-disabled:hover:bg-ink/10 not-disabled:hover:text-ink not-disabled:active:bg-ink/12 disabled:opacity-30',
link: 'bg-transparent text-accent underline-offset-2 not-disabled:hover:underline not-disabled:active:text-accent/80 disabled:text-ink-extra-muted',
accent:
- 'bg-accent text-page not-disabled:hover:bg-accent/90 not-disabled:active:bg-accent/80 disabled:bg-ink-extra-muted',
+ 'bg-accent text-panel not-disabled:hover:bg-accent/90 not-disabled:active:bg-accent/80 disabled:bg-ink-extra-muted',
};
const sizeStyles: Record<ButtonSize, string> = {