Skip to content

Commit

Permalink
状態を表すコンポーネントの追加
Browse files Browse the repository at this point in the history
  • Loading branch information
miso-devel committed Oct 29, 2023
1 parent 5d33a3c commit 251850e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions client/src/app/draw/components/DrawCondition.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { TActionState, TDrawCondition } from '@/types/app';
import { FC } from 'react';

type TProps = { drawConditionState: TActionState<TDrawCondition> };

export const DrawCondition: FC<TProps> = ({ drawConditionState }) => {
const condition: { [K in TDrawCondition]: { text: string; color: string } } =
{
DRAWING: { text: '描画中', color: 'bg-green-400' },
MOVING: { text: '移動中', color: 'bg-yellow-400' },
STOPPING: { text: '停止中', color: 'bg-red-400' },
};

return (
<>
{drawConditionState.state === 'STOPPING' ? (
<>
<div
className={`p-1 rounded-sm bg-main ms-auto ${
condition[drawConditionState.state].color
}`}
>
{condition[drawConditionState.state].text}
</div>
<button
className='border-2 p-1 rounded-sm bg-green-400'
onClick={() => drawConditionState.setState('DRAWING')}
>
▶️
</button>
</>
) : (
<>
<div
className={`p-1 rounded-sm bg-main ms-auto ${
condition[drawConditionState.state].color
}`}
>
{condition[drawConditionState.state].text}
</div>
<button
className='border-2 p-1 rounded-sm bg-red-400'
onClick={() => drawConditionState.setState('STOPPING')}
>
</button>
</>
)}
</>
);
};

0 comments on commit 251850e

Please sign in to comment.