mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Update dialog
This commit is contained in:
@@ -9,6 +9,7 @@ import { useUpdateAnyRequest } from '../hooks/useUpdateAnyRequest';
|
|||||||
import { useUpdateRequest } from '../hooks/useUpdateRequest';
|
import { useUpdateRequest } from '../hooks/useUpdateRequest';
|
||||||
import type { HttpRequest } from '../lib/models';
|
import type { HttpRequest } from '../lib/models';
|
||||||
import { Button } from './core/Button';
|
import { Button } from './core/Button';
|
||||||
|
import { Dialog } from './core/Dialog';
|
||||||
import { IconButton } from './core/IconButton';
|
import { IconButton } from './core/IconButton';
|
||||||
import { HStack, VStack } from './core/Stacks';
|
import { HStack, VStack } from './core/Stacks';
|
||||||
import { DropMarker } from './DropMarker';
|
import { DropMarker } from './DropMarker';
|
||||||
@@ -32,6 +33,7 @@ export const Sidebar = memo(function Sidebar({ className }: Props) {
|
|||||||
[unorderedRequests],
|
[unorderedRequests],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
return (
|
return (
|
||||||
<div className="relative h-full">
|
<div className="relative h-full">
|
||||||
<div
|
<div
|
||||||
@@ -46,6 +48,10 @@ export const Sidebar = memo(function Sidebar({ className }: Props) {
|
|||||||
<SidebarItems activeRequestId={activeRequest?.id} requests={requests} />
|
<SidebarItems activeRequestId={activeRequest?.id} requests={requests} />
|
||||||
</VStack>
|
</VStack>
|
||||||
<HStack className="mx-1 pb-1" alignItems="center" justifyContent="end">
|
<HStack className="mx-1 pb-1" alignItems="center" justifyContent="end">
|
||||||
|
<Dialog open={open} onOpenChange={setOpen} title={'Cool Thing'}>
|
||||||
|
Hello?
|
||||||
|
</Dialog>
|
||||||
|
<IconButton title="" icon="magicWand" onClick={() => setOpen(true)} />
|
||||||
<ToggleThemeButton />
|
<ToggleThemeButton />
|
||||||
</HStack>
|
</HStack>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as D from '@radix-ui/react-dialog';
|
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
import { Portal } from '../Portal';
|
||||||
import { IconButton } from './IconButton';
|
import { IconButton } from './IconButton';
|
||||||
import { HStack, VStack } from './Stacks';
|
import { HStack, VStack } from './Stacks';
|
||||||
|
|
||||||
@@ -25,11 +25,15 @@ export function Dialog({
|
|||||||
description,
|
description,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
return (
|
return (
|
||||||
<D.Root open={open} onOpenChange={onOpenChange}>
|
<Portal name="dialog">
|
||||||
<D.Portal container={document.querySelector<HTMLElement>('#radix-portal')}>
|
{open && (
|
||||||
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
|
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
|
||||||
<D.Overlay className="fixed inset-0 bg-gray-600/60 dark:bg-black/50" />
|
<div
|
||||||
<D.Content>
|
aria-hidden
|
||||||
|
onClick={() => onOpenChange(false)}
|
||||||
|
className="fixed inset-0 bg-gray-600/60 dark:bg-black/50"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
<div
|
<div
|
||||||
className={classnames(
|
className={classnames(
|
||||||
className,
|
className,
|
||||||
@@ -39,20 +43,25 @@ export function Dialog({
|
|||||||
wide && 'w-[80vw] max-w-[50rem]',
|
wide && 'w-[80vw] max-w-[50rem]',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<D.Close asChild className="ml-auto absolute right-1 top-1">
|
<IconButton
|
||||||
<IconButton title="Close dialog" aria-label="Close" icon="x" size="sm" />
|
onClick={() => onOpenChange(false)}
|
||||||
</D.Close>
|
title="Close dialog"
|
||||||
|
aria-label="Close"
|
||||||
|
icon="x"
|
||||||
|
size="sm"
|
||||||
|
className="ml-auto absolute right-1 top-1"
|
||||||
|
/>
|
||||||
<VStack space={3}>
|
<VStack space={3}>
|
||||||
<HStack alignItems="center" className="pb-3">
|
<HStack alignItems="center" className="pb-3">
|
||||||
<D.Title className="text-xl font-semibold">{title}</D.Title>
|
<div className="text-xl font-semibold">{title}</div>
|
||||||
</HStack>
|
</HStack>
|
||||||
{description && <D.Description>{description}</D.Description>}
|
{description && <div>{description}</div>}
|
||||||
<div>{children}</div>
|
<div>{children}</div>
|
||||||
</VStack>
|
</VStack>
|
||||||
</div>
|
</div>
|
||||||
</D.Content>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</D.Portal>
|
)}
|
||||||
</D.Root>
|
</Portal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user