forked from Weaverse/pilot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Weaverse#227 from Weaverse/dev
Dev
- Loading branch information
Showing
23 changed files
with
545 additions
and
361 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,22 @@ | ||
import { useItemInstance } from "@weaverse/hydrogen"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export function useClosestWeaverseItem(selector: string) { | ||
let [weaverseId, setWeaverseId] = useState<string>(""); | ||
let weaverseItem = useItemInstance(weaverseId); | ||
|
||
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation> | ||
useEffect(() => { | ||
if (!weaverseItem) { | ||
let target = document.querySelector(selector); | ||
if (target) { | ||
let closest = target.closest("[data-wv-id]"); | ||
if (closest) { | ||
setWeaverseId(closest.getAttribute("data-wv-id")); | ||
} | ||
} | ||
} | ||
}, []); | ||
|
||
return weaverseItem; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.