-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve peer list styling (#142)
* refactor: remove unnecessary contexts * feat: improve peer list * chore: remove commented code --------- Co-authored-by: Daniel N <2color@users.noreply.github.com>
- Loading branch information
Showing
27 changed files
with
2,433 additions
and
194 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,111 @@ | ||
import { | ||
Description as HeadlessDescription, | ||
Dialog as HeadlessDialog, | ||
DialogPanel as HeadlessDialogPanel, | ||
DialogTitle as HeadlessDialogTitle, | ||
Transition as HeadlessTransition, | ||
TransitionChild as HeadlessTransitionChild, | ||
type DialogProps as HeadlessDialogProps, | ||
} from '@headlessui/react' | ||
import clsx from 'clsx' | ||
import type React from 'react' | ||
import { Text } from './text' | ||
|
||
const sizes = { | ||
xs: 'sm:max-w-xs', | ||
sm: 'sm:max-w-sm', | ||
md: 'sm:max-w-md', | ||
lg: 'sm:max-w-lg', | ||
xl: 'sm:max-w-xl', | ||
'2xl': 'sm:max-w-2xl', | ||
'3xl': 'sm:max-w-3xl', | ||
'4xl': 'sm:max-w-4xl', | ||
'5xl': 'sm:max-w-5xl', | ||
} | ||
|
||
export function Alert({ | ||
open, | ||
onClose, | ||
size = 'md', | ||
className, | ||
children, | ||
...props | ||
}: { size?: keyof typeof sizes; children: React.ReactNode } & HeadlessDialogProps) { | ||
return ( | ||
<HeadlessTransition appear show={open} {...props}> | ||
<HeadlessDialog onClose={onClose}> | ||
<HeadlessTransitionChild | ||
enter="ease-out duration-100" | ||
enterFrom="opacity-0" | ||
enterTo="opacity-100" | ||
leave="ease-in duration-100" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<div className="fixed inset-0 flex w-screen justify-center overflow-y-auto bg-zinc-950/15 px-2 py-2 focus:outline-0 sm:px-6 sm:py-8 lg:px-8 lg:py-16 dark:bg-zinc-950/50" /> | ||
</HeadlessTransitionChild> | ||
|
||
<div className="fixed inset-0 w-screen overflow-y-auto pt-6 sm:pt-0"> | ||
<div className="grid min-h-full grid-rows-[1fr_auto_1fr] justify-items-center p-8 sm:grid-rows-[1fr_auto_3fr] sm:p-4"> | ||
<HeadlessTransitionChild | ||
enter="ease-out duration-100" | ||
enterFrom="opacity-0 scale-95" | ||
enterTo="opacity-100 scale-100" | ||
leave="ease-in duration-100" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<HeadlessDialogPanel | ||
className={clsx( | ||
className, | ||
sizes[size], | ||
'row-start-2 w-full rounded-2xl bg-white p-8 shadow-lg ring-1 ring-zinc-950/10 sm:rounded-2xl sm:p-6 dark:bg-zinc-900 dark:ring-white/10 forced-colors:outline' | ||
)} | ||
> | ||
{children} | ||
</HeadlessDialogPanel> | ||
</HeadlessTransitionChild> | ||
</div> | ||
</div> | ||
</HeadlessDialog> | ||
</HeadlessTransition> | ||
) | ||
} | ||
|
||
export function AlertTitle({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) { | ||
return ( | ||
<HeadlessDialogTitle | ||
{...props} | ||
className={clsx( | ||
className, | ||
'text-balance text-center text-base/6 font-semibold text-zinc-950 sm:text-wrap sm:text-left sm:text-sm/6 dark:text-white' | ||
)} | ||
/> | ||
) | ||
} | ||
|
||
export function AlertDescription({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) { | ||
return ( | ||
<HeadlessDescription | ||
as={Text} | ||
{...props} | ||
className={clsx(className, 'mt-2 text-pretty text-center sm:text-left')} | ||
/> | ||
) | ||
} | ||
|
||
export function AlertBody({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) { | ||
return <div {...props} className={clsx(className, 'mt-4')} /> | ||
} | ||
|
||
export function AlertActions({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) { | ||
return ( | ||
<div | ||
{...props} | ||
className={clsx( | ||
className, | ||
'mt-6 flex flex-col-reverse items-center justify-end gap-3 *:w-full sm:mt-4 sm:flex-row sm:*:w-auto' | ||
)} | ||
/> | ||
) | ||
} |
Oops, something went wrong.