This repository has been archived on 2026-10-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SmallClawViewer/index.html
T

270 lines
8.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>SmallClawViewer</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn/themes/light.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn/shoelace-autoloader.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/marked.min.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #f4f4f6;
--surface: #ffffff;
--border: #e0e0e0;
--text: #1a1a1a;
--text-muted: #666;
--accent: #0d6efd;
}
html, body {
height: 100%;
font-family: system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
}
body { display: flex; flex-direction: column; }
header {
background: var(--surface);
border-bottom: 1px solid var(--border);
padding: 1rem;
text-align: center;
position: sticky;
top: 0;
z-index: 10;
}
header h1 { font-size: 1.2rem; font-weight: 700; }
header p { font-size: 0.8rem; color: var(--text-muted); }
nav {
display: flex;
background: var(--surface);
border-bottom: 1px solid var(--border);
}
nav button {
flex: 1;
padding: 0.875rem;
border: none;
background: none;
font-size: 0.9rem;
font-weight: 500;
color: var(--text-muted);
cursor: pointer;
border-bottom: 2px solid transparent;
}
nav button.active {
color: var(--accent);
border-bottom-color: var(--accent);
}
main {
flex: 1;
overflow-y: auto;
padding: 1rem;
max-width: 640px;
margin: 0 auto;
width: 100%;
}
.card {
background: var(--surface);
border-radius: 10px;
padding: 1rem;
margin-bottom: 0.75rem;
border: 1px solid var(--border);
}
.card h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.card p { font-size: 0.85rem; color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: 0.875rem; text-align: center; padding: 2rem 0; }
/* File browser */
.file-tree { list-style: none; }
.file-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.file-item:last-child { border-bottom: none; }
.file-item:hover { color: var(--accent); }
.file-item.folder { font-weight: 600; }
/* Markdown editor */
textarea.md-editor {
width: 100%;
min-height: 300px;
font-family: monospace;
font-size: 0.875rem;
padding: 0.75rem;
border: 1px solid var(--border);
border-radius: 8px;
resize: vertical;
}
.btn-row { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
</style>
</head>
<body x-data="app()">
<header>
<h1>SmallClawViewer</h1>
<p>Arvex workspace</p>
</header>
<nav>
<button :class="{ active: tab === 'projects' }" @click="tab = 'projects'">Projects</button>
<button :class="{ active: tab === 'workspace' }" @click="tab = 'workspace'">Workspace</button>
</nav>
<main>
<!-- Projects Tab -->
<template x-if="tab === 'projects'">
<div class="projects-tab">
<div class="card" @click="selectProject('SmallClawViewer')">
<h3>SmallClawViewer</h3>
<p>Mobile workspace viewer and editor</p>
</div>
<p class="hint" x-show="projects.length === 0">No projects found</p>
</div>
</template>
<!-- Project Detail -->
<template x-if="tab === 'project-detail'">
<div class="project-detail">
<button @click="tab = 'projects'" style="margin-bottom: 1rem; color: var(--accent); background: none; border: none; cursor: pointer; font-size: 0.9rem;">&larr; Back</button>
<div class="card">
<h3 x-text="selectedProject"></h3>
<p>Status: <span x-text="projectStatus"></span></p>
</div>
<p class="hint">Project details from brain/STATUS.md will appear here.</p>
</div>
</template>
<!-- Workspace Tab -->
<template x-if="tab === 'workspace'">
<div class="workspace-tab">
<template x-if="!selectedFile">
<div>
<p class="hint" x-show="files.length === 0">Loading workspace...</p>
<ul class="file-tree">
<template x-for="f in files" :key="f.path">
<li class="file-item" :class="{ folder: f.type === 'dir' }" @click="browse(f)">
<span x-text="f.type === 'dir' ? '📁 ' + f.name : '📄 ' + f.name"></span>
</li>
</template>
</ul>
</div>
</template>
<template x-if="selectedFile">
<div>
<button @click="selectedFile = null" style="margin-bottom: 1rem; color: var(--accent); background: none; border: none; cursor: pointer; font-size: 0.9rem;">&larr; Back</button>
<div class="card">
<h3 x-text="selectedFile"></h3>
<template x-if="fileContent && !editing">
<div>
<div class="btn-row">
<sl-button size="small" @click="startEditing">Edit</sl-button>
<sl-button size="small" variant="success" @click="tab = 'workspace'">Close</sl-button>
</div>
<hr style="margin: 0.75rem 0; border: none; border-top: 1px solid var(--border);">
<div x-html="renderedContent"></div>
</div>
</template>
<template x-if="editing">
<div>
<textarea class="md-editor" x-model="fileContent"></textarea>
<div class="btn-row">
<sl-button size="small" variant="success" @click="saveFile">Save</sl-button>
<sl-button size="small" @click="editing = false">Cancel</sl-button>
</div>
</div>
</template>
<template x-if="!fileContent">
<p class="hint">Loading...</p>
</template>
</div>
</div>
</template>
</div>
</template>
</main>
<script>
function app() {
return {
tab: 'projects',
projects: ['SmallClawViewer'],
selectedProject: null,
projectStatus: 'loading',
files: [],
selectedFile: null,
fileContent: null,
editing: false,
async init() {
await this.loadWorkspaceFiles()
},
async loadWorkspaceFiles() {
try {
const res = await fetch('/api/files')
this.files = await res.json()
} catch (e) {
this.files = [{ name: 'workspace', type: 'dir', path: '.' }]
}
},
async selectProject(name) {
this.selectedProject = name
this.projectStatus = '🔧 active'
this.tab = 'project-detail'
},
async browse(f) {
if (f.type === 'dir') return
this.selectedFile = f.name
this.editing = false
await this.loadFile(f.path)
},
async loadFile(path) {
try {
const res = await fetch('/api/file/' + encodeURIComponent(path))
this.fileContent = await res.text()
} catch (e) {
this.fileContent = 'Error loading file.'
}
},
startEditing() {
this.editing = true
},
async saveFile() {
await fetch('/api/file/' + encodeURIComponent(this.selectedFile), {
method: 'PUT',
body: this.fileContent
})
this.editing = false
},
get renderedContent() {
if (!this.fileContent) return ''
try {
return marked.parse(this.fileContent)
} catch {
return this.fileContent
}
}
}
}
</script>
</body>
</html>