Skip to content

Commit

Permalink
feat: field suffix size based on field size
Browse files Browse the repository at this point in the history
  • Loading branch information
kostasdano committed May 21, 2024
1 parent 53001cb commit 71afdd8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/NumberField/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const NumberField = React.forwardRef<HTMLInputElement, NumberFieldProps>((props,
</ReactAriaNumberField>
</div>
{suffixContent && !hasStepper && (
<div aria-hidden={!suffixContent} css={suffixContainerStyle()}>
<div aria-hidden={!suffixContent} css={suffixContainerStyle({})}>
{suffixContent}
</div>
)}
Expand Down
6 changes: 4 additions & 2 deletions src/components/TextField/TextField.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { css } from '@emotion/react';
import type { Theme } from 'theme';
import { rem } from 'theme/utils';

import type { TextFieldProps } from '.';

export const iconWrapperStyle =
({ iconPosition, isClickable }: { iconPosition?: 'left' | 'right'; isClickable?: boolean }) =>
(theme: Theme): SerializedStyles =>
Expand All @@ -17,10 +19,10 @@ export const iconWrapperStyle =
`;

export const suffixContainerStyle =
(isClickable = false) =>
({ size, isClickable }: Pick<TextFieldProps, 'size'> & { isClickable?: boolean }) =>
(): SerializedStyles => {
return css`
min-width: ${rem(44)};
min-width: ${rem(size === 'compact' ? 28 : 44)};
overflow: visible;
display: flex;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>((props, ref
/>
</div>
{suffixContent && (
<div aria-hidden={!suffixContent} css={suffixContainerStyle()}>
<div aria-hidden={!suffixContent} css={suffixContainerStyle({size})}>
{suffixContent}
</div>
)}
Expand Down

0 comments on commit 71afdd8

Please sign in to comment.