Spaces:
Running

anycoder-3dfb5929 / index.html
powerllm's picture
Upload folder using huggingface_hub
755d2ad verified
Raw History Blame Contribute Delete
22 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Diff & File Tracker</title>
<!-- Import FontAwesome for Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Import Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
/* Color Palette - Dark Theme */
--bg-app: #0f1117;
--bg-sidebar: #161b22;
--bg-panel: #21262d;
--bg-hover: #30363d;
--text-main: #f0f6fc;
--text-muted: #8b949e;
--accent-primary: #58a6ff;
--accent-glow: rgba(88, 166, 255, 0.15);
/* Status Colors */
--status-added: #3fb950;
--status-added-bg: rgba(63, 185, 80, 0.15);
--status-modified: #d29922;
--status-modified-bg: rgba(210, 153, 34, 0.15);
--status-deleted: #f85149;
--status-deleted-bg: rgba(248, 81, 73, 0.15);
--border: #30363d;
--radius: 12px;
--shadow: 0 4px 24px rgba(0,0,0,0.4);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Inter', sans-serif;
background-color: var(--bg-app);
color: var(--text-main);
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* --- Header --- */
header {
height: 60px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
background: rgba(22, 27, 34, 0.8);
backdrop-filter: blur(10px);
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
font-weight: 600;
font-size: 1.1rem;
}
.brand i {
color: var(--accent-primary);
}
.anycoder-link {
font-size: 0.85rem;
color: var(--text-muted);
text-decoration: none;
padding: 6px 12px;
border-radius: 20px;
background: var(--bg-panel);
border: 1px solid var(--border);
transition: all 0.2s ease;
}
.anycoder-link:hover {
color: var(--text-main);
border-color: var(--accent-primary);
background: var(--accent-glow);
}
/* --- Main Layout --- */
main {
display: flex;
flex: 1;
overflow: hidden;
}
/* --- Sidebar (File List) --- */
aside {
width: 320px;
background: var(--bg-sidebar);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.sidebar-header {
padding: 20px;
border-bottom: 1px solid var(--border);
}
.status-filters {
display: flex;
gap: 8px;
margin-top: 12px;
}
.filter-btn {
flex: 1;
background: transparent;
border: 1px solid var(--border);
color: var(--text-muted);
padding: 6px;
border-radius: 6px;
cursor: pointer;
font-size: 0.8rem;
transition: 0.2s;
}
.filter-btn.active {
background: var(--bg-panel);
color: var(--text-main);
border-color: var(--text-muted);
}
.file-list {
flex: 1;
overflow-y: auto;
padding: 10px;
}
/* Scrollbar Styling */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--text-muted);
}
.file-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 16px;
border-radius: var(--radius);
cursor: pointer;
transition: all 0.2s;
margin-bottom: 4px;
border: 1px solid transparent;
}
.file-item:hover {
background: var(--bg-hover);
}
.file-item.active {
background: var(--bg-panel);
border-color: var(--accent-primary);
}
.file-info {
display: flex;
align-items: center;
gap: 10px;
overflow: hidden;
}
.file-icon {
font-size: 1.1rem;
width: 20px;
text-align: center;
}
.file-name {
font-family: 'JetBrains Mono', monospace;
font-size: 0.9rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* Status Badges */
.status-badge {
font-size: 0.7rem;
padding: 2px 8px;
border-radius: 12px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.status-added {
background: var(--status-added-bg);
color: var(--status-added);
}
.status-modified {
background: var(--status-modified-bg);
color: var(--status-modified);
}
.status-deleted {
background: var(--status-deleted-bg);
color: var(--status-deleted);
}
/* Special Highlight for "Edited" files as requested */
.edited-highlight {
border-left: 3px solid var(--status-modified);
}
/* --- Editor Area --- */
.editor-container {
flex: 1;
display: flex;
flex-direction: column;
background: var(--bg-app);
position: relative;
}
.editor-header {
padding: 16px 24px;
border-bottom: 1px solid var(--border);
display: flex;
justify-content: space-between;
align-items: center;
background: var(--bg-app);
}
.current-file-path {
font-family: 'JetBrains Mono', monospace;
color: var(--text-muted);
font-size: 0.9rem;
}
.current-file-path span {
color: var(--text-main);
}
.editor-actions {
display: flex;
gap: 12px;
}
.btn {
padding: 8px 16px;
border-radius: 6px;
border: none;
font-weight: 500;
cursor: pointer;
font-size: 0.9rem;
display: flex;
align-items: center;
gap: 8px;
transition: transform 0.1s, opacity 0.2s;
}
.btn:active {
transform: scale(0.98);
}
.btn-primary {
background: var(--accent-primary);
color: #fff;
box-shadow: 0 0 15px var(--accent-glow);
}
.btn-secondary {
background: var(--bg-panel);
color: var(--text-main);
border: 1px solid var(--border);
}
.code-area {
flex: 1;
padding: 20px;
overflow: auto;
font-family: 'JetBrains Mono', monospace;
font-size: 0.95rem;
line-height: 1.6;
color: #c9d1d9;
}
.code-line {
display: flex;
padding: 2px 0;
}
.line-num {
width: 40px;
color: var(--text-muted);
text-align: right;
padding-right: 16px;
user-select: none;
font-size: 0.85rem;
opacity: 0.5;
}
.line-content {
flex: 1;
white-space: pre;
}
/* Diff Highlighting */
.diff-added {
background-color: rgba(46, 160, 67, 0.15);
}
.diff-added .line-num::after {
content: '+';
color: var(--status-added);
margin-left: 4px;
}
.diff-removed {
background-color: rgba(248, 81, 73, 0.15);
text-decoration: line-through;
opacity: 0.7;
}
.diff-removed .line-num::after {
content: '-';
color: var(--status-deleted);
margin-left: 4px;
}
.keyword { color: #ff7b72; }
.string { color: #a5d6ff; }
.function { color: #d2a8ff; }
.comment { color: #8b949e; font-style: italic; }
/* --- Empty State --- */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
color: var(--text-muted);
text-align: center;
}
.empty-state i {
font-size: 4rem;
margin-bottom: 20px;
opacity: 0.2;
}
/* --- Responsive --- */
@media (max-width: 768px) {
main {
flex-direction: column;
}
aside {
width: 100%;
height: 40%;
border-right: none;
border-bottom: 1px solid var(--border);
}
.editor-container {
height: 60%;
}
}
</style>
</head>
<body>
<header>
<div class="brand">
<i class="fa-solid fa-code-branch"></i>
<span>DevTrack UI</span>
</div>
<!-- Required Link -->
<a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link" target="_blank">
Built with anycoder
</a>
</header>
<main>
<!-- Sidebar -->
<aside>
<div class="sidebar-header">
<h3 style="font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted);">Changed Files</h3>
<div class="status-filters">
<button class="filter-btn active" onclick="filterFiles('all')">All</button>
<button class="filter-btn" onclick="filterFiles('modified')">Edited</button>
<button class="filter-btn" onclick="filterFiles('added')">New</button>
</div>
</div>
<div class="file-list" id="fileList">
<!-- Files will be injected here via JS -->
</div>
</aside>
<!-- Editor View -->
<section class="editor-container">
<div class="editor-header" id="editorHeader" style="display: none;">
<div class="current-file-path" id="filePathDisplay">
<!-- Path goes here -->
</div>
<div class="editor-actions">
<button class="btn btn-secondary" onclick="discardChanges()">
<i class="fa-solid fa-rotate-left"></i> Discard
</button>
<button class="btn btn-primary" onclick="commitChanges()">
<i class="fa-solid fa-check"></i> Commit
</button>
</div>
</div>
<div class="code-area" id="codeArea">
<div class="empty-state">
<i class="fa-regular fa-folder-open"></i>
<h3>Select a file to view changes</h3>
<p>Review the diffs and commit your work.</p>
</div>
</div>
</section>
</main>
<script>
// --- Data Mockup ---
const filesData = [
{
id: 1,
name: "styles/global.css",
type: "css",
status: "modified",
icon: "fa-css3-alt",
content: `
<span class="keyword">body</span> {
<span class="keyword">background-color</span>: <span class="string">#0f1117</span>;
<span class="keyword">color</span>: <span class="string">#f0f6fc</span>;
<span class="comment">/* Updated contrast for better readability */</span>
}
<span class="keyword">.sidebar</span> {
<span class="keyword">width</span>: <span class="string">320px</span>;
<span class="keyword">border-right</span>: <span class="string">1px solid #30363d</span>;
}`
},
{
id: 2,
name: "components/Header.js",
type: "js",
status: "modified",
icon: "fa-brands fa-react",
content: `
<span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">'react'</span>;
<span class="keyword">import</span> { Link } <span class="keyword">from</span> <span class="string">'react-router-dom'</span>;
<span class="keyword">const</span> <span class="function">Header</span> = () => {
<span class="keyword">return</span> (
&lt;header&gt;
&lt;h1&gt;DevTrack&lt;/h1&gt;
<span class="comment">// Added new navigation link</span>
&lt;Link to="/settings"&gt;Settings&lt;/Link&gt;
&lt;/header&gt;
);
}`
},
{
id: 3,
name: "utils/helpers.ts",
type: "ts",
status: "added",
icon: "fa-brands fa-js",
content: `
<span class="keyword">export function</span> <span class="function">calculateDiff</span>(oldStr: string, newStr: string) {
<span class="keyword">const</span> diff = [];
<span class="comment">// Implementation of LCS algorithm</span>
<span class="keyword">return</span> diff;
}
<span class="keyword">export const</span> VERSION = <span class="string">'1.0.4'</span>;`
},
{
id: 4,
name: "assets/old_logo.png",
type: "img",
status: "deleted",
icon: "fa-regular fa-image",
content: `<div style="padding:20px; text-align:center; color: #f85149;">[Binary File Deleted]</div>`
},
{
id: 5,
name: "package.json",
type: "json",
status: "modified",
icon: "fa-brands fa-node-js",
content: `
{
<span class="string">"name"</span>: <span class="string">"dev-track-app"</span>,
<span class="string">"version"</span>: <span class="string">"2.1.0"</span>,
<span class="string">"dependencies"</span>: {
<span class="string">"react"</span>: <span class="string">"^18.2.0"</span>,
<span class="string">"lodash"</span>: <span class="string">"^4.17.21"</span> <span class="comment">// Updated version</span>
}
}`
}
];
let currentFilter = 'all';
let selectedFileId = null;
// --- DOM Elements ---
const fileListEl = document.getElementById('fileList');
const codeAreaEl = document.getElementById('codeArea');
const editorHeaderEl = document.getElementById('editorHeader');
const filePathDisplayEl = document.getElementById('filePathDisplay');
const filterBtns = document.querySelectorAll('.filter-btn');
// --- Functions ---
function renderFileList() {
fileListEl.innerHTML = '';
const filteredFiles = filesData.filter(file => {
if (currentFilter === 'all') return true;
if (currentFilter === 'modified') return file.status === 'modified';
if (currentFilter === 'added') return file.status === 'added';
if (currentFilter === 'deleted') return file.status === 'deleted';
return true;
});
if (filteredFiles.length === 0) {
fileListEl.innerHTML = `<div style="padding:20px; text-align:center; color:var(--text-muted); font-size:0.9rem;">No files found.</div>`;
return;
}
filteredFiles.forEach(file => {
const item = document.createElement('div');
item.className = `file-item ${file.status === 'modified' ? 'edited-highlight' : ''} ${selectedFileId === file.id ? 'active' : ''}`;
item.onclick = () => selectFile(file.id);
let badgeClass = '';
let badgeText = '';
if (file.status === 'added') { badgeClass = 'status-added'; badgeText = 'New'; }
else if (file.status === 'modified') { badgeClass = 'status-modified'; badgeText = 'Edited'; }
else if (file.status === 'deleted') { badgeClass = 'status-deleted'; badgeText = 'Del'; }
item.innerHTML = `
<div class="file-info">
<i class="file-icon ${file.icon}"></i>
<span class="file-name">${file.name}</span>
</div>
<span class="status-badge ${badgeClass}">${badgeText}</span>
`;
fileListEl.appendChild(item);
});
}
function selectFile(id) {
selectedFileId = id;
const file = filesData.find(f => f.id === id);
// Update UI Active State
renderFileList();
// Update Editor View
editorHeaderEl.style.display = 'flex';
filePathDisplayEl.innerHTML = `root / <span>${file.name}</span>`;
// Render Code with Line Numbers
let htmlContent = '';
const lines = file.content.split('\n');
lines.forEach((line, index) => {
let lineClass = 'code-line';
// Simple simulation of diff lines based on content keywords for visual effect
if (line.includes('// Updated') || line.includes('+')) lineClass += ' diff-added';
if (line.includes('// Removed') || line.includes('-') && !line.includes('import')) lineClass += ' diff-removed';
htmlContent += `
<div class="${lineClass}">
<div class="line-num">${index + 1}</div>
<div class="line-content">${line}</div>
</div>
`;
});
codeAreaEl.innerHTML = htmlContent;
}
function filterFiles(status) {
currentFilter = status;
// Update buttons
filterBtns.forEach(btn => {
btn.classList.remove('active');
if (btn.innerText.toLowerCase().includes(status === 'modified' ? 'edited' : status)) {
btn.classList.add('active');
}
if (status === 'all' && btn.innerText === 'All') btn.classList.add('active');
});
renderFileList();
}
function commitChanges() {
if (!selectedFileId) return;
const fileIndex = filesData.findIndex(f => f.id === selectedFileId);
if (fileIndex > -1) {
// Simulate commit by changing status to 'unchanged' or removing from list
// For this demo, we'll remove it to show the list updating
const fileName = filesData[fileIndex].name;
filesData.splice(fileIndex, 1);
// Reset view
selectedFileId = null;
editorHeaderEl.style.display = 'none';
codeAreaEl.innerHTML = `
<div class="empty-state">
<i class="fa-solid fa-check-circle" style="color: var(--status-added)"></i>
<h3>Changes Committed!</h3>
<p>${fileName} has been saved.</p>
</div>
`;
renderFileList();
setTimeout(() => {
codeAreaEl.innerHTML = `
<div class="empty-state">
<i class="fa-regular fa-folder-open"></i>
<h3>Select a file to view changes</h3>
<p>Review the diffs and commit your work.</p>
</div>
`;
}, 2000);
}
}
function discardChanges() {
if (!selectedFileId) return;
const fileIndex = filesData.findIndex(f => f.id === selectedFileId);
if (fileIndex > -1) {
filesData.splice(fileIndex, 1);
selectedFileId = null;
editorHeaderEl.style.display = 'none';
codeAreaEl.innerHTML = `
<div class="empty-state">
<i class="fa-solid fa-trash-can" style="color: var(--status-deleted)"></i>
<h3>Changes Discarded</h3>
</div>
`;
renderFileList();
}
}
// --- Init ---
renderFileList();
</script>
</body>
</html>