Skip to content

Commit fa3d664

Browse files
committed
Merge branch 'master' into fix/picker-with-render-picker-respond-to-value-change
* master: Fix Badge's size default prop (#1212) Fix RadioGroup typings to extend our ViewProps and not React Native's
2 parents baa27ae + eccce40 commit fa3d664

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

generatedTypes/components/badge/index.d.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export declare type BadgeProps = ViewProps & TouchableOpacityProps & {
2424
/**
2525
* the badge size (default, small)
2626
*/
27-
size: BadgeSizes | number;
27+
size?: BadgeSizes | number;
2828
/**
2929
* Press handler
3030
*/
@@ -91,10 +91,8 @@ export declare type BadgeProps = ViewProps & TouchableOpacityProps & {
9191
declare class Badge extends PureComponent<BadgeProps> {
9292
styles: ReturnType<typeof createStyles>;
9393
static displayName: string;
94-
static defaultProps: {
95-
size: string;
96-
};
9794
constructor(props: BadgeProps);
95+
get size(): number | "small" | "default" | "pimpleSmall" | "pimpleBig" | "pimpleHuge" | "large";
9896
getAccessibilityProps(): {
9997
accessible: boolean;
10098
accessibilityRole: string;
@@ -359,7 +357,7 @@ declare const _default: React.ComponentClass<ViewProps & TouchableOpacityProps &
359357
/**
360358
* the badge size (default, small)
361359
*/
362-
size: number | "small" | "default" | "pimpleSmall" | "pimpleBig" | "pimpleHuge" | "large";
360+
size?: number | "small" | "default" | "pimpleSmall" | "pimpleBig" | "pimpleHuge" | "large" | undefined;
363361
/**
364362
* Press handler
365363
*/

generatedTypes/components/radioButton/RadioGroup.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { PureComponent, GetDerivedStateFromProps } from 'react';
2-
import { ViewProps } from 'react-native';
32
import { BaseComponentInjectedProps, ForwardRefInjectedProps } from '../../commons/new';
3+
import { ViewProps } from '../view';
44
export declare type RadioGroupProps = ViewProps & {
55
/**
66
* The initial value of the selected radio button

src/components/avatar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ class Avatar extends PureComponent<AvatarProps> {
232232
return _.get(this.props, 'badgeProps.backgroundColor') || statusColor || onlineColor;
233233
}
234234

235-
getBadgeSize = (): number => {
236-
const badgeSize: BadgeProps['size'] = _.get(this.props, 'badgeProps.size', DEFAULT_BADGE_SIZE);
235+
getBadgeSize = () => {
236+
const badgeSize = this.props?.badgeProps?.size ?? DEFAULT_BADGE_SIZE;
237237

238238
if (_.isString(badgeSize)) {
239239
return BADGE_SIZES[badgeSize] || BADGE_SIZES[DEFAULT_BADGE_SIZE];

src/components/badge/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export type BadgeProps = ViewProps &
4848
/**
4949
* the badge size (default, small)
5050
*/
51-
size: BadgeSizes | number;
51+
size?: BadgeSizes | number;
5252
/**
5353
* Press handler
5454
*/
@@ -117,9 +117,6 @@ class Badge extends PureComponent<BadgeProps> {
117117
styles: ReturnType<typeof createStyles>;
118118

119119
static displayName = 'Badge';
120-
static defaultProps = {
121-
size: 'default'
122-
};
123120

124121
constructor(props: BadgeProps) {
125122
super(props);
@@ -130,6 +127,10 @@ class Badge extends PureComponent<BadgeProps> {
130127
}
131128
}
132129

130+
get size() {
131+
return this.props.size || 'default';
132+
}
133+
133134
getAccessibilityProps() {
134135
const {onPress, icon, label} = this.props;
135136

@@ -142,14 +143,13 @@ class Badge extends PureComponent<BadgeProps> {
142143
}
143144

144145
isSmallBadge() {
145-
const {size} = this.props;
146-
return size === 'small';
146+
return this.size === 'small';
147147
}
148148

149149
getBadgeSizeStyle() {
150-
const {borderWidth, size, icon, customElement} = this.props;
150+
const {borderWidth, icon, customElement} = this.props;
151151
const label = this.getFormattedLabel();
152-
const badgeHeight = _.isNumber(size) ? size : BADGE_SIZES[size];
152+
const badgeHeight = _.isNumber(this.size) ? this.size : BADGE_SIZES[this.size];
153153

154154
const style: any = {
155155
paddingHorizontal: this.isSmallBadge() ? 4 : 6,

src/components/radioButton/RadioGroup.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import _ from 'lodash';
22
import React, {PureComponent, GetDerivedStateFromProps} from 'react';
3-
import {ViewProps} from 'react-native';
43
import {
54
asBaseComponent,
65
forwardRef,
76
BaseComponentInjectedProps,
87
ForwardRefInjectedProps
98
} from '../../commons/new';
10-
import View from '../view';
9+
import View, {ViewProps} from '../view';
1110
import RadioGroupContext from './RadioGroupContext';
1211

1312
export type RadioGroupProps = ViewProps & {

0 commit comments

Comments
 (0)