Skip to content

Commit 9ca1695

Browse files
committed
fix(*): massive refactor
1 parent f916b26 commit 9ca1695

147 files changed

Lines changed: 566 additions & 3111 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/components/Alert/Alert.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ menu: Components
44
---
55

66
import { Playground, PropsTable } from 'docz';
7-
import Alert from './Alert';
7+
import { Alert } from './Alert';
88
import { Spacing } from '../Layout';
99

1010
# Alert

src/components/Alert/Alert.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import { DeepPartial } from 'ts-essentials';
44

55
import { Intent } from '../../constants/Intent';
66
import { Icon } from '../../icons';
7-
import { Theme, withTheme } from '../../theme';
7+
import { Theme, useTheme } from '../../theme';
88
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
99
import { Spacing } from '../Layout';
1010
import { Text } from '../Typography';
1111
import { AlertStyles, GetAlertStyles, getAlertStyles } from './Alert.styles';
1212

1313
export interface AlertProps {
14-
theme: Theme;
1514
title?: string;
1615
description?: string;
1716
testID?: string;
@@ -48,7 +47,7 @@ const resolveIcon = (intent: Intent, theme: Theme) => {
4847
}
4948
};
5049

51-
const AlertBase = (props: AlertProps) => {
50+
export const Alert = (props: AlertProps) => {
5251
const {
5352
title,
5453
description,
@@ -58,10 +57,11 @@ const AlertBase = (props: AlertProps) => {
5857
icon,
5958
intent = 'info',
6059
getStyles,
61-
theme,
6260
testID,
6361
} = props;
6462

63+
const theme = useTheme();
64+
6565
const { containerStyle, bodyStyle } = mergeStyles(getAlertStyles, getStyles)(
6666
{ intent },
6767
theme,
@@ -90,6 +90,3 @@ const AlertBase = (props: AlertProps) => {
9090
</View>
9191
);
9292
};
93-
94-
export const Alert = withTheme(AlertBase);
95-
export default Alert;

src/components/Alert/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as Alert, AlertProps } from './Alert';
1+
export * from './Alert';

src/components/Avatar/Avatar.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ menu: Components
44
---
55

66
import { Playground, PropsTable } from 'docz';
7-
import Avatar from './Avatar';
7+
import { Avatar } from './Avatar';
88

99
# Avatar
1010

src/components/Avatar/Avatar.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { Image, ImageSourcePropType, View } from 'react-native';
33
import { DeepPartial } from 'ts-essentials';
44

5-
import { Theme, withTheme } from '../../theme';
5+
import { useTheme } from '../../theme';
66
import { FillColors } from '../../theme/ThemeInterface';
77
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
88
import { Text } from '../Typography';
@@ -15,7 +15,7 @@ import {
1515
// https://github.com/segmentio/evergreen/blob/master/source/avatar/README.md
1616
export type GetInitialsType = (name?: string, fallback?: string) => string;
1717

18-
export const globalGetInitials: GetInitialsType = (name, fallback = '?') => {
18+
const globalGetInitials: GetInitialsType = (name, fallback = '?') => {
1919
if (!name) return fallback;
2020

2121
return name
@@ -77,20 +77,13 @@ export interface AvatarProps {
7777
*/
7878
sizeLimitOneCharacter?: number;
7979

80-
/**
81-
* Theme provided by ThemeProvider.
82-
*/
83-
theme: Theme;
84-
8580
getStyles?: ReplaceReturnType<GetAvatarStyles, DeepPartial<AvatarStyles>>;
8681

8782
testID?: string;
8883
}
8984

90-
export const AvatarBase = (props: AvatarProps) => {
85+
export const Avatar = (props: AvatarProps) => {
9186
const {
92-
theme,
93-
9487
source,
9588
size = 48,
9689
name,
@@ -104,6 +97,8 @@ export const AvatarBase = (props: AvatarProps) => {
10497
testID,
10598
} = props;
10699

100+
const theme = useTheme();
101+
107102
const { imageHasFailedLoading } = { imageHasFailedLoading: false };
108103
const imageUnavailable = !source || imageHasFailedLoading;
109104

@@ -144,6 +139,3 @@ export const AvatarBase = (props: AvatarProps) => {
144139
</View>
145140
);
146141
};
147-
148-
export const Avatar = withTheme(AvatarBase);
149-
export default Avatar;

src/components/Avatar/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as Avatar, AvatarProps } from './Avatar';
1+
export * from './Avatar';

src/components/Badge/Badge.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ menu: Components
44
---
55

66
import { Playground, PropsTable } from 'docz';
7-
import Badge from './Badge';
7+
import { Badge } from './Badge';
88
import { ThemeContext } from '../../theme';
99
import { Box } from '../Layout';
1010

src/components/Badge/Badge.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react';
22
import { View } from 'react-native';
33
import { DeepPartial } from 'ts-essentials';
44

5-
import { Theme, withTheme } from '../../theme';
5+
import { useTheme } from '../../theme';
66
import { FillColor } from '../../theme/ThemeInterface';
77
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
8-
import Box, { Shape } from '../Layout/Box';
8+
import { Shape } from '../Layout/Box';
99
import { Text } from '../Typography';
1010
import {
1111
BadgeSize,
@@ -16,7 +16,6 @@ import {
1616

1717
export interface BadgeProps {
1818
children: React.ReactNode;
19-
theme: Theme;
2019
color?: FillColor;
2120
size?: BadgeSize;
2221
shape?: Shape;
@@ -25,18 +24,19 @@ export interface BadgeProps {
2524
testID?: string;
2625
}
2726

28-
const BadgeBase = (props: BadgeProps) => {
27+
export const Badge = (props: BadgeProps) => {
2928
const {
3029
children,
3130
color = 'neutral',
3231
getStyles,
3332
isSolid = false,
3433
shape = 'rounded',
3534
size = 'small',
36-
theme,
3735
testID,
3836
} = props;
3937

38+
const theme = useTheme();
39+
4040
const { containerStyle, textStyle } = mergeStyles(getBadgeStyles, getStyles)(
4141
{ size, color, isSolid, shape },
4242
theme,
@@ -56,6 +56,3 @@ const BadgeBase = (props: BadgeProps) => {
5656
</View>
5757
);
5858
};
59-
60-
export const Badge = withTheme(BadgeBase);
61-
export default Badge;

src/components/Badge/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as Badge, BadgeProps } from './Badge';
1+
export * from './Badge';
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import * as React from 'react';
22

33
import { Icon } from '../../icons';
4-
import { withTheme } from '../../theme';
5-
import Button, { ButtonProps } from './Button';
4+
import { useTheme } from '../../theme';
5+
import { Button, ButtonProps } from './Button';
6+
7+
export const BackButton = (props: ButtonProps) => {
8+
const theme = useTheme();
69

7-
const BackButton = (props: ButtonProps) => {
8-
const { theme } = props;
910
return (
1011
<Button
1112
appearance="minimal"
@@ -18,5 +19,3 @@ const BackButton = (props: ButtonProps) => {
1819
/>
1920
);
2021
};
21-
22-
export default withTheme(BackButton);

0 commit comments

Comments
 (0)