diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/Dialog/context.ts | 1 | ||||
-rw-r--r-- | src/components/Dialog/index.tsx | 1 | ||||
-rw-r--r-- | src/components/Dialog/index.web.tsx | 1 | ||||
-rw-r--r-- | src/components/Dialog/types.ts | 2 | ||||
-rw-r--r-- | src/components/Layout/Header/index.tsx | 10 | ||||
-rw-r--r-- | src/components/Layout/index.tsx | 43 |
6 files changed, 49 insertions, 9 deletions
diff --git a/src/components/Dialog/context.ts b/src/components/Dialog/context.ts index b479bc7f0..331ff3f33 100644 --- a/src/components/Dialog/context.ts +++ b/src/components/Dialog/context.ts @@ -14,6 +14,7 @@ export const Context = React.createContext<DialogContextProps>({ nativeSnapPoint: BottomSheetSnapPoint.Hidden, disableDrag: false, setDisableDrag: () => {}, + isWithinDialog: false, }) export function useDialogContext() { diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index e70e4aef4..463cadf3c 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -154,6 +154,7 @@ export function Outer({ nativeSnapPoint: snapPoint, disableDrag, setDisableDrag, + isWithinDialog: true, }), [close, snapPoint, disableDrag, setDisableDrag], ) diff --git a/src/components/Dialog/index.web.tsx b/src/components/Dialog/index.web.tsx index a27222229..153954691 100644 --- a/src/components/Dialog/index.web.tsx +++ b/src/components/Dialog/index.web.tsx @@ -97,6 +97,7 @@ export function Outer({ nativeSnapPoint: 0, disableDrag: false, setDisableDrag: () => {}, + isWithinDialog: true, }), [close], ) diff --git a/src/components/Dialog/types.ts b/src/components/Dialog/types.ts index b87bfe2b7..32886f3ce 100644 --- a/src/components/Dialog/types.ts +++ b/src/components/Dialog/types.ts @@ -44,6 +44,8 @@ export type DialogContextProps = { nativeSnapPoint: BottomSheetSnapPoint disableDrag: boolean setDisableDrag: React.Dispatch<React.SetStateAction<boolean>> + // in the event that the hook is used outside of a dialog + isWithinDialog: boolean } export type DialogControlOpenOptions = { diff --git a/src/components/Layout/Header/index.tsx b/src/components/Layout/Header/index.tsx index 3af0215c5..8ef114b44 100644 --- a/src/components/Layout/Header/index.tsx +++ b/src/components/Layout/Header/index.tsx @@ -14,6 +14,7 @@ import { TextStyleProp, useBreakpoints, useGutters, + useLayoutBreakpoints, useTheme, web, } from '#/alf' @@ -23,6 +24,7 @@ import {Menu_Stroke2_Corner0_Rounded as Menu} from '#/components/icons/Menu' import { BUTTON_VISUAL_ALIGNMENT_OFFSET, HEADER_SLOT_SIZE, + SCROLLBAR_OFFSET, } from '#/components/Layout/const' import {ScrollbarOffsetContext} from '#/components/Layout/context' import {Text} from '#/components/Typography' @@ -42,6 +44,7 @@ export function Outer({ const gutters = useGutters([0, 'base']) const {gtMobile} = useBreakpoints() const {isWithinOffsetView} = useContext(ScrollbarOffsetContext) + const {centerColumnOffset} = useLayoutBreakpoints() return ( <View @@ -60,7 +63,12 @@ export function Outer({ }), t.atoms.border_contrast_low, gtMobile && [a.mx_auto, {maxWidth: 600}], - !isWithinOffsetView && a.scrollbar_offset, + !isWithinOffsetView && { + transform: [ + {translateX: centerColumnOffset ? -150 : 0}, + {translateX: web(SCROLLBAR_OFFSET) ?? 0}, + ], + }, ]}> {children} </View> diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 489ebb225..623478a6a 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -13,7 +13,15 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context' import {isWeb} from '#/platform/detection' import {useShellLayout} from '#/state/shell/shell-layout' -import {atoms as a, useBreakpoints, useTheme, web} from '#/alf' +import { + atoms as a, + useBreakpoints, + useLayoutBreakpoints, + useTheme, + web, +} from '#/alf' +import {useDialogContext} from '#/components/Dialog' +import {SCROLLBAR_OFFSET} from '#/components/Layout/const' import {ScrollbarOffsetContext} from '#/components/Layout/context' export * from '#/components/Layout/const' @@ -47,6 +55,7 @@ export const Screen = React.memo(function Screen({ export type ContentProps = AnimatedScrollViewProps & { style?: StyleProp<ViewStyle> contentContainerStyle?: StyleProp<ViewStyle> + ignoreTabletLayoutOffset?: boolean } /** @@ -56,6 +65,7 @@ export const Content = React.memo(function Content({ children, style, contentContainerStyle, + ignoreTabletLayoutOffset, ...props }: ContentProps) { const t = useTheme() @@ -84,8 +94,10 @@ export const Content = React.memo(function Content({ ]} {...props}> {isWeb ? ( - // @ts-ignore web only -esb - <Center>{children}</Center> + <Center ignoreTabletLayoutOffset={ignoreTabletLayoutOffset}> + {/* @ts-expect-error web only -esb */} + {children} + </Center> ) : ( children )} @@ -138,10 +150,13 @@ export const KeyboardAwareContent = React.memo(function LayoutScrollView({ export const Center = React.memo(function LayoutContent({ children, style, + ignoreTabletLayoutOffset, ...props -}: ViewProps) { +}: ViewProps & {ignoreTabletLayoutOffset?: boolean}) { const {isWithinOffsetView} = useContext(ScrollbarOffsetContext) const {gtMobile} = useBreakpoints() + const {centerColumnOffset} = useLayoutBreakpoints() + const {isWithinDialog} = useDialogContext() const ctx = useMemo(() => ({isWithinOffsetView: true}), []) return ( <View @@ -151,8 +166,20 @@ export const Center = React.memo(function LayoutContent({ gtMobile && { maxWidth: 600, }, + !isWithinOffsetView && { + transform: [ + { + translateX: + centerColumnOffset && + !ignoreTabletLayoutOffset && + !isWithinDialog + ? -150 + : 0, + }, + {translateX: web(SCROLLBAR_OFFSET) ?? 0}, + ], + }, style, - !isWithinOffsetView && a.scrollbar_offset, ]} {...props}> <ScrollbarOffsetContext.Provider value={ctx}> @@ -168,6 +195,7 @@ export const Center = React.memo(function LayoutContent({ const WebCenterBorders = React.memo(function LayoutContent() { const t = useTheme() const {gtMobile} = useBreakpoints() + const {centerColumnOffset} = useLayoutBreakpoints() return gtMobile ? ( <View style={[ @@ -180,9 +208,8 @@ const WebCenterBorders = React.memo(function LayoutContent() { width: 602, left: '50%', transform: [ - { - translateX: '-50%', - }, + {translateX: '-50%'}, + {translateX: centerColumnOffset ? -150 : 0}, ...a.scrollbar_offset.transform, ], }), |