Add char counter to message input
This commit is contained in:
@@ -15,16 +15,18 @@ export interface InputProps extends DefaultInputProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
||||||
{ label, error, action, suffix, ...props }: InputProps,
|
{ label, error, action, suffix, className, disabled, ...props }: InputProps,
|
||||||
ref,
|
ref,
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
{label && <Label label={label} error={error} />}
|
{label && <Label label={label} error={error} />}
|
||||||
<InputWrapper error={error} disabled={props.disabled}>
|
<InputWrapper error={error} disabled={disabled}>
|
||||||
<input
|
<input
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className="h-10 w-full bg-transparent px-3 py-2 focus:outline-none disabled:cursor-not-allowed dark:text-white"
|
className={`h-10 w-full bg-transparent px-3 py-2 focus:outline-none disabled:cursor-not-allowed dark:text-white ${
|
||||||
|
className ?? ''
|
||||||
|
}`}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
{suffix && (
|
{suffix && (
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export const MessageBar = ({ chatIndex }: MessageBarProps): JSX.Element => {
|
|||||||
<div className="mx-auto flex w-full space-x-2 bg-gray-50 bg-transparent p-3 text-gray-500 dark:text-gray-400">
|
<div className="mx-auto flex w-full space-x-2 bg-gray-50 bg-transparent p-3 text-gray-500 dark:text-gray-400">
|
||||||
<div className="mx-auto flex w-full max-w-4xl">
|
<div className="mx-auto flex w-full max-w-4xl">
|
||||||
<form
|
<form
|
||||||
className="flex w-full space-x-2"
|
className="relative flex w-full space-x-2"
|
||||||
onSubmit={(e): void => {
|
onSubmit={(e): void => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
sendMessage();
|
sendMessage();
|
||||||
@@ -70,10 +70,16 @@ export const MessageBar = ({ chatIndex }: MessageBarProps): JSX.Element => {
|
|||||||
placeholder="Enter Message"
|
placeholder="Enter Message"
|
||||||
disabled={!meshtasticState.ready}
|
disabled={!meshtasticState.ready}
|
||||||
value={currentMessage}
|
value={currentMessage}
|
||||||
|
className="mr-16"
|
||||||
onChange={(e): void => {
|
onChange={(e): void => {
|
||||||
setCurrentMessage(e.target.value);
|
setCurrentMessage(e.target.value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<div className="absolute right-1 flex h-10">
|
||||||
|
<div className="z-10 my-auto mr-0.5 rounded-md border bg-secondaryDark bg-opacity-50 p-1 font-mono text-xs text-white">
|
||||||
|
{currentMessage.length}/255
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user