element-call/src/Input.jsx

45 lines
987 B
React
Raw Normal View History

2021-08-20 00:49:45 +00:00
import React, { forwardRef } from "react";
import classNames from "classnames";
import styles from "./Input.module.css";
export function FieldRow({ children, rightAlign, className, ...rest }) {
return (
<div
className={classNames(
styles.fieldRow,
{ [styles.rightAlign]: rightAlign },
className
)}
>
{children}
</div>
);
}
export function Field({ children, className, ...rest }) {
return <div className={classNames(styles.field, className)}>{children}</div>;
}
export const InputField = forwardRef(
({ id, label, className, ...rest }, ref) => {
return (
<Field>
<input id={id} {...rest} ref={ref} />
<label for={id}>{label}</label>
</Field>
);
}
);
export const Button = forwardRef(({ className, children, ...rest }, ref) => {
return (
<button
className={classNames(styles.button, className)}
ref={ref}
{...rest}
>
{children}
</button>
);
});