Skip to content

Commit 3485402

Browse files
committed
BREAKING: rename Paper to Surface
1 parent 65ad2a0 commit 3485402

25 files changed

+93
-115
lines changed

docs/pages/3.theming.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ A theme usually contains the following properties:
5656
- `primary` - primary color for your app, usually your brand color.
5757
- `accent` - secondary color for your app which complements the primary color.
5858
- `background` - background color for pages, such as lists.
59-
- `paper` - background color for elements containing content, such as cards.
59+
- `surface` - background color for elements containing content, such as cards.
6060
- `text` - text color for content.
6161
- `disabled` - color for disabled elements.
6262
- `placeholder` - color for placeholder text, such as input placeholder.

example/DrawerItems.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,10 @@ class DrawerItems extends React.Component<Props, State> {
4747
};
4848

4949
render() {
50-
const {
51-
theme: {
52-
colors: { paper },
53-
},
54-
} = this.props;
50+
const { colors } = this.props.theme;
51+
5552
return (
56-
<View style={[styles.drawerContent, { backgroundColor: paper }]}>
53+
<View style={[styles.drawerContent, { backgroundColor: colors.surface }]}>
5754
<DrawerSection title="Subheader">
5855
{DrawerItemsData.map((props, index) => (
5956
<DrawerItem

example/src/ExampleList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import DividerExample from './DividerExample';
1313
import FABExample from './FABExample';
1414
import ListAccordionExample from './ListAccordionExample';
1515
import ListSectionExample from './ListSectionExample';
16-
import PaperExample from './PaperExample';
1716
import ProgressBarExample from './ProgressBarExample';
1817
import RadioButtonExample from './RadioButtonExample';
1918
import RadioButtonGroupExample from './RadioButtonGroupExample';
2019
import RippleExample from './RippleExample';
2120
import SearchbarExample from './SearchbarExample';
2221
import SnackbarExample from './SnackbarExample';
22+
import SurfaceExample from './SurfaceExample';
2323
import SwitchExample from './SwitchExample';
2424
import TextExample from './TextExample';
2525
import TextInputExample from './TextInputExample';
@@ -42,13 +42,13 @@ export const examples = {
4242
fab: FABExample,
4343
listAccordion: ListAccordionExample,
4444
listSection: ListSectionExample,
45-
paper: PaperExample,
4645
progressbar: ProgressBarExample,
4746
radio: RadioButtonExample,
4847
radioGroup: RadioButtonGroupExample,
4948
ripple: RippleExample,
5049
searchbar: SearchbarExample,
5150
snackbar: SnackbarExample,
51+
surface: SurfaceExample,
5252
switch: SwitchExample,
5353
text: TextExample,
5454
textInput: TextInputExample,

example/src/PaperExample.js renamed to example/src/SurfaceExample.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import * as React from 'react';
44
import { ScrollView, StyleSheet } from 'react-native';
5-
import { Text, Paper, withTheme } from 'react-native-paper';
5+
import { Text, Surface, withTheme } from 'react-native-paper';
66
import type { Theme } from 'react-native-paper/types';
77

88
type Props = {
99
theme: Theme,
1010
};
1111

12-
class PaperExample extends React.Component<Props> {
13-
static title = 'Paper';
12+
class SurfaceExample extends React.Component<Props> {
13+
static title = 'Surface';
1414

1515
render() {
1616
const {
@@ -24,9 +24,9 @@ class PaperExample extends React.Component<Props> {
2424
contentContainerStyle={styles.content}
2525
>
2626
{[1, 2, 4, 6, 12].map(i => (
27-
<Paper key={i} style={[styles.paper, { elevation: i }]}>
27+
<Surface key={i} style={[styles.surface, { elevation: i }]}>
2828
<Text>{i}</Text>
29-
</Paper>
29+
</Surface>
3030
))}
3131
</ScrollView>
3232
);
@@ -43,7 +43,7 @@ const styles = StyleSheet.create({
4343
alignItems: 'center',
4444
},
4545

46-
paper: {
46+
surface: {
4747
margin: 24,
4848
height: 80,
4949
width: 80,
@@ -52,4 +52,4 @@ const styles = StyleSheet.create({
5252
},
5353
});
5454

55-
export default withTheme(PaperExample);
55+
export default withTheme(SurfaceExample);

src/components/BottomNavigation.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import {
1313
import { polyfill } from 'react-lifecycles-compat';
1414
import color from 'color';
1515
import Icon from './Icon';
16-
import Paper from './Paper';
16+
import Surface from './Surface';
1717
import Text from './Typography/Text';
1818
import { black, grey900, white } from '../styles/colors';
1919
import withTheme from '../core/withTheme';
2020
import type { Theme } from '../types';
2121
import type { IconSource } from './Icon';
2222

2323
const AnimatedText = Animated.createAnimatedComponent(Text);
24-
const AnimatedPaper = Animated.createAnimatedComponent(Paper);
24+
const AnimatedSurface = Animated.createAnimatedComponent(Surface);
2525

2626
type Route = $Shape<{
2727
key: string,
@@ -592,7 +592,7 @@ class BottomNavigation<T: *> extends React.Component<Props<T>, State> {
592592
);
593593
})}
594594
</View>
595-
<AnimatedPaper style={[styles.bar, barStyle, { backgroundColor }]}>
595+
<AnimatedSurface style={[styles.bar, barStyle, { backgroundColor }]}>
596596
<SafeAreaView
597597
style={[styles.items, { maxWidth: maxTabWidth * routes.length }]}
598598
>
@@ -827,7 +827,7 @@ class BottomNavigation<T: *> extends React.Component<Props<T>, State> {
827827
);
828828
})}
829829
</SafeAreaView>
830-
</AnimatedPaper>
830+
</AnimatedSurface>
831831
</View>
832832
);
833833
}

src/components/Button.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import * as React from 'react';
44
import { ActivityIndicator, Animated, View, StyleSheet } from 'react-native';
55
import color from 'color';
66
import Icon from './Icon';
7-
import Paper from './Paper';
7+
import Surface from './Surface';
88
import Text from './Typography/Text';
99
import TouchableRipple from './TouchableRipple';
1010
import { black, white } from '../styles/colors';
1111
import withTheme from '../core/withTheme';
1212
import type { Theme } from '../types';
1313
import type { IconSource } from './Icon';
1414

15-
const AnimatedPaper = Animated.createAnimatedComponent(Paper);
15+
const AnimatedSurface = Animated.createAnimatedComponent(Surface);
1616

1717
type Props = {
1818
/**
@@ -186,7 +186,7 @@ class Button extends React.Component<Props, State> {
186186
const elevation = disabled ? 0 : this.state.elevation;
187187

188188
return (
189-
<AnimatedPaper
189+
<AnimatedSurface
190190
style={[
191191
styles.button,
192192
compact && styles.compact,
@@ -234,7 +234,7 @@ class Button extends React.Component<Props, State> {
234234
</Text>
235235
</View>
236236
</TouchableRipple>
237-
</AnimatedPaper>
237+
</AnimatedSurface>
238238
);
239239
}
240240
}

src/components/Card/Card.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
TouchableWithoutFeedback,
88
StyleSheet,
99
} from 'react-native';
10-
import Paper from '../Paper';
10+
import Surface from '../Surface';
1111
import withTheme from '../../core/withTheme';
1212
import type { Theme } from '../../types';
1313

14-
const AnimatedPaper = Animated.createAnimatedComponent(Paper);
14+
const AnimatedSurface = Animated.createAnimatedComponent(Surface);
1515

1616
type Props = {
1717
/**
@@ -110,7 +110,7 @@ class Card extends React.Component<Props, State> {
110110
typeof child === 'object' && child.type ? child.type.displayName : null
111111
);
112112
return (
113-
<AnimatedPaper
113+
<AnimatedSurface
114114
style={[styles.card, { borderRadius: roundness, elevation }, style]}
115115
>
116116
<TouchableWithoutFeedback
@@ -135,7 +135,7 @@ class Card extends React.Component<Props, State> {
135135
)}
136136
</View>
137137
</TouchableWithoutFeedback>
138-
</AnimatedPaper>
138+
</AnimatedSurface>
139139
);
140140
}
141141
}

src/components/Dialog/Dialog.js

+6-25
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
import * as React from 'react';
44
import { StyleSheet, Platform, Animated } from 'react-native';
55
import Modal from '../Modal';
6-
import { white } from '../../styles/colors';
7-
import Paper from '../Paper';
6+
import Surface from '../Surface';
87
import DialogActions from './DialogActions';
98
import DialogTitle from './DialogTitle';
109
import DialogContent from './DialogContent';
11-
import withTheme from '../../core/withTheme';
12-
import type { Theme } from '../../types';
1310

14-
const AnimatedPaper = Animated.createAnimatedComponent(Paper);
11+
const AnimatedSurface = Animated.createAnimatedComponent(Surface);
1512

1613
type Props = {
1714
/**
@@ -31,10 +28,6 @@ type Props = {
3128
*/
3229
children: React.Node,
3330
style?: any,
34-
/**
35-
* @optional
36-
*/
37-
theme: Theme,
3831
};
3932

4033
/**
@@ -82,23 +75,14 @@ type Props = {
8275
* }
8376
* ```
8477
*/
85-
class Dialog extends React.Component<Props, void> {
78+
export default class Dialog extends React.Component<Props, void> {
8679
static defaultProps = {
8780
dismissable: true,
8881
visible: false,
8982
};
9083

9184
render() {
92-
const {
93-
children,
94-
dismissable,
95-
onDismiss,
96-
visible,
97-
style,
98-
theme,
99-
} = this.props;
100-
101-
const backgroundColor = theme.colors.paper;
85+
const { children, dismissable, onDismiss, visible, style } = this.props;
10286

10387
const childrenArray = React.Children.toArray(children);
10488
/* $FlowFixMe */
@@ -128,18 +112,16 @@ class Dialog extends React.Component<Props, void> {
128112
}
129113
return (
130114
<Modal dismissable={dismissable} onDismiss={onDismiss} visible={visible}>
131-
<AnimatedPaper style={[styles.container, { backgroundColor }, style]}>
115+
<AnimatedSurface style={[styles.container, style]}>
132116
{title}
133117
{restOfChildrenWithoutTitle}
134118
{actionBtnsChildren}
135-
</AnimatedPaper>
119+
</AnimatedSurface>
136120
</Modal>
137121
);
138122
}
139123
}
140124

141-
export default withTheme(Dialog);
142-
143125
const styles = StyleSheet.create({
144126
container: {
145127
/**
@@ -152,7 +134,6 @@ const styles = StyleSheet.create({
152134
marginVertical: Platform.OS === 'android' ? 44 : 0,
153135
marginHorizontal: 26,
154136
borderRadius: 2,
155-
backgroundColor: white,
156137
elevation: 24,
157138
},
158139
});

src/components/FAB.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import color from 'color';
44
import * as React from 'react';
5-
import { StyleSheet, View, Animated } from 'react-native';
6-
import Paper from './Paper';
5+
import { Animated, View, StyleSheet } from 'react-native';
6+
import Surface from './Surface';
77
import CrossFadeIcon from './CrossFadeIcon';
88
import Text from './Typography/Text';
99
import TouchableRipple from './TouchableRipple';
@@ -12,7 +12,7 @@ import withTheme from '../core/withTheme';
1212
import type { Theme } from '../types';
1313
import type { IconSource } from './Icon';
1414

15-
const AnimatedPaper = Animated.createAnimatedComponent(Paper);
15+
const AnimatedSurface = Animated.createAnimatedComponent(Surface);
1616

1717
type Props = {
1818
/**
@@ -93,7 +93,7 @@ class FAB extends React.Component<Props> {
9393
.string();
9494

9595
return (
96-
<AnimatedPaper
96+
<AnimatedSurface
9797
{...rest}
9898
style={[{ backgroundColor, elevation: 12 }, styles.container, style]}
9999
>
@@ -123,7 +123,7 @@ class FAB extends React.Component<Props> {
123123
) : null}
124124
</View>
125125
</TouchableRipple>
126-
</AnimatedPaper>
126+
</AnimatedSurface>
127127
);
128128
}
129129
}

src/components/FABGroup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class FABGroup extends React.Component<Props, State> {
247247
style={[
248248
{
249249
transform: [{ scale: scales[i] }],
250-
backgroundColor: theme.colors.paper,
250+
backgroundColor: theme.colors.surface,
251251
},
252252
]}
253253
onPress={it.onPress}

src/components/Searchbar.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { StyleSheet, TextInput } from 'react-native';
66
import color from 'color';
77
import withTheme from '../core/withTheme';
88
import TouchableIcon from './TouchableIcon';
9-
import Paper from './Paper';
9+
import Surface from './Surface';
1010
import type { Theme } from '../types';
1111
import type { IconSource } from './Icon';
1212

@@ -135,7 +135,7 @@ class Searchbar extends React.Component<Props> {
135135
.string();
136136

137137
return (
138-
<Paper
138+
<Surface
139139
style={[
140140
{ borderRadius: roundness, elevation: 4 },
141141
styles.container,
@@ -171,7 +171,7 @@ class Searchbar extends React.Component<Props> {
171171
source="close"
172172
/>
173173
) : null}
174-
</Paper>
174+
</Surface>
175175
);
176176
}
177177
}

0 commit comments

Comments
 (0)