-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
120 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@itwin/itwinui-react': minor | ||
--- | ||
|
||
Nested `ThemeProvider`s will now reuse the same toaster instead of creating new ones. |
Binary file modified
BIN
-141 Bytes
(99%)
...react-workshop/cypress-visual-screenshots/baseline/DatePicker.test.ts-Basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-160 Bytes
(99%)
...t-workshop/cypress-visual-screenshots/baseline/DatePicker.test.ts-Localized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-166 Bytes
(99%)
...p/cypress-visual-screenshots/baseline/DatePicker.test.ts-With Combined Time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-97 Bytes
(100%)
...t-workshop/cypress-visual-screenshots/baseline/DatePicker.test.ts-With Time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-124 Bytes
(100%)
...t-workshop/cypress-visual-screenshots/baseline/DatePicker.test.ts-With Year.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-201 Bytes
(100%)
...ct-workshop/cypress-visual-screenshots/baseline/Table.test.ts-Custom Filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-54 Bytes
(100%)
apps/react-workshop/cypress-visual-screenshots/baseline/Table.test.ts-Filters.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-39 Bytes
(100%)
.../react-workshop/cypress-visual-screenshots/baseline/Table.test.ts-Localized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+573 Bytes
(100%)
...hop/cypress-visual-screenshots/baseline/TimePicker.test.ts-Custom Renderers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as React from 'react'; | ||
import { useSearchParams } from '@remix-run/react'; | ||
import { ThemeProvider, useToaster } from '@itwin/itwinui-react'; | ||
|
||
export default function Page() { | ||
const [searchParams] = useSearchParams(); | ||
const shouldPortal = searchParams.get('portal') === 'true'; | ||
const isClient = useIsClient(); | ||
|
||
return ( | ||
<> | ||
<Toast text='Toast (root)' /> | ||
|
||
<ThemeProvider data-container='nested'> | ||
<Toast text='Toast (nested)' /> | ||
</ThemeProvider> | ||
|
||
{isClient && shouldPortal && ( | ||
<ThemeProvider portalContainer={document.body}> | ||
<Toast text='Toast (portal)' /> | ||
</ThemeProvider> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
function Toast({ text = 'Toast' }) { | ||
const toaster = useToaster(); | ||
|
||
React.useEffect(() => { | ||
toaster.informational(text, { type: 'persisting' }); | ||
}, [toaster]); | ||
|
||
return null; | ||
} | ||
|
||
function useIsClient() { | ||
const [isClient, setIsClient] = React.useState(false); | ||
|
||
React.useEffect(() => { | ||
setIsClient(true); | ||
}, []); | ||
|
||
return isClient; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('Toaster', () => { | ||
test('should not create nested toast containers', async ({ page }) => { | ||
await page.goto('/Toaster'); | ||
|
||
const rootToast = page.getByText('Toast (root)'); | ||
await expect(rootToast).toBeVisible(); | ||
|
||
const nestedToast = page.getByText('Toast (nested)'); | ||
await expect(nestedToast).toBeVisible(); | ||
|
||
await expect(page.locator('[data-container="nested"]')).not.toContainText( | ||
'Toast', | ||
); | ||
}); | ||
|
||
test('should work when using portalContainer prop', async ({ page }) => { | ||
await page.goto('/Toaster?portal=true'); | ||
|
||
const portalToast = page.getByText('Toast (portal)'); | ||
await expect(portalToast).toBeVisible(); | ||
}); | ||
}); |