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): more native feeling default light and dark themes (#4467)

Peter Chinman70c529c72030
diff --git a/js/app/packages/app/component/mobile/EntityRow.tsx b/js/app/packages/app/component/mobile/EntityRow.tsx
index 23bed7c284..45b8b1bf8b 100644
--- a/js/app/packages/app/component/mobile/EntityRow.tsx
+++ b/js/app/packages/app/component/mobile/EntityRow.tsx
@@ -533,7 +533,7 @@ export function EntityRow(
{/* Swipe Content */}
<div
data-swipe-content
- class="size-full min-h-0 overflow-hidden flex items-center p-0 bg-surface"
+ class="size-full min-h-0 overflow-hidden flex items-center p-0 bg-panel"
>
{props.children}
</div>
diff --git a/js/app/packages/app/component/mobile/MobileDock.css b/js/app/packages/app/component/mobile/MobileDock.css
deleted file mode 100644
index 3e9a76f51b..0000000000
--- a/js/app/packages/app/component/mobile/MobileDock.css
+++ /dev/null
@@ -1,34 +0,0 @@
-@keyframes mobile-dock-menu-show {
- from {
- width: 10rem;
- height: 5rem;
- }
- to {
- width: var(
- --mobile-dock-menu-width,
- calc(100vw - 2 * var(--mobile-chrome-gutter, 0.75rem))
- );
- height: var(--mobile-dock-menu-height, 23.5rem);
- }
-}
-@keyframes mobile-dock-menu-hide {
- from {
- width: var(
- --mobile-dock-menu-width,
- calc(100vw - 2 * var(--mobile-chrome-gutter, 0.75rem))
- );
- height: var(--mobile-dock-menu-height, 23.5rem);
- opacity: 1;
- }
- to {
- width: 0rem;
- height: 0rem;
- opacity: 0;
- }
-}
-.mobile-dock-menu-content {
- animation: mobile-dock-menu-hide 120ms ease-in forwards;
-}
-.mobile-dock-menu-content[data-expanded] {
- animation: mobile-dock-menu-show 150ms cubic-bezier(0.2, 1.05, 1, 1.1);
-}
diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsx
index 5ecbb3656a..4a9dc31324 100644
--- a/js/app/packages/app/component/mobile/MobileDock.tsx
+++ b/js/app/packages/app/component/mobile/MobileDock.tsx
@@ -1,4 +1,3 @@
-import './MobileDock.css';
import type { ListView } from '@app/constants/list-views';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { globalSplitManager } from '@app/signal/splitLayout';
@@ -10,7 +9,6 @@ import {
import { useSettingsState } from '@core/constant/SettingsState';
import { triggerFocusInput } from '@core/directive/focusInput';
import { hapticImpact } from '@core/mobile/haptics';
-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import { ICON_ANIMATION_DURATION_MS } from '@icon/animation';
import IconGear from '@icon/macro-gear.svg';
import { AnimatedCallIcon } from '@icon/wide-call';
@@ -25,13 +23,16 @@ import { AnimatedTaskIcon } from '@icon/wide-task';
import CaretUpIcon from '@phosphor/caret-up.svg';
import HomeIcon from '@phosphor/house.svg';
import PlusIcon from '@phosphor/plus.svg';
-import { createElementSize } from '@solid-primitives/resize-observer';
import { useLocation } from '@solidjs/router';
-import { cn, Layer } from '@ui';
-import { type Component, createSignal, For, Show } from 'solid-js';
-import { Dynamic, Portal } from 'solid-js/web';
+import { cn } from '@ui';
+import { createSignal, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
import { CREATABLE_BLOCKS, runCreateAction } from '../Launcher';
import { useSplitLayout } from '../split-layout/layout';
+import {
+ type MobileTouchIconComponent,
+ MobileTouchMenu,
+} from './MobileTouchMenu';
import { SearchState } from './mobileSearchState';
import { pressPulse } from './pressPulse';
@@ -40,15 +41,8 @@ false && pressPulse;
type DockId = ListView | 'home';
-type IconComponentProps = {
- triggerAnimation?: boolean;
- class?: string;
-};
-
-type IconComponent = Component<IconComponentProps>;
-
type MobileDockButtonProps = {
- icon: IconComponent;
+ icon: MobileTouchIconComponent;
label?: string;
/** Accessible name for icon-only buttons (falls back to `label`). */
ariaLabel?: string;
@@ -61,9 +55,6 @@ type MobileDockButtonProps = {
class?: string;
/** Plain svg icons (Home, Caret) don't accept `triggerAnimation`. */
animateIcon?: boolean;
- /** Fire on pointer-down instead of release. (More menu: opening on press
- * enables the hold-and-drag row selection gesture.) */
- fireOnPress?: boolean;
};
function MobileDockButton(props: MobileDockButtonProps) {
@@ -81,16 +72,9 @@ function MobileDockButton(props: MobileDockButtonProps) {
setAnimating(true);
setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
}
- if (props.fireOnPress) props.onClick();
}}
- // Default: fires on release — the press pulse holds the on-state while
- // touched. (Not on fireOnPress buttons, which already fired above.)
- onClick={(e) => {
- if (props.fireOnPress) {
- // Keyboard/assistive activation dispatches click without pointerdown.
- if (e.detail === 0) props.onClick();
- return;
- }
+ // Fires on release; the press pulse holds the on-state while touched.
+ onClick={() => {
props.onClick();
}}
onTouchMove={props.onTouchMove}
@@ -115,7 +99,11 @@ function MobileDockButton(props: MobileDockButtonProps) {
);
}
-const MORE_VIEWS: { id: ListView; label: string; icon: IconComponent }[] = [
+const MORE_VIEWS: {
+ id: ListView;
+ label: string;
+ icon: MobileTouchIconComponent;
+}[] = [
{ id: 'agents', label: 'Agents', icon: AnimatedStarIcon },
{ id: 'mail', label: 'Email', icon: AnimatedEmailIcon },
{ id: 'documents', label: 'Documents', icon: AnimatedFileMdIcon },
@@ -125,207 +113,6 @@ const MORE_VIEWS: { id: ListView; label: string; icon: IconComponent }[] = [
{ id: 'folders', label: 'Folders', icon: AnimatedFolderIcon },
];
-type MobileDockMenuItem = {
- id: string;
- label: string;
- icon?: IconComponent;
- active?: () => boolean;
- animateIcon?: boolean;
- onSelect: () => void;
-};
-
-function MobileDockMenu(props: {
- triggerIcon: IconComponent;
- triggerAriaLabel: string;
- footerLabel: string;
- footerCaretClass?: string;
- items: MobileDockMenuItem[];
-}) {
- // `open` drives the show/hide animation (via data-expanded); `mounted`
- // keeps the overlay in the DOM until the hide animation finishes.
- const [open, setOpen] = createSignal(false);
- const [mounted, setMounted] = createSignal(false);
- const [hoveredId, setHoveredId] = createSignal<string | null>(null);
- // The menu's natural size, fed to the open/close animation as CSS vars —
- // the container animates its real width/height between the dock button's
- // size and these (see MobileDock.css).
- const [menuRef, setMenuRef] = createSignal<HTMLDivElement>();
- const menuSize = createElementSize(menuRef);
-
- const openMenu = () => {
- setMounted(true);
- setOpen(true);
- // Block the opening touch's trailing click (see suppressNextClick).
- };
-
- const closeMenu = () => {
- setOpen(false);
- setHoveredId(null);
- };
-
- // Row selection: unmount instantly, no hide animation. The size animation
- // is layout-bound and would drop frames while navigation mounts the
- // destination view; the animated close is kept for plain dismissals
- // (backdrop, caret, More button), where the main thread is idle.
- const dismissMenu = () => {
- setOpen(false);
- setMounted(false);
- setHoveredId(null);
- };
-
- const getItem = (id: string | null) =>
- id ? props.items.find((item) => item.id === id) : undefined;
-
- const handleTouchMove = (e: TouchEvent) => {
- if (!open()) return;
- const touch = e.touches[0];
- const el = document.elementFromPoint(touch.clientX, touch.clientY);
- const button = el?.closest(
- '[data-mobile-dock-menu-item]'
- ) as HTMLElement | null;
- const id = button?.dataset.mobileDockMenuItem ?? null;
- if (id !== hoveredId()) {
- setHoveredId(id);
- if (id) hapticImpact('light');
- }
- };
-
- const select = (id: string | null) => {
- const item = getItem(id);
- if (!item) return;
- item.onSelect();
- dismissMenu();
- };
-
- const handleTouchEnd = () => {
- const id = hoveredId();
- setHoveredId(null);
- select(id);
- };
-
- return (
- <>
- <MobileDockButton
- icon={props.triggerIcon}
- ariaLabel={props.triggerAriaLabel}
- animateIcon={false}
- fireOnPress
- onClick={() => (open() ? closeMenu() : openMenu())}
- onTouchMove={handleTouchMove}
- onTouchEnd={handleTouchEnd}
- class="size-10 rounded-full"
- />
- <Show when={mounted()}>
- <Portal>
- {/* Portaled to <body>, outside FloatRegionHost's Layer — re-apply
- depth 3 so the menu's surface matches the rest of the dock. */}
- <Layer depth={3}>
- {/* Backdrop: any tap outside the menu closes it. The bottom
- padding mirrors FloatRegionHost's, so the menu's bottom edge
- aligns with the bottom of the dock. */}
- <div
- class={cn(
- 'fixed inset-0 z-modal flex items-end justify-center pb-3',
- isNativeMobilePlatform() && 'pb-7'
- )}
- onPointerDown={(e) => {
- if (e.target === e.currentTarget) closeMenu();
- }}
- >
- {/* The container is what the open/close animation sizes; it
- expands upward from the dock line. The inner menu keeps its
- full size, pinned to the container's left edge (so it rides
- leftward as the box widens from center) and to its bottom
- edge (so it stays put vertically and is unmasked top-down as
- the box grows upward). */}
- <div
- class="mobile-dock-menu-content flex items-end justify-start overflow-hidden rounded-2xl bg-surface ring ring-edge"
- data-expanded={open() ? '' : undefined}
- style={{
- '--mobile-dock-menu-width': menuSize.width
- ? `${menuSize.width}px`
- : undefined,
- '--mobile-dock-menu-height': menuSize.height
- ? `${menuSize.height}px`
- : undefined,
- }}
- onAnimationEnd={(e) => {
- // Icon animations bubble animationend; only unmount when the
- // container's own hide animation completes.
- if (e.target === e.currentTarget && !open())
- setMounted(false);
- }}
- >
- {/* Width matches the dock: full screen minus its gutters. */}
- <div
- class="flex w-[calc(100vw-2*var(--mobile-chrome-gutter))] shrink-0 flex-col gap-1 p-1"
- ref={setMenuRef}
- >
- <For each={props.items}>
- {(item) => (
- <button
- type="button"
- data-mobile-dock-menu-item={item.id}
- class={cn(
- 'flex h-11 items-center gap-2 rounded-lg px-3 text-sm',
- item.active?.() ? 'text-accent' : 'text-ink',
- hoveredId() === item.id
- ? 'bg-hover'
- : 'hover:bg-hover'
- )}
- onClick={() => {
- hapticImpact('light');
- select(item.id);
- }}
- >
- <Show when={item.icon}>
- {(Icon) => (
- <div class="size-4 shrink-0 [&_svg]:size-4">
- <Show
- when={item.animateIcon !== false}
- fallback={<Dynamic component={Icon()} />}
- >
- <Dynamic
- component={Icon()}
- triggerAnimation={hoveredId() === item.id}
- />
- </Show>
- </div>
- )}
- </Show>
- <span>{item.label}</span>
- </button>
- )}
- </For>
- {/* Full-bleed divider between the list and the Views row. */}
- <div class="-mx-1 h-px shrink-0 bg-edge" />
- <button
- type="button"
- class="flex h-9 shrink-0 items-center justify-between px-3 text-sm font-medium text-ink-muted"
- onPointerDown={() => {
- hapticImpact('light');
- closeMenu();
- }}
- >
- <span>{props.footerLabel}</span>
- {/* Align the caret with this menu's dock trigger. */}
- <CaretUpIcon
- class={cn(
- 'size-6 rotate-180 text-ink',
- props.footerCaretClass
- )}
- />
- </button>
- </div>
- </div>
- </div>
- </Layer>
- </Portal>
- </Show>
- </>
- );
-}
-
function MoreViewsMenu(props: {
isActive: (id: DockId) => boolean;
onNavigate: (id: DockId) => void;
@@ -333,7 +120,7 @@ function MoreViewsMenu(props: {
const { settingsOpen, toggleSettings } = useSettingsState();
return (
- <MobileDockMenu
+ <MobileTouchMenu
triggerIcon={CaretUpIcon}
triggerAriaLabel="More views"
footerLabel="Views"
@@ -370,7 +157,7 @@ function CreateMenu() {
).toReversed();
return (
- <MobileDockMenu
+ <MobileTouchMenu
triggerIcon={PlusIcon}
triggerAriaLabel="Create"
footerLabel="Create"
diff --git a/js/app/packages/app/component/mobile/MobileDrawer.tsx b/js/app/packages/app/component/mobile/MobileDrawer.tsx
index cff4025fdb..57e16cdbf8 100644
--- a/js/app/packages/app/component/mobile/MobileDrawer.tsx
+++ b/js/app/packages/app/component/mobile/MobileDrawer.tsx
@@ -56,7 +56,7 @@ function MobileDrawerContent(props: ComponentProps<typeof Drawer.Content>) {
});
return (
- <Layer depth={1}>
+ <Layer depth={0}>
<Drawer.Content
onFocusIn={(e: FocusEvent) => {
scrollToFocusedInput(e);
diff --git a/js/app/packages/app/component/mobile/MobileTouchMenu.css b/js/app/packages/app/component/mobile/MobileTouchMenu.css
new file mode 100644
index 0000000000..970110ba14
--- /dev/null
+++ b/js/app/packages/app/component/mobile/MobileTouchMenu.css
@@ -0,0 +1,37 @@
+@keyframes mobile-touch-menu-show {
+ from {
+ width: 10rem;
+ height: 5rem;
+ }
+ to {
+ width: var(
+ --mobile-touch-menu-width,
+ calc(100vw - 2 * var(--mobile-chrome-gutter, 0.75rem))
+ );
+ height: var(--mobile-touch-menu-height, 23.5rem);
+ }
+}
+
+@keyframes mobile-touch-menu-hide {
+ from {
+ width: var(
+ --mobile-touch-menu-width,
+ calc(100vw - 2 * var(--mobile-chrome-gutter, 0.75rem))
+ );
+ height: var(--mobile-touch-menu-height, 23.5rem);
+ opacity: 1;
+ }
+ to {
+ width: 0rem;
+ height: 0rem;
+ opacity: 0;
+ }
+}
+
+.mobile-touch-menu-content {
+ animation: mobile-touch-menu-hide 120ms ease-in forwards;
+}
+
+.mobile-touch-menu-content[data-expanded] {
+ animation: mobile-touch-menu-show 150ms cubic-bezier(0.2, 1.05, 1, 1.1);
+}
diff --git a/js/app/packages/app/component/mobile/MobileTouchMenu.tsx b/js/app/packages/app/component/mobile/MobileTouchMenu.tsx
new file mode 100644
index 0000000000..1c6dbcf2b9
--- /dev/null
+++ b/js/app/packages/app/component/mobile/MobileTouchMenu.tsx
@@ -0,0 +1,347 @@
+import './MobileTouchMenu.css';
+import { hapticImpact } from '@core/mobile/haptics';
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
+import { ICON_ANIMATION_DURATION_MS } from '@icon/animation';
+import CaretUpIcon from '@phosphor/caret-up.svg';
+import { createElementSize } from '@solid-primitives/resize-observer';
+import { cn, Layer } from '@ui';
+import {
+ type Component,
+ createSignal,
+ For,
+ type JSXElement,
+ Show,
+} from 'solid-js';
+import { Dynamic, Portal } from 'solid-js/web';
+import { pressPulse } from './pressPulse';
+
+// Keeps the directive import from being tree-shaken / lint-flagged.
+false && pressPulse;
+
+export type MobileTouchIconComponentProps = {
+ triggerAnimation?: boolean;
+ class?: string;
+};
+
+export type MobileTouchIconComponent = Component<MobileTouchIconComponentProps>;
+
+export type MobileTouchMenuItem = {
+ id: string;
+ label: JSXElement;
+ icon?: MobileTouchIconComponent;
+ active?: () => boolean;
+ animateIcon?: boolean;
+ onSelect: () => void;
+};
+
+export type MobileTouchMenuTriggerProps = {
+ open: boolean;
+ ref: (el: HTMLElement) => void;
+ onPointerDown: () => void;
+ onClick: (e: MouseEvent) => void;
+ onTouchMove: (e: TouchEvent) => void;
+ onTouchEnd: (e: TouchEvent) => void;
+};
+
+type MobileTouchMenuButtonProps = {
+ icon: MobileTouchIconComponent;
+ ariaLabel: string;
+ ref?: HTMLButtonElement | ((el: HTMLButtonElement) => void);
+ onClick: () => void;
+ onTouchMove?: (e: TouchEvent) => void;
+ onTouchEnd?: (e: TouchEvent) => void;
+ class?: string;
+ animateIcon?: boolean;
+ fireOnPress?: boolean;
+};
+
+function MobileTouchMenuButton(props: MobileTouchMenuButtonProps) {
+ const [animating, setAnimating] = createSignal(false);
+
+ return (
+ <button
+ type="button"
+ ref={props.ref}
+ aria-label={props.ariaLabel}
+ use:pressPulse
+ onPointerDown={() => {
+ hapticImpact('light');
+ if (props.animateIcon !== false) {
+ setAnimating(true);
+ setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
+ }
+ if (props.fireOnPress) props.onClick();
+ }}
+ onClick={(e) => {
+ if (props.fireOnPress) {
+ // Keyboard/assistive activation dispatches click without pointerdown.
+ if (e.detail === 0) props.onClick();
+ return;
+ }
+ props.onClick();
+ }}
+ onTouchMove={props.onTouchMove}
+ onTouchEnd={props.onTouchEnd}
+ class={cn(
+ 'island pointer-events-auto flex items-center justify-center',
+ props.class
+ )}
+ >
+ <div class="size-6 [&_svg]:size-6">
+ {props.animateIcon === false ? (
+ <Dynamic component={props.icon} />
+ ) : (
+ <Dynamic component={props.icon} triggerAnimation={animating()} />
+ )}
+ </div>
+ </button>
+ );
+}
+
+// Touch menu triggers open on pointer-down, which also arms the
+// hold-and-drag-to-select gesture. Swallow the opening touch's trailing
+// synthesized click so it cannot accidentally select a freshly-mounted row.
+function suppressNextClick() {
+ const onClick = (e: MouseEvent) => {
+ e.stopPropagation();
+ e.preventDefault();
+ cleanup();
+ };
+ const cleanup = () => {
+ document.removeEventListener('click', onClick, true);
+ clearTimeout(timer);
+ };
+ const timer = setTimeout(cleanup, 400);
+ document.addEventListener('click', onClick, true);
+}
+
+export function MobileTouchMenu(props: {
+ triggerIcon?: MobileTouchIconComponent;
+ triggerAriaLabel: string;
+ trigger?: (props: MobileTouchMenuTriggerProps) => JSXElement;
+ position?: 'bottom-row' | 'trigger-bottom';
+ footerLabel: string;
+ footerCaretClass?: string;
+ items: MobileTouchMenuItem[];
+}) {
+ // `open` drives the show/hide animation (via data-expanded); `mounted`
+ // keeps the overlay in the DOM until the hide animation finishes.
+ const [open, setOpen] = createSignal(false);
+ const [mounted, setMounted] = createSignal(false);
+ const [hoveredId, setHoveredId] = createSignal<string | null>(null);
+ // The menu's natural size, fed to the open/close animation as CSS vars.
+ const [menuRef, setMenuRef] = createSignal<HTMLDivElement>();
+ const [triggerRef, setTriggerRef] = createSignal<HTMLElement>();
+ const [triggerBottomOffset, setTriggerBottomOffset] = createSignal<number>();
+ const menuSize = createElementSize(menuRef);
+
+ const position = () => props.position ?? 'bottom-row';
+ const triggerPositioned = () =>
+ position() === 'trigger-bottom' && triggerBottomOffset() !== undefined;
+
+ const syncTriggerPosition = () => {
+ if (position() !== 'trigger-bottom') {
+ setTriggerBottomOffset(undefined);
+ return;
+ }
+ const trigger = triggerRef();
+ if (!trigger) {
+ setTriggerBottomOffset(undefined);
+ return;
+ }
+ setTriggerBottomOffset(
+ Math.max(0, window.innerHeight - trigger.getBoundingClientRect().bottom)
+ );
+ };
+
+ const openMenu = () => {
+ syncTriggerPosition();
+ setMounted(true);
+ setOpen(true);
+ suppressNextClick();
+ };
+
+ const closeMenu = () => {
+ setOpen(false);
+ setHoveredId(null);
+ };
+
+ // Row selection unmounts instantly; the animated close is kept for plain
+ // dismissals where the main thread is idle.
+ const dismissMenu = () => {
+ setOpen(false);
+ setMounted(false);
+ setHoveredId(null);
+ };
+
+ const toggleMenu = () => (open() ? closeMenu() : openMenu());
+
+ const getItem = (id: string | null) =>
+ id ? props.items.find((item) => item.id === id) : undefined;
+
+ const handleTouchMove = (e: TouchEvent) => {
+ if (!open()) return;
+ const touch = e.touches[0];
+ const el = document.elementFromPoint(touch.clientX, touch.clientY);
+ const button = el?.closest(
+ '[data-mobile-touch-menu-item]'
+ ) as HTMLElement | null;
+ const id = button?.dataset.mobileTouchMenuItem ?? null;
+ if (id !== hoveredId()) {
+ setHoveredId(id);
+ if (id) hapticImpact('light');
+ }
+ };
+
+ const select = (id: string | null) => {
+ const item = getItem(id);
+ if (!item) return;
+ item.onSelect();
+ dismissMenu();
+ };
+
+ const handleTouchEnd = () => {
+ const id = hoveredId();
+ setHoveredId(null);
+ select(id);
+ };
+
+ const triggerProps = (): MobileTouchMenuTriggerProps => ({
+ open: open(),
+ ref: setTriggerRef,
+ onPointerDown: () => {
+ hapticImpact('light');
+ toggleMenu();
+ },
+ onClick: (e) => {
+ // Keyboard/assistive activation dispatches click without pointerdown.
+ if (e.detail === 0) toggleMenu();
+ },
+ onTouchMove: handleTouchMove,
+ onTouchEnd: handleTouchEnd,
+ });
+
+ return (
+ <>
+ <Show
+ when={props.trigger}
+ fallback={
+ <MobileTouchMenuButton
+ ref={setTriggerRef}
+ icon={props.triggerIcon!}
+ ariaLabel={props.triggerAriaLabel}
+ animateIcon={false}
+ fireOnPress
+ onClick={toggleMenu}
+ onTouchMove={handleTouchMove}
+ onTouchEnd={handleTouchEnd}
+ class="size-10 rounded-full"
+ />
+ }
+ >
+ {(trigger) => trigger()(triggerProps())}
+ </Show>
+ <Show when={mounted()}>
+ <Portal>
+ {/* Portaled to <body>, outside FloatRegionHost's Layer. Re-apply
+ depth 3 so the menu's surface matches the rest of the chrome. */}
+ <Layer depth={3}>
+ <div
+ class={cn(
+ 'fixed inset-0 z-modal flex items-end justify-center',
+ !triggerPositioned() && 'pb-3',
+ !triggerPositioned() && isNativeMobilePlatform() && 'pb-7'
+ )}
+ style={{
+ 'padding-bottom': triggerPositioned()
+ ? `${triggerBottomOffset()}px`
+ : undefined,
+ }}
+ onPointerDown={(e) => {
+ if (e.target === e.currentTarget) closeMenu();
+ }}
+ >
+ <div
+ class="mobile-touch-menu-content flex items-end justify-start overflow-hidden rounded-2xl bg-menu ring ring-edge shadow-xl"
+ data-expanded={open() ? '' : undefined}
+ style={{
+ '--mobile-touch-menu-width': menuSize.width
+ ? `${menuSize.width}px`
+ : undefined,
+ '--mobile-touch-menu-height': menuSize.height
+ ? `${menuSize.height}px`
+ : undefined,
+ }}
+ onAnimationEnd={(e) => {
+ // Icon animations bubble animationend; only unmount when the
+ // container's own hide animation completes.
+ if (e.target === e.currentTarget && !open())
+ setMounted(false);
+ }}
+ >
+ <div
+ class="flex w-[calc(100vw-2*var(--mobile-chrome-gutter))] shrink-0 flex-col gap-1 p-1"
+ ref={setMenuRef}
+ >
+ <For each={props.items}>
+ {(item) => (
+ <button
+ type="button"
+ data-mobile-touch-menu-item={item.id}
+ class={cn(
+ 'flex h-11 items-center gap-2 rounded-lg px-3 text-sm',
+ item.active?.() ? 'text-accent' : 'text-ink',
+ hoveredId() === item.id
+ ? 'bg-hover'
+ : 'hover:bg-hover'
+ )}
+ onClick={() => {
+ hapticImpact('light');
+ select(item.id);
+ }}
+ >
+ <Show when={item.icon}>
+ {(Icon) => (
+ <div class="size-4 shrink-0 [&_svg]:size-4">
+ <Show
+ when={item.animateIcon !== false}
+ fallback={<Dynamic component={Icon()} />}
+ >
+ <Dynamic
+ component={Icon()}
+ triggerAnimation={hoveredId() === item.id}
+ />
+ </Show>
+ </div>
+ )}
+ </Show>
+ <span>{item.label}</span>
+ </button>
+ )}
+ </For>
+ <div class="-mx-1 h-px shrink-0 bg-edge" />
+ <button
+ type="button"
+ class="flex h-9 shrink-0 items-center justify-between px-3 text-sm font-medium text-ink-muted"
+ onClick={() => {
+ hapticImpact('light');
+ closeMenu();
+ }}
+ >
+ <span>{props.footerLabel}</span>
+ <CaretUpIcon
+ class={cn(
+ 'size-6 rotate-180 text-ink',
+ props.footerCaretClass
+ )}
+ />
+ </button>
+ </div>
+ </div>
+ </div>
+ </Layer>
+ </Portal>
+ </Show>
+ </>
+ );
+}
diff --git a/js/app/packages/app/component/mobile/PillTabs.tsx b/js/app/packages/app/component/mobile/PillTabs.tsx
index 44295063c2..acfcae2680 100644
--- a/js/app/packages/app/component/mobile/PillTabs.tsx
+++ b/js/app/packages/app/component/mobile/PillTabs.tsx
@@ -1,11 +1,26 @@
import { hapticImpact } from '@core/mobile/haptics';
+import DotsThreeIcon from '@phosphor/dots-three.svg';
+import { createElementSize } from '@solid-primitives/resize-observer';
import { cn } from '@ui';
-import { createEffect, For, type JSXElement, on } from 'solid-js';
+import {
+ createEffect,
+ createMemo,
+ createSignal,
+ For,
+ type JSXElement,
+ on,
+ Show,
+} from 'solid-js';
+import { MobileTouchMenu } from './MobileTouchMenu';
+import { computeVisiblePillValues } from './pillTabsLayout';
import { pressPulse } from './pressPulse';
// Keeps the directive import from being tree-shaken / lint-flagged.
false && pressPulse;
+const PILL_CLASS =
+ 'h-10 shrink-0 whitespace-nowrap rounded-full px-3.5 text-xs font-medium island';
+
export type PillTabItem<T extends string = string> = {
value: T;
label: JSXElement;
@@ -18,7 +33,7 @@ export type PillTabItem<T extends string = string> = {
*
* Presentational only: the caller owns selection state via `value`/`onChange`
* and wraps this with its own layout (gutters, sibling controls, region
- * chrome). The active pill is kept scrolled into view automatically.
+ * chrome). Pills that do not fit move into the overflow menu.
*/
export function PillTabs<T extends string>(props: {
items: readonly PillTabItem<T>[];
@@ -32,49 +47,109 @@ export function PillTabs<T extends string>(props: {
/** Extra classes on the scroll strip. */
class?: string;
}) {
- let stripRef: HTMLDivElement | undefined;
+ const [stripRef, setStripRef] = createSignal<HTMLDivElement>();
+ const [measureRef, setMeasureRef] = createSignal<HTMLDivElement>();
+ const [overflowMeasureRef, setOverflowMeasureRef] =
+ createSignal<HTMLButtonElement>();
+ const stripSize = createElementSize(stripRef);
+ const measureSize = createElementSize(measureRef);
+ const overflowMeasureSize = createElementSize(overflowMeasureRef);
+ const measuredButtons = new Map<T, HTMLButtonElement>();
+ const [visibleValues, setVisibleValues] = createSignal<T[]>([]);
+ const [measured, setMeasured] = createSignal(false);
+
+ const itemKey = () => props.items.map((item) => item.value).join('\u0000');
+
+ const getContentWidth = (el: HTMLElement) => {
+ const style = window.getComputedStyle(el);
+ return (
+ el.clientWidth -
+ Number.parseFloat(style.paddingLeft || '0') -
+ Number.parseFloat(style.paddingRight || '0')
+ );
+ };
+
+ const getGap = (el: HTMLElement) => {
+ const style = window.getComputedStyle(el);
+ return Number.parseFloat(style.columnGap || style.gap || '0') || 0;
+ };
+
+ const computeVisibleValues = () => {
+ const strip = stripRef();
+ const overflowButton = overflowMeasureRef();
+ if (!strip || !overflowButton) return;
+
+ const items = props.items;
+ const values = items.map((item) => item.value);
+ const widths = items.map(
+ (item) => measuredButtons.get(item.value)?.offsetWidth ?? 0
+ );
+
+ if (items.length === 0 || widths.some((width) => width === 0)) {
+ setVisibleValues(items.map((item) => item.value));
+ setMeasured(false);
+ return;
+ }
+
+ const available = getContentWidth(strip);
+ const gap = getGap(strip);
+ const overflowWidth = overflowButton.offsetWidth;
+ setVisibleValues(
+ computeVisiblePillValues({
+ values,
+ activeValue: props.value,
+ currentVisibleValues: visibleValues(),
+ widths,
+ availableWidth: available,
+ gap,
+ overflowWidth,
+ })
+ );
+ setMeasured(true);
+ };
- // Keep the active pill scrolled into view within the horizontal strip.
- // Re-runs on selection change or when the list of items changes.
createEffect(
on(
- () => [props.value, props.items] as const,
+ () =>
+ [
+ props.value,
+ itemKey(),
+ stripSize.width,
+ measureSize.width,
+ overflowMeasureSize.width,
+ ] as const,
() => {
- const strip = stripRef;
- if (!strip) return;
- queueMicrotask(() => {
- const active = strip.querySelector<HTMLElement>('[data-checked]');
- if (!active) return;
- const stripRect = strip.getBoundingClientRect();
- const activeRect = active.getBoundingClientRect();
- if (activeRect.left < stripRect.left) {
- strip.scrollBy({
- left: activeRect.left - stripRect.left - 8,
- behavior: 'smooth',
- });
- } else if (activeRect.right > stripRect.right) {
- strip.scrollBy({
- left: activeRect.right - stripRect.right + 8,
- behavior: 'smooth',
- });
- }
- });
+ queueMicrotask(computeVisibleValues);
}
)
);
+ const visibleItems = createMemo(() => {
+ if (!measured()) return props.items;
+ const itemsByValue = new Map(props.items.map((item) => [item.value, item]));
+ return visibleValues().flatMap((value) => {
+ const item = itemsByValue.get(value);
+ return item ? [item] : [];
+ });
+ });
+
+ const overflowItems = createMemo(() => {
+ if (!measured()) return [];
+ const visible = new Set(visibleValues());
+ return props.items.filter((item) => !visible.has(item.value));
+ });
+
return (
<div
- ref={stripRef}
+ ref={setStripRef}
class={cn(
- // overflow-x:auto forces overflow-y to auto, which clips the pills'
- // shadow. The padding gives the shadow room inside the (clipping)
- // padding box; the matching negative margin cancels its layout impact.
- 'pointer-events-auto -my-3 flex min-w-0 items-center gap-2 overflow-x-auto py-3 pr-2 scrollbar-hidden',
+ // The padding gives the pills' shadow room inside the clipping box;
+ // the matching negative margin cancels its layout impact.
+ 'pointer-events-auto relative -my-3 flex w-full min-w-0 flex-1 max-w-full items-center gap-2 py-3 pr-2',
props.class
)}
>
- <For each={props.items}>
+ <For each={visibleItems()}>
{(item) => {
const active = () => props.value === item.value;
return (
@@ -83,10 +158,10 @@ export function PillTabs<T extends string>(props: {
use:pressPulse
data-checked={active() ? '' : undefined}
class={cn(
- 'h-10 shrink-0 whitespace-nowrap rounded-full border px-3.5 text-sm font-medium shadow-md',
+ PILL_CLASS,
active()
- ? 'bg-accent text-surface border-accent'
- : 'bg-surface text-ink-extra-muted border-edge'
+ ? 'bg-accent text-surface ring-accent'
+ : 'text-ink-extra-muted'
)}
onPointerDown={(e) => {
if (props.preserveFocus) e.preventDefault();
@@ -99,6 +174,61 @@ export function PillTabs<T extends string>(props: {
);
}}
</For>
+ <Show when={overflowItems().length > 0}>
+ <MobileTouchMenu
+ triggerAriaLabel="More tabs"
+ position="trigger-bottom"
+ footerLabel="Tabs"
+ items={overflowItems().map((item) => ({
+ id: item.value,
+ label: item.label,
+ active: () => props.value === item.value,
+ onSelect: () => props.onChange(item.value),
+ }))}
+ trigger={(trigger) => (
+ <button
+ type="button"
+ use:pressPulse
+ ref={trigger.ref}
+ aria-label="More tabs"
+ class="h-10 w-10 shrink-0 rounded-full text-ink-extra-muted island flex items-center justify-center [&_svg]:size-5"
+ onPointerDown={(e) => {
+ if (props.preserveFocus) e.preventDefault();
+ trigger.onPointerDown();
+ }}
+ onClick={trigger.onClick}
+ onTouchMove={trigger.onTouchMove}
+ onTouchEnd={trigger.onTouchEnd}
+ >
+ <DotsThreeIcon />
+ </button>
+ )}
+ />
+ </Show>
+ <div
+ ref={setMeasureRef}
+ aria-hidden="true"
+ class="pointer-events-none invisible absolute top-0 left-0 -z-10 flex w-max items-center gap-2 py-3 pr-2"
+ >
+ <For each={props.items}>
+ {(item) => (
+ <button
+ type="button"
+ ref={(el) => measuredButtons.set(item.value, el)}
+ tabIndex={-1}
+ class={PILL_CLASS}
+ >
+ {item.label}
+ </button>
+ )}
+ </For>
+ <button
+ type="button"
+ ref={setOverflowMeasureRef}
+ tabIndex={-1}
+ class="h-10 w-10 shrink-0 rounded-full island"
+ />
+ </div>
</div>
);
}
diff --git a/js/app/packages/app/component/mobile/pillTabsLayout.test.ts b/js/app/packages/app/component/mobile/pillTabsLayout.test.ts
new file mode 100644
index 0000000000..6370abbf7d
--- /dev/null
+++ b/js/app/packages/app/component/mobile/pillTabsLayout.test.ts
@@ -0,0 +1,63 @@
+import { describe, expect, it } from 'vitest';
+import { computeVisiblePillValues } from './pillTabsLayout';
+
+const values = ['A', 'B', 'C', 'D', 'E', 'F'] as const;
+const widths = [20, 20, 20, 20, 20, 20];
+
+describe('computeVisiblePillValues', () => {
+ it('returns all values when they fit without overflow', () => {
+ expect(
+ computeVisiblePillValues({
+ values,
+ activeValue: 'A',
+ currentVisibleValues: [],
+ widths,
+ availableWidth: 200,
+ gap: 5,
+ overflowWidth: 10,
+ })
+ ).toEqual(['A', 'B', 'C', 'D', 'E', 'F']);
+ });
+
+ it('places an overflow-selected value as the last visible pill', () => {
+ expect(
+ computeVisiblePillValues({
+ values,
+ activeValue: 'D',
+ currentVisibleValues: ['A', 'B', 'C'],
+ widths,
+ availableWidth: 85,
+ gap: 5,
+ overflowWidth: 10,
+ })
+ ).toEqual(['A', 'B', 'D']);
+ });
+
+ it('preserves the visible row when selecting an already-visible value', () => {
+ expect(
+ computeVisiblePillValues({
+ values,
+ activeValue: 'A',
+ currentVisibleValues: ['A', 'B', 'D'],
+ widths,
+ availableWidth: 85,
+ gap: 5,
+ overflowWidth: 10,
+ })
+ ).toEqual(['A', 'B', 'D']);
+ });
+
+ it('fills newly available room without replacing visible pills', () => {
+ expect(
+ computeVisiblePillValues({
+ values,
+ activeValue: 'A',
+ currentVisibleValues: ['A', 'D'],
+ widths,
+ availableWidth: 85,
+ gap: 5,
+ overflowWidth: 10,
+ })
+ ).toEqual(['A', 'D', 'B']);
+ });
+});
diff --git a/js/app/packages/app/component/mobile/pillTabsLayout.ts b/js/app/packages/app/component/mobile/pillTabsLayout.ts
new file mode 100644
index 0000000000..74e8b0dfc4
--- /dev/null
+++ b/js/app/packages/app/component/mobile/pillTabsLayout.ts
@@ -0,0 +1,118 @@
+type ComputeVisiblePillValuesInput<T extends string> = {
+ values: readonly T[];
+ activeValue: T | undefined;
+ currentVisibleValues: readonly T[];
+ widths: readonly number[];
+ availableWidth: number;
+ gap: number;
+ overflowWidth: number;
+};
+
+const totalWidth = (
+ indexes: number[],
+ widths: readonly number[],
+ gap: number
+) =>
+ indexes.reduce((total, index) => total + widths[index], 0) +
+ gap * Math.max(0, indexes.length - 1);
+
+const totalWidthWithOverflow = (
+ indexes: number[],
+ widths: readonly number[],
+ gap: number,
+ overflowWidth: number
+) =>
+ indexes.reduce((total, index) => total + widths[index], 0) +
+ overflowWidth +
+ gap * indexes.length;
+
+export function computeVisiblePillValues<T extends string>({
+ values,
+ activeValue,
+ currentVisibleValues,
+ widths,
+ availableWidth,
+ gap,
+ overflowWidth,
+}: ComputeVisiblePillValuesInput<T>): T[] {
+ const allIndexes = values.map((_, index) => index);
+
+ if (values.length === 0) return [];
+
+ if (totalWidth(allIndexes, widths, gap) <= availableWidth) {
+ return [...values];
+ }
+
+ const activeIndex =
+ activeValue === undefined ? -1 : values.indexOf(activeValue);
+ const valueToIndex = new Map(values.map((value, index) => [value, index]));
+ const currentIndexes = currentVisibleValues.flatMap((value) => {
+ const index = valueToIndex.get(value);
+ return index === undefined ? [] : [index];
+ });
+ const fitsWithOverflow = (indexes: number[]) =>
+ totalWidthWithOverflow(indexes, widths, gap, overflowWidth) <=
+ availableWidth;
+
+ const packIndexes = (orderedIndexes: number[]) => {
+ const packed: number[] = [];
+ for (const index of orderedIndexes) {
+ const candidate = [...packed, index];
+ if (fitsWithOverflow(candidate)) {
+ packed.push(index);
+ }
+ }
+ return packed;
+ };
+
+ const packIndexesEndingWith = (
+ lastIndex: number,
+ orderedIndexes: number[]
+ ) => {
+ const packed: number[] = [];
+ for (const index of orderedIndexes) {
+ if (index === lastIndex) continue;
+ const candidate = [...packed, index, lastIndex];
+ if (fitsWithOverflow(candidate)) {
+ packed.push(index);
+ }
+ }
+ return [...packed, lastIndex];
+ };
+
+ const trimIndexesKeepingActive = (indexes: number[], keepIndex: number) => {
+ const trimmed = [...indexes];
+ while (trimmed.length > 1 && !fitsWithOverflow(trimmed)) {
+ const removeIndex = trimmed.findLastIndex((index) => index !== keepIndex);
+ if (removeIndex === -1) break;
+ trimmed.splice(removeIndex, 1);
+ }
+ return trimmed;
+ };
+
+ const fillIndexes = (baseIndexes: number[], orderedIndexes: number[]) => {
+ const filled = [...baseIndexes];
+ for (const index of orderedIndexes) {
+ if (filled.includes(index)) continue;
+ const candidate = [...filled, index];
+ if (fitsWithOverflow(candidate)) {
+ filled.push(index);
+ }
+ }
+ return filled;
+ };
+
+ const naturalVisibleIndexes = packIndexes(allIndexes);
+ const activeIsCurrentlyVisible =
+ activeIndex !== -1 && currentIndexes.includes(activeIndex);
+ const visibleIndexes = activeIsCurrentlyVisible
+ ? fillIndexes(
+ trimIndexesKeepingActive(currentIndexes, activeIndex),
+ allIndexes
+ )
+ : activeIndex !== -1 && !naturalVisibleIndexes.includes(activeIndex)
+ ? packIndexesEndingWith(activeIndex, allIndexes)
+ : naturalVisibleIndexes;
+
+ return visibleIndexes.map((index) => values[index]);
+}
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
index 3ca418a773..633e204fe2 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx
@@ -266,7 +266,7 @@ export const MobileFilterDrawer = () => {
variant="ghost"
size="sm"
depth={3}
- class="island pointer-events-auto relative size-10 shrink-0 rounded-full bg-surface [&_svg]:size-5"
+ class="island bg-chrome pointer-events-auto relative size-10 shrink-0 rounded-full [&_svg]:size-5"
ref={pressPulse}
>
<SlidersHorizontalIcon />
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-file-dropzone.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-file-dropzone.tsx
index 010ce6cdd0..a3fb796721 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-file-dropzone.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-file-dropzone.tsx
@@ -14,7 +14,7 @@ export const SoupViewFileDropzone: FlowComponent = (props) => {
return (
<div
- class="relative flex flex-col bg-surface size-full"
+ class="relative flex flex-col bg-panel size-full"
use:fileFolderDrop={{
onDrop: (fileEntries, folderEntries) => {
handleFileFolderDrop(fileEntries, folderEntries, handleFileUpload);
diff --git a/js/app/packages/app/component/split-layout/components/HeaderTitleMenu.tsx b/js/app/packages/app/component/split-layout/components/HeaderTitleMenu.tsx
index fb419f2ff8..b3b937277c 100644
--- a/js/app/packages/app/component/split-layout/components/HeaderTitleMenu.tsx
+++ b/js/app/packages/app/component/split-layout/components/HeaderTitleMenu.tsx
@@ -36,7 +36,7 @@ export function HeaderTitleMenu(
{props.children}
<CaretDownIcon class="size-3 shrink-0 text-ink-muted" />
</Dropdown.Trigger>
- <Dropdown.Content depth={3} class="shadow-md">
+ <Dropdown.Content depth={3}>
<Dropdown.Group>
<For each={[...props.items]}>
{(item) => (
diff --git a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx b/js/app/packages/app/component/split-layout/components/SplitPanel.tsx
index 53372afd7e..2f3274a75b 100644
--- a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitPanel.tsx
@@ -218,7 +218,7 @@ export function SplitPanel(props: SplitPanelProps) {
!props.handle.isSpotLight()
}
class="rounded-xl mobile:rounded-none mobile:after:hidden mobile:border-0!"
- depth={1}
+ depth={isMobile() ? 0 : 1}
>
<Panel.Header
class={cn(
diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.css
index 689cc7b76e..1e64497747 100644
--- a/js/app/packages/app/index.css
+++ b/js/app/packages/app/index.css
@@ -121,13 +121,11 @@
--color-surface: var(--b0);
--color-drop-shadow: oklch(0.15 0 0 / 0.04);
- --color-message: color-mix(in oklch, var(--b1) 50%, var(--b2));
- --color-hover: var(--b2);
- --color-active: var(--b1);
--color-overlay: oklch(var(--b1l) var(--b1c) var(--b1h) / 0.8);
+
--color-edge-muted: var(--b3);
--color-edge: var(--b4);
- --color-rail: color-mix(in oklch, var(--b0) 75%, var(--c0));
+ --color-rail: color-mix(in oklch, var(--b4) 90%, var(--c0));
--color-ink: var(--c0);
--color-ink-muted: var(--c1);
@@ -135,6 +133,23 @@
--color-ink-disabled: var(--c3);
--color-ink-placeholder: var(--c4);
+ /* Below are our semantic surface tokens, which either pick up color overrides from the theme, or are set to --b0, which allows them to be controlled by our Layer system */
+ /* NOTE: these are NOT all wired up. We erased a lot of our semantic design tokens when moving to Layer system, these are part of a migration back towards semantic tokens. */
+ /* To wire them up you should change the generic '*-surface' class on a component to instead use one of these tokens. */
+ --color-page: var(--theme-page, var(--b0));
+ --color-panel: var(--theme-panel, var(--b0));
+ --color-inset: var(--theme-inset, var(--b0));
+ --color-dialog: var(--theme-dialog, var(--b0));
+ --color-menu: var(--theme-menu, var(--b0));
+ --color-input: var(--theme-input, var(--b0));
+ --color-message: var(--theme-message, color-mix(in oklch, var(--b1) 50%, var(--b2)));
+ --color-hover: var(--theme-hover, var(--b2));
+ --color-active: var(--theme-active, var(--b1));
+ --color-button: var(--theme-button, var(--b0));
+ /* Used for floating mobile navigation chrome */
+ --color-chrome: var(--theme-chrome, color-mix(in oklch, var(--color-menu) 85%, var(--color-active)));
+
+
/* Below are hardcoded colors */
--color-failure: oklch(0.637 0.237 25.331);
--color-failure-bg: oklch(from var(--color-failure) l c h / 0.15);
@@ -228,13 +243,17 @@
}
}
+@custom-variant light-mode (&:where(html[data-theme-light="true"] *));
+@custom-variant dark-mode (&:where(html[data-theme-light="false"] *));
+
+
/* Floating "island" chrome shared by the mobile dock buttons, header islands,
and other floating mobile controls. Consumers add their own shape classes
(e.g. `size-10 rounded-full` or `h-10 rounded-full px-3`). Defined as a
utility so it composes with variants — `mobile:island` — instead of
hand-prefixing each part. */
@utility island {
- @apply bg-surface text-ink ring ring-edge shadow-md;
+ @apply bg-chrome text-ink ring dark-mode:ring-edge light-mode:ring-panel light-mode:shadow-[0_4px_20px_8px_oklch(0.15_0_0/0.07)];
}
[data-press-pulse] {
diff --git a/js/app/packages/block-email/component/BottomReplyButtons.tsx b/js/app/packages/block-email/component/BottomReplyButtons.tsx
index 2611e232cd..9c89e1e556 100644
--- a/js/app/packages/block-email/component/BottomReplyButtons.tsx
+++ b/js/app/packages/block-email/component/BottomReplyButtons.tsx
@@ -26,7 +26,7 @@ function ReplyActionButton(props: {
// accessory region, match the chrome's depth so the island surface
// matches the dock buttons. (The region host's Layer can't help —
// Button's own Layer would reset it.)
- depth={isMobile() ? 4 : undefined}
+ depth={isMobile() ? 3 : undefined}
class={cn(
'rounded-lg px-3 py-1.5 text-sm text-ink-muted hover:text-ink border border-ink-muted/8 bg-ink-muted/2.5 hover:bg-ink-muted/6',
// Island pills when floating in the mobile accessory region.
diff --git a/js/app/packages/channel/Input/ChannelInput.tsx b/js/app/packages/channel/Input/ChannelInput.tsx
index ade287c64f..ef8bbf2a9f 100644
--- a/js/app/packages/channel/Input/ChannelInput.tsx
+++ b/js/app/packages/channel/Input/ChannelInput.tsx
@@ -379,7 +379,7 @@ export function ChannelInput(props: ChannelInputProps) {
data-collapsed-input-file-picker
/>
<CollapsedInput
- class="mobile:rounded-full"
+ class="mobile:rounded-full mobile:island"
draft={inputState.view().value}
renderDraft={(draft) => (
<StaticMarkdown
@@ -408,8 +408,13 @@ export function ChannelInput(props: ChannelInputProps) {
}}
onFocusIn={() => setIsFocused(true)}
active={isFocused()}
- class={cn('rounded-xl mobile:rounded-3xl', isCollapsed() && 'hidden')}
- depth={2}
+ class={cn(
+ 'rounded-xl mobile:rounded-3xl mobile:island',
+ isCollapsed() && 'hidden'
+ )}
+ bgToken={isMobile() ? 'chrome' : undefined}
+ hideBorder={isMobile()}
+ depth={isMobile() ? 3 : 2}
solid
>
<Input.DropZone
diff --git a/js/app/packages/theme/constants.ts b/js/app/packages/theme/constants.ts
index 0be24acf2f..db1b3cbd58 100644
--- a/js/app/packages/theme/constants.ts
+++ b/js/app/packages/theme/constants.ts
@@ -1,8 +1,111 @@
+import { isMobile } from '@core/mobile/isMobile';
import type { ThemeV2 } from './types/themeTypes';
export const DEFAULT_LIGHT_THEME: DefaultTheme = 'Macro Light';
export const DEFAULT_DARK_THEME: DefaultTheme = 'Macro Dark';
+const MACRO_DARK: Pick<ThemeV2, 'depth' | 'tokens' | 'overrides'> = isMobile() ? {
+ depth: 0.35,
+ tokens: {
+ a0: { l: 0.75, c: 0.20, h: 59 },
+ a1: { l: 0.75, c: 0.20, h: 99 },
+ a2: { l: 0.75, c: 0.20, h: 139 },
+ a3: { l: 0.75, c: 0.20, h: 179 },
+ a4: { l: 0.75, c: 0.20, h: 219 },
+ b0: { l: 0.00, c: 0.00, h: 21 },
+ b1: { l: 0.18, c: 0.00, h: 21 },
+ b2: { l: 0.23, c: 0.00, h: 21 },
+ b3: { l: 0.25, c: 0.00, h: 21 },
+ b4: { l: 0.28, c: 0.00, h: 21 },
+ c0: { l: 0.95, c: 0.00, h: 21 },
+ c1: { l: 0.83, c: 0.00, h: 21 },
+ c2: { l: 0.75, c: 0.00, h: 21 },
+ c3: { l: 0.63, c: 0.00, h: 21 },
+ c4: { l: 0.55, c: 0.00, h: 21 },
+ },
+ }
+ : {
+ depth: 0.15,
+ tokens: {
+ a0: { l: 0.75, c: 0.20, h: 59 },
+ a1: { l: 0.75, c: 0.20, h: 99 },
+ a2: { l: 0.75, c: 0.20, h: 139 },
+ a3: { l: 0.75, c: 0.20, h: 179 },
+ a4: { l: 0.75, c: 0.20, h: 219 },
+ b0: { l: 0.14, c: 0.00, h: 59 },
+ b1: { l: 0.20, c: 0.00, h: 59 },
+ b2: { l: 0.23, c: 0.00, h: 59 },
+ b3: { l: 0.25, c: 0.00, h: 59 },
+ b4: { l: 0.28, c: 0.00, h: 59 },
+ c0: { l: 0.95, c: 0.00, h: 59 },
+ c1: { l: 0.83, c: 0.00, h: 59 },
+ c2: { l: 0.75, c: 0.00, h: 59 },
+ c3: { l: 0.63, c: 0.00, h: 59 },
+ c4: { l: 0.55, c: 0.00, h: 59 },
+ },
+ };
+
+const MACRO_LIGHT: Pick<ThemeV2, 'depth' | 'tokens' | 'overrides'> = isMobile()
+ ? {
+ depth: 0.06,
+ tokens: {
+ a0: { l: 0.65, c: 0.20, h: 59 },
+ a1: { l: 0.65, c: 0.20, h: 99 },
+ a2: { l: 0.65, c: 0.20, h: 139 },
+ a3: { l: 0.65, c: 0.20, h: 179 },
+ a4: { l: 0.65, c: 0.20, h: 219 },
+ b0: { l: 1.00, c: 0.00, h: 59 },
+ b1: { l: 0.96, c: 0.00, h: 59 },
+ b2: { l: 0.96, c: 0.00, h: 59 },
+ b3: { l: 0.92, c: 0.00, h: 59 },
+ b4: { l: 0.91, c: 0.00, h: 59 },
+ c0: { l: 0.14, c: 0.00, h: 59 },
+ c1: { l: 0.40, c: 0.00, h: 59 },
+ c2: { l: 0.55, c: 0.00, h: 59 },
+ c3: { l: 0.65, c: 0.00, h: 59 },
+ c4: { l: 0.75, c: 0.00, h: 59 },
+ },
+ overrides: [
+ {
+ token: 'menu',
+ value: { l: 1.00, c: 0.00, h: 59 },
+ },
+ {
+ token: 'panel',
+ value: { l: 1.00, c: 0.00, h: 59 },
+ },
+ {
+ token: 'dialog',
+ value: { l: 1.00, c: 0.00, h: 59 },
+ },
+ {
+ token: 'input',
+ value: { l: 1.00, c: 0.00, h: 59 },
+ },
+ ]
+ }
+ : {
+ depth: 0.09,
+ tokens: {
+ a0: { l: 0.65, c: 0.20, h: 59 },
+ a1: { l: 0.65, c: 0.20, h: 99 },
+ a2: { l: 0.65, c: 0.20, h: 139 },
+ a3: { l: 0.65, c: 0.20, h: 179 },
+ a4: { l: 0.65, c: 0.20, h: 219 },
+ b0: { l: 0.96, c: 0.00, h: 59 },
+ b1: { l: 0.92, c: 0.00, h: 59 },
+ b2: { l: 0.91, c: 0.00, h: 59 },
+ b3: { l: 0.92, c: 0.00, h: 59 },
+ b4: { l: 0.91, c: 0.00, h: 59 },
+ c0: { l: 0.14, c: 0.00, h: 59 },
+ c1: { l: 0.40, c: 0.00, h: 59 },
+ c2: { l: 0.55, c: 0.00, h: 59 },
+ c3: { l: 0.65, c: 0.00, h: 59 },
+ c4: { l: 0.75, c: 0.00, h: 59 },
+ },
+ };
+
+
// Ordered for the theme picker: dark themes first (led by the Macro brand theme),
// then light themes (led by the Macro brand theme). ThemeList renders in array order.
export const DEFAULT_THEMES = [
@@ -10,24 +113,9 @@ export const DEFAULT_THEMES = [
id: 'Macro Dark',
name: 'Macro Dark',
version: 2,
- depth: 0.15,
- tokens: {
- a0: { l: 0.75, c: 0.20, h: 59 },
- a1: { l: 0.75, c: 0.20, h: 99 },
- a2: { l: 0.75, c: 0.20, h: 139 },
- a3: { l: 0.75, c: 0.20, h: 179 },
- a4: { l: 0.75, c: 0.20, h: 219 },
- b0: { l: 0.14, c: 0.00, h: 59 },
- b1: { l: 0.20, c: 0.00, h: 59 },
- b2: { l: 0.23, c: 0.00, h: 59 },
- b3: { l: 0.25, c: 0.00, h: 59 },
- b4: { l: 0.28, c: 0.00, h: 59 },
- c0: { l: 0.95, c: 0.00, h: 59 },
- c1: { l: 0.83, c: 0.00, h: 59 },
- c2: { l: 0.75, c: 0.00, h: 59 },
- c3: { l: 0.63, c: 0.00, h: 59 },
- c4: { l: 0.55, c: 0.00, h: 59 },
- },
+ depth: MACRO_DARK.depth,
+ tokens: MACRO_DARK.tokens,
+ overrides: MACRO_DARK.overrides
},
{
// Neutral anchor: a true graphite monochrome, accents carry only a whisper of
@@ -55,29 +143,29 @@ export const DEFAULT_THEMES = [
},
},
{
- // Warm: a deep ember charcoal with a soft amber accent — the 3am-screen glow.
- id: 'Sleepless',
- name: 'Sleepless',
- version: 2,
- depth: 0.12,
- tokens: {
- a0: { l: 0.75, c: 0.15, h: 55 },
- a1: { l: 0.75, c: 0.15, h: 95 },
- a2: { l: 0.75, c: 0.15, h: 135 },
- a3: { l: 0.75, c: 0.15, h: 175 },
- a4: { l: 0.75, c: 0.15, h: 215 },
- b0: { l: 0.16, c: 0.010, h: 55 },
- b1: { l: 0.20, c: 0.010, h: 55 },
- b2: { l: 0.24, c: 0.012, h: 55 },
- b3: { l: 0.27, c: 0.012, h: 55 },
- b4: { l: 0.31, c: 0.014, h: 55 },
- c0: { l: 0.95, c: 0.008, h: 55 },
- c1: { l: 0.83, c: 0.008, h: 55 },
- c2: { l: 0.73, c: 0.008, h: 55 },
- c3: { l: 0.63, c: 0.008, h: 55 },
- c4: { l: 0.55, c: 0.008, h: 55 },
+ // Warm: a deep ember charcoal with a soft amber accent.
+ id: 'Ember',
+ name: 'Ember',
+ version: 2,
+ depth: 0.12,
+ tokens: {
+ a0: { l: 0.75, c: 0.15, h: 55 },
+ a1: { l: 0.75, c: 0.15, h: 95 },
+ a2: { l: 0.75, c: 0.15, h: 135 },
+ a3: { l: 0.75, c: 0.15, h: 175 },
+ a4: { l: 0.75, c: 0.15, h: 215 },
+ b0: { l: 0.16, c: 0.010, h: 55 },
+ b1: { l: 0.20, c: 0.010, h: 55 },
+ b2: { l: 0.24, c: 0.012, h: 55 },
+ b3: { l: 0.27, c: 0.012, h: 55 },
+ b4: { l: 0.31, c: 0.014, h: 55 },
+ c0: { l: 0.95, c: 0.008, h: 55 },
+ c1: { l: 0.83, c: 0.008, h: 55 },
+ c2: { l: 0.73, c: 0.008, h: 55 },
+ c3: { l: 0.63, c: 0.008, h: 55 },
+ c4: { l: 0.55, c: 0.008, h: 55 },
+ },
},
- },
{
// Cool: an ethereal violet-indigo night, calm and a touch mysterious.
id: 'Spirit',
@@ -154,24 +242,9 @@ export const DEFAULT_THEMES = [
id: 'Macro Light',
name: 'Macro Light',
version: 2,
- depth: 0.09,
- tokens: {
- a0: { l: 0.65, c: 0.20, h: 59 },
- a1: { l: 0.65, c: 0.20, h: 99 },
- a2: { l: 0.65, c: 0.20, h: 139 },
- a3: { l: 0.65, c: 0.20, h: 179 },
- a4: { l: 0.65, c: 0.20, h: 219 },
- b0: { l: 0.96, c: 0.00, h: 59 },
- b1: { l: 0.92, c: 0.00, h: 59 },
- b2: { l: 0.91, c: 0.00, h: 59 },
- b3: { l: 0.92, c: 0.00, h: 59 },
- b4: { l: 0.91, c: 0.00, h: 59 },
- c0: { l: 0.14, c: 0.00, h: 59 },
- c1: { l: 0.40, c: 0.00, h: 59 },
- c2: { l: 0.55, c: 0.00, h: 59 },
- c3: { l: 0.65, c: 0.00, h: 59 },
- c4: { l: 0.75, c: 0.00, h: 59 },
- },
+ depth: MACRO_LIGHT.depth,
+ tokens: MACRO_LIGHT.tokens,
+ overrides: MACRO_LIGHT.overrides
},
{
// Warm: a cream page with a sun-ripe orange accent — citrus, but restrained.
@@ -295,6 +368,6 @@ export const DEFAULT_THEMES = [
c4: { l: 0.72, c: 0.006, h: 295 },
},
},
-] as const satisfies ReadonlyArray<ThemeV2>;
+] as const satisfies readonly ThemeV2[];
type DefaultTheme = (typeof DEFAULT_THEMES)[number]['id'];
diff --git a/js/app/packages/theme/signals/themeReactive.ts b/js/app/packages/theme/signals/themeReactive.ts
index 70bf658da5..45b528f3ac 100644
--- a/js/app/packages/theme/signals/themeReactive.ts
+++ b/js/app/packages/theme/signals/themeReactive.ts
@@ -69,6 +69,11 @@ const ALL_THEME_SIGNALS = [
themeReactive.c4.l[0], themeReactive.c4.c[0], themeReactive.c4.h[0],
];
+function syncThemeLightAttribute(): void {
+ document.documentElement.dataset.themeLight =
+ themeReactive.b0.l[0]() > themeReactive.c0.l[0]() ? 'true' : 'false';
+}
+
createEffect(
on(
ALL_THEME_SIGNALS,
@@ -121,6 +126,7 @@ createEffect(
if(themeReactive.c4.c[0]() !== previousTheme.c4.c){document.documentElement.style.setProperty( '--c4c', `${themeReactive.c4.c[0]()}` ); previousTheme.c4.c = themeReactive.c4.c[0]()}
if(themeReactive.c4.h[0]() !== previousTheme.c4.h){document.documentElement.style.setProperty( '--c4h', `${themeReactive.c4.h[0]()}deg` ); previousTheme.c4.h = themeReactive.c4.h[0]()}
+ syncThemeLightAttribute();
setThemeUpdate();
setIsThemeSaved(false);
},
diff --git a/js/app/packages/theme/signals/themeSignals.ts b/js/app/packages/theme/signals/themeSignals.ts
index f38dda186c..aebb212a72 100644
--- a/js/app/packages/theme/signals/themeSignals.ts
+++ b/js/app/packages/theme/signals/themeSignals.ts
@@ -30,7 +30,10 @@ export const [currentThemeId, setCurrentThemeId] = makePersisted(
{name: 'macro-selected-theme'}
);
-export const themes = createMemo(() => [...DEFAULT_THEMES, ...userThemes()]);
+export const themes = createMemo<ThemeV2[]>(() => [
+ ...(DEFAULT_THEMES as readonly ThemeV2[]),
+ ...userThemes(),
+]);
// Per-mode theme preferences, persisted to localStorage. Applied by
// systemThemeEffect (themeUtils.ts) when themeShouldMatchSystem is on and the OS
diff --git a/js/app/packages/theme/types/themeTypes.ts b/js/app/packages/theme/types/themeTypes.ts
index 590d178204..107c294660 100644
--- a/js/app/packages/theme/types/themeTypes.ts
+++ b/js/app/packages/theme/types/themeTypes.ts
@@ -45,12 +45,21 @@ export type ThemePrevious = {
c4: { l: number; c: number; h: number };
};
+export const semanticTokens = ['page', 'panel', 'inset', 'dialog', 'menu', 'input', 'message', 'hover', 'active', 'button', 'chrome'] as const;
+export type SemanticToken = (typeof semanticTokens)[number];
+
+type TokenColor = {
+ token: SemanticToken,
+ value: { l: number; c: number; h: number }
+}
+
export type ThemeV2 = {
id: string;
name: string;
version: number;
depth: number;
tokens: ThemeV2Tokens;
+ overrides?: TokenColor[];
};
export type ThemeV2Tokens = {
diff --git a/js/app/packages/theme/utils/themeUtils.ts b/js/app/packages/theme/utils/themeUtils.ts
index c29c98e89a..38c8f05376 100644
--- a/js/app/packages/theme/utils/themeUtils.ts
+++ b/js/app/packages/theme/utils/themeUtils.ts
@@ -1,5 +1,5 @@
import { currentThemeId, darkModeTheme, lightModeTheme, setCurrentThemeId, setDarkModeTheme, setHtmlColor, setIsThemeSaved, setLightModeTheme, setThemeDepth, setUserThemes, systemMode, themeDepth, themes, themeShouldMatchSystem, userThemes} from '../signals/themeSignals';
-import type { ThemeV2, ThemeV2Tokens } from '../types/themeTypes';
+import { semanticTokens, type ThemeV2, type ThemeV2Tokens } from '../types/themeTypes';
import { themeReactive } from '../signals/themeReactive';
import { toast } from '@core/component/Toast/Toast';
import { batch, createEffect, on } from 'solid-js';
@@ -57,6 +57,16 @@ export function applyTheme(id: string): void{
}
setCurrentThemeId(theme.id);
+ // Set theme overrides
+ for (const token of semanticTokens) {
+ const themeOverride = theme.overrides?.find((o) => o.token === token)
+ if (themeOverride) {
+ document.documentElement.style.setProperty(`--theme-${token}`, `oklch(${themeOverride.value.l} ${themeOverride.value.c} ${themeOverride.value.h})`)
+ } else {
+ document.documentElement.style.removeProperty(`--theme-${token}`)
+ }
+ }
+
batch(() => {
(Object.keys(theme!.tokens) as Array<keyof ThemeV2Tokens>).forEach((tokenKey) => {
(Object.keys(theme!.tokens[tokenKey]) as Array<'l' | 'c' | 'h'>).forEach((prop) => {
diff --git a/js/app/packages/ui/components/CollapsedInput.tsx b/js/app/packages/ui/components/CollapsedInput.tsx
index 78e116a0be..099c7ba398 100644
--- a/js/app/packages/ui/components/CollapsedInput.tsx
+++ b/js/app/packages/ui/components/CollapsedInput.tsx
@@ -4,8 +4,8 @@ import PaperclipIcon from '@phosphor-icons/core/regular/paperclip.svg?component-
import { type Accessor, type JSX, Show } from 'solid-js';
import { cn } from '../utils/classname';
import { Button } from './Button';
+import { Layer } from './Layer';
import { SendButton } from './SendButton';
-import { Surface } from './Surface';
export type CollapsedInputProps = {
/** Draft of the real input, shown as the one-line preview. */
@@ -48,17 +48,13 @@ export function CollapsedInput(props: CollapsedInputProps) {
const hasAttachments = () => attachmentCount() > 0;
return (
- <Surface
- depth={2}
- solid
- // h-12.5 and px-2 keep the attach/send buttons exactly where the
- // expanded input's footer puts them (`p-2 mb-2 h-8` plus the surface's
- // 1px border: button centers 25px above the outer bottom edge, 8px in
- // from the border).
- class={cn('rounded-xl w-full h-12.5', props.class)}
- data-collapsed-input
- >
- <div class="flex h-full min-w-0 items-center gap-1.5 px-2">
+ <Layer depth={3} data-collapsed-input>
+ <div
+ class={cn(
+ 'rounded-xl w-full h-12.5 island flex min-w-0 items-center gap-1.5 px-2',
+ props.class
+ )}
+ >
<Button
variant="ghost"
size="icon-sm"
@@ -87,7 +83,7 @@ export function CollapsedInput(props: CollapsedInputProps) {
}
>
{/* Interactive content in the rendered draft (mentions, links)
- must not swallow the tap that opens the input. */}
+ must not swallow the tap that opens the input. */}
<div class="pointer-events-none min-w-0 flex-1 truncate">
{props.renderDraft ? props.renderDraft(text) : text()}
</div>
@@ -126,6 +122,6 @@ export function CollapsedInput(props: CollapsedInputProps) {
/>
</Show>
</div>
- </Surface>
+ </Layer>
);
}
diff --git a/js/app/packages/ui/components/Dropdown.tsx b/js/app/packages/ui/components/Dropdown.tsx
index 33555e5669..0b41aba40a 100644
--- a/js/app/packages/ui/components/Dropdown.tsx
+++ b/js/app/packages/ui/components/Dropdown.tsx
@@ -120,6 +120,7 @@ function DropdownContent(props: DropdownContentProps) {
)}
depth={local.depth ?? 2}
as={Surface}
+ bgToken="menu"
{...rest}
ref={setContentRef}
>
@@ -160,6 +161,7 @@ function DropdownSubContent(props: DropdownSubContentProps) {
)}
depth={local.depth ?? 2}
as={Surface}
+ bgToken="menu"
{...rest}
ref={setContentRef}
>
@@ -176,7 +178,7 @@ function DropdownGroup(props: DropdownGroupProps) {
const [local, rest] = splitProps(props, ['class']);
return (
<KobalteDropdownMenu.Group
- class={cn('flex flex-col p-1.5 bg-surface', local.class)}
+ class={cn('flex flex-col p-1.5 bg-menu', local.class)}
{...rest}
/>
);
diff --git a/js/app/packages/ui/components/Layer.tsx b/js/app/packages/ui/components/Layer.tsx
index c46ceae535..a687746791 100644
--- a/js/app/packages/ui/components/Layer.tsx
+++ b/js/app/packages/ui/components/Layer.tsx
@@ -1,5 +1,7 @@
-import { themeDepth } from '@theme/signals/themeSignals';
-import type { JSX } from 'solid-js';
+import { isMobile } from '@core/mobile/isMobile';
+import { DEFAULT_LIGHT_THEME } from '@theme/constants';
+import { currentThemeId, themeDepth } from '@theme/signals/themeSignals';
+import { createMemo, type JSX } from 'solid-js';
type LayerProps = {
children?: JSX.Element;
@@ -7,17 +9,28 @@ type LayerProps = {
};
export function Layer(props: LayerProps) {
- const depth = () => ((props.depth ?? 0) / 5) * themeDepth();
+ const isDefaultMobileLight = createMemo(
+ () => currentThemeId() === DEFAULT_LIGHT_THEME && isMobile()
+ );
+ // HACK: on default mobile light theme, we reverse the sign
+ const sign = () => (isDefaultMobileLight() ? -1 : 1);
+ const depth = () => ((props.depth ?? 0) / 5) * themeDepth() * sign();
+
+ // As Layer depth increases, Borders should get lighter slower than surfaces. So we multiple them by this.
+ const BORDER_SCALAR = 0.4;
+ // If --b0 is black, or near black, we need to set a min step to get appropriate contrast
+ const nearBlackStepMin = () => ((props.depth ?? 0) > 0 ? 0.19 : 0);
+
return (
<div
data-layer-depth={props.depth}
style={{
display: 'contents',
- '--b0': `oklch(calc(var(--b0l) + ${depth()}) var(--b0c) var(--b0h))`,
+ '--b0': `oklch(max(var(--b0l) + ${depth()}, ${nearBlackStepMin()}) var(--b0c) var(--b0h))`,
'--b1': `oklch(calc(var(--b1l) + ${depth()}) var(--b1c) var(--b1h))`,
'--b2': `oklch(calc(var(--b2l) + ${depth()}) var(--b2c) var(--b2h))`,
- '--b3': `oklch(calc(var(--b3l) + ${depth()}) var(--b3c) var(--b3h))`,
- '--b4': `oklch(calc(var(--b4l) + ${depth()}) var(--b4c) var(--b4h))`,
+ '--b3': `oklch(calc(var(--b3l) + ${depth() * BORDER_SCALAR}) var(--b3c) var(--b3h))`,
+ '--b4': `oklch(calc(var(--b4l) + ${depth() * BORDER_SCALAR}) var(--b4c) var(--b4h))`,
'--c0': `oklch(calc(var(--c0l) + ${depth()}) var(--c0c) var(--c0h))`,
'--c1': `oklch(calc(var(--c1l) + ${depth()}) var(--c1c) var(--c1h))`,
'--c2': `oklch(calc(var(--c2l) + ${depth()}) var(--c2c) var(--c2h))`,
@@ -29,22 +42,33 @@ export function Layer(props: LayerProps) {
// TODO (seamus): --color-surface could be better handled with fractional layer depth
'--color-surface': 'var(--b0)',
+
'--color-shadow':
'oklch(calc(var(--b0l) - 0.005 ) var(--b0c) var(--b0h) / 0.2)',
// TODO (seamus): --color-message could be better handled with fractional layer depth
- '--color-message': 'color-mix(in oklch, var(--b1) 50%, var(--b2))',
- '--color-active': 'var(--b1)',
- '--color-hover': 'var(--b2)',
'--color-overlay': 'oklch(from var(--b2) l c h / 0.5)',
'--color-edge-muted': 'var(--b3)',
'--color-edge': 'var(--b4)',
- '--color-rail': 'color-mix(in oklch, var(--b0) 75%, var(--c0))',
+ '--color-rail': 'color-mix(in oklch, var(--b4) 90%, var(--c0))',
'--color-ink': 'var(--c0)',
'--color-ink-muted': 'var(--c1)',
'--color-ink-extra-muted': 'var(--c2)',
'--color-ink-disabled': 'var(--c3)',
- '--color-ink-placeholder': 'oklch(var(--c4) / 0.5))',
+ '--color-ink-placeholder': 'var(--c4)',
+
+ // Semantic design tokens with theme overrides, get set to the theme override, otherwise, they get set to --b0, same as `--color-surface`, and get controlled entirely by Layer system
+ '--color-page': 'var(--theme-page, var(--b0))',
+ '--color-panel': 'var(--theme-panel, var(--b0))',
+ '--color-inset': 'var(--theme-inset, var(--b0))',
+ '--color-dialog': 'var(--theme-dialog, var(--b0))',
+ '--color-menu': 'var(--theme-menu, var(--b0))',
+ '--color-input': 'var(--theme-input, var(--b0))',
+ '--color-message':
+ 'var(--theme-message, color-mix(in oklch, var(--b1) 50%, var(--b2)))',
+ '--color-active': 'var(--theme-active, var(--b1))',
+ '--color-hover': 'var(--theme-hover, var(--b2))',
+ '--color-button': 'var(--theme-button, var(--b0))',
}}
>
{props.children}
diff --git a/js/app/packages/ui/components/Surface.tsx b/js/app/packages/ui/components/Surface.tsx
index c5c04c4e11..c0f9cfcc70 100644
--- a/js/app/packages/ui/components/Surface.tsx
+++ b/js/app/packages/ui/components/Surface.tsx
@@ -1,3 +1,5 @@
+import { isMobile } from '@core/mobile/isMobile';
+import type { SemanticToken } from '@theme/types/themeTypes';
import { type JSX, splitProps } from 'solid-js';
import { cn } from '../utils/classname';
import { Layer } from './Layer';
@@ -8,6 +10,9 @@ export type SurfaceProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, 'style'> & {
highlightColor?: string;
active?: boolean;
solid?: boolean;
+ // Surface handles the bg color styling. It defaults to the value of our `surface` token (`var(--b0)`). You can use this if you want to instead feed it a different token (e.g. if your surface is an input, you can give it the 'input' token).
+ bgToken?: SemanticToken;
+ hideBorder?: boolean;
};
export function Surface(props: SurfaceProps) {
@@ -19,25 +24,41 @@ export function Surface(props: SurfaceProps) {
'depth',
'class',
'style',
+ 'bgToken',
+ 'hideBorder',
]);
+ const defaultHighlightColor = isMobile() ? 'var(--color-edge)' : 'var(--a0)';
+
const border = () => {
const edge = 'var(--b4)';
- const top = local.active ? (local.highlightColor ?? 'var(--a0)') : edge;
+ const top = local.active
+ ? (local.highlightColor ?? defaultHighlightColor)
+ : edge;
const bottom = local.active && !local.solid ? `${edge} 80%` : top;
return `linear-gradient(${top}, ${bottom})`;
};
+ const bgVariable = () =>
+ local.bgToken ? `--color-${local.bgToken}` : '--b0';
+
return (
<Layer depth={local.depth ?? 0}>
<div
- style={{
- 'background-image': `linear-gradient(var(--b0), var(--b0)), ${border()}`,
- 'background-origin': 'padding-box, border-box',
- 'background-clip': 'padding-box, border-box',
- border: '1px solid #0000',
- ...local.style,
- }}
+ style={
+ local.hideBorder
+ ? {
+ 'background-color': `var(${bgVariable()})`,
+ ...local.style,
+ }
+ : {
+ 'background-image': `linear-gradient(var(${bgVariable()}), var(${bgVariable()})), ${border()}`,
+ 'background-origin': 'padding-box, border-box',
+ 'background-clip': 'padding-box, border-box',
+ border: '1px solid #0000',
+ ...local.style,
+ }
+ }
class={cn(
'relative rounded-md overflow-clip min-h-0 size-full',
local.class