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[mobile]: make narrow channel soup good (#1984)

Peter Chinmanf390cce7d0a8
diff --git a/js/app/packages/core/component/EntityIcon.tsx b/js/app/packages/core/component/EntityIcon.tsx
index 9b6ca6a80b..172bcc2b70 100644
--- a/js/app/packages/core/component/EntityIcon.tsx
+++ b/js/app/packages/core/component/EntityIcon.tsx
@@ -19,7 +19,6 @@ import FileHtml from '@icon/duotone/file-html-duotone.svg';
import FileMd from '@icon/duotone/file-md-duotone.svg';
import FilePdf from '@icon/duotone/file-pdf-duotone.svg';
import FileVideo from '@icon/duotone/file-video-duotone.svg';
-import Channel from '@icon/duotone/hash-duotone.svg';
import FileImage from '@icon/duotone/image-duotone.svg';
import Canvas from '@icon/duotone/pencil-circle-duotone.svg';
import User from '@icon/duotone/user-duotone.svg';
@@ -44,7 +43,6 @@ import WideUnknown from '@macro-icons/wide/unknown.svg';
import WideUser from '@macro-icons/wide/user.svg';
import WideVideo from '@macro-icons/wide/video.svg';
import GlobeIcon from '@icon/duotone/globe-duotone.svg';
-import ThreeUsersIcon from '@icon/duotone/users-three-duotone.svg';
import { FileTypeMap } from '@service-storage/fileTypeMap';
import type { ChannelType } from '@service-cognition/generated/schemas/channelType';
import type { FileType } from '@service-storage/generated/schemas/fileType';
@@ -95,7 +93,7 @@ export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {
prettyName: 'Webpage',
},
channel: {
- icon: Channel,
+ icon: WideChannel,
foreground: 'text-default',
background: 'bg-default-bg',
prettyName: 'Channel',
@@ -113,7 +111,7 @@ export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {
prettyName: 'Organization Channel',
},
private: {
- icon: ThreeUsersIcon,
+ icon: WideChannel,
foreground: 'text-default',
background: 'bg-default-bg',
prettyName: 'Private Channel',
@@ -259,7 +257,7 @@ export const WIDE_ICONS: Record<EntityWithValidIcon, Component> = {
channel: WideChannel,
public: GlobeIcon,
organization: Building,
- private: ThreeUsersIcon,
+ private: WideChannel,
direct_message: WideChat,
email: WideEmail,
code: WideFileCode,
diff --git a/js/app/packages/core/component/LexicalMarkdown/theme.ts b/js/app/packages/core/component/LexicalMarkdown/theme.ts
index b9fa79e3a6..0c4df30023 100644
--- a/js/app/packages/core/component/LexicalMarkdown/theme.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/theme.ts
@@ -228,7 +228,7 @@ export const searchContentHitMarkdownTheme = createTheme({
root: `${theme.root} pr-[2px] cursor-default overflow-x-auto`,
});
-export const searchContentHitTwoLineClampMarkdownTheme = createTheme({
+export const twoLineClampMarkdownTheme = createTheme({
...unifiedListMarkdownTheme,
root: `${theme.root} pr-[2px] cursor-default`,
paragraph: 'md-p text-[1em] line-clamp-2',
diff --git a/js/app/packages/core/component/UserIcon.tsx b/js/app/packages/core/component/UserIcon.tsx
index 99ff089b15..1de249f4e2 100644
--- a/js/app/packages/core/component/UserIcon.tsx
+++ b/js/app/packages/core/component/UserIcon.tsx
@@ -7,6 +7,7 @@ import { useSplitLayout } from '../../app/component/split-layout/layout';
import { ProfilePicture } from './ProfilePicture';
import { Tooltip } from './Tooltip';
import { UserTooltip } from './UserTooltip';
+import { cn } from '@ui/utils/classname';
export type UserIconProps = {
isDeleted?: boolean;
@@ -16,6 +17,7 @@ export type UserIconProps = {
// TODO: remove imageUrl. not actively used.
imageURL?: string;
fetchUrl?: boolean;
+ class?: string;
} & ({ id: string; email?: never } | { email: string; id?: never });
export type SizeClass = {
@@ -73,9 +75,9 @@ export function UserIcon(props: UserIconProps) {
};
case 'fill':
return {
- container: 'w-full h-full',
+ container: 'w-full h-full @container',
icon: 'w-full h-full',
- text: 'text-[min(85%,3rem)] leading-none',
+ text: 'text-[min(calc(50cqw),3rem)] leading-none',
};
}
});
@@ -100,7 +102,11 @@ export function UserIcon(props: UserIconProps) {
const icon = createMemo(() => (
<div
onMouseDown={props.suppressClick ? undefined : getOrCreateDm}
- class={`${sizeClasses().container} shrink-0 rounded-full bg-ink-extra-muted text-panel`}
+ class={cn(
+ 'shrink-0 rounded-full bg-ink-extra-muted text-panel',
+ sizeClasses().container,
+ props.class
+ )}
>
<Switch>
<Match when={props.isDeleted}>
diff --git a/js/app/packages/entity/src/components/PulsingStar.tsx b/js/app/packages/entity/src/components/PulsingStar.tsx
index cf7a8e0599..d566e01d43 100644
--- a/js/app/packages/entity/src/components/PulsingStar.tsx
+++ b/js/app/packages/entity/src/components/PulsingStar.tsx
@@ -13,7 +13,11 @@ const kind = {
type Kind = keyof typeof kind;
-export function PulsingStar(props: { kind: Kind; animate?: boolean }) {
+export function PulsingStar(props: {
+ kind: Kind;
+ animate?: boolean;
+ class?: string;
+}) {
const [pulse, setPulse] = createSignal(false);
const interval = setInterval(() => {
@@ -28,7 +32,7 @@ export function PulsingStar(props: { kind: Kind; animate?: boolean }) {
return (
<div class={kind[props.kind]}>
- <AnimatedStarIcon triggerAnimation={pulse()} />
+ <AnimatedStarIcon class={props.class} triggerAnimation={pulse()} />
</div>
);
}
diff --git a/js/app/packages/entity/src/components/UnreadIndicator.tsx b/js/app/packages/entity/src/components/UnreadIndicator.tsx
index b4d9b945d7..dd3bb90031 100644
--- a/js/app/packages/entity/src/components/UnreadIndicator.tsx
+++ b/js/app/packages/entity/src/components/UnreadIndicator.tsx
@@ -1,12 +1,13 @@
import { cn } from '@ui/utils/classname';
-export function UnreadIndicator(props: { active?: boolean }) {
+export function UnreadIndicator(props: { class?: string; active?: boolean }) {
return (
<div
- class={cn({
- 'bg-accent rounded-full size-2': true,
- 'opacity-0': !props.active,
- })}
+ class={cn(
+ 'bg-accent rounded-full size-2 shrink-0',
+ !props.active && 'opacity-0',
+ props.class
+ )}
/>
);
}
diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsx
index f71fde7897..95ae4c7da2 100644
--- a/js/app/packages/entity/src/composed/ListEntity.tsx
+++ b/js/app/packages/entity/src/composed/ListEntity.tsx
@@ -40,7 +40,10 @@ import {
import { unreadFilterFn } from '../utils/filter';
import { cn } from '@ui/utils/classname';
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
-import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
+import {
+ twoLineClampMarkdownTheme,
+ unifiedListMarkdownTheme,
+} from '@core/component/LexicalMarkdown/theme';
import type { SearchLocation } from '../types/search';
import { isSearchEntity } from '../types/search';
import { createEntityDraggable } from '../utils/draggable';
@@ -166,16 +169,14 @@ interface LayoutProps {
function EmailIdentity(props: { entity: EmailEntity }) {
return (
<>
- <Show
- when={props.entity.isDraft}
- fallback={
- <Show when={props.entity.hasIcsAttachment}>
- <InviteBadge />
- </Show>
- }
- >
- <DraftBadge />
- </Show>
+ <Switch>
+ <Match when={props.entity.isDraft}>
+ <DraftBadge />
+ </Match>
+ <Match when={props.entity.hasIcsAttachment}>
+ <InviteBadge />
+ </Match>
+ </Switch>
<span class="truncate">
<Entity.EmailParticipants entity={props.entity} />
</span>
@@ -333,6 +334,109 @@ function NarrowLayout(props: LayoutProps) {
);
}
+function NarrowMessageLayout(props: LayoutProps) {
+ const isDirectMessage = () =>
+ isChannelEntity(props.entity) &&
+ props.entity.channelType === 'direct_message';
+ return (
+ <Entity.Layout
+ class="w-full text-sm grid"
+ style={{
+ 'grid-template-columns': 'auto 1fr 8ch',
+ 'grid-template-rows': 'auto auto auto',
+ 'grid-template-areas':
+ '"icon title timestamp" "icon body body" "icon body body"',
+ }}
+ >
+ <Entity.Slot placement="icon" class="flex items-center self-center pr-3">
+ <UnreadIndicator class="mx-2 size-2.75" active={props.unread} />
+ <div class="relative size-11 shrink-0 group">
+ <Show when={!props.checked}>
+ <div class="absolute inset-0 grid place-items-center group-hover:opacity-0 transition-opacity">
+ <Show
+ when={isDirectMessage()}
+ fallback={
+ <div class="size-11 bg-edge-muted rounded-full flex items-center justify-center">
+ <div class="size-6">
+ <Entity.Icon
+ entity={props.entity}
+ streamState={props.streamState}
+ />
+ </div>
+ </div>
+ }
+ >
+ <div class="size-11">
+ <Entity.Icon
+ entity={props.entity}
+ streamState={props.streamState}
+ class="bg-edge-muted text-ink"
+ />
+ </div>
+ </Show>
+ </div>
+ </Show>
+ {/* TODO: make multiselect work on mobile */}
+ <div
+ class={cn(
+ 'absolute inset-0 grid place-items-center opacity-0 group-hover:opacity-100 transition-opacity',
+ { 'opacity-100': props.checked }
+ )}
+ >
+ <MultiSelectCheckbox
+ checked={props.checked}
+ onChecked={props.onChecked}
+ />
+ </div>
+ </div>
+ </Entity.Slot>
+
+ <Entity.Slot
+ placement="title"
+ class="flex items-center gap-2 truncate font-semibold pt-3"
+ >
+ <Show when={isChannelEntity(props.entity) && props.entity}>
+ {(entity) => <Entity.Title entity={entity()} />}
+ </Show>
+ </Entity.Slot>
+
+ <Entity.Slot
+ placement="timestamp"
+ class="text-xs text-right text-ink-extra-muted font-light pt-3 pr-4"
+ >
+ <Show when={!props.hasNotifications}>
+ <Entity.Timestamp entity={props.entity} />
+ </Show>
+ </Entity.Slot>
+
+ <Show when={isChannelEntity(props.entity) && props.entity}>
+ {(entity) => (
+ <Show when={entity().latestMessage}>
+ {(msg) => (
+ <>
+ <Entity.Slot
+ placement="body"
+ class="text-ink-extra-muted line-clamp-2 pb-2 min-h-[2lh] pr-4 border-b border-edge-muted"
+ >
+ <Show
+ when={msg().content?.trim()}
+ fallback={<span class="italic">Attached Items</span>}
+ >
+ <StaticMarkdown
+ theme={twoLineClampMarkdownTheme}
+ markdown={msg().content.trim()}
+ />
+ </Show>
+ </Entity.Slot>
+ </>
+ )}
+ </Show>
+ )}
+ </Show>
+ </Entity.Layout>
+ );
+}
+
function WideLayout(props: LayoutProps) {
const [emailSnippetContainerRef, setEmailSnippetContainerRef] = createSignal<
HTMLElement | undefined
@@ -514,9 +618,17 @@ export function ListEntity(props: ListEntityProps) {
})}
/>
- <Show when={isWide()} fallback={<NarrowLayout {...layoutProps()} />}>
- <WideLayout {...layoutProps()} />
- </Show>
+ <Switch>
+ <Match when={isWide()}>
+ <WideLayout {...layoutProps()} />
+ </Match>
+ <Match when={isChannelEntity(props.entity) && !hasNotifications()}>
+ <NarrowMessageLayout {...layoutProps()} />
+ </Match>
+ <Match when={true}>
+ <NarrowLayout {...layoutProps()} />
+ </Match>
+ </Switch>
<Show when={hasNotifications()}>
<div class="flex gap-2 w-full h-full items-center text-sm px-2 pb-1 -mt-2 min-w-0 overflow-hidden">
diff --git a/js/app/packages/entity/src/extractors-search/search-content.tsx b/js/app/packages/entity/src/extractors-search/search-content.tsx
index c69ae25ce2..f2225aedcd 100644
--- a/js/app/packages/entity/src/extractors-search/search-content.tsx
+++ b/js/app/packages/entity/src/extractors-search/search-content.tsx
@@ -2,7 +2,7 @@ import { Show } from 'solid-js';
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import {
searchContentHitMarkdownTheme,
- searchContentHitTwoLineClampMarkdownTheme,
+ twoLineClampMarkdownTheme,
} from '@core/component/LexicalMarkdown/theme';
import type { ContentHitData } from '../types/search';
@@ -18,7 +18,7 @@ export function SearchContent(props: SearchContentProps) {
const content = () => props.hit?.content ?? '';
const theme = () => {
if (props.twoLineClamp) {
- return searchContentHitTwoLineClampMarkdownTheme;
+ return twoLineClampMarkdownTheme;
} else {
return searchContentHitMarkdownTheme;
}
diff --git a/js/app/packages/entity/src/extractors/entity-icon.tsx b/js/app/packages/entity/src/extractors/entity-icon.tsx
index 464894cb5c..77f2d6689d 100644
--- a/js/app/packages/entity/src/extractors/entity-icon.tsx
+++ b/js/app/packages/entity/src/extractors/entity-icon.tsx
@@ -15,9 +15,10 @@ import { isChannelEntity, isTaskEntity } from '../types/entity';
interface EntityIconProps {
entity: EntityData;
streamState?: StreamEvent;
+ class?: string;
}
-function DirectMessageIcon(props: { entity: ChannelEntity }) {
+function DirectMessageIcon(props: { entity: ChannelEntity; class?: string }) {
const userId = useUserId();
const participantId = () => {
const participants = props.entity.participantIds ?? [];
@@ -25,12 +26,25 @@ function DirectMessageIcon(props: { entity: ChannelEntity }) {
};
return (
- <div class="bg-panel size-full rounded-full">
+ <div class={'bg-panel size-full rounded-full'}>
<Show
when={participantId()}
- fallback={<CoreEntityIcon targetType="direct_message" size="fill" />}
+ fallback={
+ <CoreEntityIcon
+ targetType="direct_message"
+ size="fill"
+ class={props.class}
+ />
+ }
>
- {(id) => <UserIcon id={id()} isDeleted={false} size="fill" />}
+ {(id) => (
+ <UserIcon
+ id={id()}
+ isDeleted={false}
+ size="fill"
+ class={props.class}
+ />
+ )}
</Show>
</div>
);
@@ -62,15 +76,25 @@ export function EntityIcon(props: EntityIconProps) {
return (
<Switch
- fallback={<CoreEntityIcon targetType={validIconType()} size="fill" />}
+ fallback={
+ <CoreEntityIcon
+ targetType={validIconType()}
+ size="fill"
+ class={props.class}
+ />
+ }
>
<Match when={isDirectMessage()}>
- <DirectMessageIcon entity={props.entity as ChannelEntity} />
+ <DirectMessageIcon
+ entity={props.entity as ChannelEntity}
+ class={props.class}
+ />
</Match>
<Match when={isChatEntity()}>
<PulsingStar
kind="listIcon"
animate={props.streamState?.type === 'created'}
+ class={props.class}
/>
</Match>
</Switch>
diff --git a/js/app/packages/macro-icons/wide/animating/star.tsx b/js/app/packages/macro-icons/wide/animating/star.tsx
index 72b2e0c90f..31f9022e57 100644
--- a/js/app/packages/macro-icons/wide/animating/star.tsx
+++ b/js/app/packages/macro-icons/wide/animating/star.tsx
@@ -1,6 +1,10 @@
+import { cn } from '@ui/utils/classname';
import { createUniqueId } from 'solid-js';
-export const AnimatedStarIcon = (props: { triggerAnimation?: boolean }) => {
+export const AnimatedStarIcon = (props: {
+ triggerAnimation?: boolean;
+ class?: string;
+}) => {
const maskId = createUniqueId();
return (
<svg
@@ -11,7 +15,11 @@ export const AnimatedStarIcon = (props: { triggerAnimation?: boolean }) => {
stroke="none"
xmlns="http://www.w3.org/2000/svg"
overflow="visible"
- class={`animated-star-icon ${props.triggerAnimation ? 'animating' : ''}`}
+ class={cn(
+ 'animated-star-icon',
+ props.triggerAnimation && 'animating',
+ props.class
+ )}
>
{/*<title>Animated star icon</title>*/}
<style>{`
diff --git a/js/app/packages/ui/utils/classname.ts b/js/app/packages/ui/utils/classname.ts
index 92b40bcf8f..766daf0a4c 100644
--- a/js/app/packages/ui/utils/classname.ts
+++ b/js/app/packages/ui/utils/classname.ts
@@ -1,4 +1,4 @@
-import { twMerge } from 'tailwind-merge';
+import { extendTailwindMerge } from 'tailwind-merge';
// Local `clsx`-compatible types + implementation (so we don't depend on the external
// `clsx` package being installed).
@@ -35,6 +35,14 @@ const clsx = (...args: ClassValue[]): string => {
return out.join(' ');
};
+const twMerge = extendTailwindMerge({
+ extend: {
+ classGroups: {
+ 'font-size': [{ text: ['xxs'] }],
+ },
+ },
+});
+
export const cn = (...args: ClassValue[]) => {
return twMerge(clsx(...args));
};