Skip to content
Open
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
21 changes: 19 additions & 2 deletions src/app/components/ResumeForm/Form/InputGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface InputProps<K extends string, V extends string | string[]> {
value?: V;
placeholder: string;
onChange: (name: K, value: V) => void;
maxLength?: number;
}

/**
Expand Down Expand Up @@ -42,6 +43,7 @@ export const Input = <K extends string>({
onChange,
label,
labelClassName,
maxLength,
}: InputProps<K, string>) => {
return (
<InputGroupWrapper label={label} className={labelClassName}>
Expand All @@ -52,7 +54,12 @@ export const Input = <K extends string>({
placeholder={placeholder}
onChange={(e) => onChange(name, e.target.value)}
className={INPUT_CLASS_NAME}
maxLength={maxLength}
/>
<div className="mt-1 text-right text-[11px] font-normal text-gray-400">
{value.length}
{maxLength ? ` / ${maxLength}` : ""} characters
</div>
</InputGroupWrapper>
);
};
Expand All @@ -64,6 +71,7 @@ export const Textarea = <T extends string>({
value = "",
placeholder,
onChange,
maxLength,
}: InputProps<T, string>) => {
const textareaRef = useAutosizeTextareaHeight({ value });

Expand All @@ -76,7 +84,12 @@ export const Textarea = <T extends string>({
placeholder={placeholder}
value={value}
onChange={(e) => onChange(name, e.target.value)}
maxLength={maxLength}
/>
<div className="mt-1 text-right text-[11px] font-normal text-gray-400">
{value.length}
{maxLength ? ` / ${maxLength}` : ""} characters
</div>
</InputGroupWrapper>
);
};
Expand Down Expand Up @@ -122,7 +135,7 @@ const BulletListTextareaGeneral = <T extends string>({
showBulletPoints = true,
}: InputProps<T, string[]> & { showBulletPoints?: boolean }) => {
const html = getHTMLFromBulletListStrings(bulletListStrings);
const charCount = bulletListStrings.join(" ").length;
const charCount = bulletListStrings.join(" ").length;
const maxChars = 300;

return (
Expand All @@ -144,7 +157,11 @@ const BulletListTextareaGeneral = <T extends string>({
}}
html={html}
/>
<div className={`text-right text-xs mt-1 ${charCount > maxChars ? "text-red-500" : "text-gray-400"}`}>
<div
className={`mt-1 text-right text-xs ${
charCount > maxChars ? "text-red-500" : "text-gray-400"
}`}
>
{charCount} / {maxChars} characters
</div>
</InputGroupWrapper>
Expand Down