Skip to content

Commit

Permalink
Add button component.
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddaytw committed Sep 11, 2024
1 parent 51722ad commit 58872bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ReactNode } from "react"

type Props = {
children: ReactNode
children: ReactNode,
type: 'submit' | 'reset' | 'button',
}

export function Button({ children }: Props) {
export function Button(props: Props) {
return (
<div className="flex">
{children}
</div>
<button className="bg-cyan-600 text-white p-2 rounded" type={props.type} >
{props.children}
</button>
)
}
3 changes: 2 additions & 1 deletion src/routes/events/create.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createFileRoute, Link } from '@tanstack/react-router';
import { ChangeEvent, FormEvent, useEffect, useState } from 'react';
import { Button } from '../../components/Button';
import { UserController } from '../../controllers/user';
import { AuthGuard } from '../../utils/auth';
import { supabase } from '../../utils/supabase';
Expand Down Expand Up @@ -149,7 +150,7 @@ function CreateEventScreen() {
)}
</div>
<div className='mt-3'>
<button className='text-white' type='submit'>確認新增</button>
<Button type='submit'>確認新增</Button>
</div>
</form>
);
Expand Down

0 comments on commit 58872bf

Please sign in to comment.