Skip to content

Commit

Permalink
comment addressing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramir Mesquita committed Sep 3, 2024
1 parent 213ab21 commit 63f5601
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/entities/activity/ui/items/TextItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ type TextItemProps = {

export const TextItem = ({ item, value, onValueChange, isDisabled }: TextItemProps) => {
const { maxResponseLength } = item.config;
const [hasError, setHasError] = useState(false);
const [hasError, setHasError] = useState(
maxResponseLength > 0 && value.length > maxResponseLength,
);

const numCharacters = value?.length || 0;

Expand Down Expand Up @@ -51,7 +53,7 @@ export const TextItem = ({ item, value, onValueChange, isDisabled }: TextItemPro
color={hasError ? `${Theme.colors.light.error}` : Theme.colors.light.outline}
mr={2}
>
{`${t('charactersCount', { numCharacters, maxCharacters: maxResponseLength })}`}
{t('charactersCount', { numCharacters, maxCharacters: maxResponseLength })}
</Box>
</Box>
);
Expand Down
7 changes: 4 additions & 3 deletions src/shared/ui/Items/Text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ export const TextItem = ({ value = '', onValueChange, disabled, isMultiline, has
},
},
'& .MuiInputBase-root': {
paddingRight: '2px', // Reduce padding inside the input
height: '350px',
paddingRight: '2px',
...(hasError ? { border: `2px solid ${Theme.colors.light.error}` } : {}),
borderWidth: '2px',
borderRadius: '20px',
borderRadius: '12px',
},
'& .MuiOutlinedInput-notchedOutline': {
border: hasError ? 'none' : `2px solid ${Theme.colors.light.outline}`,
border: hasError ? 'none' : `2px solid ${Theme.colors.light.surfaceVariant}`,
},
}
: null
Expand Down

0 comments on commit 63f5601

Please sign in to comment.