Skip to content

Commit

Permalink
feat(Input): Update colors for error message, icon and border in dark…
Browse files Browse the repository at this point in the history
… mode. (#1501)

Co-authored-by: Nikita Orliak <[email protected]>
  • Loading branch information
nikitaorliak-cengage and Nikita Orliak authored Oct 24, 2024
1 parent 6a9e274 commit 360cf8d
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/feat-input-error-state-update-colors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-magma-dom': minor
---

feat(Input): Update colors for error message, icon and border in dark mode.
2 changes: 1 addition & 1 deletion packages/dropzone/src/components/dropzone/Dropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const Container = styled(Flex)<
? `0px`
: dragState === 'dragReject' || dragState === 'error'
? isInverse
? `1px dashed ${theme.colors.danger200}`
? `1px dashed ${theme.colors.danger300}`
: `1px dashed ${theme.colors.danger}`
: dragState === 'dragActive'
? `1px dashed ${theme.colors.primary}`
Expand Down
4 changes: 2 additions & 2 deletions packages/dropzone/src/components/dropzone/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const StyledCard = styled(Card)<{ file: FilePreview; isInverse: boolean }>`
border-color: ${({ file, theme, isInverse }) =>
file.errors
? isInverse
? theme.colors.danger200
? theme.colors.danger300
: theme.colors.danger
: theme.colors.neutral300};
border-width: 1px;
Expand Down Expand Up @@ -286,7 +286,7 @@ export const Preview = forwardRef<HTMLDivElement, PreviewProps>(
{file.errors ? (
<ErrorIcon
color={
isInverse ? theme.colors.danger200 : theme.colors.danger
isInverse ? theme.colors.danger300 : theme.colors.danger
}
size={24}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ describe('Checkbox', () => {
);

const span = container.querySelector('span');
expect(span).toHaveStyleRule('border-color', magma.colors.danger200);
expect(span).toHaveStyleRule('border-color', magma.colors.danger300);
expect(span).toHaveStyleRule('color', magma.colors.neutral100);
});

Expand Down
7 changes: 4 additions & 3 deletions packages/react-magma-dom/src/components/Input/Input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,17 @@ describe('Input', () => {
it('should render an inverse input with a correctly styled error message', () => {
const labelText = 'test label';
const testMessage = 'Test error message';
const { getByTestId, getByLabelText } = render(
const { getByTestId, getByLabelText, getByRole } = render(
<Input errorMessage={testMessage} isInverse labelText={labelText} />
);

const input = getByLabelText(labelText).parentElement;
const errorMessage = getByTestId('inputMessage');
const errorIcon = getByRole('img').firstChild;

expect(input).toHaveStyleRule('border-color', magma.colors.danger200);

expect(input).toHaveStyleRule('border-color', magma.colors.danger300);
expect(errorMessage).toHaveStyleRule('color', magma.colors.danger200);
expect(errorIcon).toHaveAttribute('fill', magma.colors.danger300);
});

it('should render an input with a right-aligned icon by default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ export const InputMessage: React.FunctionComponent<InputMessageProps> = ({
>
{hasError && (
<IconWrapper aria-label="Error" role="img" theme={theme}>
<ErrorIcon size={theme.iconSizes.small} />
<ErrorIcon
size={theme.iconSizes.small}
color={isInverse ? theme.colors.danger300 : undefined}
/>
</IconWrapper>
)}
<div>{children}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const inputWrapperStyles = (props: InputWrapperStylesProps) => css`
${props.hasError &&
css`
border-color: ${props.isInverse
? props.theme.colors.danger200
? props.theme.colors.danger300
: props.theme.colors.danger};
`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('NativeSelect', () => {

expect(getByTestId(testId).parentElement).toHaveStyleRule(
'border',
`1px solid ${magma.colors.danger200}`
`1px solid ${magma.colors.danger300}`
);

expect(getByText(errorMessage)).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const StyledNativeSelectWrapper = styled.div<{
function borderColors(props) {
if (props.isInverse) {
if (props.hasError) {
return props.theme.colors.danger200;
return props.theme.colors.danger300;
}
if (props.disabled) {
return transparentize(0.85, props.theme.colors.neutral100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe('Radio', () => {

expect(span).toHaveStyleRule(
'box-shadow',
`0 0 0 2px ${magma.colors.danger200}`
`0 0 0 2px ${magma.colors.danger300}`
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/react-magma-dom/src/components/Radio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function buildRadioIconColor(props) {
export function buildErrorBorder(props) {
if (props.hasError) {
if (props.isInverse) {
return `0 0 0 2px ${props.theme.colors.danger200}`;
return `0 0 0 2px ${props.theme.colors.danger300}`;
}
return `0 0 0 2px ${props.theme.colors.danger}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function buildDisplayInputActiveBackground(props) {
export function buildDisplayInputBorderColor(props) {
if (props.hasError) {
if (props.isInverse) {
return props.theme.colors.danger200;
return props.theme.colors.danger300;
}
return props.theme.colors.danger;
}
Expand Down

2 comments on commit 360cf8d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.