fix(ux): replace buggy margin-based centering with reliable flexbox wrapper to permanently center floating action bars
This commit is contained in:
1 parent
2097bc477a
commit
d5d79a1eda
1 file changed
+45
-37
@@ -2,6 +2,7 @@ import React from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import Paper from "@mui/material/Paper";
|
import Paper from "@mui/material/Paper";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
@@ -31,58 +32,65 @@ export const FloatingActionBar: React.FC<FloatingActionBarProps> = ({
|
|||||||
mountOnEnter
|
mountOnEnter
|
||||||
unmountOnExit
|
unmountOnExit
|
||||||
>
|
>
|
||||||
<Paper
|
<Box
|
||||||
elevation={6}
|
|
||||||
sx={{
|
sx={{
|
||||||
position: "fixed",
|
position: "fixed",
|
||||||
bottom: theme.spacing(LAYOUT.XS),
|
bottom: theme.spacing(LAYOUT.XS),
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
margin: "0 auto",
|
|
||||||
width: "max-content",
|
|
||||||
zIndex: theme.zIndex.snackbar,
|
|
||||||
px: LAYOUT.MD,
|
|
||||||
py: LAYOUT.XS,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
backgroundColor: theme.palette.background.paper,
|
|
||||||
border: `1px solid ${theme.palette.divider}`,
|
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
justifyContent: "center",
|
||||||
gap: LAYOUT.XS,
|
pointerEvents: "none",
|
||||||
boxShadow: theme.shadows[8],
|
zIndex: theme.zIndex.snackbar,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack
|
<Paper
|
||||||
direction="row"
|
elevation={6}
|
||||||
alignItems="center"
|
sx={{
|
||||||
gap={LAYOUT.XS}
|
pointerEvents: "auto",
|
||||||
|
px: LAYOUT.MD,
|
||||||
|
py: LAYOUT.XS,
|
||||||
|
borderRadius: theme.shape.borderRadius,
|
||||||
|
backgroundColor: theme.palette.background.paper,
|
||||||
|
border: `1px solid ${theme.palette.divider}`,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: LAYOUT.XS,
|
||||||
|
boxShadow: theme.shadows[8],
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
|
||||||
variant="body1"
|
|
||||||
fontWeight={600}
|
|
||||||
color={theme.palette.text.primary}
|
|
||||||
>
|
|
||||||
{selectedCount} {t("common.selected")}
|
|
||||||
</Typography>
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
onClick={onClearSelection}
|
|
||||||
aria-label="clear selection"
|
|
||||||
>
|
|
||||||
<X size={18} />
|
|
||||||
</IconButton>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
{children && (
|
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
gap={LAYOUT.XS}
|
gap={LAYOUT.XS}
|
||||||
>
|
>
|
||||||
{children}
|
<Typography
|
||||||
|
variant="body1"
|
||||||
|
fontWeight={600}
|
||||||
|
color={theme.palette.text.primary}
|
||||||
|
>
|
||||||
|
{selectedCount} {t("common.selected")}
|
||||||
|
</Typography>
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
onClick={onClearSelection}
|
||||||
|
aria-label="clear selection"
|
||||||
|
>
|
||||||
|
<X size={18} />
|
||||||
|
</IconButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
|
||||||
</Paper>
|
{children && (
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
alignItems="center"
|
||||||
|
gap={LAYOUT.XS}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
</Slide>
|
</Slide>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user