Skip to content

Commit

Permalink
add NumberField stories
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemobot committed Feb 14, 2022
1 parent 7b32879 commit 1b83564
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Field/createFormFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
createRadioGroupField,
RadioGroupFieldConfig,
} from "../RadioGroupField/createRadioGroupField";
import { createNumberInput } from "src/NumberInput/createNumberInput";
import { createNumberField } from "src/NumberField/createNumberField";
import { createNumberInput } from "../NumberInput/createNumberInput";
import { createNumberField } from "../NumberField/createNumberField";

type FieldsConfig = {
labelSize: ComponentProps<typeof Label>["size"];
Expand Down
37 changes: 37 additions & 0 deletions stories/Components/NumberField.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { NumberField } from "../";
import { createComponentStories, fieldArgTypes, formatMessage, textArgType } from "../util";

const { defaultExport, createControlledStory } = createComponentStories({
component: NumberField,
args: {
name: "applications",
label: formatMessage("Applications"),
placeholder: formatMessage("Number of target applications"),
assistiveText: formatMessage("The number of applications this campaign is targeting"),
},
argTypes: {
...fieldArgTypes,
placeholder: textArgType,
},
});

export default defaultExport;

export const Default = createControlledStory<number | undefined>(undefined, {});

export const Disabled = createControlledStory(0, {
disabled: true,
});

export const Error = createControlledStory(0, {
issues: [formatMessage("Please insert a number greater than 2")],
});

export const Currency = createControlledStory(0, {
kind: "currency",
currency: "EUR",
});

export const Percentage = createControlledStory(0, {
kind: "percentage",
});
2 changes: 1 addition & 1 deletion stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { sprinkles } from "./sprinkles.css";
export * from "../src";
export const Box = createBentoBox(sprinkles);
export const { Stack, Column, Columns, Inline, Inset } = createLayoutComponents(Box);
export const { TextField, CheckboxField, RadioGroupField } = createFormFields();
export const { CheckboxField, NumberField, RadioGroupField, TextField } = createFormFields();
export const Button = createButton({});
export const Banner = createBanner({});
export const { Toast, ToastProvider } = createToast(Button, {});
Expand Down

0 comments on commit 1b83564

Please sign in to comment.