Skip to content

Commit a4cb38d

Browse files
committed
feat(*): change touchable highlight to opacity
1 parent bad40fc commit a4cb38d

15 files changed

Lines changed: 1279 additions & 1675 deletions

File tree

src/components/Alert/Alert.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@ import { AlertStyles, GetAlertStyles, getAlertStyles } from './Alert.styles';
1616
export interface AlertProps {
1717
/** Title of the alert. */
1818
title?: string;
19+
1920
/** Description of the alert. */
2021
description?: string;
22+
2123
/** Replace the icon of the alert on the left. Set to null to remove icon */
2224
icon?: React.ReactNode;
25+
2326
/**
2427
* Intent of the alert.
2528
* @default info
2629
*/
2730
intent?: Intent;
31+
2832
/** Callback to get element styles. */
2933
getStyles?: ReplaceReturnType<GetAlertStyles, DeepPartial<AlertStyles>>;
34+
3035
/** Used to locate this view in end-to-end tests. */
3136
testID?: string;
3237
}

src/components/Avatar/Avatar.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,38 @@ const getInitials: GetInitialsType = (name, fallback = '?') => {
2929
export interface AvatarProps {
3030
/** The source attribute of the image. When it's not available, render initials instead. */
3131
source?: ImageSourcePropType;
32+
3233
/** The size of the avatar. */
3334
size?: number;
35+
3436
/**
3537
* The name used for the initials and title attribute.
3638
* @default 48
3739
*/
3840
name?: string;
41+
3942
/**
4043
* When true, render a solid avatar.
4144
* @default false
4245
*/
4346
isSolid?: boolean;
47+
4448
/**
4549
* The color used for the avatar.
4650
* When the value is `automatic`, use the hash function to determine the color.
47-
* @default automatic
51+
* @default "automatic"
4852
*/
4953
color?: 'automatic' | FillColor;
54+
5055
/**
5156
* When the size is smaller than this number, use a single initial for the avatar.
5257
* @default 20
5358
*/
5459
sizeLimitOneCharacter?: number;
60+
5561
/** Callback to get element styles. */
5662
getStyles?: ReplaceReturnType<GetAvatarStyles, DeepPartial<AvatarStyles>>;
63+
5764
/** Used to locate this view in end-to-end tests. */
5865
testID?: string;
5966
}

src/components/Badge/Badge.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import { Badge, Box } from '..';
1212

1313
<Playground>
1414
<Box>
15-
<Badge color="blue" isSolid size="large" shape="pill">
16-
Badge
17-
</Badge>
15+
<Badge title="Badge" color="blue" isSolid size="large" shape="pill" />
1816
</Box>
1917
</Playground>
2018

src/components/Badge/Badge.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,48 @@ import { Text } from '../Typography';
99
import { BadgeStyles, GetBadgeStyles, getBadgeStyles } from './Badge.styles';
1010

1111
export interface BadgeProps {
12-
children: React.ReactNode;
12+
/** Title of the badge */
13+
title?: string;
14+
1315
/**
1416
* Color of the badge
15-
* @default neutral
17+
* @default "neutral"
1618
*/
1719
color?: FillColor;
20+
1821
/**
1922
* Size of the badge
20-
* @default medium
23+
* @default "medium"
2124
*/
2225
size?: ControlSize;
26+
2327
/**
2428
* Shape of the container
25-
* @default rounded
29+
* @default "rounded"
2630
*/
2731
shape?: ContainerShape;
32+
2833
/**
2934
* When true, display in solid mode
3035
* @default false
3136
*/
3237
isSolid?: boolean;
38+
3339
/** Callback to get element styles. */
3440
getStyles?: ReplaceReturnType<GetBadgeStyles, DeepPartial<BadgeStyles>>;
41+
3542
/** Used to locate this view in end-to-end tests. */
3643
testID?: string;
3744
}
3845

3946
export const Badge = (props: BadgeProps) => {
4047
const {
41-
children,
4248
color = 'neutral',
4349
getStyles,
4450
isSolid = false,
4551
shape = 'rounded',
4652
size = 'medium',
53+
title,
4754
testID,
4855
} = props;
4956

@@ -58,7 +65,7 @@ export const Badge = (props: BadgeProps) => {
5865
return (
5966
<View style={containerStyle} testID={testID}>
6067
<Text weight="bold" size={size} getStyles={() => ({ textStyle })}>
61-
{children}
68+
{title}
6269
</Text>
6370
</View>
6471
);

src/components/Button/Button.mdx

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,6 @@ import { Box, Button } from '..';
1010

1111
### Usage
1212

13-
<Playground>
14-
<Button
15-
color="primary"
16-
appearance="primary"
17-
size="large"
18-
isLoading={false}
19-
isActive={false}
20-
isDisabled={false}
21-
isInline={false}
22-
iconBefore={null}
23-
iconAfter={null}
24-
iconLoading={null}
25-
title="Usage"
26-
onPress={() => console.log('Pressed!')}
27-
getStyles={(props, theme) => ({
28-
buttonStyle: {},
29-
textStyle: {},
30-
focusColor: '#5ab9ae',
31-
})}
32-
/>
33-
</Playground>
34-
35-
### Variants
36-
3713
<Playground>
3814
<Box flexDirection="row">
3915
<Box paddingRight={16} height={240} justifyContent="space-between">
@@ -68,21 +44,31 @@ import { Box, Button } from '..';
6844
</Box>
6945
</Playground>
7046

71-
### Positioning inline button with different sizes
47+
### Customization
7248

73-
<Playground>
74-
<Box paddingBottom={16} flexDirection="row" justifyContent="flex-start">
75-
<Button isInline color="primary" title="Left small" size="small" />
76-
</Box>
77-
<Box paddingBottom={16} flexDirection="row" justifyContent="center">
78-
<Button isInline color="primary" title="Center medium" size="medium" />
79-
</Box>
80-
<Box paddingBottom={16} flexDirection="row" justifyContent="flex-end">
81-
<Button isInline color="primary" title="Right large" size="large" />
82-
</Box>
83-
</Playground>
49+
Using `getStyles` prop
50+
51+
```
52+
ButtonStylesProps {
53+
appearance: ButtonAppearance;
54+
color: ButtonColor;
55+
size: ControlSize;
56+
isDisabled: boolean;
57+
isLoading: boolean;
58+
isInline: boolean;
59+
hasIconAfter?: boolean;
60+
hasIconBefore?: boolean;
61+
}
62+
63+
ButtonStyles {
64+
buttonStyle: ViewStyle;
65+
textStyle: TextStyle;
66+
innerButtonWrapperStyle: ViewStyle;
67+
buttonContentWrapperStyle: ViewStyle;
68+
}
8469
85-
If `isInline` does not inline the button, try wrapping it with `Box`
70+
getStyles={(ButtonStylesProps, Theme) => ButtonStyles}
71+
```
8672

8773
### Props
8874

src/components/Button/Button.styles.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { TextStyle, ViewStyle } from 'react-native';
22

33
import { ButtonColor, ControlSize, Theme } from '../../theme/Theme';
4-
import { darken } from './changeColor';
54

65
export interface ButtonColorProps {
76
backgroundColor: string;
@@ -102,24 +101,24 @@ export const getButtonAppearances = (theme: Theme): ButtonAppearances => {
102101
};
103102
};
104103

105-
export interface ButtonStyles {
106-
buttonStyle: ViewStyle;
107-
textStyle: TextStyle;
108-
focusColor: string;
109-
innerButtonWrapperStyle: ViewStyle;
110-
buttonContentWrapperStyle: ViewStyle;
111-
}
112-
113104
export interface ButtonStylesProps {
114105
appearance: ButtonAppearance;
115106
color: ButtonColor;
116107
size: ControlSize;
117108
isDisabled: boolean;
118109
isLoading: boolean;
119110
isInline: boolean;
120-
iconBefore?: any;
121-
iconAfter?: any;
111+
hasIconAfter?: boolean;
112+
hasIconBefore?: boolean;
122113
}
114+
115+
export interface ButtonStyles {
116+
buttonStyle: ViewStyle;
117+
textStyle: TextStyle;
118+
innerButtonWrapperStyle: ViewStyle;
119+
buttonContentWrapperStyle: ViewStyle;
120+
}
121+
123122
export type GetButtonStyles = (
124123
buttonStylesProps: ButtonStylesProps,
125124
theme: Theme,
@@ -133,8 +132,8 @@ export const getButtonStyles: GetButtonStyles = (buttonStyleProps, theme) => {
133132
isDisabled,
134133
isLoading,
135134
isInline,
136-
iconBefore,
137-
iconAfter,
135+
hasIconAfter,
136+
hasIconBefore,
138137
} = buttonStyleProps;
139138

140139
const buttonAppearances = getButtonAppearances(theme);
@@ -167,10 +166,6 @@ export const getButtonStyles: GetButtonStyles = (buttonStyleProps, theme) => {
167166
}
168167
: {}),
169168
},
170-
focusColor:
171-
appearance === 'minimal' || appearance === 'outline'
172-
? theme.colors.button.default
173-
: darken(buttonStyle.backgroundColor, 0.05),
174169
textStyle: {
175170
alignItems: 'center',
176171
color: isDisabled ? theme.colors.text.muted : textColor,
@@ -188,8 +183,8 @@ export const getButtonStyles: GetButtonStyles = (buttonStyleProps, theme) => {
188183
},
189184

190185
buttonContentWrapperStyle: {
191-
paddingLeft: iconBefore ? 8 : 0,
192-
paddingRight: iconAfter ? 8 : 0,
186+
paddingLeft: hasIconBefore ? 8 : 0,
187+
paddingRight: hasIconAfter ? 8 : 0,
193188
},
194189
};
195190
};

0 commit comments

Comments
 (0)