Skip to content

Commit

Permalink
Make popover fullscreen for small devices (#13553)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 4a5d0511f8fd41163c549c49a937fa735f5bac8f
  • Loading branch information
carsonp6 authored and Lightspark Eng committed Nov 26, 2024
1 parent bf36749 commit e44b6a2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
42 changes: 29 additions & 13 deletions packages/ui/src/components/DataManagerTable/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import styled from "@emotion/styled";
import { useBreakpoints } from "../../styles/breakpoints.js";
import { Spacing } from "../../styles/tokens/spacing.js";
import { z } from "../../styles/z-index.js";
import { Button } from "../Button.js";
import { Modal } from "../Modal.js";

type Side = "left" | "right";

Expand All @@ -21,6 +23,9 @@ export const Popover = ({
onClear: () => void;
children: React.ReactNode;
}) => {
const breakPoint = useBreakpoints();
const isSm = breakPoint.isSm();

const handleApply = () => {
onApply();
};
Expand All @@ -33,18 +38,29 @@ export const Popover = ({
}
};

const content = (
<Content onKeyDownCapture={handleKeyPress} isSm={isSm}>
{children}
<Footer>
<Button text="Clear" onClick={handleClear} />
<FooterRight>
<Button text="Cancel" onClick={() => setShow(false)} />
<Button text="Apply" kind="primary" onClick={handleApply} />
</FooterRight>
</Footer>
</Content>
);
if (isSm) {
return (
<Modal visible={show} onClose={() => setShow(false)} smKind="fullscreen">
{content}
</Modal>
);
}

return (
<Container show={show} side={side} onKeyDownCapture={handleKeyPress}>
<Content>
{children}
<Footer>
<Button text="Clear" onClick={handleClear} />
<FooterRight>
<Button text="Cancel" onClick={() => setShow(false)} />
<Button text="Apply" kind="primary" onClick={handleApply} />
</FooterRight>
</Footer>
</Content>
<Container show={show} side={side}>
{content}
</Container>
);
};
Expand All @@ -64,11 +80,11 @@ const Container = styled.div<{ show: boolean; side: Side }>`
0px 4px 8px 0px rgba(0, 0, 0, 0.08);
`;

const Content = styled.div`
const Content = styled.div<{ isSm?: boolean }>`
display: flex;
flex-direction: column;
gap: ${Spacing.px.xl};
padding: ${Spacing.px.lg};
padding: ${({ isSm }) => (isSm ? "0px" : Spacing.px.lg)};
`;

const Footer = styled.div`
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,15 @@ const ModalContent = styled.div<{
display: flex;
flex-direction: column;
${({ ghost, width }) => `
${({ ghost, smKind, width }) => `
${ghost ? "" : standardBorderRadius(16)}
width: ${width}px;
`}
${({ smKind }) =>
smKind === "fullscreen"
? bp.sm(`
border-radius: 0px;
width: 100%;
height: 100dvh;
`)
Expand Down

0 comments on commit e44b6a2

Please sign in to comment.