mirror of
https://github.com/outline/outline.git
synced 2026-11-26 07:33:19 +03:00
* React 19 upgrade Bumps react and react-dom to 19.2.8, with the dependency changes React 19 requires: react-is 19, @types/react 19, @types/react-dom 19, react-helmet-async 3 and react-avatar-editor 15 (which now ships its own types). framer-motion moves to 13 — its v6 types reference React.ReactHTML, removed from @types/react 19. The type changes fall into a few classes: - The global JSX namespace is gone, so JSX.Element becomes React.JSX.Element and the custom element declarations move into a module augmentation. - useRef() now requires an initial value. - A ref created with a null initial value is typed nullable, so consumers that accept one are widened to RefObject<T | null>. - React.ReactChild was removed; tooltips take React.ReactNode. - Ref callbacks may only return a cleanup function. react-dnd connectors return the connected node, so useDragRef and useDropRef wrap useDrag and useDrop and hand back a ref callback. react-i18next stays on v12: i18next 23 drops compatibilityJSON "v3", which would rewrite all 64 _plural keys across every locale. outline-icons, oy-vey and react-waypoint have no release that lists React 19 as a peer. All three render correctly under it; the install reports them as unmet peers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Remove react-helmet and forwardRef --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
114 lines
3.1 KiB
TypeScript
114 lines
3.1 KiB
TypeScript
import { AnimatePresence } from "framer-motion";
|
|
import { observer } from "mobx-react";
|
|
import * as React from "react";
|
|
import type { DefaultTheme } from "styled-components";
|
|
import styled from "styled-components";
|
|
import breakpoint from "styled-components-breakpoint";
|
|
import { s } from "@shared/styles";
|
|
import Flex from "~/components/Flex";
|
|
import { LoadingIndicatorBar } from "~/components/LoadingIndicator";
|
|
import { FallbackPageTitle } from "~/components/PageTitle";
|
|
import { useRightSidebarContent } from "~/components/RightSidebarContext";
|
|
import SkipNavContent from "~/components/SkipNavContent";
|
|
import SkipNavLink from "~/components/SkipNavLink";
|
|
import env from "~/env";
|
|
import useStores from "~/hooks/useStores";
|
|
|
|
type Props = {
|
|
/** Main content to render in the layout. */
|
|
children?: React.ReactNode;
|
|
/** Page title to display in the browser tab. Defaults to app name if not provided. */
|
|
title?: string;
|
|
/** Left sidebar content. */
|
|
sidebar?: React.ReactNode;
|
|
/** Whether the sidebar can be collapsed, defaults to true. */
|
|
sidebarCanCollapse?: boolean;
|
|
ref?: React.Ref<HTMLDivElement>;
|
|
};
|
|
|
|
function Layout({
|
|
title,
|
|
children,
|
|
sidebar,
|
|
sidebarCanCollapse = true,
|
|
ref,
|
|
}: Props) {
|
|
const { ui } = useStores();
|
|
const showSidebar = !!sidebar && !ui.sidebarHidden;
|
|
const sidebarCollapsed =
|
|
!showSidebar || (ui.sidebarIsClosed && sidebarCanCollapse);
|
|
const sidebarRight = useRightSidebarContent();
|
|
|
|
return (
|
|
<FallbackPageTitle title={title ? title : env.APP_NAME}>
|
|
<Container column auto ref={ref}>
|
|
<SkipNavLink />
|
|
|
|
{ui.progressBarVisible && <LoadingIndicatorBar />}
|
|
|
|
<Container auto>
|
|
{showSidebar && sidebar}
|
|
|
|
<SkipNavContent />
|
|
<Content
|
|
auto
|
|
justify="center"
|
|
role="main"
|
|
$isResizing={ui.sidebarIsResizing}
|
|
$sidebarCollapsed={sidebarCollapsed}
|
|
$hasSidebar={showSidebar}
|
|
style={
|
|
sidebarCollapsed
|
|
? undefined
|
|
: {
|
|
marginInlineStart: `${ui.sidebarWidth}px`,
|
|
}
|
|
}
|
|
>
|
|
{children}
|
|
</Content>
|
|
|
|
<AnimatePresence initial={false}>{sidebarRight}</AnimatePresence>
|
|
</Container>
|
|
</Container>
|
|
</FallbackPageTitle>
|
|
);
|
|
}
|
|
|
|
const Container = styled(Flex)`
|
|
background: ${s("background")};
|
|
position: relative;
|
|
width: 100%;
|
|
min-height: 100%;
|
|
`;
|
|
|
|
type ContentProps = {
|
|
$isResizing?: boolean;
|
|
$sidebarCollapsed?: boolean;
|
|
$hasSidebar?: boolean;
|
|
theme: DefaultTheme;
|
|
};
|
|
|
|
const Content = styled(Flex)<ContentProps>`
|
|
margin: 0;
|
|
transition: ${(props) =>
|
|
props.$isResizing ? "none" : `margin-inline-start 100ms ease-out`};
|
|
|
|
@media print {
|
|
margin: 0 !important;
|
|
}
|
|
|
|
${breakpoint("mobile", "tablet")`
|
|
margin-inline-start: 0 !important;
|
|
`}
|
|
|
|
${breakpoint("tablet")`
|
|
${(props: ContentProps) =>
|
|
props.$hasSidebar &&
|
|
props.$sidebarCollapsed &&
|
|
`margin-inline-start: ${props.theme.sidebarCollapsedWidth}px;`}
|
|
`};
|
|
`;
|
|
|
|
export default observer(Layout);
|