Skip to content

Commit 6e4785c

Browse files
committed
refactor: remove v2 colors
1 parent ced3c26 commit 6e4785c

30 files changed

+95
-94
lines changed

src/components/Appbar/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
33
import { StyleSheet, Animated } from 'react-native';
44

5-
import { white } from '../../styles/themes/v2/colors';
5+
import { MD3Colors } from '../../styles/themes/v3/tokens';
66
import type { InternalTheme, ThemeProp } from '../../types';
77

88
export type AppbarModes = 'small' | 'medium' | 'large' | 'center-aligned';
@@ -49,7 +49,7 @@ export const getAppbarColor = ({
4949
}
5050

5151
if (isDark) {
52-
return white;
52+
return MD3Colors.primary100;
5353
}
5454

5555
return undefined;

src/components/Avatar/AvatarIcon.tsx

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

44
import { useInternalTheme } from '../../core/theming';
5-
import { white } from '../../styles/themes/v2/colors';
5+
import { MD3Colors } from '../../styles/themes/v3/tokens';
66
import type { ThemeProp } from '../../types';
77
import getContrastingColor from '../../utils/getContrastingColor';
88
import Icon, { IconSource } from '../Icon';
@@ -56,7 +56,11 @@ const Avatar = ({
5656
StyleSheet.flatten(style) || {};
5757
const textColor =
5858
rest.color ??
59-
getContrastingColor(backgroundColor, white, 'rgba(0, 0, 0, .54)');
59+
getContrastingColor(
60+
backgroundColor,
61+
MD3Colors.primary100,
62+
'rgba(0, 0, 0, .54)'
63+
);
6064

6165
return (
6266
<View

src/components/Avatar/AvatarText.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from 'react-native';
1010

1111
import { useInternalTheme } from '../../core/theming';
12-
import { white } from '../../styles/themes/v2/colors';
12+
import { MD3Colors } from '../../styles/themes/v3/tokens';
1313
import type { ThemeProp } from '../../types';
1414
import getContrastingColor from '../../utils/getContrastingColor';
1515
import Text from '../Typography/Text';
@@ -77,7 +77,11 @@ const AvatarText = ({
7777
StyleSheet.flatten(style) || {};
7878
const textColor =
7979
customColor ??
80-
getContrastingColor(backgroundColor, white, 'rgba(0, 0, 0, .54)');
80+
getContrastingColor(
81+
backgroundColor,
82+
MD3Colors.primary100,
83+
'rgba(0, 0, 0, .54)'
84+
);
8185
const { fontScale } = useWindowDimensions();
8286

8387
return (

src/components/Button/utils.tsx

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

33
import color from 'color';
44

5-
import { black, white } from '../../styles/themes/v2/colors';
5+
import { MD3Colors } from '../../styles/themes/v3/tokens';
66
import type { InternalTheme } from '../../types';
77
import { splitStyles } from '../../utils/splitStyles';
88

@@ -109,7 +109,9 @@ const getButtonTextColor = ({
109109
isMode('contained-tonal') ||
110110
isMode('elevated')
111111
) {
112-
return isDark({ dark, backgroundColor }) ? white : black;
112+
return isDark({ dark, backgroundColor })
113+
? MD3Colors.primary100
114+
: MD3Colors.primary0;
113115
}
114116
}
115117

src/components/Card/CardCover.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Image, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
33

44
import { getCardCoverStyle } from './utils';
55
import { useInternalTheme } from '../../core/theming';
6-
import { grey200 } from '../../styles/themes/v2/colors';
76
import type { ThemeProp } from '../../types';
87
import { splitStyles } from '../../utils/splitStyles';
98

@@ -79,7 +78,6 @@ CardCover.displayName = 'Card.Cover';
7978
const styles = StyleSheet.create({
8079
container: {
8180
height: 195,
82-
backgroundColor: grey200,
8381
overflow: 'hidden',
8482
},
8583
image: {

src/components/Chip/Chip.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import useLatestCallback from 'use-latest-callback';
1818

1919
import { ChipAvatarProps, getChipColors } from './helpers';
2020
import { useInternalTheme } from '../../core/theming';
21-
import { white } from '../../styles/themes/v2/colors';
21+
import { MD3Colors } from '../../styles/themes/v3/tokens';
2222
import type { $Omit, EllipsizeProp, ThemeProp } from '../../types';
2323
import hasTouchHandler from '../../utils/hasTouchHandler';
2424
import type { IconSource } from '../Icon';
@@ -360,14 +360,20 @@ const Chip = ({
360360
{icon ? (
361361
<Icon
362362
source={icon}
363-
color={avatar ? white : !disabled ? primary : iconColor}
363+
color={
364+
avatar
365+
? MD3Colors.primary100
366+
: !disabled
367+
? primary
368+
: iconColor
369+
}
364370
size={18}
365371
theme={theme}
366372
/>
367373
) : (
368374
<MaterialCommunityIcon
369375
name="check"
370-
color={avatar ? white : iconColor}
376+
color={avatar ? MD3Colors.primary100 : iconColor}
371377
size={18}
372378
direction="ltr"
373379
/>

src/components/MaterialCommunityIcon.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import * as React from 'react';
22
import { ComponentProps } from 'react';
33
import { StyleSheet, Text, Platform, Role, ViewProps } from 'react-native';
44

5-
import { black } from '../styles/themes/v2/colors';
6-
75
export type IconProps = {
86
name: ComponentProps<typeof MaterialCommunityIcons>['name'];
97
color?: string;
@@ -97,7 +95,7 @@ const MaterialCommunityIcons: IconModuleType = IconModule || FallbackIcon;
9795
*/
9896
const DefaultIcon = ({
9997
name,
100-
color = black,
98+
color = 'black',
10199
size,
102100
direction,
103101
allowFontScaling,

src/components/Switch/utils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import { Platform } from 'react-native';
22

33
import setColor from 'color';
44

5-
import {
6-
grey400,
7-
grey800,
8-
grey50,
9-
grey700,
10-
white,
11-
black,
12-
} from '../../styles/themes/v2/colors';
135
import type { InternalTheme } from '../../types';
146

7+
export const black = '#000000';
8+
export const white = '#ffffff';
9+
export const grey50 = '#fafafa';
10+
export const grey200 = '#eeeeee';
11+
export const grey400 = '#bdbdbd';
12+
export const grey700 = '#616161';
13+
export const grey800 = '#424242';
14+
1515
type BaseProps = {
1616
theme: InternalTheme;
1717
disabled?: boolean;

src/components/__tests__/Avatar.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { StyleSheet } from 'react-native';
33

44
import { fireEvent, render } from '@testing-library/react-native';
55

6-
import { red500 } from '../../styles/themes/v2/colors';
6+
import { MD3Colors } from '../../styles/themes/v3/tokens';
77
import * as Avatar from '../Avatar/Avatar';
88

99
const styles = StyleSheet.create({
1010
bgColor: {
11-
backgroundColor: red500,
11+
backgroundColor: MD3Colors.error50,
1212
},
1313
});
1414

src/components/__tests__/Badge.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22

33
import { render } from '@testing-library/react-native';
44

5-
import { red500 } from '../../styles/themes/v2/colors';
5+
import { MD3Colors } from '../../styles/themes/v3/tokens';
66
import Badge from '../Badge';
77

88
it('renders badge', () => {
@@ -35,7 +35,7 @@ it('renders badge as hidden', () => {
3535

3636
it('renders badge in different color', () => {
3737
const tree = render(
38-
<Badge style={{ backgroundColor: red500 }}>3</Badge>
38+
<Badge style={{ backgroundColor: MD3Colors.error50 }}>3</Badge>
3939
).toJSON();
4040

4141
expect(tree).toMatchSnapshot();

0 commit comments

Comments
 (0)