stevensDemo.cursorrules9 matches
199- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
200- For persistence, use Val Town SQLite or Blob storage with `import.meta.url` for keys/table names
201- **React Configuration:** When using React libraries, pin versions with `?deps=react@18.2.0,react-dom@18.2.0` and include the `@jsxImportSource` pragma
202- When facing client-side render issues, check if all React dependencies are pinned to the same version
203- **Styling:** Default to using TailwindCSS via `<script src="https://cdn.twind.style" crossorigin></script>` unless otherwise specified
204262263### Frontend Best Practices
264- Structure as a standard client-side React app
265- Use SVG for favicons (Val Town only supports text files)
266- Separate components into individual files
267- Access bootstrapped data from `window.__INITIAL_DATA__`
268- Use React 18.2.0 consistently in all imports and the `@jsxImportSource` pragma
269- Follow the React component pattern from the example project
270- Handle API calls properly with proper error catching
271289- Always run table creation before querying
2902913. **React Configuration:**
292- All React dependencies must be pinned to 18.2.0
293- Always include `@jsxImportSource https://esm.sh/react@18.2.0` at the top of React files
294- Rendering issues often come from mismatched React versions
2952964. **File Handling:**
stevensDemoApp.tsx5 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, {
3useState,
4useEffect,
5useCallback,
6useMemo,
7} from "https://esm.sh/react@18.2.0";
8import { type Memory } from "../../shared/types.ts";
9import { ASSETS, SCENE_POSITIONS, SOURCE_TYPES } from "./assets.ts";
165}, [fetchMemories]);
166167const handleAddMemory = async (e: React.FormEvent) => {
168e.preventDefault();
169if (!newMemoryText.trim()) return;
220};
221222const handleUpdateMemory = async (e: React.FormEvent) => {
223e.preventDefault();
224if (!editingMemory || !editingMemory.text.trim()) return;
1/** @jsxImportSource https://esm.sh/react */
2import React, { useEffect, useRef, useState } from "https://esm.sh/react";
3import { createRoot } from "https://esm.sh/react-dom/client";
45const SCALES = {
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useRef } from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4import {
5Barbell,
8Calendar,
9Dumbbell
10} from "https://esm.sh/phosphor-react@2.0.0";
1112// Predefined exercise dictionary (unchanged from previous implementation)
strategistmain.tsx3 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useEffect, useRef } from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45function TypewriterEffect({ text, speed = 20, onComplete }) {
flashcardsmain.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";
45interface Flashcard {
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4import { DndProvider } from "https://esm.sh/react-dnd@16.0.1";
5import { HTML5Backend } from "https://esm.sh/react-dnd-html5-backend@16.0.1";
6import Chart from "https://esm.sh/chart.js/auto";
7import * as XLSX from "https://esm.sh/xlsx";
89// Explicit dynamic import of React hooks
10async function importReactHooks() {
11try {
12const ReactHooks = await import("https://esm.sh/react@18.2.0");
13return {
14useState: ReactHooks.useState,
15useEffect: ReactHooks.useEffect,
16useCallback: ReactHooks.useCallback
17};
18} catch (error) {
19console.error("Failed to import React hooks:", error);
20return {
21useState: () => [null, () => {}],
98function App() {
99// Defensive programming with fallback state management
100const [hooks, setHooks] = React.useState(null);
101const [charts, setCharts] = React.useState([]);
102const [showDataModal, setShowDataModal] = React.useState(false);
103const [currentChartData, setCurrentChartData] = React.useState(null);
104105// Load hooks dynamically on component mount
106React.useEffect(() => {
107importReactHooks().then((loadedHooks) => {
108setHooks(loadedHooks);
109}).catch(console.error);
111112// Defensive chart rendering with error handling
113React.useEffect(() => {
114if (!charts.length) return;
115
learningplatformmain.tsx4 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useEffect, useRef } from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45// Motivational quotes for inspiration
43* JavaScript, Python, Java
44* TypeScript, Rust
45- Frameworks: React, Node.js, Django
46- Cloud Technologies: AWS, Azure, Google Cloud
47- DevOps: Docker, Kubernetes
moiPosterImprovedProfilePreview.tsx3 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState } from "https://esm.sh/react@18.2.0";
3import { Val } from "../../shared/types.ts";
415* Mimics the buildDotMoi profile page layout with tabs for Public, Unlisted, and Private vals
16*/
17const ProfilePreview: React.FC<ProfilePreviewProps> = ({
18vals,
19username,
stevensDemotypes.ts1 match
1/**
2* @jsxImportSource https://esm.sh/react@18.2.0
3*/
4