-
Notifications
You must be signed in to change notification settings - Fork 1
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 #28 from KonferCA/feat/23/register-wallet
Registration Page
- Loading branch information
Showing
15 changed files
with
585 additions
and
50 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
const FormContainer = ({ children }: { children: ReactNode }) => { | ||
return ( | ||
<div className="min-h-screen flex flex-col items-center px-4"> | ||
<div className="w-full max-w-xl p-8"> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export { FormContainer }; |
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,73 @@ | ||
import { forwardRef } from 'react'; | ||
import { Field, Label, Textarea } from '@headlessui/react'; | ||
|
||
interface TextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> { | ||
label?: string; | ||
error?: string; | ||
description?: string; | ||
value?: string; | ||
required?: boolean; | ||
onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void; | ||
} | ||
|
||
const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>( | ||
({ label, error, description, className = '', value, required, onChange, ...props }, ref) => { | ||
const inputProps = onChange | ||
? { value, onChange } | ||
: { defaultValue: value }; | ||
|
||
const sharedClassNames = ` | ||
w-full px-4 py-2 | ||
bg-white | ||
border border-gray-300 | ||
rounded-md | ||
focus:outline-none focus:ring-2 focus:ring-blue-500 | ||
data-[invalid]:border-red-500 | ||
min-h-[100px] resize-y | ||
${className} | ||
`; | ||
|
||
return ( | ||
<div className="w-full"> | ||
<Field> | ||
{label && ( | ||
<div className="flex justify-between items-center mb-1"> | ||
<Label className="block text-md font-normal"> | ||
{label} | ||
</Label> | ||
{required && ( | ||
<span className="text-sm text-gray-500"> | ||
Required | ||
</span> | ||
)} | ||
</div> | ||
)} | ||
|
||
<Textarea | ||
ref={ref} | ||
className={sharedClassNames} | ||
invalid={!!error} | ||
required={required} | ||
{...inputProps} | ||
{...props} | ||
/> | ||
|
||
{description && ( | ||
<div className="mt-1 text-sm text-gray-500"> | ||
{description} | ||
</div> | ||
)} | ||
|
||
{error && ( | ||
<div className="mt-1 text-sm text-red-500"> | ||
{error} | ||
</div> | ||
)} | ||
</Field> | ||
</div> | ||
); | ||
} | ||
); | ||
|
||
TextArea.displayName = 'TextArea'; | ||
export { TextArea }; |
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,5 +1,7 @@ | ||
export { TextInput } from './TextInput'; | ||
export { TextArea } from './TextArea'; | ||
export { Dropdown } from './Dropdown'; | ||
export { FileUpload } from './FileUpload'; | ||
export { InfoCard } from './InfoCard'; | ||
export { Button } from './Button'; | ||
export { FormContainer } from './FormContainer'; |
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,65 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { TextArea } from '@components'; | ||
|
||
describe('TextArea', () => { | ||
it('renders with basic props', () => { | ||
render(<TextArea placeholder="Enter text" />); | ||
expect(screen.getByPlaceholderText('Enter text')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders label when provided', () => { | ||
render(<TextArea label="Description" />); | ||
expect(screen.getByText('Description')).toBeInTheDocument(); | ||
}); | ||
|
||
it('shows required text when required prop is true', () => { | ||
render(<TextArea label="Description" required />); | ||
expect(screen.getByText('Required')).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays error message', () => { | ||
render(<TextArea error="This field is required" />); | ||
expect(screen.getByText('This field is required')).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays description text', () => { | ||
render(<TextArea description="Enter detailed description" />); | ||
expect(screen.getByText('Enter detailed description')).toBeInTheDocument(); | ||
}); | ||
|
||
it('handles onChange events', async () => { | ||
const handleChange = vi.fn(); | ||
render(<TextArea onChange={handleChange} />); | ||
|
||
const textarea = screen.getByRole('textbox'); | ||
await userEvent.type(textarea, 'test'); | ||
|
||
expect(handleChange).toHaveBeenCalled(); | ||
expect(textarea).toHaveValue('test'); | ||
}); | ||
|
||
it('forwards ref correctly', () => { | ||
const ref = vi.fn(); | ||
render(<TextArea ref={ref} />); | ||
expect(ref).toHaveBeenCalled(); | ||
}); | ||
|
||
it('applies custom className', () => { | ||
render(<TextArea className="custom-class" />); | ||
expect(screen.getByRole('textbox')).toHaveClass('custom-class'); | ||
}); | ||
|
||
it('allows resizing', () => { | ||
render(<TextArea />); | ||
const textarea = screen.getByRole('textbox'); | ||
expect(textarea).toHaveClass('resize-y'); | ||
}); | ||
|
||
it('has minimum height', () => { | ||
render(<TextArea />); | ||
const textarea = screen.getByRole('textbox'); | ||
expect(textarea).toHaveClass('min-h-[100px]'); | ||
}); | ||
}); |
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,53 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { TextInput } from '@components'; | ||
|
||
describe('TextInput', () => { | ||
it('renders with basic props', () => { | ||
render(<TextInput placeholder="Enter text" />); | ||
expect(screen.getByPlaceholderText('Enter text')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders label when provided', () => { | ||
render(<TextInput label="Name" />); | ||
expect(screen.getByText('Name')).toBeInTheDocument(); | ||
}); | ||
|
||
it('shows required text when required prop is true', () => { | ||
render(<TextInput label="Name" required />); | ||
expect(screen.getByText('Required')).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays error message', () => { | ||
render(<TextInput error="This field is required" />); | ||
expect(screen.getByText('This field is required')).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays description text', () => { | ||
render(<TextInput description="Enter your full name" />); | ||
expect(screen.getByText('Enter your full name')).toBeInTheDocument(); | ||
}); | ||
|
||
it('handles onChange events', async () => { | ||
const handleChange = vi.fn(); | ||
render(<TextInput onChange={handleChange} />); | ||
|
||
const input = screen.getByRole('textbox'); | ||
await userEvent.type(input, 'test'); | ||
|
||
expect(handleChange).toHaveBeenCalled(); | ||
expect(input).toHaveValue('test'); | ||
}); | ||
|
||
it('forwards ref correctly', () => { | ||
const ref = vi.fn(); | ||
render(<TextInput ref={ref} />); | ||
expect(ref).toHaveBeenCalled(); | ||
}); | ||
|
||
it('applies custom className', () => { | ||
render(<TextInput className="custom-class" />); | ||
expect(screen.getByRole('textbox')).toHaveClass('custom-class'); | ||
}); | ||
}); |
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,3 +1,9 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap'); | ||
|
||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
body { | ||
font-family: 'Kanit', sans-serif; | ||
} |
Oops, something went wrong.