Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('StepperTextField', () => {
});
});

const renderStepperTextField = () => {
const renderStepperTextField = (props?: Partial<React.ComponentProps<typeof StepperTextField>>) => {
render(
<StepperTextField
handleOnMinusClick={() => jest.fn()}
Expand All @@ -31,6 +31,7 @@ describe('StepperTextField', () => {
error={{
type: 'min',
}}
{...props}
/>,
);
};
Expand All @@ -40,4 +41,9 @@ describe('StepperTextField', () => {
const input = screen.getByTestId('stepper-text-field');
expect(input).toBeInTheDocument();
});

it('should render suffix when provided', () => {
renderStepperTextField({ suffix: '%' });
expect(screen.getByTestId('stepper-text-field-suffix')).toHaveTextContent('%');
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.stepper_text_field {
text-align: center;
border: none;
padding-right: 0;

&::-webkit-outer-spin-button,
&::-webkit-inner-spin-button {
Expand All @@ -16,7 +17,19 @@
width: 340px;
display: flex;
justify-content: space-between;
align-items: center;
padding-block: 12px;
border: 1px solid rgba(0, 0, 0, 0.08);
}

&__input-wrapper {
display: flex;
align-items: center;
flex-grow: 1;
}

&__suffix {
margin-left: 4px;
pointer-events: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ type StepperTextFieldProps = {
name: string;
min: number;
max: number;
/**
* Optional element to display after the input value
*/
suffix?: React.ReactNode;
error: {
type: string;
};
Expand All @@ -21,6 +25,7 @@ const StepperTextField: React.FC<StepperTextFieldProps> = ({
name,
min,
max,
suffix,
error,
...rest
}) => {
Expand Down Expand Up @@ -57,14 +62,21 @@ const StepperTextField: React.FC<StepperTextFieldProps> = ({
variant='tertiary'
disabled={value <= min || error?.type === 'min'}
/>
<input
data-testid='stepper-text-field'
type='number'
className='stepper_text_field'
step='any'
{...register(name)}
{...rest}
/>
<div className='stepper_text_field__input-wrapper'>
<input
data-testid='stepper-text-field'
type='number'
className='stepper_text_field'
step='any'
{...register(name)}
{...rest}
/>
{suffix && (
<span className='stepper_text_field__suffix' data-testid='stepper-text-field-suffix'>
{suffix}
</span>
)}
</div>
<Button
color='black'
icon={<LabelPairedPlusSmFillIcon />}
Expand Down
1 change: 1 addition & 0 deletions src/features/dashboard/update-app/AppUpdateForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const AppUpdateForm = ({ initialValues, submit, onCancel, is_loading }: TAppForm
}}
min={0}
max={3}
suffix='%'
error={errors?.app_markup_percentage}
/>
{errors?.app_markup_percentage && (
Expand Down