mathFlashcardAppmain.tsx43 matches
1/** @jsxImportSource https://esm.sh/react */
2import React, { useState } from "https://esm.sh/react";
3import { createRoot } from "https://esm.sh/react-dom/client";
45function generateProblem(config) {
162};
163164return React.createElement(
165"div",
166{ className: `math-flashcard-container ${isSettingsVisible ? "flipped" : ""}` },
167React.createElement(
168"div",
169{ className: "flashcard-inner" },
170React.createElement(
171"div",
172{ className: "flashcard-front" },
173React.createElement(
174"div",
175{ className: "flashcard-header" },
176React.createElement("h1", null, "Math Flashcards 🧮"),
177React.createElement(
178"button",
179{
184),
185),
186React.createElement(
187"div",
188{ className: "flashcard" },
189React.createElement(
190"div",
191{ className: "problem" },
192React.createElement("div", { className: "first-number" }, problem.a),
193React.createElement(
194"div",
195{ className: "second-line" },
196React.createElement("span", { className: "operation" }, problem.operation),
197React.createElement("span", { className: "second-number" }, problem.b),
198),
199),
200React.createElement(
201"div",
202{ className: "result-display" },
203showResult && React.createElement("div", { className: "result" }, problem.result),
204),
205React.createElement(
206"div",
207{ className: "multiple-choice" },
208problem.choices.map((choice, index) =>
209React.createElement(
210"button",
211{
225),
226),
227React.createElement(
228"button",
229{
235),
236),
237React.createElement(
238"div",
239{ className: "flashcard-back" },
240React.createElement("h2", null, "Settings"),
241React.createElement(
242"div",
243{ className: "settings-section" },
244React.createElement("h3", null, "Operations"),
245React.createElement(
246"div",
247{ className: "toggle-group" },
248React.createElement(
249"label",
250null,
251React.createElement("input", {
252type: "checkbox",
253checked: config.addition,
256"Addition (+)",
257),
258React.createElement(
259"label",
260null,
261React.createElement("input", {
262type: "checkbox",
263checked: config.subtraction,
266"Subtraction (-)",
267),
268React.createElement(
269"label",
270null,
271React.createElement("input", {
272type: "checkbox",
273checked: config.multiplication,
278),
279),
280React.createElement(
281"div",
282{ className: "settings-section" },
283React.createElement("h3", null, "Number Ranges"),
284React.createElement(
285"div",
286{ className: "toggle-group" },
287React.createElement(
288"label",
289null,
290React.createElement("input", {
291type: "checkbox",
292checked: config.range1to10,
295"1-10",
296),
297React.createElement(
298"label",
299null,
300React.createElement("input", {
301type: "checkbox",
302checked: config.range10to90,
305"10-90 (by 10's)",
306),
307React.createElement(
308"label",
309null,
310React.createElement("input", {
311type: "checkbox",
312checked: config.range100to900,
317),
318),
319React.createElement(
320"button",
321{
331332function App() {
333return React.createElement("div", { className: "app" }, React.createElement(MathFlashcards, null));
334}
335336function client() {
337createRoot(document.getElementById("root")).render(React.createElement(App, null));
338}
339if (typeof document !== "undefined") { client(); }
supportiveTurquoiseSturgeonmain.tsx3 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState } from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45function App() {
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState } from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45function App() {
markdownBlogStarterLayout.tsx3 matches
1/** @jsxImportSource npm:react@18.2.0 */
2import type { ReactNode } from "npm:react@18.2.0";
34export function Layout({ children }: { children: ReactNode }) {
5return (
6<html lang="en">
1/** @jsxImportSource https://esm.sh/preact */
2import { makeBadge } from "npm:badge-maker";
3import { render } from "npm:preact-render-to-string";
4import prettyMilliseconds from "npm:pretty-ms";
5
linkInBioTemplatemain.tsx2 matches
1/** @jsxImportSource https://esm.sh/react */
2import { renderToString } from "npm:react-dom/server";
34export default async function(req: Request) {
cakeOffReviewPlatformREADME.md2 matches
1# React Hono Val Town Project Starter Template
23This is a starter template for a full-stack app in a Val Town Project. The app itself is a simple persistent message board.
23This template is actively accepting pull requests, particularly for bugs, but also for anything that can be done more idiomatically.
2425If you'd like to make a template with other technologies choices (ie no Hono or no React), please create a new template and we can link to it from this one as another way to go. Eventually, we'd like to be many templates that show how to use Projects. The next one I'm personally excited about making is a fullstack React Router 7 one. [This one](https://www.val.town/x/just_be/reactRouter7) is a good start, but I'd like to rebuild the message board app from this template in that format.
cakeOffReviewPlatformREADME.md5 matches
1# Frontend
23This template is a classic client-side-only React app.
45## `index.html`
9This HTML file imports `/frontend/style.css` from `/public/style.css` and `/frontend/favicon.svg` from `/frontend/favicon.svg`. Everything in `/frontend/` is mapped to `/public` by `/backend/index.ts`. This is just a convention. You could import & serve everything out of the same folder name.
1011This HTML file has a `<div id="root"></div>`, which is where we mount the React app.
1213This HTML file imports `/frontend/index.tsx` from `/public/index.tsx`, which is the **entrypoint** for all frontend JavaScript, including all the React. It is not a problem that it imports a file with a `.tsx` extension becaues browsers ignore file extensions. They only pay attention to content-types, which is great, because all these files will be returned as transpiled JS with the appropriate JS content type by [stevekrouse/utils/serve-public](https://www.val.town/x/stevekrouse/utils/branch/main/code/serve-public/README.md).)
1415## `index.tsx`
1617This file is the **entrypoint** for frontend JavaScript. It imports the React app from `/frontend/components/App.tsx` and mounts it on `<div id="root"></div>`.
1819It also looks for *bootstrapped* JSON data at `window.__INITIAL_DATA`, and passes that only to the `<App />`.
25## `components/`
2627This directory is where the React components are stored. They're pretty standard client-side React components.
cakeOffReviewPlatformREADME.md2 matches
12## Serving assets to the frontend
1314This backend HTTP server is responsible for serving all static assets to the browser to render the app, including HTML, JavaScript (including all client-side React), CSS, and even the favicon SVG.
1516In a normal server environment, you would likely use a middleware [like this one](https://hono.dev/docs/getting-started/nodejs#serve-static-files) to serve static files. Some frameworks or deployment platforms automatically make any content inside a `public/` folder public.
26## CRUD API Routes
2728This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. This routes are called from the React app to refresh and update data.
2930## Errors
8## Migrations
910In `backend/database/migrations.ts`, this app creates a new SQLite table `reactHonoStarter_messages` to store messages.
1112This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.