Skip to content

Commit 1877e88

Browse files
committed
Add index page
1 parent a8164ab commit 1877e88

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ To make your game's interface fit seamlessly into Brick 1100, there's a [Bridge
2020
Once your pull request is merged, your game will show up at `https://brick1100-games.visnalize.com/<your-game>`, and you can then access it from Brick 1100.
2121

2222
## Game list
23+
24+
> See the [Index page](https://brick1100-games.visnalize.com).

index.html

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Brick 1100 Games</title>
8+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
9+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css">
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css">
11+
<style>
12+
.container {
13+
padding: 4rem 2rem;
14+
}
15+
16+
ul {
17+
list-style: none;
18+
display: flex;
19+
flex-wrap: wrap;
20+
gap: 2rem;
21+
text-align: center;
22+
}
23+
24+
iframe {
25+
--height: 400px;
26+
height: var(--height);
27+
width: calc(var(--height) * 32 / 72);
28+
}
29+
</style>
30+
</head>
31+
32+
<body>
33+
<div class="container">
34+
<h1>Brick 1100 Games</h1>
35+
<ul id="list"></ul>
36+
</div>
37+
38+
<script src="https://unpkg.com/mithril/mithril.js"></script>
39+
<script>
40+
const list = document.getElementById("list");
41+
const gameUrl = "https://brick1100-games.visnalize.com";
42+
const previewerUrl = "https://brick1100.visnalize.com/#/online/previewer";
43+
44+
fetch("https://api.github.com/repos/Visnalize/brick-1100-games/contents")
45+
.then((response) => response.json())
46+
.then((data) => {
47+
const items = data
48+
.filter((item) => item.type === "dir")
49+
.map((item) => {
50+
const name = item.name
51+
.split("-")
52+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
53+
.join(" ");
54+
const iframe = m("iframe", {
55+
src: `${previewerUrl}?url=${gameUrl}/${item.name}`,
56+
frameborder: "0",
57+
});
58+
return m("li", [
59+
m("a", {
60+
href: `${gameUrl}/${item.name}`,
61+
target: "_blank",
62+
}, m("h2", name)),
63+
iframe,
64+
]);
65+
});
66+
m.render(list, items);
67+
});
68+
</script>
69+
</body>
70+
71+
</html>

0 commit comments

Comments
 (0)