Skip to content

Commit e71c797

Browse files
committed
chore: improves example index page
1 parent 5de15cc commit e71c797

File tree

4 files changed

+148
-27
lines changed

4 files changed

+148
-27
lines changed

index.html

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,69 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
31

4-
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
</head>
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
5+
<head>
6+
<meta charset="UTF-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Examples Index</title>
9+
<style>
10+
* {
11+
margin: 0;
12+
}
13+
14+
html {
15+
font-family: sans-serif;
16+
}
17+
18+
body {
19+
padding: 1rem;
20+
}
21+
</style>
22+
</head>
23+
24+
<body>
25+
<div style="display: flex; flex-direction: column; gap: 1rem;">
26+
<h3>Choose an example</h3>
27+
<a style="width: fit-content;" href="./packages\front\src\measurement\VolumeMeasurement\example.html">front/VolumeMeasurement</a>
28+
<a style="width: fit-content;" href="./packages\front\src\measurement\LengthMeasurement\example.html">front/LengthMeasurement</a>
29+
<a style="width: fit-content;" href="./packages\front\src\measurement\FaceMeasurement\example.html">front/FaceMeasurement</a>
30+
<a style="width: fit-content;" href="./packages\front\src\measurement\EdgeMeasurement\example.html">front/EdgeMeasurement</a>
31+
<a style="width: fit-content;" href="./packages\front\src\measurement\AreaMeasurement\example.html">front/AreaMeasurement</a>
32+
<a style="width: fit-content;" href="./packages\front\src\measurement\AngleMeasurement\example.html">front/AngleMeasurement</a>
33+
<a style="width: fit-content;" href="./packages\front\src\fragments\Plans\example.html">front/Plans</a>
34+
<a style="width: fit-content;" href="./packages\front\src\fragments\IfcStreamer\example.html">front/IfcStreamer</a>
35+
<a style="width: fit-content;" href="./packages\front\src\fragments\Highlighter\example.html">front/Highlighter</a>
36+
<a style="width: fit-content;" href="./packages\front\src\core\ShadowDropper\example.html">front/ShadowDropper</a>
37+
<a style="width: fit-content;" href="./packages\front\src\core\PostproductionRenderer\example.html">front/PostproductionRenderer</a>
38+
<a style="width: fit-content;" href="./packages\front\src\core\Marker\example.html">front/Marker</a>
39+
<a style="width: fit-content;" href="./packages\front\src\core\ClipEdges\example.html">front/ClipEdges</a>
40+
<a style="width: fit-content;" href="./packages\front\src\civil\CivilPlanNavigator\example.html">front/CivilPlanNavigator</a>
41+
<a style="width: fit-content;" href="./packages\front\src\civil\CivilElevationNavigator\example.html">front/CivilElevationNavigator</a>
42+
<a style="width: fit-content;" href="./packages\front\src\civil\CivilCrossSectionNavigator\example.html">front/CivilCrossSectionNavigator</a>
43+
<a style="width: fit-content;" href="./packages\front\src\civil\Civil3DNavigator\example.html">front/Civil3DNavigator</a>
44+
<a style="width: fit-content;" href="./packages\core\src\measurement\MeasurementUtils\example.html">core/MeasurementUtils</a>
45+
<a style="width: fit-content;" href="./packages\core\src\ifc\IfcRelationsIndexer\example.html">core/IfcRelationsIndexer</a>
46+
<a style="width: fit-content;" href="./packages\core\src\ifc\IfcPropertiesManager\example.html">core/IfcPropertiesManager</a>
47+
<a style="width: fit-content;" href="./packages\core\src\ifc\IfcJsonExporter\example.html">core/IfcJsonExporter</a>
48+
<a style="width: fit-content;" href="./packages\core\src\fragments\IfcPropertiesTiler\example.html">core/IfcPropertiesTiler</a>
49+
<a style="width: fit-content;" href="./packages\core\src\fragments\IfcLoader\example.html">core/IfcLoader</a>
50+
<a style="width: fit-content;" href="./packages\core\src\fragments\IfcGeometryTiler\example.html">core/IfcGeometryTiler</a>
51+
<a style="width: fit-content;" href="./packages\core\src\fragments\Hider\example.html">core/Hider</a>
52+
<a style="width: fit-content;" href="./packages\core\src\fragments\FragmentsManager\example.html">core/FragmentsManager</a>
53+
<a style="width: fit-content;" href="./packages\core\src\fragments\Exploder\example.html">core/Exploder</a>
54+
<a style="width: fit-content;" href="./packages\core\src\fragments\Classifier\example.html">core/Classifier</a>
55+
<a style="width: fit-content;" href="./packages\core\src\fragments\BoundingBoxer\example.html">core/BoundingBoxer</a>
56+
<a style="width: fit-content;" href="./packages\core\src\core\Worlds\example.html">core/Worlds</a>
57+
<a style="width: fit-content;" href="./packages\core\src\core\ShadowedScene\example.html">core/ShadowedScene</a>
58+
<a style="width: fit-content;" href="./packages\core\src\core\Raycasters\example.html">core/Raycasters</a>
59+
<a style="width: fit-content;" href="./packages\core\src\core\OrthoPerspectiveCamera\example.html">core/OrthoPerspectiveCamera</a>
60+
<a style="width: fit-content;" href="./packages\core\src\core\MiniMap\example.html">core/MiniMap</a>
61+
<a style="width: fit-content;" href="./packages\core\src\core\Grids\example.html">core/Grids</a>
62+
<a style="width: fit-content;" href="./packages\core\src\core\Cullers\example.html">core/Cullers</a>
63+
<a style="width: fit-content;" href="./packages\core\src\core\Clipper\example.html">core/Clipper</a>
864

9-
<body>
10-
<h2>
11-
If you're developing, append the package and component folder to the URL in order to see the example working without
12-
compiling. For example: <a id="dev"></a>
13-
</h2>
14-
<h2>
15-
To see the compiled example after you run yarn build, append the name of the component at the end of the URL. For
16-
example: <a id="exp"></a>
17-
</h2>
18-
<script>
19-
const dev = document.getElementById("dev")
20-
dev.href = location.href + "packages/core/src/core/Worlds/example.html"
21-
dev.textContent = dev.href.replace(location.href, "")
22-
23-
const exp = document.getElementById("exp")
24-
exp.href = location.href + "examples/Worlds/"
25-
exp.textContent = exp.href.replace(location.href, "")
26-
</script>
27-
</body>
28-
29-
</html>
65+
</div>
66+
</body>
67+
68+
</html>
69+

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"./packages/*"
3131
],
3232
"devDependencies": {
33+
"@types/node": "latest",
3334
"@typescript-eslint/eslint-plugin": "7.2.0",
3435
"@typescript-eslint/parser": "7.2.0",
3536
"eslint": "8.57.0",

vite.config.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
import * as fs from "fs";
3+
import * as path from "path";
4+
import { defineConfig } from "vite";
5+
import { globSync } from "glob";
6+
7+
const writeIndexHTML = () => {
8+
let links: string = "";
9+
const examplePaths = globSync("packages/**/src/**/example.html");
10+
for (const examplePath of examplePaths) {
11+
const directory = path.dirname(examplePath);
12+
const packageNameMatch = directory.match(/packages\\([^\\]+)/);
13+
if (!(packageNameMatch && packageNameMatch.length > 1)) continue;
14+
const packageName = packageNameMatch[1];
15+
const exampleName = path.basename(directory);
16+
links += `<a style="width: fit-content;" href="./${examplePath}">${packageName}/${exampleName}</a>\n`;
17+
}
18+
const index = `
19+
<!DOCTYPE html>
20+
<html lang="en">
21+
22+
<head>
23+
<meta charset="UTF-8">
24+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
25+
<title>Examples Index</title>
26+
<style>
27+
* {
28+
margin: 0;
29+
}
30+
31+
html {
32+
font-family: sans-serif;
33+
}
34+
35+
body {
36+
padding: 1rem;
37+
}
38+
</style>
39+
</head>
40+
41+
<body>
42+
<div style="display: flex; flex-direction: column; gap: 1rem;">
43+
<h3>Choose an example</h3>
44+
${links}
45+
</div>
46+
</body>
47+
48+
</html>
49+
`;
50+
fs.writeFileSync("./index.html", index);
51+
};
52+
53+
const createIndex = () => ({
54+
name: "create-index",
55+
configureServer() {
56+
// fs.watch("./packages", { recursive: true }, writeIndexHTML);
57+
writeIndexHTML();
58+
},
59+
});
60+
61+
export default defineConfig({
62+
plugins: [createIndex()],
63+
});

yarn.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,15 @@ __metadata:
733733
languageName: node
734734
linkType: hard
735735

736+
"@types/node@npm:latest":
737+
version: 22.2.0
738+
resolution: "@types/node@npm:22.2.0"
739+
dependencies:
740+
undici-types: ~6.13.0
741+
checksum: 63724799337bfb57719a1992690e738341d824e1744a2ac52c5278a008fbfadf99765519c19858feb80418cc7da0d5c8bdf7ea4d82973869b3882bd602c48ade
742+
languageName: node
743+
linkType: hard
744+
736745
"@types/semver@npm:^7.5.0":
737746
version: 7.5.8
738747
resolution: "@types/semver@npm:7.5.8"
@@ -3614,6 +3623,7 @@ __metadata:
36143623
version: 0.0.0-use.local
36153624
resolution: "root-workspace-0b6124@workspace:."
36163625
dependencies:
3626+
"@types/node": latest
36173627
"@typescript-eslint/eslint-plugin": 7.2.0
36183628
"@typescript-eslint/parser": 7.2.0
36193629
eslint: 8.57.0
@@ -4159,6 +4169,13 @@ __metadata:
41594169
languageName: node
41604170
linkType: hard
41614171

4172+
"undici-types@npm:~6.13.0":
4173+
version: 6.13.0
4174+
resolution: "undici-types@npm:6.13.0"
4175+
checksum: 9d0ef6bf58994bebbea6a4ab75f381c69a89a7ed151bfbae0d4ef95450d56502c9eccb323abf17b7d099c1d9c1cbae62e909e4dfeb8d204612d2f1fdada24707
4176+
languageName: node
4177+
linkType: hard
4178+
41624179
"unique-filename@npm:^3.0.0":
41634180
version: 3.0.0
41644181
resolution: "unique-filename@npm:3.0.0"

0 commit comments

Comments
 (0)