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

implemented skeletons loading page, for all navigation #570

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f3dd0a3
Signed-off-by: Saurabhsing21 <[email protected]>
Saurabhsing21 Jan 15, 2025
4f2ff58
implemented skeletons loading page, for all navigation
Saurabhsing21 Jan 15, 2025
175e85b
feat: Implement fancy loading page with skeleton (#533)
Saurabhsing21 Jan 16, 2025
d13340a
feat: Implement fancy loading page with skeleton (#533)
Saurabhsing21 Jan 16, 2025
00f3c90
fixed lazyImport
Saurabhsing21 Jan 16, 2025
576bfce
fixed formate issue
Saurabhsing21 Jan 16, 2025
9f3f45c
-fixed formate issue
Saurabhsing21 Jan 16, 2025
973c3d8
fixed remaning formate issue
Saurabhsing21 Jan 16, 2025
f59948e
fixed remaning formate issue
Saurabhsing21 Jan 16, 2025
05e7be8
fixed skelton div rendering
Saurabhsing21 Jan 16, 2025
a828334
fixed formate issue
Saurabhsing21 Jan 16, 2025
05b59a7
fixed formate issue
Saurabhsing21 Jan 16, 2025
67380b1
fixed formate issue
Saurabhsing21 Jan 16, 2025
3df2fda
Signed-off-by: Saurabhsing21 <[email protected]>
Saurabhsing21 Jan 20, 2025
ec0935f
fixed remaning issue
Saurabhsing21 Jan 20, 2025
de23e6c
removed loading text
Saurabhsing21 Jan 20, 2025
5a1ff97
fixed complete inside html
Saurabhsing21 Jan 21, 2025
00d79b7
-solved loading issue entirely in index.html
Saurabhsing21 Jan 21, 2025
c572300
dolved formate issue
Saurabhsing21 Jan 21, 2025
3de9d18
removed suspense components
Saurabhsing21 Jan 21, 2025
91e6615
solved formate issue
Saurabhsing21 Jan 21, 2025
9b3b126
formate issu solved and removed suspense tag
Saurabhsing21 Jan 21, 2025
035d436
solved formate issue
Saurabhsing21 Jan 21, 2025
79d6ee5
fixed issue
Saurabhsing21 Jan 21, 2025
6cbb337
fixed issue
Saurabhsing21 Jan 21, 2025
f5a4f4e
fixed issue removing suspense components doesnot worrking
Saurabhsing21 Jan 21, 2025
29b0da7
removed suspese tag
Saurabhsing21 Jan 21, 2025
09332e0
add susspense components
Saurabhsing21 Jan 21, 2025
7ac6846
solving formate issue
Saurabhsing21 Jan 21, 2025
4a409d9
fixed formate issue
Saurabhsing21 Jan 21, 2025
1ea5f8f
testing in production
Saurabhsing21 Jan 22, 2025
076e557
testing in production
Saurabhsing21 Jan 22, 2025
a9ecb98
production testing
Saurabhsing21 Jan 22, 2025
7771b77
fix: improve loader behavior for consistent development and deploymen…
Saurabhsing21 Jan 24, 2025
7f2d125
fix: improve loader behavior for consistent development and deploymen…
Saurabhsing21 Jan 24, 2025
1c5c6e8
fixed blank page
Saurabhsing21 Jan 25, 2025
fadb788
fixed blank page
Saurabhsing21 Jan 25, 2025
a47023a
testing preview for blank page
Saurabhsing21 Jan 28, 2025
d2f532c
Merge branch 'tscircuit:main' into issue533
Saurabhsing21 Jan 28, 2025
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
80 changes: 79 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="robots" content="index, follow, NOODP" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16">
<link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16" />
<title>tscircuit - Code Electronics with React</title>
<meta name="description" content="tscircuit is an open-source electronics design tool that lets you create circuits using React components. Design schematics, generate PCB layouts, export and manufacture PCBs online!" />
<meta name="keywords" content="electronic design, PCB design, schematic capture, React components, circuit design, electronics CAD, open source EDA" />
Expand All @@ -15,9 +15,87 @@
<meta name="twitter:title" content="tscircuit - Design Electronics with React Components" />
<meta name="twitter:description" content="Create electronic circuits using React components. Free open-source electronics design tool." />
<link rel="canonical" href="https://tscircuit.com" />
<!-- Inline CSS for Skeleton Loader -->
<style>
/* Reset styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}

/* Loader Overlay */
.loading-overlay {
position: fixed; /* Fixed position to overlay on top */
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.7); /* Semi-transparent background */
display: flex;
justify-content: center;
align-items: center;
z-index: 9999; /* Make sure it's on top of other elements */
}

.loading-container {
display: flex;
flex-direction: column;
align-items: center;
gap: 1em;
}

/* Loading bar container */
.loading {
background-color: lightgrey;
height: 5px;
overflow: hidden;
position: relative;
width: 12em;
border-radius: 2px;
}

/* Animated loading bar */
.loading-bar {
animation: side2side 2s ease-in-out infinite;
background-color: dodgerblue;
height: 100%;
position: absolute;
width: 50%;
}

/* Keyframes for loading bar movement */
@keyframes side2side {
0%, 100% {
transform: translateX(-50%);
}
50% {
transform: translateX(150%);
}
}

</style>
</head>
<body>
<div id="skeleton-loader" class="loading-container"> <!-- Loading Overlay (appears over all content) -->
<div id="loading-overlay" class="loading-overlay">
<div class="loading-container">
<!-- Loading bar -->
<div class="loading">
<div class="loading-bar"></div>
</div>
</div>
</div>
</div>

<!-- Main Content (other sections) -->
<div id="root"></div>

<script type="module" src="/src/main.tsx"></script>
</body>
</html>
27 changes: 21 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
import { ComponentType, Suspense, lazy } from "react"
import { ComponentType, Suspense, lazy, useEffect } from "react" // Added `useEffect` for handling skeleton cleanup
import { Toaster } from "@/components/ui/toaster"
import { Route, Switch } from "wouter"
import "./components/CmdKMenu"
import { ContextProviders } from "./ContextProviders"
import React from "react"

// Lazy loading helper
const lazyImport = (importFn: () => Promise<any>) =>
lazy<ComponentType<any>>(async () => {
try {
const module = await importFn()

if (module.default) {
return { default: module.default }
}

const pageExportNames = ["Page", "Component", "View"]
for (const suffix of pageExportNames) {
const keys = Object.keys(module).filter((key) => key.endsWith(suffix))
if (keys.length > 0) {
return { default: module[keys[0]] }
}
}

const componentExport = Object.values(module).find(
(exp) => typeof exp === "function" && exp.prototype?.isReactComponent,
)
if (componentExport) {
return { default: componentExport }
}

throw new Error(
`No valid React component found in module. Available exports: ${Object.keys(module).join(", ")}`,
)
Expand All @@ -38,6 +35,7 @@ const lazyImport = (importFn: () => Promise<any>) =>
}
})

// Lazy-loaded pages
const AiPage = lazyImport(() => import("@/pages/ai"))
const AuthenticatePage = lazyImport(() => import("@/pages/authorize"))
const DashboardPage = lazyImport(() => import("@/pages/dashboard"))
Expand Down Expand Up @@ -82,10 +80,27 @@ class ErrorBoundary extends React.Component<
}

function App() {
// Added useEffect to handle cleanup of the skeleton loader
useEffect(() => {
// Hide the skeleton from index.html when React mounts
const skeletonLoader = document.getElementById("skeleton-loader")
if (skeletonLoader) {
skeletonLoader.style.display = "none"
}
}, [])
const renderSkeleton = () => {
const skeletonLoader = document.getElementById("skeleton-loader")
if (skeletonLoader) {
return (
<div dangerouslySetInnerHTML={{ __html: skeletonLoader.outerHTML }} />
)
}
return null
}
return (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this here

<ContextProviders>
<ErrorBoundary>
<Suspense fallback={<div>Loading...</div>}>
<Suspense fallback={renderSkeleton()}>
<Switch>
<Route path="/" component={LandingPage} />
<Route path="/editor" component={EditorPage} />
Expand Down
Loading