Skip to content

Commit

Permalink
fix: merge types with the props of the component used internally
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Nov 8, 2018
1 parent aee06f3 commit 0294209
Show file tree
Hide file tree
Showing 47 changed files with 106 additions and 99 deletions.
8 changes: 2 additions & 6 deletions example/src/CardExample.js
Expand Up @@ -45,12 +45,8 @@ class CardExample extends React.Component<Props> {
<Card style={styles.card}>
<Card.Cover source={require('../assets/forest.jpg')} />
<Card.Actions>
<Button primary onPress={() => {}}>
Share
</Button>
<Button primary onPress={() => {}}>
Explore
</Button>
<Button onPress={() => {}}>Share</Button>
<Button onPress={() => {}}>Explore</Button>
</Card.Actions>
</Card>
<Card style={styles.card}>
Expand Down
14 changes: 5 additions & 9 deletions example/src/DialogExample.js
Expand Up @@ -56,19 +56,15 @@ class DialogExample extends React.Component<Props, State> {
const { visible1, visible2, visible3, visible4, visible5 } = this.state;
return (
<View style={[styles.container, { backgroundColor: background }]}>
<Button primary onPress={this._openDialog1}>
Show Dialog with long text
</Button>
<Button primary onPress={this._openDialog2}>
<Button onPress={this._openDialog1}>Show Dialog with long text</Button>
<Button onPress={this._openDialog2}>
Show Dialog with radio buttons
</Button>
<Button primary onPress={this._openDialog3}>
<Button onPress={this._openDialog3}>
Show Dialog with loading indicator
</Button>
<Button primary onPress={this._openDialog4}>
Show undismissable Dialog
</Button>
<Button primary onPress={this._openDialog5}>
<Button onPress={this._openDialog4}>Show undismissable Dialog</Button>
<Button onPress={this._openDialog5}>
Show Dialog with custom colors
</Button>
<DialogWithLongText visible={visible1} close={this._closeDialog1} />
Expand Down
4 changes: 1 addition & 3 deletions example/src/Dialogs/DialogWithLongText.js
Expand Up @@ -40,9 +40,7 @@ const DialogWithLongText = ({
</ScrollView>
</Dialog.ScrollArea>
<Dialog.Actions>
<Button primary onPress={close}>
OK
</Button>
<Button onPress={close}>OK</Button>
</Dialog.Actions>
</Dialog>
</Portal>
Expand Down
8 changes: 2 additions & 6 deletions example/src/Dialogs/DialogWithRadioBtns.js
Expand Up @@ -91,12 +91,8 @@ export default class extends React.Component<Props, State> {
</ScrollView>
</Dialog.ScrollArea>
<Dialog.Actions>
<Button primary onPress={close}>
Cancel
</Button>
<Button primary onPress={close}>
Ok
</Button>
<Button onPress={close}>Cancel</Button>
<Button onPress={close}>Ok</Button>
</Dialog.Actions>
</Dialog>
</Portal>
Expand Down
4 changes: 1 addition & 3 deletions example/src/Dialogs/UndismissableDialog.js
Expand Up @@ -20,9 +20,7 @@ const DialogWithLongText = ({
<Button color={Colors.teal500} disabled>
Disagree
</Button>
<Button primary onPress={close}>
Agree
</Button>
<Button onPress={close}>Agree</Button>
</Dialog.Actions>
</Dialog>
</Portal>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Appbar/Appbar.js
Expand Up @@ -12,7 +12,7 @@ import { withTheme } from '../../core/theming';
import { black, white } from '../../styles/colors';
import type { Theme } from '../../types';

type Props = {
type Props = React.ElementConfig<typeof View> & {
/**
* Whether the background color is a dark color. A dark appbar will render light text and vice-versa.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/Appbar/AppbarAction.js
Expand Up @@ -6,7 +6,7 @@ import { black } from '../../styles/colors';
import IconButton from '../IconButton';
import type { IconSource } from '../Icon';

type Props = {
type Props = React.ElementConfig<typeof IconButton> & {
/**
* Custom color for action icon.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/Appbar/AppbarBackAction.js
Expand Up @@ -5,7 +5,7 @@ import { View, Image, I18nManager, StyleSheet, Platform } from 'react-native';

import AppbarAction from './AppbarAction';

type Props = {
type Props = React.ElementConfig<typeof AppbarAction> & {
/**
* Custom color for back icon.
*/
Expand Down
7 changes: 4 additions & 3 deletions src/components/Appbar/AppbarContent.js
Expand Up @@ -9,9 +9,9 @@ import Text from '../Typography/Text';
import { withTheme } from '../../core/theming';
import { black } from '../../styles/colors';

import type { Theme } from '../../types';
import type { Theme, $RemoveChildren } from '../../types';

type Props = {
type Props = $RemoveChildren<typeof View> & {
/**
* CUstom color for the text.
*/
Expand Down Expand Up @@ -54,6 +54,7 @@ class AppbarContent extends React.Component<Props> {
titleStyle,
theme,
title,
...rest
} = this.props;
const { fonts } = theme;

Expand All @@ -63,7 +64,7 @@ class AppbarContent extends React.Component<Props> {
.string();

return (
<View style={[styles.container, style]}>
<View style={[styles.container, style]} {...rest}>
<Text
style={[
{
Expand Down
3 changes: 2 additions & 1 deletion src/components/Appbar/AppbarHeader.js
Expand Up @@ -7,7 +7,7 @@ import Appbar, { DEFAULT_APPBAR_HEIGHT } from './Appbar';
import { withTheme } from '../../core/theming';
import type { Theme } from '../../types';

type Props = {
type Props = React.ElementConfig<typeof Appbar> & {
/**
* Whether the background color is a dark color. A dark header will render light text and vice-versa.
*/
Expand Down Expand Up @@ -109,6 +109,7 @@ class AppbarHeader extends React.Component<Props> {

return (
<Wrapper style={[{ backgroundColor, elevation }]}>
{/* $FlowFixMe: There seems to be conflict between Appbar's props and Header's props */}
<Appbar
style={[
{ height, backgroundColor, marginTop: statusBarHeight },
Expand Down
4 changes: 2 additions & 2 deletions src/components/Banner.js
Expand Up @@ -6,9 +6,9 @@ import Surface from './Surface';
import Text from './Typography/Text';
import Button from './Button';
import { withTheme } from '../core/theming';
import type { Theme } from '../types';
import type { Theme, $RemoveChildren } from '../types';

type Props = {
type Props = $RemoveChildren<typeof Surface> & {
/**
* Whether banner is currently visible.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button.js
Expand Up @@ -12,7 +12,7 @@ import { withTheme } from '../core/theming';
import type { Theme } from '../types';
import type { IconSource } from './Icon';

type Props = {
type Props = React.ElementConfig<typeof Surface> & {
/**
* Mode of the button. You can change the mode to adjust the styling to give it desired emphasis.
* - `text` - flat button without background or outline (low emphasis)
Expand Down
16 changes: 13 additions & 3 deletions src/components/Card/Card.js
Expand Up @@ -14,7 +14,7 @@ import Surface from '../Surface';
import { withTheme } from '../../core/theming';
import type { Theme } from '../../types';

type Props = {
type Props = React.ElementConfig<typeof Surface> & {
/**
* Resting elevation of the card which controls the drop shadow.
*/
Expand Down Expand Up @@ -105,7 +105,14 @@ class Card extends React.Component<Props, State> {
};

render() {
const { children, onLongPress, onPress, style, theme } = this.props;
const {
children,
onLongPress,
onPress,
style,
theme,
...rest
} = this.props;
const { elevation } = this.state;
const { roundness } = theme;
const total = React.Children.count(children);
Expand All @@ -117,7 +124,10 @@ class Card extends React.Component<Props, State> {
: null
);
return (
<Surface style={[{ borderRadius: roundness, elevation }, style]}>
<Surface
style={[{ borderRadius: roundness, elevation }, style]}
{...rest}
>
<TouchableWithoutFeedback
delayPressIn={0}
disabled={!(onPress || onLongPress)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Card/CardActions.js
Expand Up @@ -3,9 +3,9 @@
import * as React from 'react';
import { StyleSheet, View } from 'react-native';

type Props = {
type Props = React.ElementConfig<typeof View> & {
/**
* Content of the `CardActions`.
* Items inside the `CardActions`.
*/
children: React.Node,
style?: any,
Expand Down
6 changes: 5 additions & 1 deletion src/components/Card/CardContent.js
Expand Up @@ -3,7 +3,11 @@
import * as React from 'react';
import { StyleSheet, View } from 'react-native';

type Props = {
type Props = React.ElementConfig<typeof View> & {
/**
* Items inside the `Card.Content`.
*/
children: React.Node,
/**
* @internal
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/Card/CardCover.js
Expand Up @@ -6,7 +6,7 @@ import { withTheme } from '../../core/theming';
import { grey200 } from '../../styles/colors';
import type { Theme } from '../../types';

type Props = {
type Props = React.ElementConfig<typeof Image> & {
/**
* @internal
*/
Expand Down
4 changes: 2 additions & 2 deletions src/components/CheckboxAndroid.js
Expand Up @@ -6,9 +6,9 @@ import color from 'color';
import Icon from './Icon';
import TouchableRipple from './TouchableRipple';
import { withTheme } from '../core/theming';
import type { Theme } from '../types';
import type { Theme, $RemoveChildren } from '../types';

type Props = {
type Props = $RemoveChildren<typeof TouchableRipple> & {
/**
* Status of checkbox.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/components/CheckboxIOS.js
Expand Up @@ -6,9 +6,9 @@ import color from 'color';
import Icon from './Icon';
import TouchableRipple from './TouchableRipple';
import { withTheme } from '../core/theming';
import type { Theme } from '../types';
import type { Theme, $RemoveChildren } from '../types';

type Props = {
type Props = $RemoveChildren<typeof TouchableRipple> & {
/**
* Status of checkbox.
*/
Expand Down
6 changes: 4 additions & 2 deletions src/components/Chip.js
Expand Up @@ -18,7 +18,7 @@ import { black, white } from '../styles/colors';
import type { Theme } from '../types';
import type { IconSource } from './Icon';

type Props = {
type Props = React.ElementConfig<typeof Surface> & {
/**
* Mode of the chip.
* - `flat` - flat chip without outline.
Expand Down Expand Up @@ -132,6 +132,7 @@ class Chip extends React.Component<Props, State> {
onClose,
style,
theme,
...rest
} = this.props;
const { dark, colors } = theme;

Expand Down Expand Up @@ -193,6 +194,7 @@ class Chip extends React.Component<Props, State> {
},
style,
]}
{...rest}
>
<TouchableRipple
borderless
Expand Down Expand Up @@ -248,7 +250,7 @@ class Chip extends React.Component<Props, State> {
},
]}
>
{children}
{(children: any)}
</Text>
{onClose ? (
<TouchableWithoutFeedback
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/DialogActions.js
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react';
import { StyleSheet, View } from 'react-native';

type Props = {
type Props = React.ElementConfig<typeof View> & {
/**
* Content of the `DialogActions`.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dialog/DialogContent.js
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react';
import { View, StyleSheet } from 'react-native';

type Props = {
type Props = React.ElementConfig<typeof View> & {
/**
* Content of the `DialogContent`.
*/
Expand Down Expand Up @@ -47,7 +47,7 @@ class DialogContent extends React.Component<Props> {

render() {
return (
<View style={[styles.container, this.props.style]}>
<View {...this.props} style={[styles.container, this.props.style]}>
{this.props.children}
</View>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dialog/DialogScrollArea.js
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react';
import { View, StyleSheet } from 'react-native';

type Props = {
type Props = React.ElementConfig<typeof View> & {
/**
* Content of the `DialogScrollArea`.
*/
Expand Down Expand Up @@ -51,7 +51,7 @@ class DialogScrollArea extends React.Component<Props> {

render() {
return (
<View style={[styles.container, this.props.style]}>
<View {...this.props} style={[styles.container, this.props.style]}>
{this.props.children}
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/DialogTitle.js
Expand Up @@ -6,7 +6,7 @@ import Title from '../Typography/Title';
import { withTheme } from '../../core/theming';
import type { Theme } from '../../types';

type Props = {
type Props = React.ElementConfig<typeof Title> & {
/**
* Title text for the `DialogTitle`.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/components/Divider.js
Expand Up @@ -4,10 +4,10 @@ import * as React from 'react';
import color from 'color';
import { StyleSheet, View } from 'react-native';
import { withTheme } from '../core/theming';
import type { Theme } from '../types';
import { black, white } from '../styles/colors';
import type { Theme, $RemoveChildren } from '../types';

type Props = {
type Props = $RemoveChildren<typeof View> & {
/**
* Whether divider has a left inset.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/components/Drawer/DrawerItem.js
Expand Up @@ -7,10 +7,10 @@ import Text from '../Typography/Text';
import Icon from '../Icon';
import TouchableRipple from '../TouchableRipple';
import { withTheme } from '../../core/theming';
import type { Theme } from '../../types';
import type { Theme, $RemoveChildren } from '../../types';
import type { IconSource } from '../Icon';

type Props = {
type Props = $RemoveChildren<typeof View> & {
/**
* The label text of the item.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/Drawer/DrawerSection.js
Expand Up @@ -8,7 +8,7 @@ import Divider from '../Divider';
import { withTheme } from '../../core/theming';
import type { Theme } from '../../types';

type Props = {
type Props = React.ElementConfig<typeof View> & {
/**
* Title to show as the header for the section.
*/
Expand Down

0 comments on commit 0294209

Please sign in to comment.