2021-12-14 00:00:02 +00:00
|
|
|
import clsx from 'clsx'
|
2021-12-10 14:56:17 +00:00
|
|
|
import React from 'react'
|
|
|
|
import { Row } from './layout/row'
|
|
|
|
|
|
|
|
export function YesNoSelector(props: {
|
|
|
|
selected: 'YES' | 'NO'
|
|
|
|
onSelect: (selected: 'YES' | 'NO') => void
|
|
|
|
className?: string
|
|
|
|
}) {
|
2021-12-14 00:00:02 +00:00
|
|
|
const { selected, onSelect, className } = props
|
2021-12-10 14:56:17 +00:00
|
|
|
|
|
|
|
return (
|
2021-12-14 00:00:02 +00:00
|
|
|
<Row className={clsx('space-x-3', className)}>
|
2021-12-10 14:56:17 +00:00
|
|
|
<Button
|
2021-12-14 00:00:02 +00:00
|
|
|
color={selected === 'YES' ? 'green' : 'gray'}
|
2021-12-10 14:56:17 +00:00
|
|
|
onClick={() => onSelect('YES')}
|
|
|
|
>
|
2021-12-14 00:00:02 +00:00
|
|
|
Yes
|
2021-12-10 14:56:17 +00:00
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Button
|
2021-12-14 00:00:02 +00:00
|
|
|
color={selected === 'NO' ? 'red' : 'gray'}
|
2021-12-10 14:56:17 +00:00
|
|
|
onClick={() => onSelect('NO')}
|
|
|
|
>
|
2021-12-14 00:00:02 +00:00
|
|
|
No
|
|
|
|
</Button>
|
|
|
|
</Row>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function YesNoCancelSelector(props: {
|
|
|
|
selected: 'YES' | 'NO' | 'CANCEL' | undefined
|
|
|
|
onSelect: (selected: 'YES' | 'NO' | 'CANCEL') => void
|
|
|
|
className?: string
|
|
|
|
}) {
|
|
|
|
const { selected, onSelect, className } = props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Row className={clsx('space-x-3', className)}>
|
|
|
|
<Button
|
|
|
|
color={selected === 'YES' ? 'green' : 'gray'}
|
|
|
|
onClick={() => onSelect('YES')}
|
|
|
|
className="px-6"
|
|
|
|
>
|
|
|
|
Yes
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
color={selected === 'NO' ? 'red' : 'gray'}
|
|
|
|
onClick={() => onSelect('NO')}
|
|
|
|
className="px-6"
|
|
|
|
>
|
|
|
|
No
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
color={selected === 'CANCEL' ? 'yellow' : 'gray'}
|
|
|
|
onClick={() => onSelect('CANCEL')}
|
|
|
|
className="px-6"
|
|
|
|
>
|
|
|
|
Cancel
|
2021-12-10 14:56:17 +00:00
|
|
|
</Button>
|
|
|
|
</Row>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function Button(props: {
|
|
|
|
className?: string
|
|
|
|
onClick?: () => void
|
2021-12-14 00:00:02 +00:00
|
|
|
color: 'green' | 'red' | 'yellow' | 'gray'
|
2021-12-10 14:56:17 +00:00
|
|
|
children?: any
|
|
|
|
}) {
|
2021-12-14 00:00:02 +00:00
|
|
|
const { className, onClick, children, color } = props
|
2021-12-10 14:56:17 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
type="button"
|
2021-12-14 00:00:02 +00:00
|
|
|
className={clsx(
|
2021-12-11 03:47:46 +00:00
|
|
|
'inline-flex items-center px-8 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white',
|
2021-12-13 18:26:46 +00:00
|
|
|
color === 'green' && 'btn-primary',
|
2021-12-14 00:00:02 +00:00
|
|
|
color === 'red' && 'bg-red-400 hover:bg-red-500',
|
|
|
|
color === 'yellow' && 'bg-yellow-400 hover:bg-yellow-500',
|
|
|
|
color === 'gray' && 'text-gray-700 bg-gray-300 hover:bg-gray-400',
|
2021-12-10 14:56:17 +00:00
|
|
|
className
|
|
|
|
)}
|
|
|
|
onClick={onClick}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|