Skip to content

Commit

Permalink
feat: release form component
Browse files Browse the repository at this point in the history
  • Loading branch information
sapkra committed Jun 13, 2024
1 parent a60fcee commit fe25ea4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/fragments/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from "react";
import { tv } from "@nextui-org/react";
import { Divider } from "../../components";

interface FormProps {
interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
children: React.ReactNode[];
}

Expand All @@ -17,16 +17,16 @@ const form = tv({
});

export const Form: React.FC<FormProps> = ({ children, ...props }) => {
const v = form(props);
const v = form();

return (
<section>
<form {...props}>
{children.map((child, index) => index === 0 ? child : (
<React.Fragment key={index}>
<Divider className={v.divider()} />
{child}
</React.Fragment>
))}
</section>
</form>
);
};
1 change: 1 addition & 0 deletions src/fragments/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './form/Form';
export * from './form/FormSection';
export * from './shell/Shell';
export * from './sidebar/Sidebar';
Expand Down
42 changes: 20 additions & 22 deletions src/fragments/shell/Shell.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,28 +212,26 @@ export const WithTable: Story = {
</Table>
</Tab>
<Tab key="settings" title="Settings">
<form>
<Form>
<FormSection title="Name" description="Description" direction="horizontal">
<Input label="First name" />
<Input label="Last name" />
</FormSection>
<FormSection title="Biography" description="Description">
<Textarea label="Biography" minRows={6} />
</FormSection>
<FormSection title="Notifications" description="Turn on/off email notifications." direction="horizontal">
<Switch />
</FormSection>
<FormSection title="Title" description="Description" direction="horizontal">
<Input label="First name" />
<Input label="Last name" />
</FormSection>
<FormSection title="Full Width" description="Description" direction="horizontal" fullWidth>
<Input label="First name" />
<Input label="Last name" />
</FormSection>
</Form>
</form>
<Form>
<FormSection title="Name" description="Description" direction="horizontal">
<Input label="First name" />
<Input label="Last name" />
</FormSection>
<FormSection title="Biography" description="Description">
<Textarea label="Biography" minRows={6} />
</FormSection>
<FormSection title="Notifications" description="Turn on/off email notifications." direction="horizontal">
<Switch />
</FormSection>
<FormSection title="Title" description="Description" direction="horizontal">
<Input label="First name" />
<Input label="Last name" />
</FormSection>
<FormSection title="Full Width" description="Description" direction="horizontal" fullWidth>
<Input label="First name" />
<Input label="Last name" />
</FormSection>
</Form>
</Tab>
<Tab key="videos" title="Videos">
<Card>
Expand Down

0 comments on commit fe25ea4

Please sign in to comment.