Skip to content

armgit / macro

Public Imported from GitHub
0

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

style(layout): fix broken left padding when un-authed (#2281)

Seamus284994d1beeb
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsx
index cd4b85df49..45a4cd7b8b 100644
--- a/js/app/packages/app/component/Layout.tsx
+++ b/js/app/packages/app/component/Layout.tsx
@@ -12,7 +12,14 @@ import { updateCookie } from '@core/util/cookies';
import { type RouteSectionProps, useLocation } from '@solidjs/router';
import { cn } from '@ui/utils/classname';
import { attachGlobalDOMScope } from 'core/hotkey/hotkeys';
-import { createEffect, createSignal, onMount, Show, Suspense } from 'solid-js';
+import {
+ createEffect,
+ createMemo,
+ createSignal,
+ onMount,
+ Show,
+ Suspense,
+} from 'solid-js';
import Banner from './banner/Banner';
import { GlobalBulkEditEntityModal } from './bulk-edit-entity/BulkEditEntityModal';
import { GlobalShareModal } from './global-share-modal/GlobalShareModal';
@@ -32,6 +39,11 @@ import { isMobile } from '@core/mobile/isMobile';
import { MobileDock } from './mobile/MobileDock';
import { MobileSearchOuter } from './mobile/MobileSearch';
import { makePersisted } from '@solid-primitives/storage';
+import {
+ SidebarVisibilityContext,
+ isSidebarVisible,
+} from '@app/component/sidebarVisibility';
+export { SidebarVisibilityContext, isSidebarVisible };
const AUTH_URLS = [
`${ROUTER_BASE_CONCAT}login`,
@@ -51,6 +63,23 @@ export const [sidebarState, setSidebarState] = makePersisted(
);
export function Layout(props: RouteSectionProps) {
+ const isAuthenticated = useIsAuthenticated();
+ const location = useLocation();
+ const sidebarVisible = createMemo(
+ () =>
+ !isMobile() &&
+ isAuthenticated() === true &&
+ !AUTH_URLS.includes(location.pathname)
+ );
+
+ return (
+ <SidebarVisibilityContext.Provider value={sidebarVisible}>
+ <LayoutInner {...props} />
+ </SidebarVisibilityContext.Provider>
+ );
+}
+
+function LayoutInner(props: RouteSectionProps) {
const isAuthenticated = useIsAuthenticated();
const { paywallOpen, showPaywall } = usePaywallState();
const location = useLocation();
@@ -136,13 +165,7 @@ export function Layout(props: RouteSectionProps) {
<Paywall />
</Show>
<div class="max-h-full grow-1 flex">
- <Show
- when={
- !isMobile() &&
- isAuthenticated() &&
- !AUTH_URLS.includes(location.pathname)
- }
- >
+ <Show when={isSidebarVisible()}>
<AppSidebar
sidebarState={sidebarState()}
onOpenChange={(open) => {
diff --git a/js/app/packages/app/component/sidebarVisibility.ts b/js/app/packages/app/component/sidebarVisibility.ts
new file mode 100644
index 0000000000..799bc6e23b
--- /dev/null
+++ b/js/app/packages/app/component/sidebarVisibility.ts
@@ -0,0 +1,6 @@
+import { createContext, useContext } from 'solid-js';
+
+export const SidebarVisibilityContext = createContext<() => boolean>(
+ () => false
+);
+export const isSidebarVisible = () => useContext(SidebarVisibilityContext)();
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index 1086c88dbf..e7510199ab 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -44,6 +44,8 @@ import { createHeaderCollapser } from './utils/createHeaderCollapser';
import { registerSplitHotkeys } from './registerSplitHotkeys';
import { isListViewID } from '@app/constants/list-views';
import { isMobile } from '@core/mobile/isMobile';
+import { isSidebarVisible } from '@app/component/sidebarVisibility';
+import { cn } from '@ui/utils/classname';
type SplitLayoutContainerProps = {
pairs: string[];
@@ -308,7 +310,9 @@ export function SplitLayoutContainer(props: SplitLayoutContainerProps) {
return (
<SplitLayoutContext.Provider value={{ manager: splitManager }}>
- <div class="size-full p-2 pl-0 mobile:p-0">
+ <div
+ class={cn('size-full p-2 mobile:p-0', { 'pl-0': isSidebarVisible() })}
+ >
<Resize.Zone
direction="horizontal"
gutter={4}