-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from awell-health/forms
Add form folder & components
- Loading branch information
Showing
43 changed files
with
217 additions
and
40 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
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
export * from './ui/action-icon'; | ||
export * from './ui/alert-dialog'; | ||
export * from './ui/alert'; | ||
export * from './ui/avatar'; | ||
export * from './ui/alert-dialog'; | ||
export * from './ui/badge'; | ||
export * from './ui/button'; | ||
export * from './ui/card'; | ||
export * from './ui/dropdown'; | ||
export * from './ui/form/checkbox'; | ||
export * from './ui/form/input'; | ||
export * from './ui/form/form-section'; | ||
export * from './ui/form/select'; | ||
export * from './ui/form/textarea'; | ||
export * from './ui/form/toggle'; | ||
export * from './ui/icon'; | ||
export * from './ui/input'; | ||
export * from './ui/select'; | ||
export * from './ui/tab'; | ||
export * from './ui/table'; | ||
export * from './ui/textarea'; | ||
export * from './ui/tooltip'; | ||
export * from './ui/toast'; | ||
export * from './ui/action-icon'; | ||
export * from './ui/pagination'; | ||
export * from './ui/checkbox'; | ||
export * from './ui/toggle'; | ||
export * from './ui/menu'; | ||
export * from './ui/spinner'; | ||
export * from './ui/modal'; | ||
export * from './ui/pagination'; | ||
export * from './ui/radial-progress'; | ||
export * from './ui/spinner'; | ||
export * from './ui/tab'; | ||
export * from './ui/table'; | ||
export * from './ui/toast'; | ||
export * from './ui/tooltip'; |
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,11 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { expect, it, describe } from 'vitest'; | ||
import { Divider } from './Divider'; | ||
|
||
describe('Divider', () => { | ||
it('match snapshot', () => { | ||
const { container } = render(<Divider />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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 @@ | ||
export const Divider = (): JSX.Element => <div className='h-[1.5px] bg-gray-200 w-full' />; |
9 changes: 9 additions & 0 deletions
9
src/components/ui/divider/__snapshots__/Divider.spec.tsx.snap
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,9 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Divider > match snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="h-[1.5px] bg-gray-200 w-full" | ||
/> | ||
</div> | ||
`; |
22 changes: 22 additions & 0 deletions
22
src/components/ui/divider/__snapshots__/FormSection.spec.tsx.snap
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,22 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`FormSection > match snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="py-6 flex flex-col gap-2" | ||
> | ||
<h5 | ||
class="text-lg font-medium leading-5 text-neutral-dark-800" | ||
> | ||
Test Title | ||
</h5> | ||
<div | ||
class="mt-2" | ||
> | ||
<div> | ||
Test Content | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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,3 @@ | ||
import { Divider } from './Divider'; | ||
|
||
export { Divider }; |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,37 @@ | ||
import * as React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { expect, it, describe } from 'vitest'; | ||
import { FormSection } from './FormSection'; | ||
|
||
describe('FormSection', () => { | ||
const subject = (props = {}) => ( | ||
<FormSection title='Test Title' {...props}> | ||
<div>Test Content</div> | ||
</FormSection> | ||
); | ||
|
||
it('match snapshot', () => { | ||
const { container } = render(subject()); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders the title', () => { | ||
render(subject()); | ||
expect(screen.getByText('Test Title')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the hint when provided', () => { | ||
render(subject({ hint: 'Test Hint' })); | ||
expect(screen.getByText('Test Hint')).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render the hint when not provided', () => { | ||
render(subject()); | ||
expect(screen.queryByText('Test Hint')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('renders children content', () => { | ||
render(subject({ children: 'Test Content' })); | ||
expect(screen.getByText('Test Content')).toBeInTheDocument(); | ||
}); | ||
}); |
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,17 @@ | ||
import { FC } from 'react'; | ||
|
||
interface Props { | ||
title: string; | ||
hint?: string; | ||
children: React.ReactNode | JSX.Element | string; | ||
} | ||
|
||
export const FormSection: FC<Props> = ({ children, title, hint = null }) => { | ||
return ( | ||
<div className='py-6 flex flex-col gap-2'> | ||
<h5 className='text-lg font-medium leading-5 text-neutral-dark-800'>{title}</h5> | ||
{hint !== null && <div className='text-gray-500'>{hint}</div>} | ||
<div className='mt-2'>{children}</div> | ||
</div> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
src/components/ui/form/form-section/__snapshots__/FormSection.spec.tsx.snap
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,22 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`FormSection > match snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="py-6 flex flex-col gap-2" | ||
> | ||
<h5 | ||
class="text-lg font-medium leading-5 text-neutral-dark-800" | ||
> | ||
Test Title | ||
</h5> | ||
<div | ||
class="mt-2" | ||
> | ||
<div> | ||
Test Content | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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,3 @@ | ||
import { FormSection } from './FormSection'; | ||
|
||
export { FormSection }; |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/components/ui/input/input.spec.tsx → src/components/ui/form/input/input.spec.tsx
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,14 @@ | ||
import { Divider } from '@/components/ui/divider'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta = { | ||
component: Divider | ||
} satisfies Meta<typeof Divider>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Divider>; | ||
|
||
export const Example = { | ||
render: () => <Divider /> | ||
} satisfies Story; |
2 changes: 1 addition & 1 deletion
2
src/stories/Checkbox.stories.tsx → src/stories/Form/Checkbox.stories.tsx
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,25 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { FormSection } from '@/components/ui/form/form-section'; | ||
import { Input } from '../../components'; | ||
|
||
const meta = { | ||
component: FormSection | ||
} satisfies Meta<typeof FormSection>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof FormSection>; | ||
|
||
export const Example = { | ||
args: { | ||
title: 'Form Section Title', | ||
hint: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' | ||
}, | ||
render: (args) => ( | ||
<FormSection {...args}> | ||
<div className='flex flex-col gap-4'> | ||
<Input /> | ||
</div> | ||
</FormSection> | ||
) | ||
} satisfies Story; |
4 changes: 2 additions & 2 deletions
4
src/stories/Input.stories.tsx → src/stories/Form/Input.stories.tsx
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
4 changes: 2 additions & 2 deletions
4
src/stories/Select.stories.tsx → src/stories/Form/Select.stories.tsx
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
2 changes: 1 addition & 1 deletion
2
src/stories/Textarea.stories.tsx → src/stories/Form/Textarea.stories.tsx
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
2 changes: 1 addition & 1 deletion
2
src/stories/Toggle.stories.tsx → src/stories/Form/Toggle.stories.tsx
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