Skip to content

Commit

Permalink
ui(InputNumber): adding label element in InputNumber Component and … (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sofien-Sellami authored Jul 7, 2023
1 parent 92273b2 commit 5ab74f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion platform/ui/src/components/InputNumber/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React, { useState, useCallback } from 'react';
import IconButton from '../IconButton';
import Icon from '../Icon';
import './InputNumber.css';
import Label from '../Label';

/**
* React Number Input component'
* React Number Input component'
* it has two props, value and onChange
* value is a number value
* onChange is a function that will be called when the number input is changed
Expand All @@ -14,6 +15,7 @@ import './InputNumber.css';

const sizesClasses = {
sm: 'w-[45px] h-[28px]',
lg: 'w-[206px] h-[35px]',
};

const InputNumber: React.FC<{
Expand All @@ -24,6 +26,8 @@ const InputNumber: React.FC<{
step: number;
size?: string;
className?: string;
labelClassName?: string;
label?: string;
}> = ({
value,
onChange,
Expand All @@ -32,6 +36,8 @@ const InputNumber: React.FC<{
size = 'sm',
minValue = 0,
maxValue = 100,
labelClassName,
label,
}) => {
const [numberValue, setNumberValue] = useState(value);

Expand Down Expand Up @@ -76,6 +82,8 @@ const InputNumber: React.FC<{
);

return (
<div className={'flex flex-col flex-1'}>
{label && <Label className={labelClassName} text={label}></Label>}
<div
className={`flex items-center bg-black border-2 px-1 overflow-hidden justify-center border-secondary-light rounded-md ${sizesClasses[size]
} ${className ? className : ''}`}
Expand Down Expand Up @@ -112,6 +120,7 @@ const InputNumber: React.FC<{
</div>
</div>
</div>
</div>
);
};

Expand Down
1 change: 1 addition & 0 deletions platform/ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export {
IconButton,
Input,
InputRange,
InputNumber,
InputDateRange,
InputGroup,
InputLabelWrapper,
Expand Down

0 comments on commit 5ab74f5

Please sign in to comment.