Skip to content

Commit

Permalink
Use dynamic height and width for dialogs (#4567)
Browse files Browse the repository at this point in the history
* Use dynamic height and width for dialogs

* Update tall-forks-bathe.md

---------

Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com>
  • Loading branch information
dgreif and siddharthkp authored May 7, 2024
1 parent 32c088d commit e39fcf8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-forks-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Dialog: Use dynamic view height/width. This allows available visible space to be properly computed on iOS devices.
4 changes: 2 additions & 2 deletions packages/react/src/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const DialogBase = styled.div<StyledDialogBaseProps>`
outline: none;
@media screen and (max-width: 750px) {
width: 100vw;
width: 100dvw;
margin: 0;
border-radius: 0;
height: 100vh;
height: 100dvh;
}
${sx};
Expand Down
18 changes: 9 additions & 9 deletions packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ const StyledDialog = styled.div<StyledDialogProps>`
width: ${props => widthMap[props.width ?? ('xlarge' as const)]};
height: ${props => heightMap[props.height ?? ('auto' as const)]};
min-width: 296px;
max-width: calc(100vw - 64px);
max-height: calc(100vh - 64px);
max-width: calc(100dvw - 64px);
max-height: calc(100dvh - 64px);
border-radius: 12px;
opacity: 1;
Expand All @@ -257,7 +257,7 @@ const StyledDialog = styled.div<StyledDialogProps>`
}
&[data-position-regular='left'] {
height: 100vh;
height: 100dvh;
max-height: unset;
border-radius: var(--borderRadius-large, 0.75rem);
border-top-left-radius: 0;
Expand All @@ -269,7 +269,7 @@ const StyledDialog = styled.div<StyledDialogProps>`
}
&[data-position-regular='right'] {
height: 100vh;
height: 100dvh;
max-height: unset;
border-radius: var(--borderRadius-large, 0.75rem);
border-top-right-radius: 0;
Expand All @@ -288,10 +288,10 @@ const StyledDialog = styled.div<StyledDialogProps>`
}
&[data-position-narrow='bottom'] {
width: 100vw;
width: 100dvw;
height: auto;
max-width: 100vw;
max-height: calc(100vh - 64px);
max-width: 100dvw;
max-height: calc(100dvh - 64px);
border-radius: var(--borderRadius-large, 0.75rem);
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
Expand All @@ -303,9 +303,9 @@ const StyledDialog = styled.div<StyledDialogProps>`
&[data-position-narrow='fullscreen'] {
width: 100%;
max-width: 100vw;
max-width: 100dvw;
height: 100%;
max-height: 100vh;
max-height: 100dvh;
border-radius: unset !important;
flex-grow: 1;
Expand Down

0 comments on commit e39fcf8

Please sign in to comment.