mirror of
https://github.com/outline/outline.git
synced 2026-11-29 00:29:36 +03:00
* Mobile spacing fixes * Keep mobile selection toolbar sticky above the iOS keyboard The mobile selection toolbar positioned itself with absolute positioning and a bottom calc derived from the document body rect and visual viewport height. On iOS the layout viewport (which fixed/absolute elements anchor to) does not shrink when the software keyboard opens, only the visual viewport does, so the toolbar drifted and lagged relative to the keyboard. Anchor the toolbar with position: fixed; bottom: 0 and introduce useKeyboardStickyOffset, which translates it up by the gap between the layout and visual viewport bottoms. It recomputes on visual viewport resize/scroll and runs a short requestAnimationFrame loop so the toolbar glides with the keyboard's open/close animation, and re-applies after every render so parent re-renders cannot clobber the offset. --------- Co-authored-by: Claude <noreply@anthropic.com>
42 lines
1017 B
TypeScript
42 lines
1017 B
TypeScript
import * as React from "react";
|
|
import styled from "styled-components";
|
|
import breakpoint from "styled-components-breakpoint";
|
|
import { EditorStyleHelper } from "@shared/editor/styles/EditorStyleHelper";
|
|
|
|
type Props = {
|
|
children?: React.ReactNode;
|
|
maxWidth?: string;
|
|
withStickyHeader?: boolean;
|
|
};
|
|
|
|
const Container = styled.div<Props>`
|
|
width: 100%;
|
|
max-width: 100vw;
|
|
padding: ${(props) => (props.withStickyHeader ? "4px 16px" : "60px 16px")};
|
|
|
|
${breakpoint("tablet")`
|
|
padding: ${(props: Props) =>
|
|
props.withStickyHeader ? "4px 44px 60px" : "60px 44px"};
|
|
`};
|
|
`;
|
|
|
|
type ContentProps = { $maxWidth?: string };
|
|
|
|
const Content = styled.div<ContentProps>`
|
|
max-width: ${(props: ContentProps) =>
|
|
props.$maxWidth ?? EditorStyleHelper.documentWidth};
|
|
margin: 0 auto;
|
|
`;
|
|
|
|
const CenteredContent: React.FC<Props> = ({
|
|
children,
|
|
maxWidth,
|
|
...rest
|
|
}: Props) => (
|
|
<Container {...rest}>
|
|
<Content $maxWidth={maxWidth}>{children}</Content>
|
|
</Container>
|
|
);
|
|
|
|
export default CenteredContent;
|