Skip to content

Commit 4dfb4cf

Browse files
committed
chore: align demo page with graph plugin
1 parent cb0293b commit 4dfb4cf

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

demo/index.html

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
<!--
33
YASGUI Table Plugin - Demo Page
44
5-
Demonstrates the advanced table plugin for YASGUI with virtual scrolling,
6-
search, filtering, column management, cell selection, and export features.
5+
This demo automatically detects the environment:
6+
- Development (localhost/file): Loads ES modules from src/ for live reload
7+
- Production (GitHub Pages): Loads minified bundle from dist/
8+
9+
To develop locally: Open this file directly or run: npm run dev
10+
For production builds: npm run build
711
-->
812
<html lang="en">
913
<head>
@@ -12,7 +16,7 @@
1216
<title>YASGUI Table Plugin Demo</title>
1317

1418
<!-- YASGUI CSS -->
15-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.5.0/build/yasgui.min.css">
19+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.6.0/build/yasgui.min.css">
1620

1721
<!-- Table Plugin CSS -->
1822
<link rel="stylesheet" href="../dist/table-plugin.css">
@@ -98,6 +102,7 @@
98102
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
99103
}
100104
</style>
105+
101106
</head>
102107
<body>
103108
<h1>🔷 YASGUI TABLE Plugin Demo</h1>
@@ -133,34 +138,41 @@ <h2 onclick="toggleInstructions()">
133138
<div id="yasgui"></div>
134139

135140
<!-- YASGUI JavaScript -->
136-
<script src="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.5.0/build/yasgui.min.js"></script>
141+
<script src="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.6.0/build/yasgui.min.js"></script>
137142

138143
<!-- Table Plugin JavaScript -->
139144
<!-- Vite will automatically replace this with ES modules during dev, or use the built version for production -->
140145
<script type="module">
141146
// Detect if running in Vite dev server (module system available)
142147
const isViteDev = import.meta.env?.DEV;
143148

149+
let pluginLoaded = false;
150+
144151
if (isViteDev) {
145152
// Development mode: Load plugin from source
146-
const { TablePlugin } = await import('@matdata/yasgui-table-plugin');
153+
const { default: TablePlugin } = await import('@matdata/yasgui-table-plugin');
147154
window.YasguiTablePlugin = { TablePlugin };
155+
pluginLoaded = true;
148156
console.log('✅ Table Plugin loaded from source (Vite dev mode)');
149-
} else {
150-
// Production mode: Load from built UMD bundle
151-
// This runs when opening index.html directly in browser
152-
if (!window.YasguiTablePlugin) {
153-
const script = document.createElement('script');
154-
script.src = '../dist/table-plugin.umd.js';
155-
await new Promise((resolve, reject) => {
156-
script.onload = resolve;
157-
script.onerror = reject;
158-
document.head.appendChild(script);
159-
});
160-
console.log('✅ Table Plugin loaded from bundle (production mode)');
161-
}
162-
}
157+
}
163158

159+
// In production mode or if dev load failed, load the bundle
160+
if (!pluginLoaded) {
161+
const script = document.createElement('script');
162+
await new Promise((resolve, reject) => {
163+
script.onload = () => {
164+
console.log('✅ Table Plugin loaded from bundle (production mode)');
165+
resolve();
166+
};
167+
script.onerror = () => {
168+
console.error('❌ Failed to load Table Plugin bundle');
169+
reject();
170+
};
171+
document.head.appendChild(script);
172+
script.src = './dist/yasgui-table-plugin.min.js';
173+
});
174+
}
175+
164176
// Initialize demo after plugin is loaded
165177
// Sample SELECT queries for testing the table plugin
166178
const queries = {

0 commit comments

Comments
 (0)