step 1: build something

This commit is contained in:
Jacob Heider 2022-11-09 21:45:40 -05:00
parent 2ffca106c7
commit d7d480c4f7
No known key found for this signature in database
GPG key ID: A98011B5713535BF
8 changed files with 1911 additions and 0 deletions

View file

@ -41,6 +41,8 @@ Execute the following command just once per version of
| Project | Version | | Project | Version |
|------------|---------| |------------|---------|
| gohugo.io | >=0.99 | | gohugo.io | >=0.99 |
| nodejs.org | >=14 |
| npmjs.com | * |
Install them yourself or use tea: Install them yourself or use tea:
@ -56,6 +58,7 @@ $ tea .
Builds a static, deployable version of the website. Builds a static, deployable version of the website.
```sh ```sh
npm ci
hugo --source src --destination ../public --minify hugo --source src --destination ../public --minify
``` ```

11
babel.config.js Normal file
View file

@ -0,0 +1,11 @@
module.exports = function (api) {
api.cache(true);
const presets = [
["@babel/preset-react"]
]
const plugins = [];
return {
presets,
plugins
};
}

1789
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

24
package.json Normal file
View file

@ -0,0 +1,24 @@
{
"name": "tea-www",
"version": "0.1.0",
"description": "basic react config for https://tea.xyz",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/teaxyz/www.git"
},
"author": "Jacob Heider <jacob@tea.xyz>",
"license": "CC-BY-NC-4.0",
"bugs": {
"url": "https://github.com/teaxyz/www/issues"
},
"homepage": "https://github.com/teaxyz/www#readme",
"dependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.20.2",
"@babel/preset-react": "^7.18.6"
}
}

View file

@ -0,0 +1,69 @@
function Bottles() {
const [bottles, setBottles] = React.useState();
React.useEffect(() => {
fetch("https://app.tea.xyz/api/bottles")
.then((res) => res.json())
.then((res) => setBottles(res));
}, []);
if (!bottles) return null;
const names = [...new Set(bottles.map((b) => b.name))];
return (
<div>
<p>{names.length} packages</p>
{names.map((name) => (
<Bottle key={name} name={name} />
))}
</div>
);
function Bottle({ name }) {
const [expanded, toggleExpanded] = React.useState(false);
const versions = [
...new Set(bottles.filter((b) => b.name === name).map((b) => b.version)),
];
return (
<div onClick={() => toggleExpanded(!expanded)}>
<h3>{name}</h3>
<h4>
{versions.length} version{versions.length === 1 ? "" : "s"} bottled
</h4>
{expanded && (
<table>
<thead>
<tr>
<th>version</th>
<th>darwin-aarch64</th>
<th>darwin-x86-64</th>
<th>linux-aarch64</th>
<th>linux-x86-64</th>
</tr>
</thead>
<tbody>
{versions.map((v) => {
const available = new Set(
bottles
.filter((b) => b.name === name && b.version == v)
.map((b) => `${b.platform}-${b.arch}`)
);
return (
<tr key={v}>
<th>{v}</th>
<td>{available.has("darwin-aarch64") ? "✅" : "❌"}</td>
<td>{available.has("darwin-x86-64") ? "✅" : "❌"}</td>
<td>{available.has("linux-aarch64") ? "✅" : "❌"}</td>
<td>{available.has("linux-x86-64") ? "✅" : "❌"}</td>
</tr>
);
})}
</tbody>
</table>
)}
</div>
);
}
}
ReactDOM.render(React.createElement(Bottles), document.getElementById("app"));

View file

@ -23,3 +23,7 @@ title = 'Equitable Open-Source for Web3'
title = 'github' title = 'github'
url = 'https://github.com/teaxyz' url = 'https://github.com/teaxyz'
weight = 6 weight = 6
[security]
[security.exec]
allow = ['^go$', '^postcss$', '^npx$', '^babel$']

View file

@ -152,6 +152,10 @@
</style> </style>
<span class="grid-bottle-display">
{{- partial "bottle-grid.html" . -}}
</span>
<!-- Package CTA Section --> <!-- Package CTA Section -->
<hr> <hr>

View file

@ -0,0 +1,7 @@
<section>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="app"></div>
{{ $app := resources.Get "scripts/bottles.jsx" | babel -}}
<script src="{{ $app.RelPermalink }}"></script>
</section>