Skip to content

Commit c0cd6c9

Browse files
authored
fix: correct text color (#3686)
1 parent 738d65a commit c0cd6c9

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

src/components/HelperText.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ const HelperText = ({
124124

125125
const { colors, dark } = theme;
126126

127-
const textColor =
128-
type === 'error'
129-
? colors?.error
130-
: color(theme.isV3 ? theme.colors.onSurface : theme?.colors?.text)
131-
.alpha(dark ? 0.7 : 0.54)
132-
.rgb()
133-
.string();
127+
const infoTextColor = theme.isV3
128+
? theme.colors.onSurfaceVariant
129+
: color(theme?.colors?.text)
130+
.alpha(dark ? 0.7 : 0.54)
131+
.rgb()
132+
.string();
133+
const textColor = type === 'error' ? colors?.error : infoTextColor;
134134

135135
return (
136136
<AnimatedText
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
3+
import { render } from '@testing-library/react-native';
4+
5+
import { getTheme } from '../../core/theming';
6+
import HelperText from '../HelperText';
7+
8+
describe('HelperText', () => {
9+
it('should have correct text color for info type', () => {
10+
const { getByTestId } = render(
11+
<HelperText testID="helper-text" type="info">
12+
Info: Maximum length is 100 characters
13+
</HelperText>
14+
);
15+
16+
expect(getByTestId('helper-text')).toHaveStyle({
17+
color: getTheme().colors.onSurfaceVariant,
18+
});
19+
});
20+
21+
it('should have correct text color for error type', () => {
22+
const { getByTestId } = render(
23+
<HelperText testID="helper-text" type="error">
24+
Error: Only letters are allowed
25+
</HelperText>
26+
);
27+
28+
expect(getByTestId('helper-text')).toHaveStyle({
29+
color: getTheme().colors.error,
30+
});
31+
});
32+
});

0 commit comments

Comments
 (0)