Skip to content

Commit 8190dfa

Browse files
committed
feat(refactor): refactor typography and toast
1 parent 61e74b7 commit 8190dfa

23 files changed

Lines changed: 106 additions & 146 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Ongoing development
1+
# Warning
22

3-
Basic components are available and usable. However, until 2.0, updates in 1.\* may have breaking changes, and have some cross-platform incompabilities
3+
Until 2.0, updates in 1.\* will have breaking changes as it is continuously being refined
44

5-
# Paramount
5+
# Goals
66

77
Cross platform React Native and React Web UI components library
88

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"react-dom": "16.8.3",
4747
"react-icons": "3.3.0",
4848
"react-native-web": "0.10.0",
49-
"react-powerplug": "1.0.0",
5049
"react-spring": "7.2.11",
5150
"terser": "3.16",
5251
"ts-essentials": "2.0.0"
@@ -84,6 +83,7 @@
8483
"metro-react-native-babel-preset": "0.52.0",
8584
"prettier": "1.16.4",
8685
"react-docgen-typescript-loader": "3.0.1",
86+
"react-powerplug": "1.0.0",
8787
"react-test-renderer": "16.8.3",
8888
"rimraf": "2.6.3",
8989
"semantic-release": "15.13.3",

src/components/Alert/Alert.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Icon } from '../../icons';
77
import { Theme, withTheme } from '../../theme';
88
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
99
import { Spacing } from '../Layout';
10-
import { Strong, Text } from '../Typography';
10+
import { Text } from '../Typography';
1111
import { AlertStyles, GetAlertStyles, getAlertStyles } from './Alert.styles';
1212

1313
export interface AlertProps {
@@ -76,7 +76,7 @@ const AlertBase = (props: AlertProps) => {
7676
)}
7777
{component || (
7878
<View style={bodyStyle}>
79-
<Strong>{title}</Strong>
79+
<Text bold>{title}</Text>
8080
<Text>{description}</Text>
8181
</View>
8282
)}

src/components/Badge/Badge.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Theme, withTheme } from '../../theme';
66
import { FillColor } from '../../theme/ThemeInterface';
77
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
88
import Box, { Shape } from '../Layout/Box';
9-
import { Strong } from '../Typography';
9+
import { Text } from '../Typography';
1010
import {
1111
BadgeSize,
1212
BadgeStyles,
@@ -44,14 +44,15 @@ const BadgeBase = (props: BadgeProps) => {
4444

4545
return (
4646
<View style={containerStyle} testID={testID}>
47-
<Strong
47+
<Text
48+
bold
4849
size={size}
4950
getStyles={() => ({
5051
textStyle,
5152
})}
5253
>
5354
{children}
54-
</Strong>
55+
</Text>
5556
</View>
5657
);
5758
};

src/components/ListItem/ListItem.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from 'react-native';
99
import { DeepPartial } from 'ts-essentials';
1010

11-
import { Theme, withTheme } from '../../theme';
11+
import { ThemeContext } from '../../theme';
1212
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
1313
import { Avatar, AvatarProps } from '../Avatar';
1414
import { Text } from '../Typography';
@@ -20,7 +20,6 @@ import {
2020
} from './ListItem.styles';
2121

2222
export interface ListItemProps extends AccessibilityProps {
23-
theme: Theme;
2423
size?: ListItemSize;
2524
isDisabled?: boolean;
2625
label: string;
@@ -33,7 +32,7 @@ export interface ListItemProps extends AccessibilityProps {
3332
testID?: string;
3433
}
3534

36-
const ListItemBase = (props: ListItemProps) => {
35+
const ListItem = (props: ListItemProps) => {
3736
const {
3837
getStyles,
3938
isDisabled = false,
@@ -43,11 +42,11 @@ const ListItemBase = (props: ListItemProps) => {
4342
size = 'medium',
4443
onPress,
4544
rightIcon = null,
46-
theme,
4745
avatarProps,
4846
testID,
4947
...accessibilityProps
5048
} = props;
49+
const theme = React.useContext(ThemeContext);
5150

5251
const {
5352
imageWrapperStyle,
@@ -90,5 +89,4 @@ const ListItemBase = (props: ListItemProps) => {
9089
);
9190
};
9291

93-
export const ListItem = withTheme(React.memo(ListItemBase));
9492
export default ListItem;

src/components/Modal/FormModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { TouchableOpacity, View } from 'react-native';
33

4-
import { Strong } from '../Typography';
4+
import { Text } from '../Typography';
55
import CloseableModal, { CloseableModalProps } from './CloseableModal';
66

77
export interface FormModalProps extends CloseableModalProps {
@@ -37,7 +37,7 @@ const FormModalBase = (props: FormModalProps) => {
3737
paddingHorizontal: 16,
3838
}}
3939
>
40-
<Strong>{clearText}</Strong>
40+
<Text bold>{clearText}</Text>
4141
</View>
4242
</TouchableOpacity>
4343
}

src/components/Toast/Toast.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import Toast from './Toast';
1111

1212
## Usage
1313

14-
ToastProvider should inserted at the top-level component so that it displays from within the window container. However, it is possible to display Toast within another component like in the below example.
15-
16-
You could additionally wrap the container component with `overflow="hidden"` so that it disappears correctly
17-
1814
Composes `Alert`
1915

2016
<Playground>

src/components/Toast/Toast.styles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TextStyle, ViewStyle } from 'react-native';
1+
import { Platform, TextStyle, ViewStyle } from 'react-native';
22

33
import { Intent } from '../../constants';
44
import { Theme } from '../../theme/ThemeInterface';
@@ -65,7 +65,8 @@ export const getToastVariables = (theme: Theme): ToastVariables => {
6565
marginRight: 'auto',
6666
marginTop: 0,
6767
maxWidth: 560,
68-
position: 'absolute',
68+
// @ts-ignore: Compat with web
69+
position: Platform.OS === 'web' ? 'fixed' : 'absolute',
6970
right: 32,
7071
top: 10,
7172
zIndex: 100,

src/components/Toast/Toast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ToastBase extends React.Component<ToastProps, ToastState> {
4545
}
4646

4747
public componentDidMount() {
48-
const { onRemove, duration = 3000, offset = 75 } = this.props;
48+
const { onRemove, duration = 3000, offset = 16 } = this.props;
4949
const { value } = this.state;
5050

5151
Animated.sequence([
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as React from 'react';
2+
3+
import { TextColor } from '../../theme/ThemeInterface';
4+
import ListItem, { ListItemProps } from './ListItem';
5+
6+
export interface BulletItemProps extends ListItemProps {
7+
icon?: React.ReactNode;
8+
children: React.ReactNode;
9+
iconColor?: TextColor;
10+
}
11+
12+
const BulletItem = (props: BulletItemProps) => {
13+
const { icon, iconColor, ...listItemProps } = props;
14+
15+
return <ListItem mark={icon} {...listItemProps} />;
16+
};
17+
18+
export default BulletItem;

0 commit comments

Comments
 (0)