-
Notifications
You must be signed in to change notification settings - Fork 75
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
1 parent
7eb69d9
commit cf06607
Showing
14 changed files
with
324 additions
and
276 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,68 @@ | ||
import { | ||
autoUpdate, | ||
flip, | ||
offset, | ||
shift, | ||
useDismiss, | ||
useFloating, | ||
useFocus, | ||
useHover, | ||
useInteractions, | ||
useRole, | ||
} from "@floating-ui/react"; | ||
import { useState } from "react"; | ||
|
||
interface TooltipProps { | ||
content: React.ReactNode; | ||
children: React.ReactNode; | ||
placement?: "top" | "bottom" | "left" | "right"; | ||
isDarkMode?: boolean; | ||
} | ||
|
||
export const Tooltip: React.FC<TooltipProps> = ({ content, children, placement = "bottom", isDarkMode = false }) => { | ||
const [isVisible, setIsVisible] = useState(false); | ||
const { refs, floatingStyles, context } = useFloating({ | ||
open: isVisible, | ||
onOpenChange: setIsVisible, | ||
placement: placement, | ||
whileElementsMounted: autoUpdate, | ||
middleware: [ | ||
offset(5), | ||
flip({ | ||
fallbackAxisSideDirection: "start", | ||
}), | ||
shift(), | ||
], | ||
}); | ||
|
||
const hover = useHover(context, { move: false }); | ||
const focus = useFocus(context); | ||
const dismiss = useDismiss(context); | ||
const role = useRole(context, { role: "tooltip" }); | ||
|
||
const { getReferenceProps, getFloatingProps } = useInteractions([hover, focus, dismiss, role]); | ||
|
||
return ( | ||
<div | ||
className="relative inline-block" | ||
onMouseEnter={() => setIsVisible(true)} | ||
onMouseLeave={() => setIsVisible(false)} | ||
ref={refs.setReference} | ||
{...getReferenceProps()} | ||
> | ||
{children} | ||
{isVisible && ( | ||
<div | ||
ref={refs.setFloating} | ||
style={{ ...floatingStyles, zIndex: 1000 }} | ||
{...getFloatingProps()} | ||
className={`p-2 rounded-md ${ | ||
isDarkMode ? "bg-whiteDefault text-blackDefault" : "bg-blackDefault text-whiteDefault" | ||
}`} | ||
> | ||
{content} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; |
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 was deleted.
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
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
24 changes: 24 additions & 0 deletions
24
explorer/src/pages/Attestations/components/CardView/index.tsx
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,24 @@ | ||
import { AttestationCard } from "@/pages/Attestation/components/AttestationCard"; | ||
|
||
import { ICardViewProps } from "./interface"; | ||
|
||
export const CardView: React.FC<ICardViewProps> = ({ attestationsList }) => { | ||
return ( | ||
<div className="flex flex-col gap-14 md:gap-[4.5rem] container mt-14 md:mt-12"> | ||
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6"> | ||
{attestationsList?.map((attestation) => { | ||
return ( | ||
<AttestationCard | ||
key={attestation.id} | ||
id={attestation.id} | ||
schemaId={attestation.schema.id} | ||
portalId={attestation.portal.id} | ||
issuanceDate={attestation.attestedDate} | ||
expiryDate={attestation.expirationDate} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
}; |
13 changes: 13 additions & 0 deletions
13
explorer/src/pages/Attestations/components/CardView/interface.ts
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,13 @@ | ||
export interface ICardViewProps { | ||
attestationsList: Array<{ | ||
id: string; | ||
schema: { | ||
id: string; | ||
}; | ||
portal: { | ||
id: string; | ||
}; | ||
attestedDate: number; | ||
expirationDate?: number; | ||
}>; | ||
} |
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
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.