Skip to content

Commit

Permalink
feat: export old colors as MD2Colors and new as MD3Colors (#3074)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak committed Jun 8, 2022
1 parent 329b775 commit 72b53fd
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 55 deletions.
4 changes: 2 additions & 2 deletions example/src/DrawerItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Switch,
TouchableRipple,
Text,
Colors,
MD2Colors,
useTheme,
} from 'react-native-paper';
import * as Updates from 'expo-updates';
Expand Down Expand Up @@ -73,7 +73,7 @@ const DrawerItems = ({
key={props.key}
theme={
props.key === 3
? { colors: { primary: Colors.tealA200 } }
? { colors: { primary: MD2Colors.tealA200 } }
: undefined
}
active={drawerItemIndex === index}
Expand Down
4 changes: 2 additions & 2 deletions example/src/Examples/ActivityIndicatorExample.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { ActivityIndicator, Colors, FAB } from 'react-native-paper';
import { ActivityIndicator, MD2Colors, FAB } from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';

const ActivityIndicatorExample = () => {
Expand Down Expand Up @@ -29,7 +29,7 @@ const ActivityIndicatorExample = () => {
</View>

<View style={styles.row}>
<ActivityIndicator animating={animating} color={Colors.red500} />
<ActivityIndicator animating={animating} color={MD2Colors.red500} />
</View>
</ScreenWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { View, StyleSheet, FlatList, Animated, Platform } from 'react-native';
import type { NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
import { Colors, useTheme, Avatar, Paragraph } from 'react-native-paper';
import { MD2Colors, useTheme, Avatar, Paragraph } from 'react-native-paper';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { animatedFABExampleData } from '../../../utils';
import CustomFAB from './CustomFAB';
Expand Down Expand Up @@ -42,7 +42,7 @@ const AnimatedFABExample = () => {
<Avatar.Text
style={[styles.avatar, { backgroundColor: item.bgColor }]}
label={item.initials}
color={Colors.white}
color={MD2Colors.white}
size={40}
/>
<View style={styles.itemTextContentContainer}>
Expand Down Expand Up @@ -75,7 +75,7 @@ const AnimatedFABExample = () => {

<Icon
name={item.favorite ? 'star' : 'star-outline'}
color={item.favorite ? Colors.orange500 : Colors.grey500}
color={item.favorite ? MD2Colors.orange500 : MD2Colors.grey500}
size={20}
onPress={() => setVisible(!visible)}
style={styles.icon}
Expand Down
4 changes: 2 additions & 2 deletions example/src/Examples/AnimatedFABExample/CustomFABControls.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { StyleSheet, View, FlatList } from 'react-native';
import { Colors, Paragraph, RadioButton } from 'react-native-paper';
import { MD2Colors, Paragraph, RadioButton } from 'react-native-paper';
import type {
AnimatedFABAnimateFrom,
AnimatedFABIconMode,
Expand Down Expand Up @@ -106,7 +106,7 @@ const styles = StyleSheet.create({
top: 0,
left: 0,
right: 0,
backgroundColor: Colors.white,
backgroundColor: MD2Colors.white,
paddingVertical: 12,
paddingHorizontal: 16,
},
Expand Down
10 changes: 5 additions & 5 deletions example/src/Examples/AvatarExample.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Avatar, List, Colors } from 'react-native-paper';
import { Avatar, List, MD2Colors } from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';

const AvatarExample = () => {
Expand All @@ -9,9 +9,9 @@ const AvatarExample = () => {
<List.Section title="Text">
<View style={styles.row}>
<Avatar.Text
style={[styles.avatar, { backgroundColor: Colors.yellow500 }]}
style={[styles.avatar, { backgroundColor: MD2Colors.yellow500 }]}
label="XD"
color={Colors.black}
color={MD2Colors.black}
/>
<Avatar.Text style={styles.avatar} label="XD" />
<Avatar.Text style={styles.avatar} label="XD" size={80} />
Expand All @@ -20,9 +20,9 @@ const AvatarExample = () => {
<List.Section title="Icon">
<View style={styles.row}>
<Avatar.Icon
style={[styles.avatar, { backgroundColor: Colors.yellow500 }]}
style={[styles.avatar, { backgroundColor: MD2Colors.yellow500 }]}
icon="folder"
color={Colors.black}
color={MD2Colors.black}
/>
<Avatar.Icon style={styles.avatar} icon="folder" />
<Avatar.Icon style={styles.avatar} icon="folder" size={80} />
Expand Down
4 changes: 2 additions & 2 deletions example/src/Examples/BadgeExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
List,
Paragraph,
Switch,
Colors,
MD2Colors,
} from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';

Expand Down Expand Up @@ -34,7 +34,7 @@ const BadgeExample = () => {
<IconButton icon="inbox" size={36} style={styles.button} />
<Badge
visible={visible}
style={[styles.badge, { backgroundColor: Colors.blue500 }]}
style={[styles.badge, { backgroundColor: MD2Colors.blue500 }]}
>
999+
</Badge>
Expand Down
4 changes: 2 additions & 2 deletions example/src/Examples/CheckboxExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { View, StyleSheet } from 'react-native';
import {
Paragraph,
Checkbox,
Colors,
MD2Colors,
TouchableRipple,
} from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';
Expand All @@ -29,7 +29,7 @@ const CheckboxExample = () => {
<Paragraph>Custom</Paragraph>
<View pointerEvents="none">
<Checkbox
color={Colors.blue500}
color={MD2Colors.blue500}
status={checkedCustom ? 'checked' : 'unchecked'}
/>
</View>
Expand Down
16 changes: 11 additions & 5 deletions example/src/Examples/Dialogs/DialogWithCustomColors.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as React from 'react';
import { Paragraph, Button, Portal, Dialog, Colors } from 'react-native-paper';
import {
Paragraph,
Button,
Portal,
Dialog,
MD2Colors,
} from 'react-native-paper';

const DialogWithCustomColors = ({
visible,
Expand All @@ -11,17 +17,17 @@ const DialogWithCustomColors = ({
<Portal>
<Dialog
onDismiss={close}
style={{ backgroundColor: Colors.purple900 }}
style={{ backgroundColor: MD2Colors.purple900 }}
visible={visible}
>
<Dialog.Title style={{ color: Colors.white }}>Alert</Dialog.Title>
<Dialog.Title style={{ color: MD2Colors.white }}>Alert</Dialog.Title>
<Dialog.Content>
<Paragraph style={{ color: Colors.white }}>
<Paragraph style={{ color: MD2Colors.white }}>
This is a dialog with custom colors
</Paragraph>
</Dialog.Content>
<Dialog.Actions>
<Button color={Colors.white} onPress={close}>
<Button color={MD2Colors.white} onPress={close}>
OK
</Button>
</Dialog.Actions>
Expand Down
4 changes: 2 additions & 2 deletions example/src/Examples/Dialogs/DialogWithLoadingIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { ActivityIndicator, Platform, View, StyleSheet } from 'react-native';
import { Paragraph, Colors, Portal, Dialog } from 'react-native-paper';
import { Paragraph, MD2Colors, Portal, Dialog } from 'react-native-paper';

const isIOS = Platform.OS === 'ios';

Expand All @@ -17,7 +17,7 @@ const DialogWithLoadingIndicator = ({
<Dialog.Content>
<View style={styles.flexing}>
<ActivityIndicator
color={Colors.indigo500}
color={MD2Colors.indigo500}
size={isIOS ? 'large' : 48}
style={styles.marginRight}
/>
Expand Down
10 changes: 8 additions & 2 deletions example/src/Examples/Dialogs/UndismissableDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as React from 'react';
import { Paragraph, Button, Portal, Dialog, Colors } from 'react-native-paper';
import {
Paragraph,
Button,
Portal,
Dialog,
MD2Colors,
} from 'react-native-paper';

const DialogWithLongText = ({
visible,
Expand All @@ -15,7 +21,7 @@ const DialogWithLongText = ({
<Paragraph>This is an undismissable dialog!!</Paragraph>
</Dialog.Content>
<Dialog.Actions>
<Button color={Colors.teal500} disabled>
<Button color={MD2Colors.teal500} disabled>
Disagree
</Button>
<Button onPress={close}>Agree</Button>
Expand Down
6 changes: 3 additions & 3 deletions example/src/Examples/IconButtonExample.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { StyleSheet } from 'react-native';
import { IconButton, Colors } from 'react-native-paper';
import { IconButton, MD2Colors } from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';

const ButtonExample = () => {
Expand All @@ -10,15 +10,15 @@ const ButtonExample = () => {
<IconButton
icon="lock"
size={24}
color={Colors.green500}
color={MD2Colors.green500}
onPress={() => {}}
/>
<IconButton icon="camera" size={36} onPress={() => {}} />
<IconButton
icon="lock"
size={36}
onPress={() => {}}
style={{ backgroundColor: Colors.lightGreen200 }}
style={{ backgroundColor: MD2Colors.lightGreen200 }}
/>
<IconButton icon="heart" size={60} onPress={() => {}} />
</ScreenWrapper>
Expand Down
8 changes: 4 additions & 4 deletions example/src/Examples/ProgressBarExample.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Button, ProgressBar, Paragraph, Colors } from 'react-native-paper';
import { Button, ProgressBar, Paragraph, MD2Colors } from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';

const ProgressBarExample = () => {
Expand Down Expand Up @@ -29,7 +29,7 @@ const ProgressBarExample = () => {
<ProgressBar
progress={progress}
visible={visible}
color={Colors.red800}
color={MD2Colors.red800}
/>
</View>

Expand All @@ -38,8 +38,8 @@ const ProgressBarExample = () => {
<ProgressBar
progress={progress}
visible={visible}
color={Colors.red800}
style={{ backgroundColor: Colors.teal500 }}
color={MD2Colors.red800}
style={{ backgroundColor: MD2Colors.teal500 }}
/>
</View>

Expand Down
4 changes: 2 additions & 2 deletions example/src/Examples/RadioButtonExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { View, StyleSheet } from 'react-native';
import {
Paragraph,
RadioButton,
Colors,
MD2Colors,
TouchableRipple,
} from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';
Expand Down Expand Up @@ -43,7 +43,7 @@ const RadioButtonExample = () => {
<View pointerEvents="none">
<RadioButton
value="custom"
color={Colors.blue500}
color={MD2Colors.blue500}
status={checked === 'custom' ? 'checked' : 'unchecked'}
/>
</View>
Expand Down
11 changes: 8 additions & 3 deletions example/src/Examples/SwitchExample.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react';
import { View, StyleSheet, Platform } from 'react-native';
import { Paragraph, Switch, Colors, TouchableRipple } from 'react-native-paper';
import {
Paragraph,
Switch,
MD2Colors,
TouchableRipple,
} from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';

const SwitchExample = () => {
Expand Down Expand Up @@ -28,7 +33,7 @@ const SwitchExample = () => {
<View style={styles.row}>
<Paragraph>Custom {switchValueCustomlLabel}</Paragraph>
<View pointerEvents="none">
<Switch value={valueCustom} color={Colors.blue500} />
<Switch value={valueCustom} color={MD2Colors.blue500} />
</View>
</View>
</TouchableRipple>
Expand All @@ -55,7 +60,7 @@ const SwitchExample = () => {
<Switch
value={valueCustom}
onValueChange={() => setCustomValue(!valueCustom)}
color={Colors.blue500}
color={MD2Colors.blue500}
/>
</View>
<View style={styles.row}>
Expand Down
3 changes: 2 additions & 1 deletion src/babel/__fixtures__/rewrite-imports/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
Button,
FAB,
Appbar,
Colors,
MD2Colors,
MD3Colors,
NonExistent,
NonExistentSecond as Stuff,
ThemeProvider,
Expand Down
3 changes: 2 additions & 1 deletion src/babel/__fixtures__/rewrite-imports/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import BottomNavigation from "react-native-paper/lib/module/components/BottomNav
import Button from "react-native-paper/lib/module/components/Button";
import FAB from "react-native-paper/lib/module/components/FAB";
import Appbar from "react-native-paper/lib/module/components/Appbar";
import * as Colors from "react-native-paper/lib/module/styles/themes/v2/colors";
import * as MD2Colors from "react-native-paper/lib/module/styles/themes/v2/colors";
import { MD3Colors } from "react-native-paper/lib/module/styles/themes/v3/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";
Expand Down
4 changes: 2 additions & 2 deletions src/components/ActivityIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ const DURATION = 2400;
* ## Usage
* ```js
* import * as React from 'react';
* import { ActivityIndicator, Colors } from 'react-native-paper';
* import { ActivityIndicator, MD2Colors } from 'react-native-paper';
*
* const MyComponent = () => (
* <ActivityIndicator animating={true} color={Colors.red800} />
* <ActivityIndicator animating={true} color={MD2Colors.red800} />
* );
*
* export default MyComponent;
Expand Down
4 changes: 2 additions & 2 deletions src/components/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ type Props = $RemoveChildren<typeof TouchableRipple> & {
* ## Usage
* ```js
* import * as React from 'react';
* import { IconButton, Colors } from 'react-native-paper';
* import { IconButton, MD2Colors } from 'react-native-paper';
*
* const MyComponent = () => (
* <IconButton
* icon="camera"
* color={Colors.red500}
* color={MD2Colors.red500}
* size={20}
* onPress={() => console.log('Pressed')}
* />
Expand Down
8 changes: 4 additions & 4 deletions src/components/List/ListIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const ICON_SIZE = 24;
* ## Usage
* ```js
* import * as React from 'react';
* import { List, Colors } from 'react-native-paper';
* import { List, MD2Colors } from 'react-native-paper';
*
* const MyComponent = () => (
* <>
* <List.Icon color={Colors.blue500} icon="folder" />
* <List.Icon color={Colors.blue500} icon="equal" />
* <List.Icon color={Colors.blue500} icon="calendar" />
* <List.Icon color={MD2Colors.blue500} icon="folder" />
* <List.Icon color={MD2Colors.blue500} icon="equal" />
* <List.Icon color={MD2Colors.blue500} icon="calendar" />
* </>
* );
*
Expand Down
Loading

0 comments on commit 72b53fd

Please sign in to comment.