code: tsx,nextjs,frontends (25 files)

This commit is contained in:
Richard Ward
2025-12-30 12:28:40 +00:00
parent 9977dbd838
commit dfb3822512
25 changed files with 23 additions and 223 deletions

View File

@@ -1,5 +1,5 @@
import { useKV } from '@github/spark/hooks'
import { ArrowCounterClockwise, FloppyDisk, Moon, Palette, Sun } from '@phosphor-icons/react'
import { ArrowCounterClockwise, FloppyDisk, Moon, Palette, Sun } from '@/fakemui/icons'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'

View File

@@ -1,5 +1,5 @@
import Editor from '@monaco-editor/react'
import { FloppyDisk, Warning, X } from '@phosphor-icons/react'
import { FloppyDisk, Warning, X } from '@/fakemui/icons'
import { useState } from 'react'
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { Check, Copy, Eye, EyeSlash, Warning } from '@phosphor-icons/react'
import { Check, Copy, Eye, EyeSlash, Warning } from '@/fakemui/icons'
import { Alert, AlertDescription } from '@/components/ui'
import { Button } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { Trash } from '@phosphor-icons/react'
import { Trash } from '@/fakemui/icons'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui'
import { Button } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { Envelope } from '@phosphor-icons/react'
import { Envelope } from '@/fakemui/icons'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui'
import { Button } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { Download, Eye, House, SignOut, Terminal, Upload } from '@phosphor-icons/react'
import { Download, Eye, House, SignOut, Terminal, Upload } from '@/fakemui/icons'
import { Button } from '@/components/ui'
import { Badge } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { Crown, SignOut, Terminal } from '@phosphor-icons/react'
import { Crown, SignOut, Terminal } from '@/fakemui/icons'
import { Button } from '@/components/ui'
import { Badge } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { ArrowsOutCardinal, Plus, Tree } from '@phosphor-icons/react'
import { ArrowsOutCardinal, Plus, Tree } from '@/fakemui/icons'
import { useCallback, useId, useMemo, useState } from 'react'
import { toast } from 'sonner'

View File

@@ -1,4 +1,4 @@
import { Cursor } from '@phosphor-icons/react'
import { Cursor } from '@/fakemui/icons'
import type React from 'react'
import type { ComponentNode } from '@/lib/database'

View File

@@ -1,4 +1,4 @@
import { CaretDown, CaretRight, GearSix, Trash, Tree } from '@phosphor-icons/react'
import { CaretDown, CaretRight, GearSix, Trash, Tree } from '@/fakemui/icons'
import type React from 'react'
import { Badge, Button } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { FloppyDisk, X } from '@phosphor-icons/react'
import { FloppyDisk, X } from '@/fakemui/icons'
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui'
import { Badge } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { FloppyDisk, Pencil, Plus, Trash, X } from '@phosphor-icons/react'
import { FloppyDisk, Pencil, Plus, Trash, X } from '@/fakemui/icons'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'

View File

@@ -1,4 +1,4 @@
import { Plus } from '@phosphor-icons/react'
import { Plus } from '@/fakemui/icons'
import {
Button,

View File

@@ -1,4 +1,4 @@
import { ArrowsClockwise, Export, Trash, UploadSimple } from '@phosphor-icons/react'
import { ArrowsClockwise, Export, Trash, UploadSimple } from '@/fakemui/icons'
import { Button } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { Key } from '@phosphor-icons/react'
import { Key } from '@/fakemui/icons'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'

View File

@@ -1,4 +1,4 @@
import { Lock } from '@phosphor-icons/react'
import { Lock } from '@/fakemui/icons'
import { useState } from 'react'
import { toast } from 'sonner'

View File

@@ -1,4 +1,4 @@
import { ArrowLeft, Envelope, SignIn, UserPlus } from '@phosphor-icons/react'
import { ArrowLeft, Envelope, SignIn, UserPlus } from '@/fakemui/icons'
import { useState } from 'react'
import { toast } from 'sonner'

View File

@@ -1,4 +1,4 @@
import { Eye, Layout, ShieldCheck } from '@phosphor-icons/react'
import { Eye, Layout, ShieldCheck } from '@/fakemui/icons'
import {
Badge,

View File

@@ -1,4 +1,4 @@
import { ArrowClockwise, Info, Warning } from '@phosphor-icons/react'
import { ArrowClockwise, Info, Warning } from '@/fakemui/icons'
import { useEffect } from 'react'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui'

View File

@@ -1,4 +1,4 @@
import { CheckCircle, Info, ShieldWarning, Warning } from '@phosphor-icons/react'
import { CheckCircle, Info, ShieldWarning, Warning } from '@/fakemui/icons'
import { Alert, AlertDescription } from '@/components/ui'
import { Badge } from '@/components/ui'

View File

@@ -1,74 +1,3 @@
-- Header render component
---@class HeaderProps
---@field variant? "default"|"admin"
---@field title? string
---@field showHome? boolean
---@field username? string
---@field showBadge? boolean
---@field showAvatar? boolean
---@field showLogout? boolean
---@class UIComponent
---@field type string
---@field props? table
---@field children? UIComponent[]
local M = {}
---@param props HeaderProps
---@return UIComponent
function M.render(props)
local variant = props.variant or "default"
local bg = variant == "admin" and "bg-sidebar" or "bg-card"
return {
type = "Box",
props = { className = "border-b sticky top-0 z-50 " .. bg },
children = {
{
type = "Container",
props = { className = "flex justify-between items-center h-16 px-4" },
children = {
M.logo_section(props),
M.user_section(props)
}
}
}
}
end
---@param props HeaderProps
---@return UIComponent
function M.logo_section(props)
return {
type = "Flex",
props = { className = "items-center gap-6" },
children = {
{ type = "Box", props = { className = "w-8 h-8 rounded-lg bg-gradient-to-br from-primary to-accent" } },
{ type = "Typography", props = { variant = "h6", text = props.title or "MetaBuilder" } },
props.showHome and {
type = "Button",
props = { variant = "ghost", text = "Home", onClick = "navigateHome" }
} or nil
}
}
end
---@param props HeaderProps
---@return UIComponent
function M.user_section(props)
local children = {}
if props.username and props.showBadge then
children[#children + 1] = { type = "Badge", props = { text = props.username } }
end
if props.username and props.showAvatar then
children[#children + 1] = { type = "Avatar", props = { fallback = string.sub(props.username, 1, 1) } }
end
if props.showLogout then
children[#children + 1] = { type = "Button", props = { variant = "ghost", text = "Logout", onClick = "handleLogout" } }
end
return { type = "Flex", props = { className = "items-center gap-2" }, children = children }
end
return M
-- Header render module redirect
-- This file now redirects to the modular implementation in render/
return require("render.init")

View File

@@ -1,35 +0,0 @@
-- Logo section component for header
---@class HeaderProps
---@field variant? "default"|"admin"
---@field title? string
---@field showHome? boolean
---@field username? string
---@field showBadge? boolean
---@field showAvatar? boolean
---@field showLogout? boolean
---@class UIComponent
---@field type string
---@field props? table
---@field children? UIComponent[]
---Renders the logo and navigation section of the header
---@param props HeaderProps
---@return UIComponent
local function logo_section(props)
return {
type = "Flex",
props = { className = "items-center gap-6" },
children = {
{ type = "Box", props = { className = "w-8 h-8 rounded-lg bg-gradient-to-br from-primary to-accent" } },
{ type = "Typography", props = { variant = "h6", text = props.title or "MetaBuilder" } },
props.showHome and {
type = "Button",
props = { variant = "ghost", text = "Home", onClick = "navigateHome" }
} or nil
}
}
end
return logo_section

View File

@@ -1,43 +0,0 @@
-- Main render function for header
local logo_section = require("render.logo_section")
local user_section = require("render.user_section")
---@class HeaderProps
---@field variant? "default"|"admin"
---@field title? string
---@field showHome? boolean
---@field username? string
---@field showBadge? boolean
---@field showAvatar? boolean
---@field showLogout? boolean
---@class UIComponent
---@field type string
---@field props? table
---@field children? UIComponent[]
---Renders the complete header component
---@param props HeaderProps
---@return UIComponent
local function render(props)
local variant = props.variant or "default"
local bg = variant == "admin" and "bg-sidebar" or "bg-card"
return {
type = "Box",
props = { className = "border-b sticky top-0 z-50 " .. bg },
children = {
{
type = "Container",
props = { className = "flex justify-between items-center h-16 px-4" },
children = {
logo_section(props),
user_section(props)
}
}
}
}
end
return render

View File

@@ -1,17 +0,0 @@
-- Type definitions for header render components
---@class HeaderProps
---@field variant? "default"|"admin"
---@field title? string
---@field showHome? boolean
---@field username? string
---@field showBadge? boolean
---@field showAvatar? boolean
---@field showLogout? boolean
---@class UIComponent
---@field type string
---@field props? table
---@field children? UIComponent[]
return {}

View File

@@ -1,34 +0,0 @@
-- User section component for header
---@class HeaderProps
---@field variant? "default"|"admin"
---@field title? string
---@field showHome? boolean
---@field username? string
---@field showBadge? boolean
---@field showAvatar? boolean
---@field showLogout? boolean
---@class UIComponent
---@field type string
---@field props? table
---@field children? UIComponent[]
---Renders the user info and actions section of the header
---@param props HeaderProps
---@return UIComponent
local function user_section(props)
local children = {}
if props.username and props.showBadge then
children[#children + 1] = { type = "Badge", props = { text = props.username } }
end
if props.username and props.showAvatar then
children[#children + 1] = { type = "Avatar", props = { fallback = string.sub(props.username, 1, 1) } }
end
if props.showLogout then
children[#children + 1] = { type = "Button", props = { variant = "ghost", text = "Logout", onClick = "handleLogout" } }
end
return { type = "Flex", props = { className = "items-center gap-2" }, children = children }
end
return user_section