-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Dialog } from "@kobalte/core"; | ||
import cn from "classnames"; | ||
import { Component, JSX } from "solid-js"; | ||
|
||
interface Props { | ||
children?: JSX.Element; | ||
style?: JSX.CSSProperties; | ||
class?: string; | ||
image: Component<any>; | ||
thumbnail: Component<any>; | ||
alt: string; | ||
} | ||
|
||
const DialogImage: Component<Props> = (props) => { | ||
const { children, class: $class, alt, ...rest } = $destructure(props); | ||
|
||
return ( | ||
<div class={cn($class, "relative overflow-hidden")} {...rest}> | ||
<Dialog.Root> | ||
<Dialog.Trigger class="block"> | ||
<props.thumbnail | ||
class={cn("absolute left-0 top-0 h-full w-full object-cover")} | ||
alt={alt} | ||
/> | ||
</Dialog.Trigger> | ||
<Dialog.Portal> | ||
<Dialog.Overlay | ||
class="fixed inset-0 z-50 cursor-pointer" | ||
style={{ background: "rgba(0, 0, 0, 0.5)" }} | ||
/> | ||
<div class="fixed inset-0 z-50 flex items-center justify-center"> | ||
<Dialog.Content class="flex max-h-[90vh] max-w-[90vw] items-center justify-center"> | ||
<Dialog.CloseButton> | ||
<props.image | ||
class={cn( | ||
"max-h-[90vh] max-w-[90vw] overflow-hidden object-contain" | ||
)} | ||
alt={alt} | ||
/> | ||
</Dialog.CloseButton> | ||
</Dialog.Content> | ||
</div> | ||
</Dialog.Portal> | ||
</Dialog.Root> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DialogImage; |
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