2023-01-01 17:26:09 +01:00
|
|
|
import { ActionIcon, Button, Tooltip } from '@mantine/core';
|
2022-12-04 21:19:40 +01:00
|
|
|
import { openContextModal } from '@mantine/modals';
|
|
|
|
|
import { IconApps } from '@tabler/icons';
|
|
|
|
|
import { useTranslation } from 'next-i18next';
|
|
|
|
|
|
2023-01-01 17:26:09 +01:00
|
|
|
interface AddElementActionProps {
|
|
|
|
|
type: 'action-icon' | 'button';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AddElementAction = ({ type }: AddElementActionProps) => {
|
2022-12-20 11:34:07 +09:00
|
|
|
const { t } = useTranslation('layout/element-selector/selector');
|
2022-12-04 21:19:40 +01:00
|
|
|
|
2023-01-01 17:26:09 +01:00
|
|
|
switch (type) {
|
|
|
|
|
case 'button':
|
|
|
|
|
return (
|
|
|
|
|
<Tooltip label={t('actionIcon.tooltip')} withinPortal withArrow>
|
|
|
|
|
<Button
|
|
|
|
|
radius="md"
|
2023-01-06 11:18:47 +09:00
|
|
|
variant="default"
|
2023-01-01 17:26:09 +01:00
|
|
|
style={{ height: 43 }}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
openContextModal({
|
|
|
|
|
modal: 'selectElement',
|
|
|
|
|
title: t('modal.title'),
|
|
|
|
|
size: 'xl',
|
|
|
|
|
innerProps: {},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<IconApps />
|
|
|
|
|
</Button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
);
|
|
|
|
|
case 'action-icon':
|
|
|
|
|
return (
|
|
|
|
|
<Tooltip label={t('actionIcon.tooltip')} withinPortal withArrow>
|
|
|
|
|
<ActionIcon
|
|
|
|
|
variant="default"
|
|
|
|
|
radius="md"
|
|
|
|
|
size="xl"
|
|
|
|
|
color="blue"
|
|
|
|
|
onClick={() =>
|
|
|
|
|
openContextModal({
|
|
|
|
|
modal: 'selectElement',
|
|
|
|
|
title: t('modal.title'),
|
|
|
|
|
size: 'xl',
|
|
|
|
|
innerProps: {},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<IconApps />
|
|
|
|
|
</ActionIcon>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
);
|
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-12-04 21:19:40 +01:00
|
|
|
};
|