UI: init FieldLayout wrapper
This commit is contained in:
29
pkgs/webview-ui/app/src/Form/fields/layout.tsx
Normal file
29
pkgs/webview-ui/app/src/Form/fields/layout.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { JSX, splitProps } from "solid-js";
|
||||
import cx from "classnames";
|
||||
|
||||
interface LayoutProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
||||
field?: JSX.Element;
|
||||
label?: JSX.Element;
|
||||
error?: JSX.Element;
|
||||
}
|
||||
export const FieldLayout = (props: LayoutProps) => {
|
||||
const [intern, divProps] = splitProps(props, [
|
||||
"field",
|
||||
"label",
|
||||
"error",
|
||||
"class",
|
||||
]);
|
||||
return (
|
||||
<div
|
||||
class={cx("grid grid-cols-12 items-center", intern.class)}
|
||||
classList={{
|
||||
"mb-[14.5px]": !props.error,
|
||||
}}
|
||||
{...divProps}
|
||||
>
|
||||
<label class="col-span-2">{props.label}</label>
|
||||
<div class="col-span-10">{props.field}</div>
|
||||
{props.error && <span class="col-span-full">{props.error}</span>}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user