Skip to content

Commit

Permalink
πŸ’„ locate add button to be in container zone
Browse files Browse the repository at this point in the history
  • Loading branch information
dxanh97 committed Nov 12, 2024
1 parent c53678e commit d3806dc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/shared/AddActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import { MouseEventHandler } from 'react';
import { ActionIcon } from '@mantine/core';
import { ActionIcon, useMantineTheme } from '@mantine/core';
import { IconPlus } from '@tabler/icons-react';
import { useMediaQuery, useViewportSize } from '@mantine/hooks';

interface Props {
onClick: MouseEventHandler<HTMLButtonElement>;
}

function AddActionButton(props: Props) {
const { onClick } = props;
const { width } = useViewportSize();

const theme = useMantineTheme();
const isMd = useMediaQuery(`(max-width: ${theme.breakpoints.md})`);
const right = isMd
? 20
: `calc((${width}px - ${theme.breakpoints.md}) / 2 + 20px)`;

return (
<ActionIcon
size="xl"
radius="xl"
pos="fixed"
bottom={20}
right={20}
right={right}
onClick={onClick}
>
<IconPlus />
Expand Down

0 comments on commit d3806dc

Please sign in to comment.