energycommunityshowcasemain.tsx3 matches
3import React, { useState } from "https://esm.sh/react@18.2.0";
45function EnergyCommunityApp() {
6const steps = [
7{
127}
128129function client() {
130createRoot(document.getElementById("root")).render(<EnergyCommunityApp />);
131}
133if (typeof document !== "undefined") { client(); }
134135export default async function server(request: Request): Promise<Response> {
136return new Response(
137`
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
45function App() {
6const [currentTime, setCurrentTime] = useState(new Date());
758}
5960function client() {
61const rootElement = document.getElementById("root");
62if (rootElement) {
69if (typeof document !== "undefined") { client(); }
7071export default async function server(request: Request): Promise<Response> {
72return new Response(
73`
logoWorkshop_migratedmain.tsx2 matches
253};
254255function client() {
256createRoot(document.getElementById("root")).render(<SimpleLogoGenerator />);
257}
261}
262263export default async function server(request: Request): Promise<Response> {
264return new Response(`
265<!DOCTYPE html>
campycardsmain.tsx11 matches
6const LOCAL_STORAGE_KEY = "aiCardGradingResults_v1"; // Change version if structure changes
78// --- Helper Functions ---
9function generateTimestamp() {
10// Note: Using Chandler, AZ time as requested. For server-side consistency, UTC is often preferred.
11// This example uses the browser's local time formatted, which might vary.
18}
1920function getRandomGrade() { // Used by ScoreRevealAnimation if needed
21const grades = ["A", "B", "C", "D", "F"];
22return grades[Math.floor(Math.random() * grades.length)];
23}
2425function getGradeColorClass(grade) { // Used by ScoreRevealAnimation
26switch (grade) {
27case "A":
40}
4142function formatNumber(num) { // Used by ScoreRevealAnimation
43return Math.round(num).toString();
44}
4546// --- Score Reveal Animation Component ---
47function ScoreRevealAnimation({ startSignal, gradeData, onComplete }) {
48// --- State ---
49const [phase, setPhase] = useState("idle"); // 'idle', 'anticipating', 'stamping', 'fading', 'report', 'finished'
94}
9596// --- Cleanup function ---
97const clearTimers = useCallback(() => {
98clearInterval(scoreIntervalRef.current);
256257// --- Card Grader Frontend Component ---
258function CardGraderApp() {
259const [imageFile, setImageFile] = useState(null);
260const [imageBase64, setImageBase64] = useState(null);
421};
422423// --- Render Functions ---
424const renderReport = (report) => {
425if (!report) return null;
553554// --- Client-side Rendering ---
555function client() {
556const rootElement = document.getElementById("root");
557if (rootElement) {
566567// --- Backend Server (Val Town) ---
568export default async function server(request: Request): Promise<Response> {
569const { OpenAI } = await import("https://esm.town/v/std/openai");
570
6const LOCAL_STORAGE_KEY = "aiCardGradingResults_v1"; // Change version if structure changes
78// --- Helper Function ---
9function generateTimestamp() {
10return new Date().toLocaleString();
11}
1213// --- Frontend Component ---
14function CardGraderApp() {
15const [imageFile, setImageFile] = useState(null);
16const [imageBase64, setImageBase64] = useState(null);
141};
142143// --- Render Functions ---
144145const renderReport = (report) => {
257258// --- Client-side Rendering ---
259function client() {
260const rootElement = document.getElementById("root");
261if (rootElement) {
270271// --- Backend Server (Val Town) ---
272export default async function server(request: Request): Promise<Response> {
273const { OpenAI } = await import("https://esm.town/v/std/openai");
274411}
412413// --- HTML Content --- (Moved outside the server function for clarity)
414const htmlContent = `
415<!DOCTYPE html>
13];
1415function LearningApp() {
16const [state, setState] = useState({
17topics: INITIAL_TOPICS,
29});
3031// --- Helper Functions ---
32const setLoading = (message) => setState(prev => ({ ...prev, loadingMessage: message, error: null }));
33const setError = (errorMessage) => setState(prev => ({ ...prev, loadingMessage: null, error: errorMessage }));
34const clearLoadingError = () => setState(prev => ({ ...prev, loadingMessage: null, error: null }));
3536// --- API Interaction Functions ---
3738const fetchStudyMaterial = useCallback(async (topic) => {
64setState(prev => ({ ...prev, stage: "topic-selection", selectedTopic: null }));
65}
66}, []); // Empty dependency array means this function is created once
6768const startQuiz = useCallback(async () => {
384385// --- Client-side Rendering ---
386function client() {
387const rootElement = document.getElementById("root");
388if (rootElement) {
399400// --- Backend Server (Val Town) ---
401export default async function server(request: Request): Promise<Response> {
402// Standard Val Town imports (ensure these versions are suitable)
403const { OpenAI } = await import("http://esm.town/v/std/openai"); // Use npm import for better version control if needed
590}
591592// --- CSS Styling (moved outside main function for clarity) ---
593const css = `
594:root {
homerepairmain.tsx5 matches
57| { type: "RESET_STATE" };
5859function appReducer(state: AppState, action: AppAction): AppState {
60switch (action.type) {
61case "SELECT_AGENT":
119}
120121function HomeRepairAssistants() {
122const initialAgents: Agent[] = [
123{
199{
200name: "fix-light-switch",
201description: "Fix a malfunctioning light switch",
202inputs: [
203{
517518// Client-side rendering
519function client() {
520// Inject styles
521const styleElement = document.createElement("style");
528if (typeof document !== "undefined") { client(); }
529530export default async function server(request: Request): Promise<Response> {
531const { OpenAI } = await import("https://esm.town/v/std/openai");
532const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
13}
1415export function ProjectForm({ onSubmit, onCancel, initialValues = {} }: ProjectFormProps) {
16const [formData, setFormData] = useState({
17name: initialValues.name || '',
8}
910export function SubscribersList({ subscribers, projects }: SubscribersListProps) {
11const [searchTerm, setSearchTerm] = useState('');
12
11}
1213export function ProjectsList({
14projects,
15loading,