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

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
92 changes: 89 additions & 3 deletions 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,95 @@
<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" />

<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

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

/* Loader Styles */
.loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}

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

.loading {
background-color: lightgrey;
height: 2px;
overflow: hidden;
position: relative;
width: 12em;
border-radius: 2px;
}

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

@keyframes side2side {
0%, 100% {
transform: translateX(-50%);
}
50% {
transform: translateX(150%);
}
}
</style>

<script>
window.onload = function() {
const loader = document.getElementById("loader");
const root = document.getElementById("root");

// Hide the loader and show the root when the page has fully loaded
loader.style.transition = "opacity 0.3s ease";
loader.style.opacity = "0"; // Fade out the loader
setTimeout(function() {
loader.style.display = "none"; // Hide loader completely
root.style.visibility = "visible"; // Show the root content
}, 300); // Match the opacity transition duration
};
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<div class="loaderanimation">
<div id="loader" class="loading-overlay">
<div class="loading-container">
<div class="loading">
<div class="loading-bar"></div>
</div>
</div>
</div>
</div>

<div id="root" class="loaderanimation" style="visibility: hidden;"></div> <!-- Initially hidden -->

<script type="module" src="./src/main.tsx"></script>
</body>
</html>
9 changes: 3 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,24 @@ import React from "react"
const lazyImport = (importFn: () => Promise<any>) =>
lazy<ComponentType<any>>(async () => {
try {
await new Promise((resolve) => setTimeout(resolve, 500))
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 @@ -80,12 +78,11 @@ class ErrorBoundary extends React.Component<
return this.props.children
}
}

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