diff --git a/docs/src/components/BannerExample.tsx b/docs/src/components/BannerExample.tsx index 7f4acdc7bc..59ec60634a 100644 --- a/docs/src/components/BannerExample.tsx +++ b/docs/src/components/BannerExample.tsx @@ -9,8 +9,8 @@ import { Avatar, Button, FAB, - MD3DarkTheme as DarkTheme, - MD3LightTheme as DefaultTheme, + DarkTheme, + LightTheme, ProgressBar, PaperProvider, RadioButton, @@ -167,7 +167,7 @@ const Shimmer = () => { const ThemedBannerExample = () => { const isDarkTheme = useColorMode().colorMode === 'dark'; return ( - + ); diff --git a/docs/src/components/GetStartedButtons.tsx b/docs/src/components/GetStartedButtons.tsx index 4debe5b5ac..fd00420b46 100644 --- a/docs/src/components/GetStartedButtons.tsx +++ b/docs/src/components/GetStartedButtons.tsx @@ -9,8 +9,8 @@ import Link from '@docusaurus/Link'; import { useColorMode } from '@docusaurus/theme-common'; import { Button, - MD3DarkTheme as DarkTheme, - MD3LightTheme as DefaultTheme, + DarkTheme, + LightTheme, PaperProvider, } from 'react-native-paper'; @@ -95,7 +95,7 @@ const Shimmer = () => { const ThemedGetStarted = () => { const isDarkTheme = useColorMode().colorMode === 'dark'; return ( - + ); diff --git a/example/src/DrawerItems.tsx b/example/src/DrawerItems.tsx index 44d5163cbf..d4571d0f0b 100644 --- a/example/src/DrawerItems.tsx +++ b/example/src/DrawerItems.tsx @@ -9,7 +9,7 @@ import { Button, Dialog, Drawer, - MD3Colors, + Colors, Switch, Text, TouchableRipple, @@ -136,8 +136,8 @@ function DrawerItems() { const coloredLabelTheme = { colors: { - secondaryContainer: MD3Colors.tertiary80, - onSecondaryContainer: MD3Colors.tertiary20, + secondaryContainer: Colors.tertiary80, + onSecondaryContainer: Colors.tertiary20, }, }; @@ -184,7 +184,7 @@ function DrawerItems() { {deviceColorsSupported ? ( - Use device colors * + Use device colors @@ -213,7 +213,7 @@ function DrawerItems() { - Collapsed drawer * + Collapsed drawer @@ -222,7 +222,7 @@ function DrawerItems() { - Custom font * + Custom font @@ -232,7 +232,7 @@ function DrawerItems() { - {isIOS ? 'Highlight' : 'Ripple'} effect * + {isIOS ? 'Highlight' : 'Ripple'} effect @@ -240,11 +240,6 @@ function DrawerItems() { - {!collapsed && ( - - * - available only for MD3 - - )} React Native Paper Version{' '} {require('react-native-paper/package.json').version} diff --git a/example/src/Examples/ActivityIndicatorExample.tsx b/example/src/Examples/ActivityIndicatorExample.tsx index 15686054fa..9c0fa5f0c4 100644 --- a/example/src/Examples/ActivityIndicatorExample.tsx +++ b/example/src/Examples/ActivityIndicatorExample.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { StyleSheet, View } from 'react-native'; -import { ActivityIndicator, FAB, List, MD3Colors } from 'react-native-paper'; +import { ActivityIndicator, FAB, List, Colors } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; @@ -41,7 +41,7 @@ const ActivityIndicatorExample = () => { diff --git a/example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx b/example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx index 4712da7349..b92ecc3a2f 100644 --- a/example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx +++ b/example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx @@ -3,7 +3,7 @@ import type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native'; import { Animated, FlatList, Platform, StyleSheet, View } from 'react-native'; import Icon from '@expo/vector-icons/MaterialCommunityIcons'; -import { Avatar, MD3Colors, Text, useTheme } from 'react-native-paper'; +import { Avatar, Colors, Text, useTheme } from 'react-native-paper'; import CustomFAB from './CustomFAB'; import CustomFABControls, { @@ -44,7 +44,7 @@ const AnimatedFABExample = () => { @@ -86,9 +86,7 @@ const AnimatedFABExample = () => { setVisible(!visible)} style={styles.icon} diff --git a/example/src/Examples/AvatarExample.tsx b/example/src/Examples/AvatarExample.tsx index 229c2f4a0b..e98ff023dd 100644 --- a/example/src/Examples/AvatarExample.tsx +++ b/example/src/Examples/AvatarExample.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { StyleSheet, View } from 'react-native'; -import { Avatar, List, MD3Colors } from 'react-native-paper'; +import { Avatar, List, Colors } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; @@ -14,11 +14,11 @@ const AvatarExample = () => { style={[ styles.avatar, { - backgroundColor: MD3Colors.error70, + backgroundColor: Colors.error70, }, ]} label="XD" - color={MD3Colors.primary0} + color={Colors.primary0} /> @@ -30,11 +30,11 @@ const AvatarExample = () => { style={[ styles.avatar, { - backgroundColor: MD3Colors.error70, + backgroundColor: Colors.error70, }, ]} icon="folder" - color={MD3Colors.primary0} + color={Colors.primary0} /> diff --git a/example/src/Examples/BadgeExample.tsx b/example/src/Examples/BadgeExample.tsx index 3269dc70a8..b94c8e72b1 100644 --- a/example/src/Examples/BadgeExample.tsx +++ b/example/src/Examples/BadgeExample.tsx @@ -5,7 +5,7 @@ import { Badge, IconButton, List, - MD3Colors, + Colors, Text, Switch, } from 'react-native-paper'; @@ -41,7 +41,7 @@ const BadgeExample = () => { style={[ styles.badge, { - backgroundColor: MD3Colors.primary80, + backgroundColor: Colors.primary80, }, ]} > diff --git a/example/src/Examples/BannerExample.tsx b/example/src/Examples/BannerExample.tsx index 6e26b984ea..84bfd4986b 100644 --- a/example/src/Examples/BannerExample.tsx +++ b/example/src/Examples/BannerExample.tsx @@ -8,7 +8,7 @@ import { View, } from 'react-native'; -import { Banner, FAB, MD3Colors, useTheme } from 'react-native-paper'; +import { Banner, FAB, Colors, useTheme } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; @@ -31,11 +31,11 @@ const BannerExample = () => { const customTheme = { ...theme, colors: { - onSurface: MD3Colors.tertiary100, + onSurface: Colors.tertiary100, elevation: { - level1: MD3Colors.tertiary50, + level1: Colors.tertiary50, }, - primary: MD3Colors.tertiary10, + primary: Colors.tertiary10, }, }; diff --git a/example/src/Examples/CheckboxExample.tsx b/example/src/Examples/CheckboxExample.tsx index 06088a646a..252d2c8a82 100644 --- a/example/src/Examples/CheckboxExample.tsx +++ b/example/src/Examples/CheckboxExample.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { StyleSheet, View } from 'react-native'; -import { Checkbox, MD3Colors, Text, TouchableRipple } from 'react-native-paper'; +import { Checkbox, Colors, Text, TouchableRipple } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; @@ -26,7 +26,7 @@ const CheckboxExample = () => { Custom diff --git a/example/src/Examples/ChipExample.tsx b/example/src/Examples/ChipExample.tsx index 5ea6373856..7b9215d8d5 100644 --- a/example/src/Examples/ChipExample.tsx +++ b/example/src/Examples/ChipExample.tsx @@ -2,11 +2,11 @@ import * as React from 'react'; import { Image, StyleSheet, View } from 'react-native'; import color from 'color'; -import { Chip, List, MD3Colors, Snackbar, Text } from 'react-native-paper'; +import { Chip, List, Colors, Snackbar, Text } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; -const customColor = MD3Colors.error50; +const customColor = Colors.error50; const ChipExample = () => { const [snackbarProperties, setSnackbarProperties] = React.useState({ diff --git a/example/src/Examples/Dialogs/DialogWithCustomColors.tsx b/example/src/Examples/Dialogs/DialogWithCustomColors.tsx index 11aa996d48..2d30828073 100644 --- a/example/src/Examples/Dialogs/DialogWithCustomColors.tsx +++ b/example/src/Examples/Dialogs/DialogWithCustomColors.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { Button, Portal, Dialog, MD3Colors } from 'react-native-paper'; +import { Button, Portal, Dialog, Colors } from 'react-native-paper'; import { TextComponent } from './DialogTextComponent'; @@ -16,20 +16,18 @@ const DialogWithCustomColors = ({ - - Alert - + Alert - + This is a dialog with custom colors - diff --git a/example/src/Examples/Dialogs/DialogWithDismissableBackButton.tsx b/example/src/Examples/Dialogs/DialogWithDismissableBackButton.tsx index 689a22b082..dcaab4e0e0 100644 --- a/example/src/Examples/Dialogs/DialogWithDismissableBackButton.tsx +++ b/example/src/Examples/Dialogs/DialogWithDismissableBackButton.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { Button, Portal, Dialog, MD3Colors } from 'react-native-paper'; +import { Button, Portal, Dialog, Colors } from 'react-native-paper'; import { TextComponent } from './DialogTextComponent'; @@ -26,7 +26,7 @@ const DialogWithDismissableBackButton = ({ - diff --git a/example/src/Examples/Dialogs/DialogWithIcon.tsx b/example/src/Examples/Dialogs/DialogWithIcon.tsx index d939d4e401..3a0c5f7cfe 100644 --- a/example/src/Examples/Dialogs/DialogWithIcon.tsx +++ b/example/src/Examples/Dialogs/DialogWithIcon.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { StyleSheet } from 'react-native'; -import { Button, Portal, Dialog, MD3Colors } from 'react-native-paper'; +import { Button, Portal, Dialog, Colors } from 'react-native-paper'; import { TextComponent } from './DialogTextComponent'; @@ -24,7 +24,7 @@ const DialogWithIcon = ({ - diff --git a/example/src/Examples/Dialogs/DialogWithLoadingIndicator.tsx b/example/src/Examples/Dialogs/DialogWithLoadingIndicator.tsx index 5860737e3e..158e1b6577 100644 --- a/example/src/Examples/Dialogs/DialogWithLoadingIndicator.tsx +++ b/example/src/Examples/Dialogs/DialogWithLoadingIndicator.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { ActivityIndicator, Platform, StyleSheet, View } from 'react-native'; -import { Dialog, MD3Colors, Portal } from 'react-native-paper'; +import { Dialog, Colors, Portal } from 'react-native-paper'; import { TextComponent } from './DialogTextComponent'; @@ -21,7 +21,7 @@ const DialogWithLoadingIndicator = ({ diff --git a/example/src/Examples/Dialogs/UndismissableDialog.tsx b/example/src/Examples/Dialogs/UndismissableDialog.tsx index 647d3c96d3..b3a0d686ff 100644 --- a/example/src/Examples/Dialogs/UndismissableDialog.tsx +++ b/example/src/Examples/Dialogs/UndismissableDialog.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { Button, Portal, Dialog, MD3Colors } from 'react-native-paper'; +import { Button, Portal, Dialog, Colors } from 'react-native-paper'; import { TextComponent } from './DialogTextComponent'; @@ -18,7 +18,7 @@ const UndismissableDialog = ({ This is an undismissable dialog!! - diff --git a/example/src/Examples/IconButtonExample.tsx b/example/src/Examples/IconButtonExample.tsx index a776815a37..2f558db65d 100644 --- a/example/src/Examples/IconButtonExample.tsx +++ b/example/src/Examples/IconButtonExample.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { StyleSheet, View } from 'react-native'; -import { IconButton, List, MD3Colors } from 'react-native-paper'; +import { IconButton, List, Colors } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; @@ -121,7 +121,7 @@ const ButtonExample = () => { {}} /> { mode="contained" style={styles.square} size={24} - iconColor={MD3Colors.tertiary50} + iconColor={Colors.tertiary50} onPress={() => {}} /> { style={styles.slightlyRounded} size={24} contentStyle={styles.padding} - iconColor={MD3Colors.tertiary50} + iconColor={Colors.tertiary50} onPress={() => {}} /> { mode="contained-tonal" style={styles.differentBorderRadius} size={24} - iconColor={MD3Colors.tertiary50} + iconColor={Colors.tertiary50} onPress={() => {}} /> { mode="outlined" style={styles.differentBorderRadius} size={24} - iconColor={MD3Colors.tertiary50} + iconColor={Colors.tertiary50} onPress={() => {}} /> {}} /> @@ -162,7 +162,7 @@ const ButtonExample = () => { icon="lock" size={36} onPress={() => {}} - containerColor={MD3Colors.tertiary60} + containerColor={Colors.tertiary60} /> {}} /> {}} loading /> diff --git a/example/src/Examples/ProgressBarExample.tsx b/example/src/Examples/ProgressBarExample.tsx index 76fc3b4a02..08c23696d4 100644 --- a/example/src/Examples/ProgressBarExample.tsx +++ b/example/src/Examples/ProgressBarExample.tsx @@ -4,7 +4,7 @@ import { View, StyleSheet, Animated } from 'react-native'; import { Button, ProgressBar, - MD3Colors, + Colors, ProgressBarProps, Text, useTheme, @@ -63,7 +63,7 @@ const ProgressBarExample = () => { @@ -74,9 +74,9 @@ const ProgressBarExample = () => { diff --git a/example/src/Examples/RadioButtonExample.tsx b/example/src/Examples/RadioButtonExample.tsx index 7e3b3cf754..501245c7a1 100644 --- a/example/src/Examples/RadioButtonExample.tsx +++ b/example/src/Examples/RadioButtonExample.tsx @@ -1,12 +1,7 @@ import * as React from 'react'; import { StyleSheet, View } from 'react-native'; -import { - MD3Colors, - RadioButton, - Text, - TouchableRipple, -} from 'react-native-paper'; +import { Colors, RadioButton, Text, TouchableRipple } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; @@ -45,7 +40,7 @@ const RadioButtonExample = () => { diff --git a/example/src/Examples/SearchbarExample.tsx b/example/src/Examples/SearchbarExample.tsx index 9ba8a4cfb0..b9fa687409 100644 --- a/example/src/Examples/SearchbarExample.tsx +++ b/example/src/Examples/SearchbarExample.tsx @@ -5,7 +5,7 @@ import type { DrawerNavigationProp } from '@react-navigation/drawer'; import type { StackNavigationProp } from '@react-navigation/stack'; import { List, - MD3Colors, + Colors, Searchbar, Snackbar, Avatar, @@ -57,7 +57,7 @@ const SearchExample = ({ navigation }: Props) => { value={searchQueries.traileringIcon} traileringIcon={'microphone'} traileringIconColor={ - isVisible ? MD3Colors.error40 : colors.onSurfaceVariant + isVisible ? Colors.error40 : colors.onSurfaceVariant } traileringIconAccessibilityLabel={'microphone button'} onTraileringIconPress={() => setIsVisible(true)} @@ -76,7 +76,7 @@ const SearchExample = ({ navigation }: Props) => { value={searchQueries.traileringIconWithRightItem} traileringIcon={'microphone'} traileringIconColor={ - isVisible ? MD3Colors.error40 : colors.onSurfaceVariant + isVisible ? Colors.error40 : colors.onSurfaceVariant } traileringIconAccessibilityLabel={'microphone button'} onTraileringIconPress={() => setIsVisible(true)} diff --git a/example/src/Examples/SurfaceExample.tsx b/example/src/Examples/SurfaceExample.tsx index 1db20da5d0..5183697b15 100644 --- a/example/src/Examples/SurfaceExample.tsx +++ b/example/src/Examples/SurfaceExample.tsx @@ -1,13 +1,7 @@ import * as React from 'react'; import { ScrollView, StyleSheet, View } from 'react-native'; -import { - MD3Elevation, - Surface, - Text, - MD3Colors, - List, -} from 'react-native-paper'; +import { Elevation, Surface, Text, Colors, List } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; @@ -19,7 +13,7 @@ const SurfaceExample = () => { key={index} style={styles.surface} mode={mode} - elevation={index as MD3Elevation} + elevation={index as Elevation} > `Elevation ${index === 1 ? '(default)' : ''} ${index}` @@ -85,7 +79,7 @@ const styles = StyleSheet.create({ justifyContent: 'space-between', width: '100%', marginBottom: 20, - borderColor: MD3Colors.tertiary50, + borderColor: Colors.tertiary50, padding: 10, borderWidth: 1, }, @@ -98,7 +92,7 @@ const styles = StyleSheet.create({ justifyContent: 'space-between', width: '100%', marginBottom: 100, - borderColor: MD3Colors.tertiary50, + borderColor: Colors.tertiary50, padding: 10, borderWidth: 1, }, diff --git a/example/src/Examples/SwitchExample.tsx b/example/src/Examples/SwitchExample.tsx index 51baa12b01..6a430cecfa 100644 --- a/example/src/Examples/SwitchExample.tsx +++ b/example/src/Examples/SwitchExample.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { Platform, StyleSheet, View } from 'react-native'; -import { MD3Colors, Switch, Text, TouchableRipple } from 'react-native-paper'; +import { Colors, Switch, Text, TouchableRipple } from 'react-native-paper'; import ScreenWrapper from '../ScreenWrapper'; @@ -30,7 +30,7 @@ const SwitchExample = () => { Custom {switchValueCustomlLabel} - + @@ -57,7 +57,7 @@ const SwitchExample = () => { setCustomValue(!valueCustom)} - color={MD3Colors.tertiary50} + color={Colors.tertiary50} /> diff --git a/example/src/Examples/TextExample.tsx b/example/src/Examples/TextExample.tsx index 1cb96edfaf..ea814c1c18 100644 --- a/example/src/Examples/TextExample.tsx +++ b/example/src/Examples/TextExample.tsx @@ -3,7 +3,7 @@ import { Platform, StyleSheet, View } from 'react-native'; import { configureFonts, - MD3LightTheme, + LightTheme, PaperProvider, customText, } from 'react-native-paper'; @@ -30,7 +30,7 @@ const TextExample = () => { } as const; const theme = { - ...MD3LightTheme, + ...LightTheme, fonts: configureFonts({ config: fontConfig }), }; return ( diff --git a/example/src/Examples/TextInputExample.tsx b/example/src/Examples/TextInputExample.tsx index 376dd57818..c5cae00aa9 100644 --- a/example/src/Examples/TextInputExample.tsx +++ b/example/src/Examples/TextInputExample.tsx @@ -13,7 +13,7 @@ import { configureFonts, HelperText, List, - MD3Colors, + Colors, TextInput, useTheme, } from 'react-native-paper'; @@ -565,7 +565,7 @@ const TextInputExample = () => { * @@ -595,8 +595,8 @@ const TextInputExample = () => { onChangeText={(flatUnderlineColors) => inputActionHandler('flatUnderlineColors', flatUnderlineColors) } - underlineColor={MD3Colors.primary70} - activeUnderlineColor={MD3Colors.tertiary50} + underlineColor={Colors.primary70} + activeUnderlineColor={Colors.tertiary50} /> { onChangeText={(outlinedColors) => inputActionHandler('outlinedColors', outlinedColors) } - outlineColor={MD3Colors.primary70} - activeOutlineColor={MD3Colors.tertiary50} + outlineColor={Colors.primary70} + activeOutlineColor={Colors.tertiary50} /> void; @@ -9,7 +9,7 @@ export const PreferencesContext = React.createContext<{ toggleCustomFont: () => void; toggleRippleEffect: () => void; toggleShouldUseDeviceColors?: () => void; - theme: MD3Theme; + theme: Theme; rtl: boolean; collapsed: boolean; customFontLoaded: boolean; diff --git a/example/src/index.native.tsx b/example/src/index.native.tsx index c6bba2b1bd..7a7e73feca 100644 --- a/example/src/index.native.tsx +++ b/example/src/index.native.tsx @@ -9,7 +9,7 @@ import { useFonts } from 'expo-font'; import { useKeepAwake } from 'expo-keep-awake'; import { StatusBar } from 'expo-status-bar'; import * as Updates from 'expo-updates'; -import { PaperProvider, MD3DarkTheme, MD3LightTheme } from 'react-native-paper'; +import { PaperProvider, DarkTheme, LightTheme } from 'react-native-paper'; import { SafeAreaInsetsContext } from 'react-native-safe-area-context'; import DrawerItems from './DrawerItems'; @@ -53,12 +53,12 @@ export default function PaperExample() { const { theme: mdTheme } = useMaterial3Theme(); const theme = React.useMemo(() => { if (!deviceColorsSupported || !shouldUseDeviceColors) { - return isDarkMode ? MD3DarkTheme : MD3LightTheme; + return isDarkMode ? DarkTheme : LightTheme; } return isDarkMode - ? { ...MD3DarkTheme, colors: mdTheme.dark } - : { ...MD3LightTheme, colors: mdTheme.light }; + ? { ...DarkTheme, colors: mdTheme.dark } + : { ...LightTheme, colors: mdTheme.light }; }, [isDarkMode, mdTheme, shouldUseDeviceColors]); React.useEffect(() => { diff --git a/example/src/index.tsx b/example/src/index.tsx index ce4df07253..0b666f425b 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -5,7 +5,7 @@ import { createDrawerNavigator } from '@react-navigation/drawer'; import { InitialState, NavigationContainer } from '@react-navigation/native'; import { useFonts } from 'expo-font'; import { useKeepAwake } from 'expo-keep-awake'; -import { PaperProvider, MD3DarkTheme, MD3LightTheme } from 'react-native-paper'; +import { PaperProvider, DarkTheme, LightTheme } from 'react-native-paper'; import { SafeAreaInsetsContext } from 'react-native-safe-area-context'; import DrawerItems from './DrawerItems'; @@ -42,7 +42,7 @@ export default function PaperExample() { const [rippleEffectEnabled, setRippleEffectEnabled] = React.useState(true); const theme = React.useMemo(() => { - return isDarkMode ? MD3DarkTheme : MD3LightTheme; + return isDarkMode ? DarkTheme : LightTheme; }, [isDarkMode]); React.useEffect(() => { diff --git a/example/utils/index.ts b/example/utils/index.ts index 5c15917644..3d4e14587e 100644 --- a/example/utils/index.ts +++ b/example/utils/index.ts @@ -1,7 +1,7 @@ import { Platform } from 'react-native'; import ExpoMaterial3ThemeModule from '@pchmn/expo-material3-theme/build/ExpoMaterial3ThemeModule'; -import { MD3DarkTheme, MD3LightTheme, MD3Theme } from 'react-native-paper'; +import { DarkTheme, LightTheme, Theme } from 'react-native-paper'; type ReducerAction = { payload: State[T]; @@ -1156,80 +1156,80 @@ const darkCyanColors = { export const colorThemes = { paper: { - light: MD3LightTheme, - dark: MD3DarkTheme, + light: LightTheme, + dark: DarkTheme, }, pink: { light: { - ...MD3LightTheme, + ...LightTheme, ...lightPinkColors, }, dark: { - ...MD3DarkTheme, + ...DarkTheme, ...darkPinkColors, }, }, green: { light: { - ...MD3LightTheme, + ...LightTheme, ...lightGreenColors, }, dark: { - ...MD3DarkTheme, + ...DarkTheme, ...darkGreenColors, }, }, blue: { light: { - ...MD3LightTheme, + ...LightTheme, ...lightBlueColors, }, dark: { - ...MD3DarkTheme, + ...DarkTheme, ...darkBlueColors, }, }, orange: { light: { - ...MD3LightTheme, + ...LightTheme, ...lightOrangeColors, }, dark: { - ...MD3DarkTheme, + ...DarkTheme, ...darkOrangeColors, }, }, red: { light: { - ...MD3LightTheme, + ...LightTheme, ...lightRedColors, }, dark: { - ...MD3DarkTheme, + ...DarkTheme, ...darkRedColors, }, }, yellow: { light: { - ...MD3LightTheme, + ...LightTheme, ...lightYellowColors, }, dark: { - ...MD3DarkTheme, + ...DarkTheme, ...darkYellowColors, }, }, cyan: { light: { - ...MD3LightTheme, + ...LightTheme, ...lightCyanColors, }, dark: { - ...MD3DarkTheme, + ...DarkTheme, ...darkCyanColors, }, }, -} as { [key: string]: { light: MD3Theme; dark: MD3Theme } }; +} as { [key: string]: { light: Theme; dark: Theme } }; export const songsData = [ { diff --git a/example/utils/themes.ts b/example/utils/themes.ts index 85e4bb4f81..173a18077a 100644 --- a/example/utils/themes.ts +++ b/example/utils/themes.ts @@ -4,8 +4,8 @@ import { } from '@react-navigation/native'; import { adaptNavigationTheme, - MD3DarkTheme, - MD3LightTheme, + DarkTheme as PaperDarkTheme, + LightTheme as PaperLightTheme, configureFonts, } from 'react-native-paper'; @@ -15,27 +15,27 @@ const { LightTheme, DarkTheme } = adaptNavigationTheme({ }); export const CombinedDefaultTheme = { - ...MD3LightTheme, + ...PaperLightTheme, ...LightTheme, colors: { - ...MD3LightTheme.colors, + ...PaperLightTheme.colors, ...LightTheme.colors, }, fonts: { - ...MD3LightTheme.fonts, + ...PaperLightTheme.fonts, ...LightTheme.fonts, }, }; export const CombinedDarkTheme = { - ...MD3DarkTheme, + ...PaperDarkTheme, ...DarkTheme, colors: { - ...MD3DarkTheme.colors, + ...PaperDarkTheme.colors, ...DarkTheme.colors, }, fonts: { - ...MD3DarkTheme.fonts, + ...PaperDarkTheme.fonts, ...DarkTheme.fonts, }, }; diff --git a/src/babel/__fixtures__/rewrite-imports/code.js b/src/babel/__fixtures__/rewrite-imports/code.js index 6509ef2f67..189a3d1105 100644 --- a/src/babel/__fixtures__/rewrite-imports/code.js +++ b/src/babel/__fixtures__/rewrite-imports/code.js @@ -5,7 +5,7 @@ import { Button, FAB, Appbar, - MD3Colors, + Colors, NonExistent, NonExistentSecond as Stuff, ThemeProvider, diff --git a/src/babel/__fixtures__/rewrite-imports/output.js b/src/babel/__fixtures__/rewrite-imports/output.js index 7204b0ca33..753c24618a 100644 --- a/src/babel/__fixtures__/rewrite-imports/output.js +++ b/src/babel/__fixtures__/rewrite-imports/output.js @@ -4,7 +4,7 @@ import BottomNavigation from "react-native-paper/lib/module/components/BottomNav import Button from "react-native-paper/lib/module/components/Button/Button"; import FAB from "react-native-paper/lib/module/components/FAB"; import Appbar from "react-native-paper/lib/module/components/Appbar"; -import { MD3Colors } from "react-native-paper/lib/module/styles/themes/v3/tokens"; +import { Colors } from "react-native-paper/lib/module/styles/themes/tokens"; import { NonExistent, NonExistentSecond as Stuff } from "react-native-paper/lib/module/index.js"; import { ThemeProvider } from "react-native-paper/lib/module/core/theming"; import { withTheme } from "react-native-paper/lib/module/core/theming"; diff --git a/src/components/ActivityIndicator.tsx b/src/components/ActivityIndicator.tsx index 1857663071..17b95f1f4e 100644 --- a/src/components/ActivityIndicator.tsx +++ b/src/components/ActivityIndicator.tsx @@ -45,10 +45,10 @@ const DURATION = 2400; * ## Usage * ```js * import * as React from 'react'; - * import { ActivityIndicator, MD3Colors } from 'react-native-paper'; + * import { ActivityIndicator, Colors } from 'react-native-paper'; * * const MyComponent = () => ( - * + * * ); * * export default MyComponent; diff --git a/src/components/Appbar/Appbar.tsx b/src/components/Appbar/Appbar.tsx index 66faeebf7b..a699b1b931 100644 --- a/src/components/Appbar/Appbar.tsx +++ b/src/components/Appbar/Appbar.tsx @@ -18,7 +18,7 @@ import { AppbarChildProps, } from './utils'; import { useInternalTheme } from '../../core/theming'; -import type { MD3Elevation, ThemeProp } from '../../types'; +import type { Elevation, ThemeProp } from '../../types'; import Surface from '../Surface'; export type Props = Omit< @@ -237,7 +237,7 @@ const Appbar = ({ insets, restStyle, ]} - elevation={elevation as MD3Elevation} + elevation={elevation as Elevation} {...rest} > {shouldAddLeftSpacing ? : null} diff --git a/src/components/Appbar/AppbarContent.tsx b/src/components/Appbar/AppbarContent.tsx index 11b6a847dd..cff1efacde 100644 --- a/src/components/Appbar/AppbarContent.tsx +++ b/src/components/Appbar/AppbarContent.tsx @@ -14,7 +14,7 @@ import { import { modeTextVariant } from './utils'; import { useInternalTheme } from '../../core/theming'; -import type { $RemoveChildren, MD3TypescaleKey, ThemeProp } from '../../types'; +import type { $RemoveChildren, TypescaleKey, ThemeProp } from '../../types'; import Text, { TextRef } from '../Typography/Text'; type TitleString = { @@ -125,7 +125,7 @@ const AppbarContent = ({ 'center-aligned': styles.v3DefaultContainer, }; - const variant = modeTextVariant[mode] as MD3TypescaleKey; + const variant = modeTextVariant[mode] as TypescaleKey; const contentWrapperProps = { pointerEvents: 'box-none' as ViewProps['pointerEvents'], diff --git a/src/components/Appbar/utils.ts b/src/components/Appbar/utils.ts index 1f899975c4..0fb63bdc0a 100644 --- a/src/components/Appbar/utils.ts +++ b/src/components/Appbar/utils.ts @@ -2,7 +2,7 @@ import React from 'react'; import type { ColorValue, StyleProp, ViewStyle } from 'react-native'; import { StyleSheet, Animated } from 'react-native'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import type { InternalTheme, ThemeProp } from '../../types'; export type AppbarModes = 'small' | 'medium' | 'large' | 'center-aligned'; @@ -49,7 +49,7 @@ export const getAppbarColor = ({ } if (isDark) { - return MD3Colors.primary100; + return Colors.primary100; } return undefined; @@ -86,13 +86,13 @@ type RenderAppbarContentProps = BaseProps & { theme?: ThemeProp; }; -const MD3_DEFAULT_APPBAR_HEIGHT = 64; +const DEFAULT_APPBAR_HEIGHT = 64; export const modeAppbarHeight = { - small: MD3_DEFAULT_APPBAR_HEIGHT, + small: DEFAULT_APPBAR_HEIGHT, medium: 112, large: 152, - 'center-aligned': MD3_DEFAULT_APPBAR_HEIGHT, + 'center-aligned': DEFAULT_APPBAR_HEIGHT, }; export const modeTextVariant = { @@ -102,12 +102,6 @@ export const modeTextVariant = { 'center-aligned': 'titleLarge', } as const; -/** - * Filtruje akcje w Appbarze na podstawie właściwości isLeading. - * @param children - Dzieci komponentu Appbar do przefiltrowania - * @param isLeading - Czy filtrować akcje wiodące (true) czy niewiodące (false). Domyślnie false. - * @returns Przefiltrowana tablica elementów React - */ export const filterAppbarActions = ( children: React.ReactNode, isLeading = false diff --git a/src/components/Avatar/AvatarIcon.tsx b/src/components/Avatar/AvatarIcon.tsx index db07b0f9ae..8129bec35e 100644 --- a/src/components/Avatar/AvatarIcon.tsx +++ b/src/components/Avatar/AvatarIcon.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'; import { useInternalTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import type { ThemeProp } from '../../types'; import getContrastingColor from '../../utils/getContrastingColor'; import Icon, { IconSource } from '../Icon'; @@ -58,7 +58,7 @@ const Avatar = ({ rest.color ?? getContrastingColor( backgroundColor, - MD3Colors.primary100, + Colors.primary100, 'rgba(0, 0, 0, .54)' ); diff --git a/src/components/Avatar/AvatarText.tsx b/src/components/Avatar/AvatarText.tsx index 63045b62cf..f5e96b94c8 100644 --- a/src/components/Avatar/AvatarText.tsx +++ b/src/components/Avatar/AvatarText.tsx @@ -9,7 +9,7 @@ import { } from 'react-native'; import { useInternalTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import type { ThemeProp } from '../../types'; import getContrastingColor from '../../utils/getContrastingColor'; import Text from '../Typography/Text'; @@ -79,7 +79,7 @@ const AvatarText = ({ customColor ?? getContrastingColor( backgroundColor, - MD3Colors.primary100, + Colors.primary100, 'rgba(0, 0, 0, .54)' ); const { fontScale } = useWindowDimensions(); diff --git a/src/components/Button/utils.tsx b/src/components/Button/utils.tsx index 3a883d5722..0963f06f8f 100644 --- a/src/components/Button/utils.tsx +++ b/src/components/Button/utils.tsx @@ -2,7 +2,7 @@ import { type ViewStyle } from 'react-native'; import color from 'color'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import type { InternalTheme } from '../../types'; import { splitStyles } from '../../utils/splitStyles'; @@ -110,8 +110,8 @@ const getButtonTextColor = ({ isMode('elevated') ) { return isDark({ dark, backgroundColor }) - ? MD3Colors.primary100 - : MD3Colors.primary0; + ? Colors.primary100 + : Colors.primary0; } } diff --git a/src/components/Card/CardTitle.tsx b/src/components/Card/CardTitle.tsx index a8642d9723..1c30e0f7f5 100644 --- a/src/components/Card/CardTitle.tsx +++ b/src/components/Card/CardTitle.tsx @@ -7,7 +7,7 @@ import { ViewStyle, } from 'react-native'; -import type { MD3TypescaleKey, ThemeProp } from '../../types'; +import type { TypescaleKey, ThemeProp } from '../../types'; import Text from '../Typography/Text'; export type Props = React.ComponentPropsWithRef & { @@ -39,7 +39,7 @@ export type Props = React.ComponentPropsWithRef & { * * Body: `bodyLarge`, `bodyMedium`, `bodySmall` */ - titleVariant?: keyof typeof MD3TypescaleKey; + titleVariant?: keyof typeof TypescaleKey; /** * Text for the subtitle. Note that this will only accept a string or ``-based node. */ @@ -68,7 +68,7 @@ export type Props = React.ComponentPropsWithRef & { * * Body: `bodyLarge`, `bodyMedium`, `bodySmall` */ - subtitleVariant?: keyof typeof MD3TypescaleKey; + subtitleVariant?: keyof typeof TypescaleKey; /** * Callback which returns a React element to display on the left side. */ diff --git a/src/components/Checkbox/CheckboxItem.tsx b/src/components/Checkbox/CheckboxItem.tsx index c87d873e36..dec53d8e75 100644 --- a/src/components/Checkbox/CheckboxItem.tsx +++ b/src/components/Checkbox/CheckboxItem.tsx @@ -14,7 +14,7 @@ import Checkbox from './Checkbox'; import CheckboxAndroid from './CheckboxAndroid'; import CheckboxIOS from './CheckboxIOS'; import { useInternalTheme } from '../../core/theming'; -import type { ThemeProp, MD3TypescaleKey } from '../../types'; +import type { ThemeProp, TypescaleKey } from '../../types'; import TouchableRipple, { Props as TouchableRippleProps, } from '../TouchableRipple/TouchableRipple'; @@ -90,7 +90,7 @@ export type Props = { * * Body: `bodyLarge`, `bodyMedium`, `bodySmall` */ - labelVariant?: keyof typeof MD3TypescaleKey; + labelVariant?: keyof typeof TypescaleKey; /** * @optional */ diff --git a/src/components/Chip/Chip.tsx b/src/components/Chip/Chip.tsx index 85fceabf66..b87bfa2cf3 100644 --- a/src/components/Chip/Chip.tsx +++ b/src/components/Chip/Chip.tsx @@ -18,7 +18,7 @@ import useLatestCallback from 'use-latest-callback'; import { ChipAvatarProps, getChipColors } from './helpers'; import { useInternalTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import type { $Omit, EllipsizeProp, ThemeProp } from '../../types'; import hasTouchHandler from '../../utils/hasTouchHandler'; import type { IconSource } from '../Icon'; @@ -361,11 +361,7 @@ const Chip = ({ diff --git a/src/components/Drawer/DrawerSection.tsx b/src/components/Drawer/DrawerSection.tsx index c5c90d2c39..5dba48e548 100644 --- a/src/components/Drawer/DrawerSection.tsx +++ b/src/components/Drawer/DrawerSection.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'; import { useInternalTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import type { ThemeProp } from '../../types'; import Divider from '../Divider'; import Text from '../Typography/Text'; @@ -119,7 +119,7 @@ const styles = StyleSheet.create({ }, divider: { marginTop: 4, - backgroundColor: MD3Colors.neutralVariant50, + backgroundColor: Colors.neutralVariant50, }, }); diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index 1fc1eb490b..ef322b98c6 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -86,12 +86,12 @@ export type Props = IconProps & { * ## Usage * ```js * import * as React from 'react'; - * import { Icon, MD3Colors } from 'react-native-paper'; + * import { Icon, Colors } from 'react-native-paper'; * * const MyComponent = () => ( * * ); diff --git a/src/components/IconButton/IconButton.tsx b/src/components/IconButton/IconButton.tsx index f960177769..a5cd26a1df 100644 --- a/src/components/IconButton/IconButton.tsx +++ b/src/components/IconButton/IconButton.tsx @@ -98,12 +98,12 @@ export type Props = Omit<$RemoveChildren, 'style'> & { * ## Usage * ```js * import * as React from 'react'; - * import { IconButton, MD3Colors } from 'react-native-paper'; + * import { IconButton, Colors } from 'react-native-paper'; * * const MyComponent = () => ( * console.log('Pressed')} * /> diff --git a/src/components/List/ListIcon.tsx b/src/components/List/ListIcon.tsx index 79e9e09235..fda5e77367 100644 --- a/src/components/List/ListIcon.tsx +++ b/src/components/List/ListIcon.tsx @@ -29,13 +29,13 @@ const ICON_SIZE = 24; * ## Usage * ```js * import * as React from 'react'; - * import { List, MD3Colors } from 'react-native-paper'; + * import { List, Colors } from 'react-native-paper'; * * const MyComponent = () => ( * <> - * - * - * + * + * + * * * ); * diff --git a/src/components/List/ListImage.tsx b/src/components/List/ListImage.tsx index 084c7d8755..312bb53892 100644 --- a/src/components/List/ListImage.tsx +++ b/src/components/List/ListImage.tsx @@ -25,7 +25,7 @@ export type Props = { * ## Usage * ```js * import * as React from 'react'; - * import { List, MD3Colors } from 'react-native-paper'; + * import { List, Colors } from 'react-native-paper'; * * const MyComponent = () => ( * <> diff --git a/src/components/List/ListSection.tsx b/src/components/List/ListSection.tsx index 59640c70da..6d3b0fa287 100644 --- a/src/components/List/ListSection.tsx +++ b/src/components/List/ListSection.tsx @@ -37,7 +37,7 @@ export type Props = React.ComponentPropsWithRef & { * ## Usage * ```js * import * as React from 'react'; - * import { List, MD3Colors } from 'react-native-paper'; + * import { List, Colors } from 'react-native-paper'; * * const MyComponent = () => ( * @@ -45,7 +45,7 @@ export type Props = React.ComponentPropsWithRef & { * } /> * } + * left={() => } * /> * * ); diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx index c551a78ea1..6a30d6e034 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/components/Menu/Menu.tsx @@ -23,7 +23,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'; import MenuItem from './MenuItem'; import { useInternalTheme } from '../../core/theming'; -import type { MD3Elevation, ThemeProp } from '../../types'; +import type { Elevation, ThemeProp } from '../../types'; import { ElevationLevels } from '../../types'; import { addEventListener } from '../../utils/addEventListener'; import { BackHandler } from '../../utils/BackHandler/BackHandler'; @@ -72,7 +72,7 @@ export type Props = { * Elevation level of the menu's content. Shadow styles are calculated based on this value. Default `backgroundColor` is taken from the corresponding `theme.colors.elevation` property. By default equals `2`. * @supported Available in v5.x with theme version 3 */ - elevation?: MD3Elevation; + elevation?: Elevation; /** * Mode of the menu's content. * - `elevated` - Surface with a shadow and background color corresponding to set `elevation` value. @@ -104,7 +104,7 @@ const EASING = Easing.bezier(0.4, 0, 0.2, 1); const WINDOW_LAYOUT = Dimensions.get('window'); -const DEFAULT_ELEVATION: MD3Elevation = 2; +const DEFAULT_ELEVATION: Elevation = 2; export const ELEVATION_LEVELS_MAP = Object.values( ElevationLevels ) as ElevationLevels[]; diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx index 5313b54dfe..dbf8597879 100644 --- a/src/components/ProgressBar.tsx +++ b/src/components/ProgressBar.tsx @@ -61,10 +61,10 @@ const { isRTL } = I18nManager; * ## Usage * ```js * import * as React from 'react'; - * import { ProgressBar, MD3Colors } from 'react-native-paper'; + * import { ProgressBar, Colors } from 'react-native-paper'; * * const MyComponent = () => ( - * + * * ); * * export default MyComponent; diff --git a/src/components/RadioButton/RadioButtonItem.tsx b/src/components/RadioButton/RadioButtonItem.tsx index d3eea54842..21f677cb92 100644 --- a/src/components/RadioButton/RadioButtonItem.tsx +++ b/src/components/RadioButton/RadioButtonItem.tsx @@ -16,7 +16,7 @@ import { RadioButtonContext, RadioButtonContextType } from './RadioButtonGroup'; import RadioButtonIOS from './RadioButtonIOS'; import { handlePress, isChecked } from './utils'; import { useInternalTheme } from '../../core/theming'; -import type { ThemeProp, MD3TypescaleKey } from '../../types'; +import type { ThemeProp, TypescaleKey } from '../../types'; import TouchableRipple, { Props as TouchableRippleProps, } from '../TouchableRipple/TouchableRipple'; @@ -92,7 +92,7 @@ export type Props = { * * Body: `bodyLarge`, `bodyMedium`, `bodySmall` */ - labelVariant?: keyof typeof MD3TypescaleKey; + labelVariant?: keyof typeof TypescaleKey; /** * Specifies the largest possible scale a label font can reach. */ diff --git a/src/components/Surface.tsx b/src/components/Surface.tsx index 1f66fbb7db..00e9e21f04 100644 --- a/src/components/Surface.tsx +++ b/src/components/Surface.tsx @@ -12,11 +12,11 @@ import { import { useInternalTheme } from '../core/theming'; import { isAnimatedValue } from '../styles/overlay'; import shadow from '../styles/shadow'; -import type { ThemeProp, MD3Elevation } from '../types'; +import type { ThemeProp, Elevation } from '../types'; import { forwardRef } from '../utils/forwardRef'; import { splitStyles } from '../utils/splitStyles'; -type Elevation = 0 | 1 | 2 | 3 | 4 | 5 | Animated.Value; +type SurfaceElevation = Elevation | Animated.Value; export type Props = Omit, 'style'> & { /** @@ -34,7 +34,7 @@ export type Props = Omit, 'style'> & { * Note: In version 2 the `elevation` prop was accepted via `style` prop i.e. `style={{ elevation: 4 }}`. * It's no longer supported with theme version 3 and you should use `elevation` property instead. */ - elevation?: Elevation; + elevation?: SurfaceElevation; /** * @supported Available in v5.x with theme version 3 * Mode of the Surface. @@ -86,7 +86,7 @@ const iOSShadowOutputRanges = [ ]; const inputRange = [0, 1, 2, 3, 4, 5]; function getStyleForShadowLayer( - elevation: Elevation, + elevation: SurfaceElevation, layer: 0 | 1 ): Animated.WithAnimatedValue { if (isAnimatedValue(elevation)) { @@ -125,7 +125,7 @@ function getStyleForShadowLayer( const SurfaceIOS = forwardRef< View, Omit & { - elevation: Elevation; + elevation: SurfaceElevation; backgroundColor?: string | Animated.AnimatedInterpolation; } >( @@ -255,7 +255,7 @@ const Surface = forwardRef( return elevation.interpolate({ inputRange, outputRange: inputRange.map((elevation) => { - return elevationColors?.[`level${elevation as MD3Elevation}`]; + return elevationColors?.[`level${elevation as Elevation}`]; }), }); } diff --git a/src/components/TextInput/Adornment/TextInputAdornment.tsx b/src/components/TextInput/Adornment/TextInputAdornment.tsx index 364019486e..cbbc56e13d 100644 --- a/src/components/TextInput/Adornment/TextInputAdornment.tsx +++ b/src/components/TextInput/Adornment/TextInputAdornment.tsx @@ -16,7 +16,7 @@ import type { AdornmentConfig, AdornmentStyleAdjustmentForNativeInput, } from './types'; -import { getConstants } from '../helpers'; +import { ADORNMENT_OFFSET, OUTLINED_INPUT_OFFSET } from '../constants'; export function getAdornmentConfig({ left, @@ -64,8 +64,6 @@ export function getAdornmentStyleAdjustmentForNativeInput({ mode?: 'outlined' | 'flat'; paddingHorizontal?: DimensionValue; }): AdornmentStyleAdjustmentForNativeInput | {} { - const { OUTLINED_INPUT_OFFSET, ADORNMENT_OFFSET } = getConstants(); - if (adornmentConfig.length) { const adornmentStyleAdjustmentForNativeInput = adornmentConfig.map( ({ type, side }: AdornmentConfig) => { diff --git a/src/components/TextInput/Adornment/TextInputAffix.tsx b/src/components/TextInput/Adornment/TextInputAffix.tsx index 71a2b78475..ac515e0ec9 100644 --- a/src/components/TextInput/Adornment/TextInputAffix.tsx +++ b/src/components/TextInput/Adornment/TextInputAffix.tsx @@ -16,7 +16,7 @@ import { AdornmentSide } from './enums'; import { getTextColor } from './utils'; import { useInternalTheme } from '../../../core/theming'; import type { ThemeProp } from '../../../types'; -import { getConstants } from '../helpers'; +import { AFFIX_OFFSET } from '../constants'; export type Props = { /** @@ -130,7 +130,6 @@ const TextInputAffix = ({ accessibilityLabel = text, }: Props) => { const theme = useInternalTheme(themeOverrides); - const { AFFIX_OFFSET } = getConstants(); const { textStyle, diff --git a/src/components/TextInput/Adornment/TextInputIcon.tsx b/src/components/TextInput/Adornment/TextInputIcon.tsx index 2a037716f6..f9c4d0291d 100644 --- a/src/components/TextInput/Adornment/TextInputIcon.tsx +++ b/src/components/TextInput/Adornment/TextInputIcon.tsx @@ -13,8 +13,7 @@ import { useInternalTheme } from '../../../core/theming'; import type { $Omit, ThemeProp } from '../../../types'; import type { IconSource } from '../../Icon'; import IconButton from '../../IconButton/IconButton'; -import { ICON_SIZE } from '../constants'; -import { getConstants } from '../helpers'; +import { ICON_OFFSET, ICON_SIZE } from '../constants'; export type Props = $Omit< React.ComponentProps, @@ -81,8 +80,6 @@ const IconAdornment: React.FunctionComponent< testID, disabled, }) => { - const { ICON_OFFSET } = getConstants(); - const style = { top: topPosition, [side]: ICON_OFFSET, diff --git a/src/components/TextInput/Label/InputLabel.tsx b/src/components/TextInput/Label/InputLabel.tsx index 4877bc236e..3146c1cf50 100644 --- a/src/components/TextInput/Label/InputLabel.tsx +++ b/src/components/TextInput/Label/InputLabel.tsx @@ -9,7 +9,7 @@ import { } from 'react-native'; import AnimatedText from '../../Typography/AnimatedText'; -import { getConstants } from '../helpers'; +import { INPUT_PADDING_HORIZONTAL } from '../constants'; import type { InputLabelProps } from '../types'; const InputLabel = (props: InputLabelProps) => { @@ -52,7 +52,6 @@ const InputLabel = (props: InputLabelProps) => { scaledLabel, } = props; - const { INPUT_PADDING_HORIZONTAL } = getConstants(); const { width } = useWindowDimensions(); const isWeb = Platform.OS === 'web'; diff --git a/src/components/TextInput/TextInputFlat.tsx b/src/components/TextInput/TextInputFlat.tsx index 330d90feaf..03c91d4585 100644 --- a/src/components/TextInput/TextInputFlat.tsx +++ b/src/components/TextInput/TextInputFlat.tsx @@ -20,6 +20,8 @@ import { } from './Adornment/TextInputAdornment'; import { ADORNMENT_SIZE, + FLAT_INPUT_OFFSET, + LABEL_PADDING_TOP, LABEL_PADDING_TOP_DENSE, LABEL_WIGGLE_X_OFFSET, MAXIMIZED_LABEL_FONT_SIZE, @@ -27,6 +29,8 @@ import { MINIMIZED_LABEL_Y_OFFSET, MIN_DENSE_HEIGHT, MIN_DENSE_HEIGHT_WL, + MIN_HEIGHT, + MIN_WIDTH, } from './constants'; import { adjustPaddingFlat, @@ -35,7 +39,6 @@ import { calculateInputHeight, calculateLabelTopPosition, calculatePadding, - getConstants, getFlatInputColors, Padding, } from './helpers'; @@ -85,9 +88,6 @@ const TextInputFlat = ({ } = theme; const hasActiveOutline = parentState.focused || error; - const { LABEL_PADDING_TOP, FLAT_INPUT_OFFSET, MIN_HEIGHT, MIN_WIDTH } = - getConstants(); - const { fontSize: fontSizeStyle, lineHeight: lineHeightStyle, diff --git a/src/components/TextInput/TextInputOutlined.tsx b/src/components/TextInput/TextInputOutlined.tsx index 592053eb25..59d62a4561 100644 --- a/src/components/TextInput/TextInputOutlined.tsx +++ b/src/components/TextInput/TextInputOutlined.tsx @@ -24,9 +24,13 @@ import { LABEL_WIGGLE_X_OFFSET, ADORNMENT_SIZE, OUTLINE_MINIMIZED_LABEL_Y_OFFSET, - LABEL_PADDING_TOP, MIN_DENSE_HEIGHT_OUTLINED, LABEL_PADDING_TOP_DENSE, + ADORNMENT_OFFSET, + MIN_HEIGHT, + INPUT_PADDING_HORIZONTAL, + MIN_WIDTH, + OUTLINED_INPUT_OFFSET, } from './constants'; import { calculateLabelTopPosition, @@ -36,7 +40,6 @@ import { Padding, calculateOutlinedIconAndAffixTopPosition, getOutlinedInputColors, - getConstants, } from './helpers'; import InputLabel from './Label/InputLabel'; import LabelBackground from './Label/LabelBackground'; @@ -88,9 +91,6 @@ const TextInputOutlined = ({ } = theme; const hasActiveOutline = parentState.focused || error; - const { INPUT_PADDING_HORIZONTAL, MIN_HEIGHT, ADORNMENT_OFFSET, MIN_WIDTH } = - getConstants(); - const { fontSize: fontSizeStyle, fontWeight, @@ -122,7 +122,7 @@ const TextInputOutlined = ({ }); const densePaddingTop = label ? LABEL_PADDING_TOP_DENSE : 0; - const paddingTop = label ? LABEL_PADDING_TOP : 0; + const paddingTop = label ? OUTLINED_INPUT_OFFSET / 2 : 0; const yOffset = label ? OUTLINE_MINIMIZED_LABEL_Y_OFFSET : 0; const labelScale = MINIMIZED_LABEL_FONT_SIZE / fontSize; diff --git a/src/components/TextInput/constants.tsx b/src/components/TextInput/constants.tsx index 82779e4b34..fd574e89fc 100644 --- a/src/components/TextInput/constants.tsx +++ b/src/components/TextInput/constants.tsx @@ -6,35 +6,33 @@ export const ADORNMENT_SIZE = 24; export const MIN_WIDTH = 100; //Text input affix offset -export const MD3_AFFIX_OFFSET = 16; +export const AFFIX_OFFSET = 16; // Text input icon export const ICON_SIZE = 24; -export const MD2_ICON_OFFSET = 12; -export const MD3_ICON_OFFSET = 16; +export const ICON_OFFSET = 16; // Text input common -export const MD3_MIN_HEIGHT = 56; -export const MD3_ADORNMENT_OFFSET = 16; +export const MIN_HEIGHT = 56; +export const ADORNMENT_OFFSET = 16; export const LABEL_PADDING_TOP_DENSE = 24; -export const LABEL_PADDING_TOP = 8; // Text input flat -export const MD3_LABEL_PADDING_TOP = 26; +export const LABEL_PADDING_TOP = 26; -export const MD3_LABEL_PADDING_HORIZONTAL = 16; +export const LABEL_PADDING_HORIZONTAL = 16; -export const MD3_FLAT_INPUT_OFFSET = 16; +export const FLAT_INPUT_OFFSET = 16; export const MINIMIZED_LABEL_Y_OFFSET = -18; export const MIN_DENSE_HEIGHT_WL = 52; export const MIN_DENSE_HEIGHT = 40; // Text input outlined -export const MD3_INPUT_PADDING_HORIZONTAL = 16; +export const INPUT_PADDING_HORIZONTAL = 16; // extra space to avoid overlapping input's text and icon -export const MD3_OUTLINED_INPUT_OFFSET = 16; +export const OUTLINED_INPUT_OFFSET = 16; export const OUTLINE_MINIMIZED_LABEL_Y_OFFSET = -6; export const MIN_DENSE_HEIGHT_OUTLINED = 48; diff --git a/src/components/TextInput/helpers.tsx b/src/components/TextInput/helpers.tsx index b30a425dd3..10e70a6916 100644 --- a/src/components/TextInput/helpers.tsx +++ b/src/components/TextInput/helpers.tsx @@ -5,17 +5,10 @@ import color from 'color'; import { AdornmentSide, AdornmentType } from './Adornment/enums'; import type { AdornmentConfig } from './Adornment/types'; import { - MIN_WIDTH, ADORNMENT_SIZE, - MD3_ADORNMENT_OFFSET, - MD3_AFFIX_OFFSET, - MD3_FLAT_INPUT_OFFSET, - MD3_ICON_OFFSET, - MD3_INPUT_PADDING_HORIZONTAL, - MD3_LABEL_PADDING_HORIZONTAL, - MD3_LABEL_PADDING_TOP, - MD3_MIN_HEIGHT, - MD3_OUTLINED_INPUT_OFFSET, + LABEL_PADDING_HORIZONTAL, + ADORNMENT_OFFSET, + FLAT_INPUT_OFFSET, } from './constants'; import type { TextInputLabelProp } from './types'; import type { InternalTheme } from '../../types'; @@ -272,9 +265,6 @@ export const calculateFlatInputHorizontalPadding = ({ }: { adornmentConfig: AdornmentConfig[]; }) => { - const { LABEL_PADDING_HORIZONTAL, ADORNMENT_OFFSET, FLAT_INPUT_OFFSET } = - getConstants(); - let paddingLeft = LABEL_PADDING_HORIZONTAL; let paddingRight = LABEL_PADDING_HORIZONTAL; @@ -531,22 +521,3 @@ export const getOutlinedInputColors = ({ errorColor, }; }; - -export const getConstants = () => { - return { - MIN_WIDTH, - // Text input affix - AFFIX_OFFSET: MD3_AFFIX_OFFSET, - // Text input icon - ICON_OFFSET: MD3_ICON_OFFSET, - //Text input flat - LABEL_PADDING_TOP: MD3_LABEL_PADDING_TOP, - LABEL_PADDING_HORIZONTAL: MD3_LABEL_PADDING_HORIZONTAL, - FLAT_INPUT_OFFSET: MD3_FLAT_INPUT_OFFSET, - MIN_HEIGHT: MD3_MIN_HEIGHT, - // Text input outlined; - INPUT_PADDING_HORIZONTAL: MD3_INPUT_PADDING_HORIZONTAL, - ADORNMENT_OFFSET: MD3_ADORNMENT_OFFSET, - OUTLINED_INPUT_OFFSET: MD3_OUTLINED_INPUT_OFFSET, - }; -}; diff --git a/src/components/ToggleButton/utils.ts b/src/components/ToggleButton/utils.ts index 3e5f0cb05f..184dbaa1c4 100644 --- a/src/components/ToggleButton/utils.ts +++ b/src/components/ToggleButton/utils.ts @@ -1,6 +1,6 @@ import color from 'color'; -import { tokens } from '../../styles/themes/v3/tokens'; +import { tokens } from '../../styles/themes/tokens'; import type { InternalTheme } from '../../types'; export const getToggleButtonColor = ({ diff --git a/src/components/Typography/types.tsx b/src/components/Typography/types.tsx index 61a6dc7c1e..3f1754521a 100644 --- a/src/components/Typography/types.tsx +++ b/src/components/Typography/types.tsx @@ -1,5 +1,5 @@ -import type { MD3TypescaleKey } from '../../types'; +import type { TypescaleKey } from '../../types'; export type VariantProp = | (T extends string ? (string extends T ? never : T) : never) - | keyof typeof MD3TypescaleKey; + | keyof typeof TypescaleKey; diff --git a/src/components/__tests__/AnimatedFAB.test.tsx b/src/components/__tests__/AnimatedFAB.test.tsx index a31f6d5fb4..a848c2a1c8 100644 --- a/src/components/__tests__/AnimatedFAB.test.tsx +++ b/src/components/__tests__/AnimatedFAB.test.tsx @@ -6,12 +6,12 @@ import { Animated, StyleSheet } from 'react-native'; import { fireEvent, render } from '@testing-library/react-native'; import { act } from 'react-test-renderer'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import AnimatedFAB from '../FAB/AnimatedFAB'; const styles = StyleSheet.create({ background: { - backgroundColor: MD3Colors.tertiary50, + backgroundColor: Colors.tertiary50, }, }); diff --git a/src/components/__tests__/Appbar/Appbar.test.tsx b/src/components/__tests__/Appbar/Appbar.test.tsx index a80a2bb4ee..e2d061908f 100644 --- a/src/components/__tests__/Appbar/Appbar.test.tsx +++ b/src/components/__tests__/Appbar/Appbar.test.tsx @@ -5,7 +5,7 @@ import { act, render } from '@testing-library/react-native'; import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock'; import { getTheme } from '../../../core/theming'; -import { tokens } from '../../../styles/themes/v3/tokens'; +import { tokens } from '../../../styles/themes/tokens'; import Appbar from '../../Appbar'; import { getAppbarBackgroundColor, diff --git a/src/components/__tests__/Avatar.test.tsx b/src/components/__tests__/Avatar.test.tsx index 7e7acd9563..99e7776aa9 100644 --- a/src/components/__tests__/Avatar.test.tsx +++ b/src/components/__tests__/Avatar.test.tsx @@ -3,12 +3,12 @@ import { StyleSheet } from 'react-native'; import { fireEvent, render } from '@testing-library/react-native'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import * as Avatar from '../Avatar/Avatar'; const styles = StyleSheet.create({ bgColor: { - backgroundColor: MD3Colors.error50, + backgroundColor: Colors.error50, }, }); diff --git a/src/components/__tests__/Badge.test.tsx b/src/components/__tests__/Badge.test.tsx index 7366d1ff47..f379eb81a2 100644 --- a/src/components/__tests__/Badge.test.tsx +++ b/src/components/__tests__/Badge.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { render } from '@testing-library/react-native'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import Badge from '../Badge'; it('renders badge', () => { @@ -35,7 +35,7 @@ it('renders badge as hidden', () => { it('renders badge in different color', () => { const tree = render( - 3 + 3 ).toJSON(); expect(tree).toMatchSnapshot(); diff --git a/src/components/__tests__/BottomNavigation.test.tsx b/src/components/__tests__/BottomNavigation.test.tsx index 8cf7638f5a..755ffe1d07 100644 --- a/src/components/__tests__/BottomNavigation.test.tsx +++ b/src/components/__tests__/BottomNavigation.test.tsx @@ -4,7 +4,7 @@ import { Animated, Easing, Platform, StyleSheet } from 'react-native'; import { act, fireEvent, render } from '@testing-library/react-native'; import { getTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import BottomNavigation from '../BottomNavigation/BottomNavigation'; import BottomNavigationRouteScreen from '../BottomNavigation/BottomNavigationRouteScreen'; import { @@ -16,7 +16,7 @@ import Icon from '../Icon'; const styles = StyleSheet.create({ backgroundColor: { - backgroundColor: MD3Colors.error30, + backgroundColor: Colors.error30, }, }); @@ -376,7 +376,7 @@ it('renders custom background color passed to barStyle property', () => { ); const wrapper = getByTestId('bottom-navigation-bar-content'); - expect(wrapper).toHaveStyle({ backgroundColor: MD3Colors.error30 }); + expect(wrapper).toHaveStyle({ backgroundColor: Colors.error30 }); }); it('renders a single tab', () => { @@ -463,7 +463,7 @@ describe('getActiveTintColor', () => { it.each` activeColor | expected ${'#FBF7DB'} | ${'#FBF7DB'} - ${undefined} | ${MD3Colors.secondary10} + ${undefined} | ${Colors.secondary10} `( 'returns $expected when activeColor: $activeColor', ({ activeColor, expected }) => { @@ -478,7 +478,7 @@ describe('getInactiveTintColor', () => { it.each` inactiveColor | expected ${'#853D4B'} | ${'#853D4B'} - ${undefined} | ${MD3Colors.neutralVariant30} + ${undefined} | ${Colors.neutralVariant30} `( 'returns $expected when inactiveColor: $inactiveColor', ({ inactiveColor, expected }) => { @@ -497,8 +497,8 @@ describe('getLabelColor', () => { tintColor | focused | expected ${'#FBF7DB'} | ${true} | ${'#FBF7DB'} ${'#853D4B'} | ${true} | ${'#853D4B'} - ${undefined} | ${true} | ${MD3Colors.neutral10} - ${undefined} | ${false} | ${MD3Colors.neutralVariant30} + ${undefined} | ${true} | ${Colors.neutral10} + ${undefined} | ${false} | ${Colors.neutralVariant30} `( 'returns $expected when tintColor: $tintColor, focused: $focused', ({ tintColor, focused, expected }) => { diff --git a/src/components/__tests__/Button.test.tsx b/src/components/__tests__/Button.test.tsx index f3c8191870..abe901a619 100644 --- a/src/components/__tests__/Button.test.tsx +++ b/src/components/__tests__/Button.test.tsx @@ -4,7 +4,7 @@ import { Animated, StyleSheet } from 'react-native'; import { act, fireEvent, render } from '@testing-library/react-native'; import { getTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import Button from '../Button/Button'; import { getButtonColors } from '../Button/utils'; @@ -105,7 +105,7 @@ it('renders active button if only onLongPress handler is passed', () => { it('renders button with color', () => { const tree = render( - + ).toJSON(); expect(tree).toMatchSnapshot(); @@ -113,7 +113,7 @@ it('renders button with color', () => { it('renders button with button color', () => { const tree = render( - + ).toJSON(); expect(tree).toMatchSnapshot(); @@ -511,7 +511,7 @@ describe('getButtonColors - text color', () => { dark: true, }) ).toMatchObject({ - textColor: MD3Colors.primary100, + textColor: Colors.primary100, }); }) ); diff --git a/src/components/__tests__/Card/Card.test.tsx b/src/components/__tests__/Card/Card.test.tsx index a7dc736c62..d39434cb9f 100644 --- a/src/components/__tests__/Card/Card.test.tsx +++ b/src/components/__tests__/Card/Card.test.tsx @@ -4,7 +4,7 @@ import { Animated, StyleSheet, Text } from 'react-native'; import { act, render } from '@testing-library/react-native'; import { getTheme } from '../../../core/theming'; -import { MD3Colors } from '../../../styles/themes/v3/tokens'; +import { Colors } from '../../../styles/themes/tokens'; import Button from '../../Button/Button'; import Card from '../../Card/Card'; import { getCardColors, getCardCoverStyle } from '../../Card/utils'; @@ -53,14 +53,14 @@ describe('Card', () => { {null} ); expect(getByLabelText('card')).toHaveStyle({ - borderColor: MD3Colors.error50, + borderColor: Colors.error50, }); }); diff --git a/src/components/__tests__/IconButton.test.tsx b/src/components/__tests__/IconButton.test.tsx index 48961548fc..bea2bb27a4 100644 --- a/src/components/__tests__/IconButton.test.tsx +++ b/src/components/__tests__/IconButton.test.tsx @@ -5,7 +5,7 @@ import { act, render } from '@testing-library/react-native'; import color from 'color'; import { getTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import IconButton from '../IconButton/IconButton'; import { getIconButtonColor } from '../IconButton/utils'; @@ -26,7 +26,7 @@ it('renders icon button by default', () => { it('renders icon button with color', () => { const tree = render( - + ).toJSON(); expect(tree).toMatchSnapshot(); diff --git a/src/components/__tests__/ListAccordion.test.tsx b/src/components/__tests__/ListAccordion.test.tsx index b99d383636..31e0e7b765 100644 --- a/src/components/__tests__/ListAccordion.test.tsx +++ b/src/components/__tests__/ListAccordion.test.tsx @@ -5,7 +5,7 @@ import { render } from '@testing-library/react-native'; import color from 'color'; import { getTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import ListAccordion from '../List/ListAccordion'; import ListAccordionGroup from '../List/ListAccordionGroup'; import ListIcon from '../List/ListIcon'; @@ -14,7 +14,7 @@ import { getAccordionColors } from '../List/utils'; const styles = StyleSheet.create({ coloring: { - color: MD3Colors.error50, + color: Colors.error50, }, }); diff --git a/src/components/__tests__/ListItem.test.tsx b/src/components/__tests__/ListItem.test.tsx index 507b3179d6..7529eae8f2 100644 --- a/src/components/__tests__/ListItem.test.tsx +++ b/src/components/__tests__/ListItem.test.tsx @@ -4,7 +4,7 @@ import { Text, View } from 'react-native'; import { fireEvent, render } from '@testing-library/react-native'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import Chip from '../Chip/Chip'; import IconButton from '../IconButton/IconButton'; import ListIcon from '../List/ListIcon'; @@ -15,7 +15,7 @@ const styles = StyleSheet.create({ fontSize: 20, }, description: { - color: MD3Colors.error50, + color: Colors.error50, }, content: { paddingLeft: 0, diff --git a/src/components/__tests__/ListSection.test.tsx b/src/components/__tests__/ListSection.test.tsx index 4a21b1b367..ab737073d8 100644 --- a/src/components/__tests__/ListSection.test.tsx +++ b/src/components/__tests__/ListSection.test.tsx @@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native'; import { render } from '@testing-library/react-native'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import ListIcon from '../List/ListIcon'; import ListItem from '../List/ListItem'; import ListSection from '../List/ListSection'; @@ -11,7 +11,7 @@ import ListSubheader from '../List/ListSubheader'; const styles = StyleSheet.create({ itemColor: { - color: MD3Colors.error50, + color: Colors.error50, }, }); diff --git a/src/components/__tests__/Menu.test.tsx b/src/components/__tests__/Menu.test.tsx index 2ba63111ee..4558919b95 100644 --- a/src/components/__tests__/Menu.test.tsx +++ b/src/components/__tests__/Menu.test.tsx @@ -4,7 +4,7 @@ import { Animated, StyleSheet, View } from 'react-native'; import { act, render, screen, waitFor } from '@testing-library/react-native'; import { getTheme } from '../../core/theming'; -import { MD3Elevation } from '../../types'; +import { Elevation } from '../../types'; import Button from '../Button/Button'; import Menu, { ELEVATION_LEVELS_MAP } from '../Menu/Menu'; import Portal from '../Portal/Portal'; @@ -68,7 +68,7 @@ it('renders menu with content styles', () => { expect(tree).toMatchSnapshot(); }); -([0, 1, 2, 3, 4, 5] as MD3Elevation[]).forEach((elevation) => +([0, 1, 2, 3, 4, 5] as Elevation[]).forEach((elevation) => it(`renders menu with background color based on elevation value = ${elevation}`, () => { const { colors: { elevation: elevationColors }, diff --git a/src/components/__tests__/Modal.test.tsx b/src/components/__tests__/Modal.test.tsx index 96502f8550..fa9a3279ff 100644 --- a/src/components/__tests__/Modal.test.tsx +++ b/src/components/__tests__/Modal.test.tsx @@ -8,7 +8,7 @@ import { import { act, fireEvent, render } from '@testing-library/react-native'; -import { MD3LightTheme } from '../../styles/themes'; +import { LightTheme } from '../../styles/themes'; import Modal from '../Modal'; interface BackHandlerStatic extends RNBackHandlerStatic { @@ -60,7 +60,7 @@ describe('Modal', () => { ); expect(getByTestId('modal-backdrop')).toHaveStyle({ - backgroundColor: MD3LightTheme.colors.backdrop, + backgroundColor: LightTheme.colors.backdrop, }); }); diff --git a/src/components/__tests__/Snackbar.test.tsx b/src/components/__tests__/Snackbar.test.tsx index 4ef9e2f337..953c52cdc2 100644 --- a/src/components/__tests__/Snackbar.test.tsx +++ b/src/components/__tests__/Snackbar.test.tsx @@ -3,7 +3,7 @@ import { Animated, StyleSheet, Text, View } from 'react-native'; import { act, render } from '@testing-library/react-native'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import Snackbar from '../Snackbar'; const styles = StyleSheet.create({ @@ -12,11 +12,11 @@ const styles = StyleSheet.create({ alignItems: 'center', }, iconView: { - backgroundColor: MD3Colors.error20, + backgroundColor: Colors.error20, padding: 15, }, text: { - color: MD3Colors.primary100, + color: Colors.primary100, marginLeft: 10, flexWrap: 'wrap', flexShrink: 1, diff --git a/src/components/__tests__/Switch.test.tsx b/src/components/__tests__/Switch.test.tsx index 4b42e82124..add1a87c96 100644 --- a/src/components/__tests__/Switch.test.tsx +++ b/src/components/__tests__/Switch.test.tsx @@ -5,7 +5,7 @@ import { render } from '@testing-library/react-native'; import color from 'color'; import { getTheme } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import Switch from '../Switch/Switch'; import { white, @@ -36,7 +36,7 @@ it('renders disabled switch', () => { }); it('renders switch with color', () => { - const tree = render().toJSON(); + const tree = render().toJSON(); expect(tree).toMatchSnapshot(); }); diff --git a/src/components/__tests__/TextInput.test.tsx b/src/components/__tests__/TextInput.test.tsx index 0e91b4da95..78b21bf5de 100644 --- a/src/components/__tests__/TextInput.test.tsx +++ b/src/components/__tests__/TextInput.test.tsx @@ -6,7 +6,7 @@ import { fireEvent, render } from '@testing-library/react-native'; import color from 'color'; import { DefaultTheme, getTheme, ThemeProvider } from '../../core/theming'; -import { MD3Colors } from '../../styles/themes/v3/tokens'; +import { Colors } from '../../styles/themes/tokens'; import { getFlatInputColors, getOutlinedInputColors, @@ -15,7 +15,7 @@ import TextInput, { Props } from '../TextInput/TextInput'; const style = StyleSheet.create({ inputStyle: { - color: MD3Colors.error50, + color: Colors.error50, }, centered: { textAlign: 'center', @@ -119,7 +119,7 @@ it('correctly applies cursorColor prop', () => { label="Flat input" placeholder="Type something" value={'Some test value'} - cursorColor={MD3Colors.error50} + cursorColor={Colors.error50} /> ); diff --git a/src/components/__tests__/ToggleButton.test.tsx b/src/components/__tests__/ToggleButton.test.tsx index a0e2bbafcb..35b1d63484 100644 --- a/src/components/__tests__/ToggleButton.test.tsx +++ b/src/components/__tests__/ToggleButton.test.tsx @@ -5,7 +5,7 @@ import { act, render } from '@testing-library/react-native'; import color from 'color'; import { getTheme } from '../../core/theming'; -import { tokens } from '../../styles/themes/v3/tokens'; +import { tokens } from '../../styles/themes/tokens'; import ToggleButton from '../ToggleButton'; import { getToggleButtonColor } from '../ToggleButton/utils'; diff --git a/src/components/__tests__/Typography/Text.test.tsx b/src/components/__tests__/Typography/Text.test.tsx index 2560920322..0e0bb64303 100644 --- a/src/components/__tests__/Typography/Text.test.tsx +++ b/src/components/__tests__/Typography/Text.test.tsx @@ -4,8 +4,8 @@ import { render } from '@testing-library/react-native'; import PaperProvider from '../../../core/PaperProvider'; import configureFonts from '../../../styles/fonts'; -import { MD3LightTheme } from '../../../styles/themes'; -import { tokens } from '../../../styles/themes/v3/tokens'; +import { LightTheme } from '../../../styles/themes'; +import { tokens } from '../../../styles/themes/tokens'; import Text, { customText } from '../../Typography/Text'; const content = 'Something rendered as a child content'; @@ -64,7 +64,7 @@ it('renders v3 Text component with custom variant correctly', () => { } as const; const theme = { - ...MD3LightTheme, + ...LightTheme, fonts: configureFonts({ config: fontConfig }), }; const Text = customText<'customVariant'>(); @@ -86,9 +86,7 @@ it("nested text with variant should override parent's variant", () => { ); - expect(getByTestId('parent-text')).toHaveStyle( - MD3LightTheme.fonts.displayLarge - ); + expect(getByTestId('parent-text')).toHaveStyle(LightTheme.fonts.displayLarge); }); it("nested non-text component should not override parent's variant", () => { @@ -100,9 +98,7 @@ it("nested non-text component should not override parent's variant", () => { ); - expect(getByTestId('parent-text')).toHaveStyle( - MD3LightTheme.fonts.displayLarge - ); + expect(getByTestId('parent-text')).toHaveStyle(LightTheme.fonts.displayLarge); }); it("nested text without variant, but with styles, should override parent's styles", () => { diff --git a/src/core/__tests__/PaperProvider.test.tsx b/src/core/__tests__/PaperProvider.test.tsx index 84bd950eca..1835ae9dd8 100644 --- a/src/core/__tests__/PaperProvider.test.tsx +++ b/src/core/__tests__/PaperProvider.test.tsx @@ -8,7 +8,7 @@ import { import { render, act } from '@testing-library/react-native'; -import { MD3LightTheme, MD3DarkTheme } from '../../styles/themes'; +import { LightTheme, DarkTheme } from '../../styles/themes'; import type { ThemeProp } from '../../types'; import PaperProvider from '../PaperProvider'; import { useTheme } from '../theming'; @@ -111,24 +111,24 @@ describe('PaperProvider', () => { mockAppearance(); const { getByTestId } = render(createProvider()); expect(getByTestId('provider-child-view').props.theme).toStrictEqual( - MD3LightTheme + LightTheme ); act(() => Appearance.__internalListeners[0]({ colorScheme: 'dark' })); expect(getByTestId('provider-child-view').props.theme).toStrictEqual( - MD3DarkTheme + DarkTheme ); }); it('handles overriding animation with the custom one', () => { const { getByTestId } = render( createProvider({ - ...MD3LightTheme, + ...LightTheme, animation: { defaultAnimationDuration: 250 }, }) ); expect(getByTestId('provider-child-view').props.theme).toStrictEqual({ - ...MD3LightTheme, + ...LightTheme, animation: { scale: 1, defaultAnimationDuration: 250 }, }); }); @@ -150,18 +150,18 @@ describe('PaperProvider', () => { getByTestId('provider-child-view').props.theme.animation.scale ).toStrictEqual(0); - rerender(createProvider(MD3LightTheme)); + rerender(createProvider(LightTheme)); expect(AccessibilityInfo.removeEventListener).toHaveBeenCalled(); }); it('should not set AccessibilityInfo listeners, if there is a theme', async () => { mockAppearance(); - const { getByTestId } = render(createProvider(MD3DarkTheme)); + const { getByTestId } = render(createProvider(DarkTheme)); expect(AccessibilityInfo.addEventListener).not.toHaveBeenCalled(); expect(AccessibilityInfo.removeEventListener).not.toHaveBeenCalled(); expect(getByTestId('provider-child-view').props.theme).toStrictEqual( - MD3DarkTheme + DarkTheme ); }); @@ -172,18 +172,18 @@ describe('PaperProvider', () => { expect(Appearance.addChangeListener).toHaveBeenCalled(); act(() => Appearance.__internalListeners[0]({ colorScheme: 'dark' })); expect(getByTestId('provider-child-view').props.theme).toStrictEqual( - MD3DarkTheme + DarkTheme ); }); it('should not set Appearance listeners, if the theme is passed', async () => { mockAppearance(); - const { getByTestId } = render(createProvider(MD3LightTheme)); + const { getByTestId } = render(createProvider(LightTheme)); expect(Appearance.addChangeListener).not.toHaveBeenCalled(); expect(Appearance.removeChangeListener).not.toHaveBeenCalled(); expect(getByTestId('provider-child-view').props.theme).toStrictEqual( - MD3LightTheme + LightTheme ); }); @@ -194,14 +194,14 @@ describe('PaperProvider', () => { const { getByTestId } = render(createProvider()); expect(Appearance).toEqual(null); expect(getByTestId('provider-child-view').props.theme).toStrictEqual( - MD3LightTheme + LightTheme ); }); it.each` - label | theme | colorScheme - ${'default theme'} | ${MD3LightTheme} | ${'light'} - ${'dark theme'} | ${MD3DarkTheme} | ${'dark'} + label | theme | colorScheme + ${'default theme'} | ${LightTheme} | ${'light'} + ${'dark theme'} | ${DarkTheme} | ${'dark'} `( 'provides $label for $colorScheme color scheme', async ({ theme, colorScheme }) => { @@ -217,9 +217,9 @@ describe('PaperProvider', () => { it('uses provided custom theme', async () => { mockAppearance(); const customTheme = { - ...MD3LightTheme, + ...LightTheme, colors: { - ...MD3LightTheme.colors, + ...LightTheme.colors, primary: 'tomato', accent: 'yellow', }, @@ -232,8 +232,8 @@ describe('PaperProvider', () => { it.each` colorScheme | expectedTheme - ${'light'} | ${MD3LightTheme} - ${'dark'} | ${MD3DarkTheme} + ${'light'} | ${LightTheme} + ${'dark'} | ${DarkTheme} `( 'uses correct theme, $colorScheme mode, version $version', async ({ colorScheme, expectedTheme }) => { diff --git a/src/core/__tests__/theming.test.tsx b/src/core/__tests__/theming.test.tsx index 7b069cd482..f00951e96c 100644 --- a/src/core/__tests__/theming.test.tsx +++ b/src/core/__tests__/theming.test.tsx @@ -1,4 +1,7 @@ -import { MD3DarkTheme, MD3LightTheme } from '../../styles/themes'; +import { + DarkTheme as PaperDarkTheme, + LightTheme as PaperLightTheme, +} from '../../styles/themes'; import { adaptNavigationTheme } from '../theming'; const NavigationLightTheme = { @@ -40,17 +43,17 @@ const NavigationCustomLightTheme = { }; const AppCustomLightTheme = { - ...MD3LightTheme, + ...PaperLightTheme, colors: { - ...MD3LightTheme.colors, + ...PaperLightTheme.colors, primary: 'purple', }, }; const AppCustomDarkTheme = { - ...MD3DarkTheme, + ...PaperDarkTheme, colors: { - ...MD3DarkTheme.colors, + ...PaperDarkTheme.colors, primary: 'orchid', }, }; @@ -89,24 +92,24 @@ describe('adaptNavigationTheme', () => { ...NavigationLightTheme, colors: { ...NavigationLightTheme.colors, - primary: MD3LightTheme.colors.primary, - background: MD3LightTheme.colors.background, - card: MD3LightTheme.colors.elevation.level2, - text: MD3LightTheme.colors.onSurface, - border: MD3LightTheme.colors.outline, - notification: MD3LightTheme.colors.error, + primary: PaperLightTheme.colors.primary, + background: PaperLightTheme.colors.background, + card: PaperLightTheme.colors.elevation.level2, + text: PaperLightTheme.colors.onSurface, + border: PaperLightTheme.colors.outline, + notification: PaperLightTheme.colors.error, }, }, DarkTheme: { ...NavigationDarkTheme, colors: { ...NavigationDarkTheme.colors, - primary: MD3DarkTheme.colors.primary, - background: MD3DarkTheme.colors.background, - card: MD3DarkTheme.colors.elevation.level2, - text: MD3DarkTheme.colors.onSurface, - border: MD3DarkTheme.colors.outline, - notification: MD3DarkTheme.colors.error, + primary: PaperDarkTheme.colors.primary, + background: PaperDarkTheme.colors.background, + card: PaperDarkTheme.colors.elevation.level2, + text: PaperDarkTheme.colors.onSurface, + border: PaperDarkTheme.colors.outline, + notification: PaperDarkTheme.colors.error, }, }, }); @@ -117,7 +120,7 @@ describe('adaptNavigationTheme', () => { reactNavigationLight: NavigationLightTheme, }); - const { colors } = MD3LightTheme; + const { colors } = PaperLightTheme; expect(LightTheme).toMatchObject({ ...NavigationLightTheme, @@ -138,7 +141,7 @@ describe('adaptNavigationTheme', () => { reactNavigationDark: NavigationDarkTheme, }); - const { colors } = MD3DarkTheme; + const { colors } = PaperDarkTheme; expect(DarkTheme).toMatchObject({ ...NavigationDarkTheme, @@ -159,7 +162,7 @@ describe('adaptNavigationTheme', () => { reactNavigationLight: NavigationCustomLightTheme, }); - const { colors } = MD3LightTheme; + const { colors } = PaperLightTheme; expect(LightTheme).toMatchObject({ ...NavigationCustomLightTheme, @@ -230,33 +233,33 @@ describe('adaptNavigationTheme', () => { ...NavigationThemeWithFonts, colors: { ...NavigationThemeWithFonts.colors, - primary: MD3LightTheme.colors.primary, - background: MD3LightTheme.colors.background, - card: MD3LightTheme.colors.elevation.level2, - text: MD3LightTheme.colors.onSurface, - border: MD3LightTheme.colors.outline, - notification: MD3LightTheme.colors.error, + primary: PaperLightTheme.colors.primary, + background: PaperLightTheme.colors.background, + card: PaperLightTheme.colors.elevation.level2, + text: PaperLightTheme.colors.onSurface, + border: PaperLightTheme.colors.outline, + notification: PaperLightTheme.colors.error, }, fonts: { regular: { - fontFamily: MD3LightTheme.fonts.bodyMedium.fontFamily, - fontWeight: MD3LightTheme.fonts.bodyMedium.fontWeight, - letterSpacing: MD3LightTheme.fonts.bodyMedium.letterSpacing, + fontFamily: PaperLightTheme.fonts.bodyMedium.fontFamily, + fontWeight: PaperLightTheme.fonts.bodyMedium.fontWeight, + letterSpacing: PaperLightTheme.fonts.bodyMedium.letterSpacing, }, medium: { - fontFamily: MD3LightTheme.fonts.titleMedium.fontFamily, - fontWeight: MD3LightTheme.fonts.titleMedium.fontWeight, - letterSpacing: MD3LightTheme.fonts.titleMedium.letterSpacing, + fontFamily: PaperLightTheme.fonts.titleMedium.fontFamily, + fontWeight: PaperLightTheme.fonts.titleMedium.fontWeight, + letterSpacing: PaperLightTheme.fonts.titleMedium.letterSpacing, }, bold: { - fontFamily: MD3LightTheme.fonts.headlineSmall.fontFamily, - fontWeight: MD3LightTheme.fonts.headlineSmall.fontWeight, - letterSpacing: MD3LightTheme.fonts.headlineSmall.letterSpacing, + fontFamily: PaperLightTheme.fonts.headlineSmall.fontFamily, + fontWeight: PaperLightTheme.fonts.headlineSmall.fontWeight, + letterSpacing: PaperLightTheme.fonts.headlineSmall.letterSpacing, }, heavy: { - fontFamily: MD3LightTheme.fonts.headlineLarge.fontFamily, - fontWeight: MD3LightTheme.fonts.headlineLarge.fontWeight, - letterSpacing: MD3LightTheme.fonts.headlineLarge.letterSpacing, + fontFamily: PaperLightTheme.fonts.headlineLarge.fontFamily, + fontWeight: PaperLightTheme.fonts.headlineLarge.fontWeight, + letterSpacing: PaperLightTheme.fonts.headlineLarge.letterSpacing, }, }, }); diff --git a/src/core/theming.tsx b/src/core/theming.tsx index fe4c67a0bf..0b77390992 100644 --- a/src/core/theming.tsx +++ b/src/core/theming.tsx @@ -1,25 +1,19 @@ import type { ComponentType } from 'react'; import { $DeepPartial, createTheming } from '@callstack/react-theme-provider'; -import color from 'color'; -import { MD3DarkTheme, MD3LightTheme } from '../styles/themes'; -import type { - InternalTheme, - MD3Theme, - MD3AndroidColors, - NavigationTheme, -} from '../types'; +import { DarkTheme, LightTheme } from '../styles/themes'; +import type { InternalTheme, Theme, NavigationTheme } from '../types'; -export const DefaultTheme = MD3LightTheme; +export const DefaultTheme = LightTheme; export const { ThemeProvider, withTheme, useTheme: useAppTheme, -} = createTheming(MD3LightTheme); +} = createTheming(LightTheme); -export function useTheme(overrides?: $DeepPartial) { +export function useTheme(overrides?: $DeepPartial) { return useAppTheme(overrides); } @@ -32,8 +26,8 @@ export const withInternalTheme = ( ) => withTheme(WrappedComponent); export const defaultThemesByVersion = { - light: MD3LightTheme, - dark: MD3DarkTheme, + light: LightTheme, + dark: DarkTheme, }; export const getTheme = ( @@ -47,14 +41,14 @@ export const getTheme = ( // eslint-disable-next-line no-redeclare export function adaptNavigationTheme(themes: { reactNavigationLight: T; - materialLight?: MD3Theme; + materialLight?: Theme; }): { LightTheme: NavigationTheme; }; // eslint-disable-next-line no-redeclare export function adaptNavigationTheme(themes: { reactNavigationDark: T; - materialDark?: MD3Theme; + materialDark?: Theme; }): { DarkTheme: NavigationTheme; }; @@ -65,8 +59,8 @@ export function adaptNavigationTheme< >(themes: { reactNavigationLight: TLight; reactNavigationDark: TDark; - materialLight?: MD3Theme; - materialDark?: MD3Theme; + materialLight?: Theme; + materialDark?: Theme; }): { LightTheme: TLight; DarkTheme: TDark }; // eslint-disable-next-line no-redeclare export function adaptNavigationTheme(themes: any) { @@ -77,19 +71,19 @@ export function adaptNavigationTheme(themes: any) { materialDark, } = themes; - const MD3Themes = { - light: materialLight || MD3LightTheme, - dark: materialDark || MD3DarkTheme, + const Theme = { + light: materialLight || LightTheme, + dark: materialDark || DarkTheme, }; const result: { LightTheme?: any; DarkTheme?: any } = {}; if (reactNavigationLight) { - result.LightTheme = getAdaptedTheme(reactNavigationLight, MD3Themes.light); + result.LightTheme = getAdaptedTheme(reactNavigationLight, Theme.light); } if (reactNavigationDark) { - result.DarkTheme = getAdaptedTheme(reactNavigationDark, MD3Themes.dark); + result.DarkTheme = getAdaptedTheme(reactNavigationDark, Theme.dark); } return result; @@ -97,7 +91,7 @@ export function adaptNavigationTheme(themes: any) { const getAdaptedTheme = ( theme: T, - materialTheme: MD3Theme + materialTheme: Theme ): T => { const base = { ...theme, @@ -142,19 +136,3 @@ const getAdaptedTheme = ( return base; }; - -export const getDynamicThemeElevations = (scheme: MD3AndroidColors) => { - const elevationValues = ['transparent', 0.05, 0.08, 0.11, 0.12, 0.14]; - return elevationValues.reduce((elevations, elevationValue, index) => { - return { - ...elevations, - [`level${index}`]: - index === 0 - ? elevationValue - : color(scheme.surface) - .mix(color(scheme.primary), elevationValue as number) - .rgb() - .string(), - }; - }, {}); -}; diff --git a/src/index.tsx b/src/index.tsx index 8bdc5009e0..b3949e865d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,4 +1,4 @@ -export { MD3Colors } from './styles/themes/v3/tokens'; +export { Colors } from './styles/themes/tokens'; export { useTheme, @@ -145,9 +145,4 @@ export type { MaterialBottomTabScreenProps, } from './react-navigation'; -export type { - MD3Theme, - ThemeBase, - MD3Elevation, - MD3TypescaleKey, -} from './types'; +export type { Theme, ThemeBase, Elevation, TypescaleKey } from './types'; diff --git a/src/styles/__tests__/fonts.test.js b/src/styles/__tests__/fonts.test.js index 5d1108767b..41c55a6e85 100644 --- a/src/styles/__tests__/fonts.test.js +++ b/src/styles/__tests__/fonts.test.js @@ -1,5 +1,5 @@ import configureFonts from '../fonts'; -import { typescale } from '../themes/v3/tokens'; +import { typescale } from '../themes/tokens'; const customFontV3 = { displayLarge: { diff --git a/src/styles/fonts.tsx b/src/styles/fonts.tsx index 8d26388853..03cf4f247e 100644 --- a/src/styles/fonts.tsx +++ b/src/styles/fonts.tsx @@ -1,18 +1,18 @@ -import type { MD3Type, MD3Typescale, MD3TypescaleKey } from '../types'; -import { typescale } from './themes/v3/tokens'; +import type { TypescaleConfig, Typescale, TypescaleKey } from '../types'; +import { typescale } from './themes/tokens'; -type MD3FontsConfig = +type FontsConfig = | { - [key in MD3TypescaleKey]: Partial; + [key in TypescaleKey]: Partial; } | { - [key: string]: MD3Type; + [key: string]: TypescaleConfig; } - | Partial; + | Partial; -function configureV3Fonts( - config: MD3FontsConfig -): MD3Typescale | (MD3Typescale & { [key: string]: MD3Type }) { +function mergeFontsConfig( + config: FontsConfig +): Typescale | (Typescale & { [key: string]: TypescaleConfig }) { if (!config) { return typescale; } @@ -27,7 +27,7 @@ function configureV3Fonts( variantName, { ...variantProperties, ...config }, ]) - ) as MD3Typescale; + ) as Typescale; } return Object.assign( @@ -35,7 +35,7 @@ function configureV3Fonts( typescale, ...Object.entries(config).map(([variantName, variantProperties]) => ({ [variantName]: { - ...typescale[variantName as MD3TypescaleKey], + ...typescale[variantName as TypescaleKey], ...variantProperties, }, })) @@ -44,18 +44,18 @@ function configureV3Fonts( // eslint-disable-next-line no-redeclare export default function configureFonts(params?: { - config?: Partial; -}): MD3Typescale; + config?: Partial; +}): Typescale; // eslint-disable-next-line no-redeclare export default function configureFonts(params?: { - config?: Partial>>; -}): MD3Typescale; + config?: Partial>>; +}): Typescale; // eslint-disable-next-line no-redeclare export default function configureFonts(params: { - config: Record; -}): MD3Typescale & { [key: string]: MD3Type }; + config: Record; +}): Typescale & { [key: string]: TypescaleConfig }; // eslint-disable-next-line no-redeclare export default function configureFonts(params?: any) { const { config } = params || {}; - return configureV3Fonts(config); + return mergeFontsConfig(config); } diff --git a/src/styles/shadow.tsx b/src/styles/shadow.tsx index 57cc3612de..5476ccdb76 100644 --- a/src/styles/shadow.tsx +++ b/src/styles/shadow.tsx @@ -1,22 +1,18 @@ import { Animated } from 'react-native'; -import { MD3Colors } from './themes/v3/tokens'; +import { Colors } from './themes/tokens'; -const MD3_SHADOW_OPACITY = 0.3; -const MD3_SHADOW_COLOR = MD3Colors.primary0; +const SHADOW_OPACITY = 0.3; +const SHADOW_COLOR = Colors.primary0; export default function shadow(elevation: number | Animated.Value = 0) { - return v3Shadow(elevation); -} - -function v3Shadow(elevation: number | Animated.Value = 0) { const inputRange = [0, 1, 2, 3, 4, 5]; const shadowHeight = [0, 1, 2, 4, 6, 8]; const shadowRadius = [0, 3, 6, 8, 10, 12]; if (elevation instanceof Animated.Value) { return { - shadowColor: MD3_SHADOW_COLOR, + shadowColor: SHADOW_COLOR, shadowOffset: { width: new Animated.Value(0), height: elevation.interpolate({ @@ -26,7 +22,7 @@ function v3Shadow(elevation: number | Animated.Value = 0) { }, shadowOpacity: elevation.interpolate({ inputRange: [0, 1], - outputRange: [0, MD3_SHADOW_OPACITY], + outputRange: [0, SHADOW_OPACITY], extrapolate: 'clamp', }), shadowRadius: elevation.interpolate({ @@ -36,8 +32,8 @@ function v3Shadow(elevation: number | Animated.Value = 0) { }; } else { return { - shadowColor: MD3_SHADOW_COLOR, - shadowOpacity: elevation ? MD3_SHADOW_OPACITY : 0, + shadowColor: SHADOW_COLOR, + shadowOpacity: elevation ? SHADOW_OPACITY : 0, shadowOffset: { width: 0, height: shadowHeight[elevation], diff --git a/src/styles/themes/v3/DarkTheme.tsx b/src/styles/themes/DarkTheme.tsx similarity index 88% rename from src/styles/themes/v3/DarkTheme.tsx rename to src/styles/themes/DarkTheme.tsx index 246925859c..f7e52634f1 100644 --- a/src/styles/themes/v3/DarkTheme.tsx +++ b/src/styles/themes/DarkTheme.tsx @@ -1,13 +1,13 @@ import color from 'color'; -import { MD3LightTheme } from './LightTheme'; -import { MD3Colors, tokens } from './tokens'; -import type { MD3Theme } from '../../../types'; +import { LightTheme } from './LightTheme'; +import { Colors, tokens } from './tokens'; +import type { Theme } from '../../types'; const { palette, opacity } = tokens.md.ref; -export const MD3DarkTheme: MD3Theme = { - ...MD3LightTheme, +export const DarkTheme: Theme = { + ...LightTheme, dark: true, mode: 'adaptive', colors: { @@ -48,7 +48,7 @@ export const MD3DarkTheme: MD3Theme = { inversePrimary: palette.primary40, shadow: palette.neutral0, scrim: palette.neutral0, - backdrop: color(MD3Colors.neutralVariant20).alpha(0.4).rgb().string(), + backdrop: color(Colors.neutralVariant20).alpha(0.4).rgb().string(), elevation: { level0: 'transparent', // Note: Color values with transparency cause RN to transfer shadows to children nodes diff --git a/src/styles/themes/v3/LightTheme.tsx b/src/styles/themes/LightTheme.tsx similarity index 89% rename from src/styles/themes/v3/LightTheme.tsx rename to src/styles/themes/LightTheme.tsx index 19ec23fcfc..56df4d3494 100644 --- a/src/styles/themes/v3/LightTheme.tsx +++ b/src/styles/themes/LightTheme.tsx @@ -1,12 +1,12 @@ import color from 'color'; -import { MD3Colors, tokens } from './tokens'; -import type { MD3Theme } from '../../../types'; -import configureFonts from '../../fonts'; +import { Colors, tokens } from './tokens'; +import type { Theme } from '../../types'; +import configureFonts from '../fonts'; const { palette, opacity } = tokens.md.ref; -export const MD3LightTheme: MD3Theme = { +export const LightTheme: Theme = { dark: false, roundness: 4, colors: { @@ -47,7 +47,7 @@ export const MD3LightTheme: MD3Theme = { inversePrimary: palette.primary80, shadow: palette.neutral0, scrim: palette.neutral0, - backdrop: color(MD3Colors.neutralVariant20).alpha(0.4).rgb().string(), + backdrop: color(Colors.neutralVariant20).alpha(0.4).rgb().string(), elevation: { level0: 'transparent', // Note: Color values with transparency cause RN to transfer shadows to children nodes diff --git a/src/styles/themes/index.ts b/src/styles/themes/index.ts index 39bcb6648c..26daa493ef 100644 --- a/src/styles/themes/index.ts +++ b/src/styles/themes/index.ts @@ -1,2 +1,2 @@ -export { MD3LightTheme } from './v3/LightTheme'; -export { MD3DarkTheme } from './v3/DarkTheme'; +export { LightTheme } from './LightTheme'; +export { DarkTheme } from './DarkTheme'; diff --git a/src/styles/themes/v3/tokens.tsx b/src/styles/themes/tokens.tsx similarity index 98% rename from src/styles/themes/v3/tokens.tsx rename to src/styles/themes/tokens.tsx index d008944d86..77902a8526 100644 --- a/src/styles/themes/v3/tokens.tsx +++ b/src/styles/themes/tokens.tsx @@ -1,6 +1,6 @@ import { Platform } from 'react-native'; -import type { Font } from '../../../types'; +import type { Font } from '../../types'; const ref = { palette: { @@ -227,4 +227,4 @@ export const tokens = { }, }; -export const MD3Colors = ref.palette; +export const Colors = ref.palette; diff --git a/src/types.tsx b/src/types.tsx index 24ad37883f..d257c3ec30 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -21,7 +21,7 @@ export type Font = { type Mode = 'adaptive' | 'exact'; -export type MD3Colors = { +export type Colors = { primary: string; primaryContainer: string; secondary: string; @@ -54,43 +54,9 @@ export type MD3Colors = { shadow: string; scrim: string; backdrop: string; - elevation: MD3ElevationColors; + elevation: ElevationColors; }; -export type MD3AndroidColors = { - primary: number; - primaryContainer: number; - secondary: number; - secondaryContainer: number; - tertiary: number; - tertiaryContainer: number; - surface: number; - surfaceVariant: number; - background: number; - error: number; - errorContainer: number; - onPrimary: number; - onPrimaryContainer: number; - onSecondary: number; - onSecondaryContainer: number; - onTertiary: number; - onTertiaryContainer: number; - onSurface: number; - onSurfaceVariant: number; - onError: number; - onErrorContainer: number; - onBackground: number; - outline: number; - outlineVariant: number; - inverseSurface: number; - inverseOnSurface: number; - inversePrimary: number; - shadow: number; - scrim: number; -}; - -export type MD3Palette = {}; - export type ThemeProp = $DeepPartial; export type ThemeBase = { @@ -103,15 +69,14 @@ export type ThemeBase = { }; }; -export type MD3Theme = ThemeBase & { - colors: MD3Colors; - fonts: MD3Typescale; +export type Theme = ThemeBase & { + colors: Colors; + fonts: Typescale; }; -export type InternalTheme = MD3Theme; +export type InternalTheme = Theme; -// MD3 types -export enum MD3TypescaleKey { +export enum TypescaleKey { displayLarge = 'displayLarge', displayMedium = 'displayMedium', displaySmall = 'displaySmall', @@ -133,7 +98,7 @@ export enum MD3TypescaleKey { bodySmall = 'bodySmall', } -export type MD3Type = { +export type TypescaleConfig = { fontFamily: string; letterSpacing: number; fontWeight: Font['fontWeight']; @@ -142,14 +107,14 @@ export type MD3Type = { fontStyle?: Font['fontStyle']; }; -export type MD3Typescale = +export type Typescale = | { - [key in MD3TypescaleKey]: MD3Type; + [key in TypescaleKey]: TypescaleConfig; } & { - ['default']: Omit; + ['default']: Omit; }; -export type MD3Elevation = 0 | 1 | 2 | 3 | 4 | 5; +export type Elevation = 0 | 1 | 2 | 3 | 4 | 5; export enum ElevationLevels { 'level0', @@ -160,7 +125,7 @@ export enum ElevationLevels { 'level5', } -export type MD3ElevationColors = { +export type ElevationColors = { [key in keyof typeof ElevationLevels]: string; };