-
Notifications
You must be signed in to change notification settings - Fork 607
chore: Dialog container into UI step 1 #3294
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
34bd2a0
init
MichaelUnkey 8f8c4f3
Merge branch 'main' of https://github.com/unkeyed/unkey into dialog-c…
MichaelUnkey 745d449
[autofix.ci] apply automated fixes
autofix-ci[bot] 91451ce
started docs
MichaelUnkey 1f8b3d1
Merge branch 'main' of https://github.com/unkeyed/unkey into dialog-c…
MichaelUnkey 55c2a07
pull from remote
MichaelUnkey 1252178
Merge branch 'main' of https://github.com/unkeyed/unkey into dialog-c…
MichaelUnkey 4836038
Dialogs and docs
MichaelUnkey a5b3be5
[autofix.ci] apply automated fixes
autofix-ci[bot] 86f4024
Comment changes
MichaelUnkey 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
2 changes: 1 addition & 1 deletion
2
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.constants.tsx
This file contains hidden or 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
18 changes: 9 additions & 9 deletions
18
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/index.tsx
This file contains hidden or 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 hidden or 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
77 changes: 77 additions & 0 deletions
77
apps/engineering/content/design/components/dialog-container.mdx
This file contains hidden or 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,77 @@ | ||
| --- | ||
| title: DialogContainer | ||
| summary: The Dialog Container is a flexible modal component that provides a consistent way to display content in a modal dialog. It's built on top of Radix UI's Dialog primitive with additional styling and functionality. | ||
| --- | ||
| import { DialogContainerExample } from "./dialog/dialog-container.example" | ||
|
|
||
| ## Features | ||
|
|
||
| - Accessible modal implementation | ||
| - Customizable overlay and content styling | ||
| - Close button with warning support | ||
| - Keyboard navigation support | ||
| - Customizable animations | ||
| - Responsive design | ||
|
|
||
| ## Structure | ||
|
|
||
| The DialogContainer is composed of three main parts: | ||
|
|
||
| 1. **Header** - Contains the title and optional subtitle | ||
| 2. **Content Area** - The main content section where children are rendered | ||
| 3. **Footer** - Optional section for actions like buttons or additional information | ||
|
|
||
| ## Styling | ||
|
|
||
| The component comes with default styling that includes: | ||
|
|
||
| - Responsive width and height constraints | ||
| - Drop shadow and rounded corners | ||
| - Overlay with backdrop blur | ||
| - Dark mode support | ||
| - Customizable through `className` and `contentClassName` props | ||
|
|
||
| ## Usage | ||
|
|
||
| ```tsx | ||
| <DialogContainer | ||
| isOpen={isOpen} | ||
| onOpenChange={setIsOpen} | ||
| title="Example Dialog" | ||
| subTitle="Optional subtitle text" | ||
| footer={ | ||
| <Button onClick={handleAction}> | ||
| Confirm | ||
| </Button> | ||
| } | ||
| > | ||
| <div>Your dialog content here</div> | ||
| </DialogContainer> | ||
| ``` | ||
|
|
||
| ### Basic Example | ||
|
|
||
| <DialogContainerExample /> | ||
|
|
||
| ## Props | ||
|
|
||
| | Prop | Type | Default | Description | | ||
| |-------------------|-------------------------|-----------|--------------------------------------------------| | ||
| | isOpen | boolean | - | Controls the open state of the dialog | | ||
| | onOpenChange | (value: boolean) => void | - | Callback when the open state changes | | ||
| | title | string | - | The title of the dialog | | ||
| | subTitle | string | - | Optional subtitle for the dialog | | ||
| | footer | ReactNode | - | Optional footer content | | ||
| | className | string | - | Additional classes for the dialog container | | ||
| | contentClassName | string | - | Additional classes for the dialog content | | ||
| | preventAutoFocus | boolean | true | Whether to prevent auto-focus on open | | ||
| | children | ReactNode | - | The content to display in the dialog | | ||
|
|
||
| ## Accessibility | ||
|
|
||
| The DialogContainer implements the following accessibility features: | ||
|
|
||
| - Manages focus trap within the dialog | ||
| - Supports keyboard navigation (Esc to close) | ||
| - Proper ARIA attributes for screen readers | ||
| - Focus management can be controlled via `preventAutoFocus` |
63 changes: 63 additions & 0 deletions
63
apps/engineering/content/design/components/dialog/dialog-container.example.tsx
This file contains hidden or 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,63 @@ | ||
| "use client"; | ||
| import { RenderComponentWithSnippet } from "@/app/components/render"; | ||
| import { DialogContainer } from "@unkey/ui"; | ||
| import { Button, Input } from "@unkey/ui"; | ||
| import { useState } from "react"; | ||
|
|
||
| export function DialogContainerExample() { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [inputValue, setInputValue] = useState(""); | ||
| const [inputResult, setInputResult] = useState(""); | ||
|
|
||
| const handleSubmit = () => { | ||
| setInputResult(inputValue); | ||
| setIsOpen(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <RenderComponentWithSnippet> | ||
| <div className="flex flex-row gap-2 justify-center"> | ||
| <div className="flex flex-col gap-2 w-[200px]"> | ||
| <Button className="text-gray-11 text-[13px]" onClick={() => setIsOpen(!isOpen)}> | ||
| Open Dialog | ||
| </Button> | ||
|
|
||
| <DialogContainer | ||
| isOpen={isOpen} | ||
| onOpenChange={() => setIsOpen(!isOpen)} | ||
| subTitle="This is an example of a subTitle. Normally used to describe the dialog" | ||
| title="Example Dialog Title" | ||
| footer={ | ||
| <div className="flex flex-col w-full gap-2 items-center justify-center"> | ||
| <Button | ||
| type="submit" | ||
| variant="primary" | ||
| size="lg" | ||
| className="w-full" | ||
| onClick={() => handleSubmit()} | ||
| > | ||
| Submit | ||
| </Button> | ||
| <div className="text-error-11 text-xs"> | ||
| This is an example of a footer with a button for actions needed to be done | ||
| </div> | ||
| </div> | ||
| } | ||
| > | ||
| <div className="flex flex-col text-gray-11 text-[13px] gap-2"> | ||
| <p>Dialog Content</p> | ||
| <Input | ||
| placeholder="Example Input" | ||
| type="text" | ||
| onChange={(e) => setInputValue(e.target.value)} | ||
| /> | ||
| </div> | ||
| </DialogContainer> | ||
| <p> | ||
| Input Result: <span className="text-success-6">{inputResult}</span> | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </RenderComponentWithSnippet> | ||
| ); | ||
| } | ||
101 changes: 101 additions & 0 deletions
101
apps/engineering/content/design/components/dialog/navigable-dialog.example.tsx
This file contains hidden or 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,101 @@ | ||
| "use client"; | ||
|
|
||
| import { RenderComponentWithSnippet } from "@/app/components/render"; | ||
| import { Book2, Key } from "@unkey/icons"; | ||
| import type { IconProps } from "@unkey/icons/src/props"; | ||
| import { | ||
| Button, | ||
| NavigableDialogBody, | ||
| NavigableDialogContent, | ||
| NavigableDialogFooter, | ||
| NavigableDialogHeader, | ||
| NavigableDialogNav, | ||
| NavigableDialogRoot, | ||
| } from "@unkey/ui"; | ||
| import { memo, useState } from "react"; | ||
| import type { FC } from "react"; | ||
|
|
||
| // Memoize static content to prevent unnecessary re-renders | ||
| const TabContent = memo(({ title, description }: { title: string; description: string }) => ( | ||
| <div className="p-4"> | ||
| <h3 className="text-lg font-medium mb-2">{title}</h3> | ||
| <p className="text-gray-11">{description}</p> | ||
| </div> | ||
| )); | ||
| TabContent.displayName = "TabContent"; | ||
|
|
||
| type TabId = "docs" | "security"; | ||
|
|
||
| // Pre-define navigation items to prevent recreation on each render | ||
| const NAV_ITEMS: Array<{ | ||
| id: TabId; | ||
| label: string; | ||
| icon: FC<IconProps>; | ||
| }> = [ | ||
| { | ||
| id: "docs", | ||
| label: "Documentation", | ||
| icon: Book2, | ||
| }, | ||
| { | ||
| id: "security", | ||
| label: "Security", | ||
| icon: Key, | ||
| }, | ||
| ]; | ||
|
|
||
| // Pre-define content items using the memoized TabContent | ||
| const CONTENT_ITEMS: Array<{ | ||
| id: TabId; | ||
| content: JSX.Element; | ||
| }> = [ | ||
| { | ||
| id: "docs", | ||
| content: ( | ||
| <TabContent | ||
| title="Documentation" | ||
| description="Access comprehensive guides and documentation for the NavigableDialog component." | ||
| /> | ||
| ), | ||
| }, | ||
| { | ||
| id: "security", | ||
| content: ( | ||
| <TabContent | ||
| title="Security" | ||
| description="Review security settings and configurations for your application." | ||
| /> | ||
| ), | ||
| }, | ||
| ]; | ||
|
|
||
| // Main example component | ||
| export const NavigableDialogExample = memo(() => { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
|
|
||
| return ( | ||
| <RenderComponentWithSnippet> | ||
| <div className="flex justify-center"> | ||
| <Button onClick={() => setIsOpen(true)}>Open Example Dialog</Button> | ||
|
|
||
| <NavigableDialogRoot isOpen={isOpen} onOpenChange={setIsOpen} preventAutoFocus> | ||
| <NavigableDialogHeader | ||
| title="NavigableDialog Example" | ||
| subTitle="A simple demonstration" | ||
| /> | ||
|
|
||
| <NavigableDialogBody> | ||
| <NavigableDialogNav items={NAV_ITEMS} /> | ||
| <NavigableDialogContent items={CONTENT_ITEMS} /> | ||
| </NavigableDialogBody> | ||
|
|
||
| <NavigableDialogFooter> | ||
| <Button onClick={() => setIsOpen(false)}>Close</Button> | ||
| </NavigableDialogFooter> | ||
| </NavigableDialogRoot> | ||
| </div> | ||
| </RenderComponentWithSnippet> | ||
| ); | ||
| }); | ||
|
|
||
| NavigableDialogExample.displayName = "NavigableDialogExample"; |
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.
Uh oh!
There was an error while loading. Please reload this page.