-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: add documentation for the upload component
- Loading branch information
1 parent
e886b5f
commit 672f7e0
Showing
3 changed files
with
48 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { useForm, FormProvider, UseFormReturn } from 'react-hook-form'; | ||
|
||
interface MockFormProviderProps { | ||
children: React.ReactNode; | ||
defaultValues?: Record<string, any>; | ||
methods?: Partial<UseFormReturn>; | ||
} | ||
|
||
export const MockFormProvider: React.FC<MockFormProviderProps> = ({ children, defaultValues = {}, methods = {} }) => { | ||
const formMethods = useForm({ defaultValues }); | ||
const combinedMethods = { ...formMethods, ...methods }; | ||
|
||
return <FormProvider {...combinedMethods}>{children}</FormProvider>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import { Upload } from "./index"; | ||
import { MockFormProvider as FormProvider } from './MockFormProvider'; | ||
|
||
type Story = StoryObj<typeof Upload>; | ||
|
||
const meta: Meta<typeof Upload> = { | ||
component: Upload, | ||
title: 'Components/Upload', | ||
argTypes:{ | ||
name:{ | ||
control:{type:'text'}, | ||
description: 'Field identifier in React hook form' | ||
} | ||
}, | ||
parameters: { | ||
layout: 'centered' | ||
} | ||
}; | ||
export default meta | ||
|
||
export const Default:Story = { | ||
render: () => ( | ||
<FormProvider> | ||
<Upload/> | ||
</FormProvider> | ||
) | ||
} |