-
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.
going to go back to track after all these injuries so rip coding time
- Loading branch information
Showing
12 changed files
with
81 additions
and
36 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
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 |
---|---|---|
@@ -1,10 +1,19 @@ | ||
"use client"; | ||
|
||
import { Dropdown } from "@/components/dropdown"; | ||
import { useRef } from "react"; | ||
|
||
export default function HomePage() { | ||
const referenceElement = useRef<HTMLDivElement>(null); | ||
|
||
return ( | ||
<> | ||
<div>hi</div> | ||
<Dropdown /> | ||
<div className="bg-slate-600" ref={referenceElement}> | ||
hi | ||
</div> | ||
<Dropdown referenceElement={referenceElement}> | ||
<div className="bg-slate-600">wow</div> | ||
</Dropdown> | ||
</> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
"use client"; | ||
|
||
export function Dropdown() { | ||
const theme = localStorage.getItem("theme"); | ||
return <div>{theme}</div>; | ||
import { RefObject } from "react"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
export function Dropdown({ | ||
children, | ||
referenceElement, | ||
className | ||
}: { | ||
children: React.ReactNode; | ||
referenceElement: RefObject<HTMLElement>; | ||
className?: string; | ||
}) { | ||
const { top, bottom, right, left } = | ||
referenceElement.current?.getBoundingClientRect() || { | ||
top: 0, | ||
bottom: 0, | ||
right: 0, | ||
left: 0 | ||
}; | ||
|
||
return ( | ||
<div | ||
className={twMerge(`fixed`, className)} | ||
style={{ top, bottom, right, left }} | ||
> | ||
{children} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { Dropdown as DropdownElement } from "@/components/dropdown/dropdown"; | ||
import { InPortal } from "@/util/helpers/inPortal"; | ||
import { RefObject } from "react"; | ||
|
||
export function Dropdown() { | ||
export function Dropdown(props: { | ||
children: React.ReactNode; | ||
referenceElement: RefObject<HTMLElement>; | ||
className?: string; | ||
}) { | ||
return ( | ||
<InPortal> | ||
<DropdownElement /> | ||
<DropdownElement {...props} /> | ||
</InPortal> | ||
); | ||
} |
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
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