This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Takeout Cursor Rules | |
You are an expert in cross-platform development with React Native, Expo, TypeScript, React, PostgreSQL, Tamagui, Expo Router, tRPC, Solito, Supabase, and more. You possess deep knowledge of best practices and performance optimization techniques across these technologies. Our codebase is a shared Turborepo called "Takeout". | |
• Prompt Context: | |
1. If the question explicitly mentions any of the tools or technologies listed above or pertains to the Takeout codebase, ensure your answer incorporates best practices relevant to the mentioned technologies. | |
2. If the question is about frontend/backend without specific mentions, apply general best practices relevant to the context. | |
3. If the question involves general TypeScript or other unrelated tasks, stick to general best practices. | |
4. For follow-up questions unrelated to the technologies or content specified in these rules, the rules do not apply. Focus on answering the question without considering the specified best practices unless explicit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createContext as create, useContext } from 'react' | |
export function createContext<T>(initial?: T) { | |
const ctx = create<T>(initial ?? (null as any)) | |
return Object.assign( | |
function Provider(props: React.ComponentProps<typeof ctx.Provider>) { | |
return <ctx.Provider {...props} /> | |
}, | |
ctx, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import React, { useEffect, useId, useState } from "react"; | |
import { motion, AnimatePresence, MotionConfig } from "framer-motion"; | |
import { PlusIcon, XIcon } from "lucide-react"; | |
import { createPortal } from "react-dom"; | |
import { cn } from "@/lib/utils"; | |
import { buttonVariants } from "../button"; | |
const transition = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ChatGPTTextField: View { | |
// MARK: - State | |
/// State to hold our `TextField` query. | |
@State private var queryMessage: String = "" | |
/// Focus state for our `TextField`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ExpoModulesCore | |
import SwiftUI | |
public class SwiftuiViewModule: Module { | |
public func definition() -> ModuleDefinition { | |
Name("SwiftuiForm") | |
View(SwiftuiView.self) { | |
Prop("name") { (view, name: String) in | |
view.name = name | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
import { useOptimisticMutation } from "./useOptimisticMutation.ts" | |
type Response = boolean | |
type Error = unknown | |
type MutationVariables = {itemId: string} | |
type Items = {id: string; name: string}[] | |
type Likes = {itemId: string}[] | |
type History = {type: string}[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { z } from "zod"; | |
import { zodToTs, printNode } from "zod-to-ts"; | |
// Replace with your `openai` thing | |
import { openai } from "../openai.server"; | |
import endent from "endent"; | |
function createJSONCompletion<T extends z.ZodType>({ | |
prompt, | |
schema_name, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const chaosTestStrings = (): void => { | |
const textNodes = getAllTextNodes(document.body); | |
for (const node of textNodes) { | |
const textNodeLength = node.textContent ? node.textContent.length : 0; | |
if (node.textContent === null) { | |
return; | |
} | |
if (node.parentElement instanceof Element) { | |
if (node.parentElement.dataset.originalText === undefined) { |
NewerOlder