-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modal): enhance modal component with multiple animation variants
Fixes #65 Add support for multiple animation variants in the Modal component. * Extend the `modalVariants` object in `packages/ui/src/components/modal.tsx` to include multiple animation options such as `fade`, `zoom`, `scaleBounce`, `slideUp`, `slideDown`, `slideRight`, `slideLeft`, `flip`, and `rotate`. * Allow dynamic selection of animation variants based on the `animationVariant` prop in the `Modal` component. * Update the documentation in `apps/www/content/docs/components/modal.mdx` to explain how to select and use the new animation variants. * Add test cases in `apps/www/app/playground/page.tsx` to cover all supported animation options for the `Modal` component. * Add a new file `apps/www/components/preview/Modal/modalAnimation.tsx` to demonstrate the use of different animation variants in the Modal component. * Update the version in `packages/ui/package.json` from `2.2.3` to `2.2.4`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ruru-m07/ruru-ui/issues/65?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
Showing
6 changed files
with
383 additions
and
30 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
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,74 @@ | ||
"use client"; | ||
|
||
import React, { useState } from "react"; | ||
import { Stack } from "ruru-ui/components/stack"; | ||
import { | ||
Select, | ||
SelectGroup, | ||
SelectValue, | ||
SelectTrigger, | ||
SelectContent, | ||
SelectLabel, | ||
SelectItem, | ||
SelectSeparator, | ||
} from "ruru-ui/components/select"; | ||
import Modal, { ModalProvider, modalVariants } from "ruru-ui/components/modal"; | ||
import { Input } from "ruru-ui/components/input"; | ||
|
||
const ModalAnimation = (): React.ReactNode => { | ||
const [selectedVariant, setSelectedVariant] = useState<string>("default"); | ||
|
||
const handleSubmit = async () => { | ||
// Your submit logic here | ||
console.log("Submitted"); | ||
// Simulate an API call or any async operation | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
}; | ||
|
||
return ( | ||
<Stack direction={"column"} justify={"center"} align={"center"} gap={20}> | ||
<Select | ||
onValueChange={(e) => setSelectedVariant(e)} | ||
defaultValue="default" | ||
> | ||
<SelectTrigger className="w-[180px]"> | ||
<SelectValue placeholder="Select a animation variants" /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectGroup> | ||
<SelectLabel>variants</SelectLabel> | ||
<SelectSeparator /> | ||
{( | ||
Object.keys(modalVariants) as Array<keyof typeof modalVariants> | ||
).map((variantKey, index) => ( | ||
<SelectItem value={variantKey}>{variantKey}</SelectItem> | ||
))} | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
<ModalProvider> | ||
<Modal.Trigger>Open {selectedVariant} Modal</Modal.Trigger> | ||
<Modal animationVariant={selectedVariant as keyof typeof modalVariants}> | ||
<Modal.Body> | ||
<Modal.Header> | ||
<Modal.Title>Create Username</Modal.Title> | ||
<Modal.Subtitle> | ||
Enter a unique name for your token to differentiate it from | ||
other tokens and then select the scope. | ||
</Modal.Subtitle> | ||
</Modal.Header> | ||
<Modal.Content> | ||
<Input label="username" placeholder="enter your username." /> | ||
</Modal.Content> | ||
</Modal.Body> | ||
<Modal.Actions> | ||
<Modal.Close variant="secondary">Cancel</Modal.Close> | ||
<Modal.Action onClick={handleSubmit}>Submit</Modal.Action> | ||
</Modal.Actions> | ||
</Modal> | ||
</ModalProvider> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default ModalAnimation; |
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
Oops, something went wrong.