Cleanup unused props from dialogs (#5665)

This commit is contained in:
Hailey
2024-10-09 14:50:54 -07:00
committed by GitHub
parent 86b0d3b498
commit 9f070cd9cd
7 changed files with 15 additions and 35 deletions
+11 -11
View File
@@ -153,18 +153,18 @@ export function Outer({
) )
return ( return (
<Context.Provider value={context}> <BottomSheet
<BottomSheet ref={ref}
ref={ref} cornerRadius={20}
cornerRadius={20} backgroundColor={t.atoms.bg.backgroundColor}
backgroundColor={t.atoms.bg.backgroundColor} {...nativeOptions}
{...nativeOptions} onSnapPointChange={onSnapPointChange}
onSnapPointChange={onSnapPointChange} onStateChange={onStateChange}
onStateChange={onStateChange} disableDrag={disableDrag}>
disableDrag={disableDrag}> <Context.Provider value={context}>
<View testID={testID}>{children}</View> <View testID={testID}>{children}</View>
</BottomSheet> </Context.Provider>
</Context.Provider> </BottomSheet>
) )
} }
-2
View File
@@ -6,7 +6,6 @@ import type {
} from 'react-native' } from 'react-native'
import {ViewStyleProp} from '#/alf' import {ViewStyleProp} from '#/alf'
import {PortalComponent} from '#/components/Portal'
import {BottomSheetViewProps} from '../../../modules/bottom-sheet' import {BottomSheetViewProps} from '../../../modules/bottom-sheet'
import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types' import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types'
@@ -61,7 +60,6 @@ export type DialogOuterProps = {
nativeOptions?: Omit<BottomSheetViewProps, 'children'> nativeOptions?: Omit<BottomSheetViewProps, 'children'>
webOptions?: {} webOptions?: {}
testID?: string testID?: string
Portal?: PortalComponent
} }
type DialogInnerPropsBase<T> = React.PropsWithChildren<ViewStyleProp> & T type DialogInnerPropsBase<T> = React.PropsWithChildren<ViewStyleProp> & T
+1 -5
View File
@@ -18,7 +18,6 @@ import {
ItemTextProps, ItemTextProps,
TriggerProps, TriggerProps,
} from '#/components/Menu/types' } from '#/components/Menu/types'
import {PortalComponent} from '#/components/Portal'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
export { export {
@@ -78,11 +77,9 @@ export function Trigger({children, label}: TriggerProps) {
export function Outer({ export function Outer({
children, children,
showCancel, showCancel,
Portal,
}: React.PropsWithChildren<{ }: React.PropsWithChildren<{
showCancel?: boolean showCancel?: boolean
style?: StyleProp<ViewStyle> style?: StyleProp<ViewStyle>
Portal?: PortalComponent
}>) { }>) {
const context = React.useContext(Context) const context = React.useContext(Context)
const {_} = useLingui() const {_} = useLingui()
@@ -90,8 +87,7 @@ export function Outer({
return ( return (
<Dialog.Outer <Dialog.Outer
control={context.control} control={context.control}
nativeOptions={{preventExpansion: true}} nativeOptions={{preventExpansion: true}}>
Portal={Portal}>
<Dialog.Handle /> <Dialog.Handle />
{/* Re-wrap with context since Dialogs are portal-ed to root */} {/* Re-wrap with context since Dialogs are portal-ed to root */}
<Context.Provider value={context}> <Context.Provider value={context}>
-2
View File
@@ -12,8 +12,6 @@ type ComponentMap = {
[id: string]: Component [id: string]: Component
} }
export type PortalComponent = ({children}: {children?: React.ReactNode}) => null
export function createPortalGroup() { export function createPortalGroup() {
const Context = React.createContext<ContextType>({ const Context = React.createContext<ContextType>({
outlet: null, outlet: null,
+1 -7
View File
@@ -6,7 +6,6 @@ import {useLingui} from '@lingui/react'
import {atoms as a, useBreakpoints, useTheme} from '#/alf' import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {Button, ButtonColor, ButtonText} from '#/components/Button' import {Button, ButtonColor, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog' import * as Dialog from '#/components/Dialog'
import {PortalComponent} from '#/components/Portal'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {BottomSheetViewProps} from '../../modules/bottom-sheet' import {BottomSheetViewProps} from '../../modules/bottom-sheet'
@@ -27,12 +26,10 @@ export function Outer({
children, children,
control, control,
testID, testID,
Portal,
nativeOptions, nativeOptions,
}: React.PropsWithChildren<{ }: React.PropsWithChildren<{
control: Dialog.DialogControlProps control: Dialog.DialogControlProps
testID?: string testID?: string
Portal?: PortalComponent
nativeOptions?: Omit<BottomSheetViewProps, 'children'> nativeOptions?: Omit<BottomSheetViewProps, 'children'>
}>) { }>) {
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
@@ -48,7 +45,6 @@ export function Outer({
<Dialog.Outer <Dialog.Outer
control={control} control={control}
testID={testID} testID={testID}
Portal={Portal}
nativeOptions={{preventExpansion: true, ...nativeOptions}}> nativeOptions={{preventExpansion: true, ...nativeOptions}}>
<Dialog.Handle /> <Dialog.Handle />
<Context.Provider value={context}> <Context.Provider value={context}>
@@ -190,7 +186,6 @@ export function Basic({
onConfirm, onConfirm,
confirmButtonColor, confirmButtonColor,
showCancel = true, showCancel = true,
Portal,
}: React.PropsWithChildren<{ }: React.PropsWithChildren<{
control: Dialog.DialogOuterProps['control'] control: Dialog.DialogOuterProps['control']
title: string title: string
@@ -207,10 +202,9 @@ export function Basic({
onConfirm: (e: GestureResponderEvent) => void onConfirm: (e: GestureResponderEvent) => void
confirmButtonColor?: ButtonColor confirmButtonColor?: ButtonColor
showCancel?: boolean showCancel?: boolean
Portal?: PortalComponent
}>) { }>) {
return ( return (
<Outer control={control} testID="confirmModal" Portal={Portal}> <Outer control={control} testID="confirmModal">
<TitleText>{title}</TitleText> <TitleText>{title}</TitleText>
<DescriptionText>{description}</DescriptionText> <DescriptionText>{description}</DescriptionText>
<Actions> <Actions>
+1 -4
View File
@@ -30,7 +30,6 @@ import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash'
import {Link} from '#/components/Link' import {Link} from '#/components/Link'
import {MediaInsetBorder} from '#/components/MediaInsetBorder' import {MediaInsetBorder} from '#/components/MediaInsetBorder'
import * as Menu from '#/components/Menu' import * as Menu from '#/components/Menu'
import {PortalComponent} from '#/components/Portal'
import {ProfileHoverCard} from '#/components/ProfileHoverCard' import {ProfileHoverCard} from '#/components/ProfileHoverCard'
import {openCamera, openCropper, openPicker} from '../../../lib/media/picker' import {openCamera, openCropper, openPicker} from '../../../lib/media/picker'
@@ -51,7 +50,6 @@ interface UserAvatarProps extends BaseUserAvatarProps {
interface EditableUserAvatarProps extends BaseUserAvatarProps { interface EditableUserAvatarProps extends BaseUserAvatarProps {
onSelectNewAvatar: (img: RNImage | null) => void onSelectNewAvatar: (img: RNImage | null) => void
Portal?: PortalComponent
} }
interface PreviewableUserAvatarProps extends BaseUserAvatarProps { interface PreviewableUserAvatarProps extends BaseUserAvatarProps {
@@ -268,7 +266,6 @@ let EditableUserAvatar = ({
size, size,
avatar, avatar,
onSelectNewAvatar, onSelectNewAvatar,
Portal,
}: EditableUserAvatarProps): React.ReactNode => { }: EditableUserAvatarProps): React.ReactNode => {
const t = useTheme() const t = useTheme()
const pal = usePalette('default') const pal = usePalette('default')
@@ -366,7 +363,7 @@ let EditableUserAvatar = ({
</Pressable> </Pressable>
)} )}
</Menu.Trigger> </Menu.Trigger>
<Menu.Outer showCancel Portal={Portal}> <Menu.Outer showCancel>
<Menu.Group> <Menu.Group>
{isNative && ( {isNative && (
<Menu.Item <Menu.Item
+1 -4
View File
@@ -25,7 +25,6 @@ import {
import {StreamingLive_Stroke2_Corner0_Rounded as Library} from '#/components/icons/StreamingLive' import {StreamingLive_Stroke2_Corner0_Rounded as Library} from '#/components/icons/StreamingLive'
import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash' import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash'
import * as Menu from '#/components/Menu' import * as Menu from '#/components/Menu'
import {PortalComponent} from '#/components/Portal'
import {openCamera, openCropper, openPicker} from '../../../lib/media/picker' import {openCamera, openCropper, openPicker} from '../../../lib/media/picker'
export function UserBanner({ export function UserBanner({
@@ -33,13 +32,11 @@ export function UserBanner({
banner, banner,
moderation, moderation,
onSelectNewBanner, onSelectNewBanner,
Portal,
}: { }: {
type?: 'labeler' | 'default' type?: 'labeler' | 'default'
banner?: string | null banner?: string | null
moderation?: ModerationUI moderation?: ModerationUI
onSelectNewBanner?: (img: RNImage | null) => void onSelectNewBanner?: (img: RNImage | null) => void
Portal?: PortalComponent
}) { }) {
const pal = usePalette('default') const pal = usePalette('default')
const theme = useTheme() const theme = useTheme()
@@ -118,7 +115,7 @@ export function UserBanner({
</Pressable> </Pressable>
)} )}
</Menu.Trigger> </Menu.Trigger>
<Menu.Outer showCancel Portal={Portal}> <Menu.Outer showCancel>
<Menu.Group> <Menu.Group>
{isNative && ( {isNative && (
<Menu.Item <Menu.Item