Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog: Full screen & Bottom sheet support #4048

Merged
merged 100 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
0f8ad0b
Kickoff
maximedegreve Dec 4, 2023
623f300
Start adding action-sheet
maximedegreve Dec 4, 2023
d251d91
WIP
maximedegreve Dec 5, 2023
3179354
Fix dragging
maximedegreve Dec 6, 2023
522f3fd
Improvements
maximedegreve Dec 6, 2023
4249d9f
Add hover state
maximedegreve Dec 6, 2023
7bd0a10
Remove unused backdropRef
maximedegreve Dec 8, 2023
6970801
Remove listeners
maximedegreve Dec 8, 2023
de138d4
Fix warnings
maximedegreve Dec 8, 2023
1a01741
Reduce code
maximedegreve Dec 8, 2023
b3f17cb
Fix reduce motion
maximedegreve Dec 8, 2023
e8b3be9
Add open animation
maximedegreve Dec 8, 2023
80c6a29
Improvements
maximedegreve Dec 9, 2023
8dc8a17
Improve the docs
maximedegreve Dec 9, 2023
ca03cf5
Make the storybook easier to manage
maximedegreve Dec 9, 2023
1acf99b
Fix
maximedegreve Dec 9, 2023
75eba83
Make it easier to get the code for custom renderes
maximedegreve Dec 9, 2023
4ff9440
Revert
maximedegreve Dec 11, 2023
bf4b3d0
Remove unused imports
maximedegreve Dec 11, 2023
5c50140
Use ' instead
maximedegreve Dec 11, 2023
88afe61
Remove unused props
maximedegreve Dec 11, 2023
7c3c892
Improve accessibility further
maximedegreve Dec 11, 2023
4c15927
Fix typescript warnings
maximedegreve Dec 11, 2023
a593387
Remove more warnings
maximedegreve Dec 11, 2023
2cf0fb2
Remove more warnings
maximedegreve Dec 11, 2023
5bb1b5f
Fix
maximedegreve Dec 11, 2023
16c8253
Update docs
maximedegreve Dec 11, 2023
9e6efe6
Merge branch 'main' into feature/full-screen-clean
maximedegreve Dec 11, 2023
d2b64dd
Fix
maximedegreve Dec 12, 2023
f7cd19a
Use a slider instead of resizing
maximedegreve Dec 12, 2023
3538a94
Improve code
maximedegreve Dec 12, 2023
318fe3f
Fix
maximedegreve Dec 12, 2023
ba765f5
Fix dragging
maximedegreve Dec 12, 2023
24ceca7
Create rare-geese-melt.md
maximedegreve Dec 12, 2023
6df46ae
Update rare-geese-melt.md
maximedegreve Dec 12, 2023
6a60f2a
Fixes for FireFox
maximedegreve Dec 12, 2023
5f93411
Merge branch 'main' into feature/full-screen-clean
maximedegreve Dec 12, 2023
245f453
Fix: Type number trivially inferred from a number literal, remove typ…
maximedegreve Dec 12, 2023
c09c492
Switch refs to const
maximedegreve Dec 12, 2023
b98a2ed
Fix linter warnings
maximedegreve Dec 12, 2023
28801c3
Add missing props back
maximedegreve Dec 12, 2023
1f8b552
Increase the hit target on mobile
maximedegreve Dec 13, 2023
8655d47
Add preventDefault() for Firefox
maximedegreve Dec 13, 2023
2d64cbb
Merge branch 'main' into feature/full-screen-clean
maximedegreve Dec 13, 2023
d648ab2
Add support for setting overflow area height
maximedegreve Dec 13, 2023
1b5f6c8
Rename ActionSheet to BottomSheet and add max-width
maximedegreve Dec 14, 2023
f58a1e9
Remove minHeight
maximedegreve Dec 14, 2023
6e8a964
Merge branch 'main' into feature/full-screen-clean
maximedegreve Dec 14, 2023
77cfbcd
Merge branch 'main' into feature/full-screen-clean
maximedegreve Dec 20, 2023
d980b62
Fix merge conflicts
maximedegreve Dec 20, 2023
2f95899
Merge branch 'main' into feature/full-screen-clean
maximedegreve Jan 2, 2024
de74cbc
Fix close button interactions
maximedegreve Jan 10, 2024
5c4e8f5
Remove gestures we won't use
maximedegreve Jan 10, 2024
f6f4199
Fix copy
maximedegreve Jan 10, 2024
1e41f5e
Remove overkill isReduced
maximedegreve Jan 10, 2024
4aef90c
Auto focus on close button if no buttons
maximedegreve Jan 10, 2024
932e26c
Remove gestures
maximedegreve Jan 11, 2024
62de09e
Revert
maximedegreve Jan 11, 2024
95ba1b6
Merge branch 'main' into feature/full-screen-clean
mperrotti Jan 11, 2024
5f9aa8d
Fix JEST files
maximedegreve Jan 11, 2024
c49377a
Merge branch 'feature/full-screen-clean' of https://github.com/primer…
maximedegreve Jan 11, 2024
8fb0b5e
Update exports.test.ts.snap
maximedegreve Jan 11, 2024
50a322d
Fix isReduced function
maximedegreve Jan 11, 2024
2f45725
Keep dialog open
maximedegreve Jan 11, 2024
c75c681
Remove Truncate
maximedegreve Jan 11, 2024
cf4e983
Fix test
maximedegreve Jan 12, 2024
0e31960
Fix close button in custom UI
maximedegreve Jan 12, 2024
910452d
Update Dialog.tsx
maximedegreve Jan 12, 2024
7676e66
Fix test
maximedegreve Jan 12, 2024
1414c49
test(vrt): update snapshots
maximedegreve Jan 12, 2024
c05611c
Add more snapshots
maximedegreve Jan 12, 2024
a965cdd
Merge branch 'feature/full-screen-clean' of https://github.com/primer…
maximedegreve Jan 12, 2024
281227a
test(vrt): update snapshots
maximedegreve Jan 12, 2024
44f458e
Merge branch 'main' into feature/full-screen-clean
maximedegreve Jan 12, 2024
3ec3ec0
Can't get this to work
maximedegreve Jan 15, 2024
9dbe4fa
Update src/Dialog/DialogBottomSheet.tsx
maximedegreve Jan 17, 2024
26732d5
Remove test
maximedegreve Jan 17, 2024
9409c33
Push it real good
maximedegreve Jan 17, 2024
85ba6af
Merge branch 'main' of github.com:primer/react into feature/full-scre…
mperrotti Jan 17, 2024
d72614f
Remove test
maximedegreve Jan 18, 2024
fb08993
Adress PR feedback
maximedegreve Jan 18, 2024
ad9ecd4
Revert PR suggestions
maximedegreve Jan 18, 2024
1ab34b6
Fix
maximedegreve Jan 18, 2024
26f20ac
Merge branch 'feature/full-screen-clean' of github.com:primer/react i…
mperrotti Jan 18, 2024
b67a7d4
Fix close button
maximedegreve Jan 18, 2024
1201b6a
adds an option to render tests using testing-library render in behave…
mperrotti Jan 18, 2024
27f076d
Merge branch 'feature/full-screen-clean' of github.com:primer/react i…
mperrotti Jan 18, 2024
78563ab
Merge branch 'main' of github.com:primer/react into feature/full-scre…
mperrotti Jan 18, 2024
53069a8
Add a simple test
maximedegreve Jan 18, 2024
231d661
Update snapshot
maximedegreve Jan 18, 2024
6fab9c1
Push
maximedegreve Jan 19, 2024
02da92b
Add test for expanding
maximedegreve Jan 19, 2024
40bf62d
Add more tests based on Mike's
maximedegreve Jan 19, 2024
d33db09
Merge branch 'main' into feature/full-screen-clean
maximedegreve Jan 23, 2024
d30733a
Add more tests and update snapshot
maximedegreve Jan 23, 2024
ef8317d
Add another test
maximedegreve Jan 23, 2024
fdffab2
Linter fixes
maximedegreve Jan 23, 2024
884cc11
Fix border in dark mode
maximedegreve Jan 23, 2024
7f1225f
Fix linter
maximedegreve Jan 23, 2024
db63923
test(vrt): update snapshots
maximedegreve Jan 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-geese-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Dialog: `full-screen` and `action-sheet` variants
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
187 changes: 184 additions & 3 deletions e2e/components/Dialog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,190 @@ test.describe('Dialog', () => {
}
})

test.describe('Bottom Sheet', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--bottom-sheet',
globals: {
colorScheme: theme,
},
})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`Dialog.Bottom Sheet.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--bottom-sheet',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Full Screen', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--full-screen',
globals: {
colorScheme: theme,
},
})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`Dialog.Full Screen.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--full-screen',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Non Declaritive', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--non-declaritive',
globals: {
colorScheme: theme,
},
})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`Dialog.Non Declaritve.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--non-declaritive',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Responsive', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--responsive',
globals: {
colorScheme: theme,
},
})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`Dialog.Responsive.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--responsive',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Size Large', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--size-large',
globals: {
colorScheme: theme,
},
})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`Dialog.Size Large.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--size-large',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Size Small', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--size-small',
globals: {
colorScheme: theme,
},
})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`Dialog.Size Small.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--size-small',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Size X Dialog', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--size-x-large',
globals: {
colorScheme: theme,
},
})
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(
`Dialog.Size X Large Test.${theme}.png`,
)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-dialog-features--size-x-large',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

test.describe('Stress Test', () => {
for (const theme of themes) {
test.describe(theme, () => {
Expand All @@ -42,8 +226,6 @@ test.describe('Dialog', () => {
colorScheme: theme,
},
})

await page.getByRole('button', {name: 'Show dialog'}).click()
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(`Dialog.Stress Test.${theme}.png`)
})

Expand Down Expand Up @@ -71,7 +253,6 @@ test.describe('Dialog', () => {
},
})

await page.getByRole('button', {name: 'Show dialog'}).click()
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(
`Dialog.With Custom Renderers.${theme}.png`,
)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/ConfirmationDialog/ConfirmationDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ import {ThemeProvider} from '../ThemeProvider'
import {SSRProvider} from '../utils/ssr'
import {behavesAsComponent, checkExports} from '../utils/testing'

// The Dialog uses `matchMedia` to determine whether or not to reduce motion.

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})

const Basic = ({confirmButtonType}: Pick<React.ComponentProps<typeof ConfirmationDialog>, 'confirmButtonType'>) => {
const [isOpen, setIsOpen] = useState(false)
const buttonRef = useRef<HTMLButtonElement>(null)
Expand Down
3 changes: 1 addition & 2 deletions src/ConfirmationDialog/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export interface ConfirmationDialogProps {
* Required. This callback is invoked when a gesture to close the dialog
* is performed. The first argument indicates the gesture.
*/
onClose: (gesture: 'confirm' | 'close-button' | 'cancel' | 'escape') => void

onClose: (gesture: 'confirm' | 'cancel' | 'close-button' | 'escape') => void
/**
* Required. The title of the ConfirmationDialog. This is usually a brief
* question.
Expand Down
16 changes: 16 additions & 0 deletions src/DataTable/__tests__/ErrorDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ import {render, screen} from '@testing-library/react'
import React from 'react'
import {ErrorDialog} from '../ErrorDialog'

// The ErrorDialog uses `matchMedia` because the ConfirmationDialog uses it to determine whether or not to reduce motion.

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})

describe('Table.ErrorDialog', () => {
it('should use a default title of "Error" if `title` is not provided', () => {
render(<ErrorDialog />)
Expand Down
9 changes: 7 additions & 2 deletions src/Dialog/Dialog.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@
},
{
"name": "onClose",
"type": "(gesture: 'close-button' | 'escape') => void",
"description": "This method is invoked when a gesture to close the dialog is used (either an Escape key press or clicking the 'X' in the top-right corner). The gesture argument indicates the gesture that was used to close the dialog (either 'close-button' or 'escape')."
"type": "(gesture: 'close-button' | 'escape' | 'drag' | 'overlay') => void",
"description": "This method is invoked when a gesture to close the dialog is used (either an Escape key press, clicking/tapping on the backdrop, clicking/tapping the 'X' in the top-right corner or dragging away a bottom sheet). The gesture argument indicates the gesture that was used to close the dialog."
},
{
"name": "role",
"type": "'dialog' | 'alertdialog'",
"description": "The ARIA role to assign to this dialog."
},
{
"name": "type",
"type": "'default' | 'full-screen' | 'bottom-sheet'",
maximedegreve marked this conversation as resolved.
Show resolved Hide resolved
"description": "The type of dialog to render. 'default' renders a dialog in the center of the screen. 'full-screen' renders the dialog full screen and ignored the width and height. 'full-screen' is often used for mobile breakpoints."
},
{
"name": "width",
"type": "'small' | 'medium' | 'large' | 'xlarge'"
Expand Down
Loading
Loading