Skip to content

Commit

Permalink
feat(StringInputWithCharacterCount): handle plural form
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Sep 11, 2024
1 parent 005f8b5 commit e2cfad5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion studio/components/StringInputWithCharacterCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ export const StringInputWithCharacterCount = ({
...defaultProps
}: StringInputWithCharacterCountProps) => {
const characterCount = defaultProps.value?.length ?? 0;
const isPlural =
(maxCount !== undefined && maxCount !== 1) ||
(maxCount === undefined && characterCount !== 1);

return (
<Stack space={3}>
<Box>{defaultProps.renderDefault(defaultProps)}</Box>
<Text size={1} muted>
{characterCount}
{maxCount && `/${maxCount}`} characters
{maxCount && `/${maxCount}`} character{isPlural ? "s" : ""}
</Text>
</Stack>
);
Expand Down

0 comments on commit e2cfad5

Please sign in to comment.