Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct text color #3686

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/components/HelperText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ const HelperText = ({

const { colors, dark } = theme;

const textColor =
type === 'error'
? colors?.error
: color(theme.isV3 ? theme.colors.onSurface : theme?.colors?.text)
.alpha(dark ? 0.7 : 0.54)
.rgb()
.string();
const infoTextColor = theme.isV3
? theme.colors.onSurfaceVariant
: color(theme?.colors?.text)
.alpha(dark ? 0.7 : 0.54)
.rgb()
.string();
const textColor = type === 'error' ? colors?.error : infoTextColor;

return (
<AnimatedText
Expand Down
32 changes: 32 additions & 0 deletions src/components/__tests__/HelperText.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';

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

import { getTheme } from '../../core/theming';
import HelperText from '../HelperText';

describe('HelperText', () => {
it('should have correct text color for info type', () => {
const { getByTestId } = render(
<HelperText testID="helper-text" type="info">
Info: Maximum length is 100 characters
</HelperText>
);

expect(getByTestId('helper-text')).toHaveStyle({
color: getTheme().colors.onSurfaceVariant,
});
});

it('should have correct text color for error type', () => {
const { getByTestId } = render(
<HelperText testID="helper-text" type="error">
Error: Only letters are allowed
</HelperText>
);

expect(getByTestId('helper-text')).toHaveStyle({
color: getTheme().colors.error,
});
});
});