Mark old components as deprecated (#8747)

* mark a bunch of stuff as deprecated

* mark s as deprecated (serverence reference????)

* rm type import
This commit is contained in:
Samuel Newman
2025-07-30 21:05:45 +03:00
committed by GitHub
parent fade51e9eb
commit 25e60548c4
12 changed files with 124 additions and 34 deletions
+7 -3
View File
@@ -1,7 +1,8 @@
import React, {createContext, ReactNode, useContext} from 'react' import {type ReactNode} from 'react'
import {TextStyle, ViewStyle} from 'react-native' import {createContext, useContext} from 'react'
import {type TextStyle, type ViewStyle} from 'react-native'
import {ThemeName} from '#/alf/types' import {type ThemeName} from '#/alf/types'
import {darkTheme, defaultTheme, dimTheme} from './themes' import {darkTheme, defaultTheme, dimTheme} from './themes'
export type ColorScheme = 'light' | 'dark' export type ColorScheme = 'light' | 'dark'
@@ -29,6 +30,9 @@ export type Palette = Record<PaletteColorName, PaletteColor>
export type ShapeName = 'button' | 'bigButton' | 'smallButton' export type ShapeName = 'button' | 'bigButton' | 'smallButton'
export type Shapes = Record<ShapeName, ViewStyle> export type Shapes = Record<ShapeName, ViewStyle>
/**
* @deprecated use typography atoms from `#/alf`
*/
export type TypographyVariant = export type TypographyVariant =
| '2xl-thin' | '2xl-thin'
| '2xl' | '2xl'
+10 -2
View File
@@ -1,7 +1,11 @@
import {useMemo} from 'react' import {useMemo} from 'react'
import {TextStyle, ViewStyle} from 'react-native' import {type TextStyle, type ViewStyle} from 'react-native'
import {PaletteColor, PaletteColorName, useTheme} from '../ThemeContext' import {
type PaletteColor,
type PaletteColorName,
useTheme,
} from '../ThemeContext'
export interface UsePaletteValue { export interface UsePaletteValue {
colors: PaletteColor colors: PaletteColor
@@ -16,6 +20,10 @@ export interface UsePaletteValue {
link: TextStyle link: TextStyle
icon: TextStyle icon: TextStyle
} }
/**
* @deprecated use `useTheme` from `#/alf`
*/
export function usePalette(color: PaletteColorName): UsePaletteValue { export function usePalette(color: PaletteColorName): UsePaletteValue {
const theme = useTheme() const theme = useTheme()
return useMemo(() => { return useMemo(() => {
+13 -2
View File
@@ -1,9 +1,17 @@
import {Dimensions, StyleProp, StyleSheet, TextStyle} from 'react-native' import {
Dimensions,
type StyleProp,
StyleSheet,
type TextStyle,
} from 'react-native'
import {isWeb} from '#/platform/detection' import {isWeb} from '#/platform/detection'
import {Theme, TypographyVariant} from './ThemeContext' import {type Theme, type TypographyVariant} from './ThemeContext'
// 1 is lightest, 2 is light, 3 is mid, 4 is dark, 5 is darkest // 1 is lightest, 2 is light, 3 is mid, 4 is dark, 5 is darkest
/**
* @deprecated use ALF colors instead
*/
export const colors = { export const colors = {
white: '#ffffff', white: '#ffffff',
black: '#000000', black: '#000000',
@@ -63,6 +71,9 @@ export const gradients = {
blueDark: {start: '#5F45E0', end: colors.blue3}, // avis, banner blueDark: {start: '#5F45E0', end: colors.blue3}, // avis, banner
} }
/**
* @deprecated use atoms from `#/alf`
*/
export const s = StyleSheet.create({ export const s = StyleSheet.create({
// helpers // helpers
footerSpacer: {height: 100}, footerSpacer: {height: 100},
+9
View File
@@ -43,6 +43,9 @@ export interface ChangePasswordModal {
name: 'change-password' name: 'change-password'
} }
/**
* @deprecated DO NOT ADD NEW MODALS
*/
export type Modal = export type Modal =
// Account // Account
| DeleteAccountModal | DeleteAccountModal
@@ -125,10 +128,16 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
) )
} }
/**
* @deprecated use the dialog system from `#/components/Dialog.tsx`
*/
export function useModals() { export function useModals() {
return React.useContext(ModalContext) return React.useContext(ModalContext)
} }
/**
* @deprecated use the dialog system from `#/components/Dialog.tsx`
*/
export function useModalControls() { export function useModalControls() {
return React.useContext(ModalControlContext) return React.useContext(ModalControlContext)
} }
+9
View File
@@ -56,6 +56,9 @@ interface Props extends React.ComponentProps<typeof TouchableOpacity> {
onBeforePress?: () => void onBeforePress?: () => void
} }
/**
* @deprecated use Link from `#/components/Link.tsx` instead
*/
export const Link = memo(function Link({ export const Link = memo(function Link({
testID, testID,
style, style,
@@ -156,6 +159,9 @@ export const Link = memo(function Link({
) )
}) })
/**
* @deprecated use InlineLinkText from `#/components/Link.tsx` instead
*/
export const TextLink = memo(function TextLink({ export const TextLink = memo(function TextLink({
testID, testID,
type = 'md', type = 'md',
@@ -301,6 +307,9 @@ interface TextLinkOnWebOnlyProps extends TextProps {
onPointerEnter?: () => void onPointerEnter?: () => void
anchorNoUnderline?: boolean anchorNoUnderline?: boolean
} }
/**
* @deprecated use WebOnlyInlineLinkText from `#/components/Link.tsx` instead
*/
export const TextLinkOnWebOnly = memo(function DesktopWebTextLink({ export const TextLinkOnWebOnly = memo(function DesktopWebTextLink({
testID, testID,
type = 'md', type = 'md',
+1 -1
View File
@@ -3,7 +3,7 @@ import {Header} from '#/components/Layout'
/** /**
* Legacy ViewHeader component. Use Layout.Header going forward. * Legacy ViewHeader component. Use Layout.Header going forward.
* *
* @deprecated * @deprecated use `Layout.Header` from `#/components/Layout.tsx`
*/ */
export function ViewHeader({ export function ViewHeader({
title, title,
+10 -8
View File
@@ -1,16 +1,16 @@
import React from 'react' import React from 'react'
import { import {
ActivityIndicator, ActivityIndicator,
GestureResponderEvent, type GestureResponderEvent,
NativeSyntheticEvent, type NativeSyntheticEvent,
NativeTouchEvent, type NativeTouchEvent,
Pressable, Pressable,
PressableStateCallbackType, type PressableStateCallbackType,
StyleProp, type StyleProp,
StyleSheet, StyleSheet,
TextStyle, type TextStyle,
View, View,
ViewStyle, type ViewStyle,
} from 'react-native' } from 'react-native'
import {choose} from '#/lib/functions' import {choose} from '#/lib/functions'
@@ -37,7 +37,9 @@ declare module 'react-native' {
} }
} }
// TODO: Enforce that button always has a label /**
* @deprecated use Button from `#/components/Button.tsx` instead
*/
export function Button({ export function Button({
type = 'primary', type = 'primary',
label, label,
+12 -7
View File
@@ -1,22 +1,24 @@
import React, {PropsWithChildren, useMemo, useRef} from 'react' import {type PropsWithChildren} from 'react'
import {useMemo, useRef} from 'react'
import { import {
Dimensions, Dimensions,
GestureResponderEvent, type GestureResponderEvent,
Insets, type Insets,
StyleProp, type StyleProp,
StyleSheet, StyleSheet,
TouchableOpacity, TouchableOpacity,
TouchableWithoutFeedback, TouchableWithoutFeedback,
useWindowDimensions, useWindowDimensions,
View, View,
ViewStyle, type ViewStyle,
} from 'react-native' } from 'react-native'
import Animated, {FadeIn, FadeInDown, FadeInUp} from 'react-native-reanimated' import Animated, {FadeIn, FadeInDown, FadeInUp} from 'react-native-reanimated'
import RootSiblings from 'react-native-root-siblings' import RootSiblings from 'react-native-root-siblings'
import {IconProp} from '@fortawesome/fontawesome-svg-core' import {type IconProp} from '@fortawesome/fontawesome-svg-core'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {msg} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import type React from 'react'
import {HITSLOP_10} from '#/lib/constants' import {HITSLOP_10} from '#/lib/constants'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
@@ -26,7 +28,7 @@ import {isWeb} from '#/platform/detection'
import {native} from '#/alf' import {native} from '#/alf'
import {FullWindowOverlay} from '#/components/FullWindowOverlay' import {FullWindowOverlay} from '#/components/FullWindowOverlay'
import {Text} from '../text/Text' import {Text} from '../text/Text'
import {Button, ButtonType} from './Button' import {Button, type ButtonType} from './Button'
const ESTIMATED_BTN_HEIGHT = 50 const ESTIMATED_BTN_HEIGHT = 50
const ESTIMATED_SEP_HEIGHT = 16 const ESTIMATED_SEP_HEIGHT = 16
@@ -70,6 +72,9 @@ interface DropdownButtonProps {
accessibilityHint?: string accessibilityHint?: string
} }
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export function DropdownButton({ export function DropdownButton({
testID, testID,
type = 'bare', type = 'bare',
+34 -4
View File
@@ -1,9 +1,15 @@
import React from 'react' import React from 'react'
import {Platform, Pressable, StyleSheet, View, ViewStyle} from 'react-native' import {
import {IconProp} from '@fortawesome/fontawesome-svg-core' Platform,
Pressable,
StyleSheet,
View,
type ViewStyle,
} from 'react-native'
import {type IconProp} from '@fortawesome/fontawesome-svg-core'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import * as DropdownMenu from 'zeego/dropdown-menu' import * as DropdownMenu from 'zeego/dropdown-menu'
import {MenuItemCommonProps} from 'zeego/lib/typescript/menu' import {type MenuItemCommonProps} from 'zeego/lib/typescript/menu'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
import {useTheme} from '#/lib/ThemeContext' import {useTheme} from '#/lib/ThemeContext'
@@ -12,8 +18,14 @@ import {Portal} from '#/components/Portal'
// Custom Dropdown Menu Components // Custom Dropdown Menu Components
// == // ==
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export const DropdownMenuRoot = DropdownMenu.Root export const DropdownMenuRoot = DropdownMenu.Root
// export const DropdownMenuTrigger = DropdownMenu.Trigger // export const DropdownMenuTrigger = DropdownMenu.Trigger
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export const DropdownMenuContent = DropdownMenu.Content export const DropdownMenuContent = DropdownMenu.Content
type TriggerProps = Omit< type TriggerProps = Omit<
@@ -25,6 +37,9 @@ type TriggerProps = Omit<
accessibilityLabel?: string accessibilityLabel?: string
accessibilityHint?: string accessibilityHint?: string
}> }>
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export const DropdownMenuTrigger = DropdownMenu.create( export const DropdownMenuTrigger = DropdownMenu.create(
(props: TriggerProps) => { (props: TriggerProps) => {
const theme = useTheme() const theme = useTheme()
@@ -59,6 +74,9 @@ export const DropdownMenuTrigger = DropdownMenu.create(
) )
type ItemProps = React.ComponentProps<(typeof DropdownMenu)['Item']> type ItemProps = React.ComponentProps<(typeof DropdownMenu)['Item']>
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export const DropdownMenuItem = DropdownMenu.create( export const DropdownMenuItem = DropdownMenu.create(
(props: ItemProps & {testID?: string}) => { (props: ItemProps & {testID?: string}) => {
const theme = useTheme() const theme = useTheme()
@@ -84,6 +102,9 @@ export const DropdownMenuItem = DropdownMenu.create(
) )
type TitleProps = React.ComponentProps<(typeof DropdownMenu)['ItemTitle']> type TitleProps = React.ComponentProps<(typeof DropdownMenu)['ItemTitle']>
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export const DropdownMenuItemTitle = DropdownMenu.create( export const DropdownMenuItemTitle = DropdownMenu.create(
(props: TitleProps) => { (props: TitleProps) => {
const pal = usePalette('default') const pal = usePalette('default')
@@ -98,11 +119,17 @@ export const DropdownMenuItemTitle = DropdownMenu.create(
) )
type IconProps = React.ComponentProps<(typeof DropdownMenu)['ItemIcon']> type IconProps = React.ComponentProps<(typeof DropdownMenu)['ItemIcon']>
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export const DropdownMenuItemIcon = DropdownMenu.create((props: IconProps) => { export const DropdownMenuItemIcon = DropdownMenu.create((props: IconProps) => {
return <DropdownMenu.ItemIcon {...props} /> return <DropdownMenu.ItemIcon {...props} />
}, 'ItemIcon') }, 'ItemIcon')
type SeparatorProps = React.ComponentProps<(typeof DropdownMenu)['Separator']> type SeparatorProps = React.ComponentProps<(typeof DropdownMenu)['Separator']>
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export const DropdownMenuSeparator = DropdownMenu.create( export const DropdownMenuSeparator = DropdownMenu.create(
(props: SeparatorProps) => { (props: SeparatorProps) => {
const pal = usePalette('default') const pal = usePalette('default')
@@ -142,11 +169,14 @@ type Props = {
triggerStyle?: ViewStyle triggerStyle?: ViewStyle
} }
/* The `NativeDropdown` function uses native iOS and Android dropdown menus. /**
* The `NativeDropdown` function uses native iOS and Android dropdown menus.
* It also creates a animated custom dropdown for web that uses * It also creates a animated custom dropdown for web that uses
* Radix UI primitives under the hood * Radix UI primitives under the hood
* @prop {DropdownItem[]} items - An array of dropdown items * @prop {DropdownItem[]} items - An array of dropdown items
* @prop {React.ReactNode} children - A custom dropdown trigger * @prop {React.ReactNode} children - A custom dropdown trigger
*
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/ */
export function NativeDropdown({ export function NativeDropdown({
items, items,
@@ -63,6 +63,9 @@ type Props = {
triggerStyle?: ViewStyle triggerStyle?: ViewStyle
} }
/**
* @deprecated use Menu from `#/components/Menu.tsx` instead
*/
export function NativeDropdown({ export function NativeDropdown({
items, items,
children, children,
+12 -3
View File
@@ -1,12 +1,21 @@
import {StyleProp, StyleSheet, TextStyle, View, ViewStyle} from 'react-native' import {
type StyleProp,
StyleSheet,
type TextStyle,
View,
type ViewStyle,
} from 'react-native'
import {choose} from '#/lib/functions' import {choose} from '#/lib/functions'
import {colors} from '#/lib/styles' import {colors} from '#/lib/styles'
import {useTheme} from '#/lib/ThemeContext' import {useTheme} from '#/lib/ThemeContext'
import {TypographyVariant} from '#/lib/ThemeContext' import {type TypographyVariant} from '#/lib/ThemeContext'
import {Text} from '../text/Text' import {Text} from '../text/Text'
import {Button, ButtonType} from './Button' import {Button, type ButtonType} from './Button'
/**
* @deprecated use Toggle from `#/components/form/Toggle.tsx` instead
*/
export function ToggleButton({ export function ToggleButton({
testID, testID,
type = 'default-light', type = 'default-light',
+4 -4
View File
@@ -1,16 +1,16 @@
import React from 'react' import React from 'react'
import {StyleSheet, TextProps} from 'react-native' import {StyleSheet, type TextProps} from 'react-native'
import {UITextView} from 'react-native-uitextview' import {UITextView} from 'react-native-uitextview'
import {lh, s} from '#/lib/styles' import {lh, s} from '#/lib/styles'
import {TypographyVariant, useTheme} from '#/lib/ThemeContext' import {type TypographyVariant, useTheme} from '#/lib/ThemeContext'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isIOS, isWeb} from '#/platform/detection' import {isIOS, isWeb} from '#/platform/detection'
import {applyFonts, useAlf} from '#/alf' import {applyFonts, useAlf} from '#/alf'
import { import {
childHasEmoji, childHasEmoji,
renderChildrenWithEmoji, renderChildrenWithEmoji,
StringChild, type StringChild,
} from '#/alf/typography' } from '#/alf/typography'
export type CustomTextProps = Omit<TextProps, 'children'> & { export type CustomTextProps = Omit<TextProps, 'children'> & {
@@ -32,7 +32,7 @@ export type CustomTextProps = Omit<TextProps, 'children'> & {
export {Text_DEPRECATED as Text} export {Text_DEPRECATED as Text}
/** /**
* @deprecated use Text from Typography instead. * @deprecated use Text from `#/components/Typography.tsx` instead
*/ */
function Text_DEPRECATED({ function Text_DEPRECATED({
type = 'md', type = 'md',