Skip to content

Commit

Permalink
fix: Form Props are Now Complete
Browse files Browse the repository at this point in the history
We were missing the HTML attributes and more from the Form component,
so things like `onClick` weren't being recognized.
  • Loading branch information
jherdman authored and haideralsh committed Feb 29, 2024
1 parent a04941c commit c59039f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
16 changes: 15 additions & 1 deletion src/Form/Form.story.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { FormEvent } from "react";
import {
Alert,
Input,
Expand All @@ -13,6 +13,7 @@ import {
ListItem,
Select,
Text,
Button,
} from "../index";

const options = [
Expand Down Expand Up @@ -162,3 +163,16 @@ export const DemoForm = () => (
DemoForm.story = {
name: "Demo form",
};

export const WithAnAction = () => {
function handleSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
alert("Hello!");
}

return (
<Form onSubmit={handleSubmit}>
<Button type="submit">Click me</Button>
</Form>
);
};
20 changes: 8 additions & 12 deletions src/Form/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import React from "react";
import * as React from "react";
import styled from "styled-components";
import { space, SpaceProps } from "styled-system";
import { space } from "styled-system";
import type { SpaceProps } from "styled-system";
import { Heading2 } from "../Type";
import { Alert } from "../Alert";
import { ThemeType } from "../theme.type";
import type { ThemeType } from "../theme.type";
import Field from "./Field";
import Fieldset from "./Fieldset";
import FormSection from "./FormSection";

type FormProps = SpaceProps & {
title?: string;
children: React.ReactNode;
style?: React.CSSProperties;
id?: string;
};
interface FormProps extends SpaceProps, React.HTMLProps<HTMLFormElement> {}

type FormStylesProps = {
title?: string;
interface FormStylesProps {
title?: FormProps["title"];
theme: ThemeType;
};
}

const FormStyles = ({ title, theme }: FormStylesProps) => ({
width: "100%",
Expand Down

0 comments on commit c59039f

Please sign in to comment.