feat: move Snackbar to top of screen on mobile (#5567)

... and change SnackBar blur to medium.

@Bonapara Following
https://github.com/twentyhq/twenty/pull/5515#discussion_r1609618980

Related issue: https://github.com/twentyhq/twenty/issues/5383

<img width="386" alt="image"
src="https://github.com/twentyhq/twenty/assets/3098428/de2f0be4-9d9c-4013-bed2-774e0599ce49">
This commit is contained in:
Thaïs
2024-05-24 17:58:12 +02:00
committed by GitHub
parent de9321dcd9
commit 9ad3fb96b7
3 changed files with 25 additions and 15 deletions

View File

@ -7,6 +7,7 @@ import {
IconInfoCircle, IconInfoCircle,
IconSquareRoundedCheck, IconSquareRoundedCheck,
IconX, IconX,
MOBILE_VIEWPORT,
} from 'twenty-ui'; } from 'twenty-ui';
import { ProgressBar } from '@/ui/feedback/progress-bar/components/ProgressBar'; import { ProgressBar } from '@/ui/feedback/progress-bar/components/ProgressBar';
@ -39,7 +40,7 @@ export type SnackBarProps = Pick<
}; };
const StyledContainer = styled.div` const StyledContainer = styled.div`
backdrop-filter: ${({ theme }) => theme.blur.light}; backdrop-filter: ${({ theme }) => theme.blur.medium};
background-color: ${({ theme }) => theme.background.transparent.primary}; background-color: ${({ theme }) => theme.background.transparent.primary};
border-radius: ${({ theme }) => theme.border.radius.md}; border-radius: ${({ theme }) => theme.border.radius.md};
box-shadow: ${({ theme }) => theme.boxShadow.strong}; box-shadow: ${({ theme }) => theme.boxShadow.strong};
@ -49,6 +50,11 @@ const StyledContainer = styled.div`
padding: ${({ theme }) => theme.spacing(2)}; padding: ${({ theme }) => theme.spacing(2)};
position: relative; position: relative;
width: 296px; width: 296px;
@media (max-width: ${MOBILE_VIEWPORT}px) {
border-radius: 0;
width: 100%;
}
`; `;
const StyledProgressBar = styled(ProgressBar)` const StyledProgressBar = styled(ProgressBar)`

View File

@ -4,6 +4,7 @@ import { MOBILE_VIEWPORT } from 'twenty-ui';
import { useSnackBarManagerScopedStates } from '@/ui/feedback/snack-bar-manager/hooks/internal/useSnackBarManagerScopedStates'; import { useSnackBarManagerScopedStates } from '@/ui/feedback/snack-bar-manager/hooks/internal/useSnackBarManagerScopedStates';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { SnackBar } from './SnackBar'; import { SnackBar } from './SnackBar';
@ -16,26 +17,28 @@ const StyledSnackBarContainer = styled.div`
z-index: ${({ theme }) => theme.lastLayerZIndex}; z-index: ${({ theme }) => theme.lastLayerZIndex};
@media (max-width: ${MOBILE_VIEWPORT}px) { @media (max-width: ${MOBILE_VIEWPORT}px) {
bottom: ${({ theme }) => theme.spacing(16)}; top: 0;
right: 50%; bottom: auto;
transform: translateX(50%); left: 0;
right: 0;
} }
`; `;
const variants = {
out: {
opacity: 0,
y: 40,
},
in: {
opacity: 1,
y: 0,
},
};
export const SnackBarProvider = ({ children }: React.PropsWithChildren) => { export const SnackBarProvider = ({ children }: React.PropsWithChildren) => {
const { snackBarInternal } = useSnackBarManagerScopedStates(); const { snackBarInternal } = useSnackBarManagerScopedStates();
const { handleSnackBarClose } = useSnackBar(); const { handleSnackBarClose } = useSnackBar();
const isMobile = useIsMobile();
const variants = {
out: {
opacity: 0,
y: isMobile ? -40 : 40,
},
in: {
opacity: 1,
y: 0,
},
};
return ( return (
<> <>

View File

@ -1,4 +1,5 @@
export const BLUR = { export const BLUR = {
light: 'blur(6px)', light: 'blur(6px)',
medium: 'blur(12px)',
strong: 'blur(20px)', strong: 'blur(20px)',
}; };