-
Notifications
You must be signed in to change notification settings - Fork 323
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
Fix resize animations in Dialog #11643
Merged
mergify
merged 15 commits into
develop
from
wip/sergeigarin/fix-dialog-resize-animations
Nov 28, 2024
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b1d2314
Fix Dialog animations
MrFlashAccount 40c0704
Prettier
MrFlashAccount 73b9e9d
Fix lint errors
MrFlashAccount d1b4e18
Fix docs alignment
MrFlashAccount 6721983
Fixes
MrFlashAccount 1021d74
Fixes
MrFlashAccount 791c004
Disable snapshot for resing story
MrFlashAccount 0e17420
Fix prettier
MrFlashAccount 8485485
Remove unrelated change
MrFlashAccount 459d417
Remove unrelated change
MrFlashAccount 1ee7a65
Fix popover
MrFlashAccount 763b6af
Tests
MrFlashAccount 995950a
Fix
MrFlashAccount a093c14
open popover
MrFlashAccount beaf8b1
fix prettier
MrFlashAccount File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
105 changes: 105 additions & 0 deletions
105
app/gui/src/dashboard/components/AriaComponents/Dialog/Dialog.stories.tsx
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,105 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { useSuspenseQuery } from '@tanstack/react-query' | ||
import { useLayoutEffect, useRef } from 'react' | ||
import { DialogTrigger } from 'react-aria-components' | ||
import { Button } from '../Button' | ||
import { Dialog, type DialogProps } from './Dialog' | ||
|
||
type Story = StoryObj<DialogProps> | ||
|
||
export default { | ||
title: 'AriaComponents/Dialog', | ||
component: Dialog, | ||
render: (args) => ( | ||
<DialogTrigger defaultOpen> | ||
<Button>Open Dialog</Button> | ||
|
||
<Dialog {...args} /> | ||
</DialogTrigger> | ||
), | ||
args: { | ||
type: 'modal', | ||
title: 'Dialog Title', | ||
children: 'Dialog Content', | ||
}, | ||
} as Meta<DialogProps> | ||
|
||
export const Default = {} | ||
|
||
// Use a random query key to avoid caching | ||
const QUERY_KEY = Math.random().toString() | ||
|
||
function SuspenseContent({ delay = 10_000 }: { delay?: number }): React.ReactNode { | ||
useSuspenseQuery({ | ||
queryKey: [QUERY_KEY], | ||
gcTime: 0, | ||
initialDataUpdatedAt: 0, | ||
queryFn: () => | ||
new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve('resolved') | ||
}, delay) | ||
}), | ||
}) | ||
|
||
return ( | ||
<div className="flex h-[250px] flex-col items-center justify-center text-center"> | ||
Unsuspended content | ||
</div> | ||
) | ||
} | ||
|
||
export const Suspened = { | ||
args: { | ||
children: <SuspenseContent delay={10_000_000_000} />, | ||
}, | ||
} | ||
|
||
function BrokenContent(): React.ReactNode { | ||
throw new Error('💣') | ||
} | ||
|
||
export const Broken = { | ||
args: { | ||
children: <BrokenContent />, | ||
}, | ||
} | ||
|
||
function ResizableContent() { | ||
const divRef = useRef<HTMLDivElement>(null) | ||
|
||
useLayoutEffect(() => { | ||
const getRandomHeight = () => Math.floor(Math.random() * 250 + 100) | ||
|
||
if (divRef.current) { | ||
divRef.current.style.height = `${getRandomHeight()}px` | ||
|
||
setInterval(() => { | ||
if (divRef.current) { | ||
divRef.current.style.height = `${getRandomHeight()}px` | ||
} | ||
}, 2_000) | ||
} | ||
}, []) | ||
|
||
return ( | ||
<div ref={divRef} className="flex flex-none items-center justify-center text-center"> | ||
This dialog should resize with animation | ||
</div> | ||
) | ||
} | ||
|
||
export const AnimateSize: Story = { | ||
args: { | ||
children: <ResizableContent />, | ||
}, | ||
parameters: { | ||
chromatic: { disableSnapshot: true }, | ||
}, | ||
} | ||
|
||
export const Fullscreen = { | ||
args: { | ||
type: 'fullscreen', | ||
}, | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we only move the MotionConfig from
<App />
to<UIProvider />
to reuse it inStorybook