Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: demo app can't be displayed in doc site. #697

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions example/app/app/+html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,14 @@ export default function Root({ children }: { children: React.ReactNode }) {
dangerouslySetInnerHTML={{
__html: `
window.addEventListener("load", () => {
console.log("load called!");
console.log(window.location.search);
// get in_doc search param and condition if it's set to true
const inDoc = window.location.search.includes("in_doc=true");
console.log("inDoc", inDoc);

if (!inDoc) {
return;
}

const carouselComponent = document.getElementById("carousel-component");
console.log("carouselComponent exists!");
console.log(carouselComponent);
if (carouselComponent) {
console.log(carouselComponent.offsetHeight);
window.parent.postMessage(
{
type: "carouselHeight",
Expand Down
7 changes: 3 additions & 4 deletions example/website/components/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const ResizableIframe: React.FC<ResizableIframeProps> = ({ pagePath }) => {
const handleIframeLoad = () => {
// get carousel-component height by postmessage
window.addEventListener("message", (event) => {
console.log(event);
if (event.data.type === "carouselHeight") {
setCarouselHeight(event.data.height);
setIsLoading(false);
Expand All @@ -25,13 +24,13 @@ const ResizableIframe: React.FC<ResizableIframeProps> = ({ pagePath }) => {
style={{
marginTop: "24px",
width: "100%",
height: carouselHeight ?? 280,
height: carouselHeight ?? 28,
position: "relative",
overflow: "hidden",
transition: "height 0.3s ease-in-out",
}}
>
{/* {isLoading && <div style={{ textAlign: "center" }}>Loading...</div>} */}
{isLoading && <div style={{ textAlign: "center" }}>Loading...</div>}
<iframe
id="carousel-iframe"
onLoad={handleIframeLoad}
Expand All @@ -41,7 +40,7 @@ const ResizableIframe: React.FC<ResizableIframeProps> = ({ pagePath }) => {
height: "100%",
border: "none",
overflow: "hidden",
// opacity: isLoading ? 0 : 1,
opacity: isLoading ? 0 : 1,
}}
></iframe>
</div>
Expand Down
Loading