extract dialog component
This commit is contained in:
parent
5fc21494ef
commit
a952d4227d
|
@ -9,18 +9,6 @@
|
|||
}
|
||||
|
||||
.JoinForm {
|
||||
border: solid var(--border-size-thick) var(--color-secondary);
|
||||
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
background: var(--color-background);
|
||||
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
|
||||
animation-duration: 1s;
|
||||
animation-name: BlinkJoinFormBorder;
|
||||
animation-iteration-count: infinite;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import {useState} from 'react';
|
||||
import './JoinForm.css';
|
||||
import {useMutation} from '@tanstack/react-query';
|
||||
|
||||
import {makeApiUrl} from './serverCalls';
|
||||
import Column from './components/Column.tsx';
|
||||
import Button from './components/Button.tsx';
|
||||
import TextInput from './components/TextInput.tsx';
|
||||
import {useMutation} from '@tanstack/react-query';
|
||||
import Dialog from './components/Dialog.tsx';
|
||||
import './JoinForm.css';
|
||||
|
||||
export default function JoinForm({onDone}: {
|
||||
onDone: (name: string) => void;
|
||||
|
@ -29,7 +30,7 @@ export default function JoinForm({onDone}: {
|
|||
|
||||
const confirm = () => postPlayer.mutate({name});
|
||||
|
||||
return <Column className="JoinForm">
|
||||
return <Dialog className="JoinForm">
|
||||
<h3> Enter your name to play </h3>
|
||||
<TextInput
|
||||
value={name}
|
||||
|
@ -42,5 +43,5 @@ export default function JoinForm({onDone}: {
|
|||
disabled={disableButtons}
|
||||
text="INSERT COIN"/>
|
||||
{postPlayer.isError && <p>{postPlayer.error.message}</p>}
|
||||
</Column>;
|
||||
</Dialog>;
|
||||
}
|
||||
|
|
13
tank-frontend/src/components/Dialog.css
Normal file
13
tank-frontend/src/components/Dialog.css
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
.Dialog {
|
||||
border: solid var(--border-size-thick) var(--color-secondary);
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
background: var(--color-background);
|
||||
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
}
|
12
tank-frontend/src/components/Dialog.tsx
Normal file
12
tank-frontend/src/components/Dialog.tsx
Normal file
|
@ -0,0 +1,12 @@
|
|||
import {ReactNode} from 'react';
|
||||
import Column from './Column.tsx';
|
||||
import './Dialog.css';
|
||||
|
||||
export default function Dialog({children, className}: {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return <Column className={'Dialog ' + className ?? ''}>
|
||||
{children}
|
||||
</Column>
|
||||
}
|
Loading…
Reference in a new issue