| 1 |
import { __ } from '@wordpress/i18n' |
| 2 |
import classNames from 'classnames' |
| 3 |
import { useGlobalStore } from '@library/state/GlobalState' |
| 4 |
import { useTemplatesStore } from '@library/state/Templates' |
| 5 |
|
| 6 |
export const TypeSelect = ({ className }) => { |
| 7 |
const updateType = useTemplatesStore((state) => state.updateType) |
| 8 |
const currentType = useGlobalStore( |
| 9 |
(state) => state?.currentType ?? 'pattern', |
| 10 |
) |
| 11 |
|
| 12 |
return ( |
| 13 |
<div className={className}> |
| 14 |
<h4 className="sr-only">{__('Type select', 'extendify')}</h4> |
| 15 |
<div className="flex justify-evenly border border-gray-900 p-0.5 rounded"> |
| 16 |
<button |
| 17 |
type="button" |
| 18 |
className={classNames({ |
| 19 |
'w-full m-0 min-w-sm cursor-pointer rounded py-2.5 px-4 text-xs leading-none': true, |
| 20 |
'bg-gray-900 text-white': currentType === 'pattern', |
| 21 |
'bg-transparent text-black': currentType !== 'pattern', |
| 22 |
})} |
| 23 |
onClick={() => updateType('pattern')}> |
| 24 |
<span className="">{__('Patterns', 'extendify')}</span> |
| 25 |
</button> |
| 26 |
<button |
| 27 |
type="button" |
| 28 |
className={classNames({ |
| 29 |
'outline-none w-full m-0 -ml-px min-w-sm cursor-pointer items-center rounded py-2.5 px-4 text-xs leading-none': true, |
| 30 |
'bg-gray-900 text-white': currentType === 'template', |
| 31 |
'bg-transparent text-black': currentType !== 'template', |
| 32 |
})} |
| 33 |
onClick={() => updateType('template')}> |
| 34 |
<span className="">{__('Templates', 'extendify')}</span> |
| 35 |
</button> |
| 36 |
</div> |
| 37 |
</div> |
| 38 |
) |
| 39 |
} |
| 40 |
|