feat: add resizable terminal panel to main layout
- Integrate terminal as persistent component in main App layout - Add drag-to-resize functionality with min/max height constraints - Implement auto-scroll to bottom for new terminal lines - Prevent context menu and enable text selection in terminal content - Add responsive behavior that hides terminal on small screens
This commit is contained in:
@@ -4,12 +4,38 @@ import Header from './components/Header.svelte';
|
|||||||
import Tabs from './components/Tabs.svelte';
|
import Tabs from './components/Tabs.svelte';
|
||||||
import Overview from './components/Overview.svelte';
|
import Overview from './components/Overview.svelte';
|
||||||
import Settings from './components/Settings.svelte';
|
import Settings from './components/Settings.svelte';
|
||||||
|
import Terminal from './components/Terminal.svelte';
|
||||||
|
|
||||||
let activeTab = 'overview';
|
let activeTab = 'overview';
|
||||||
let status = 'Status';
|
let status = 'Status';
|
||||||
let uptime = '0s';
|
let uptime = '0s';
|
||||||
let qrCodesFound = 0;
|
let qrCodesFound = 0;
|
||||||
let isOnline = false;
|
let isOnline = false;
|
||||||
|
let terminalLines = [
|
||||||
|
'Window()',
|
||||||
|
'[Fx] INVOKE main.main.func1()',
|
||||||
|
'[Fx] BEFORE RUN provide: git.weirdcat.su/weirdcat/auto-attendance/internal/ui.NewBuilder()',
|
||||||
|
'[Fx] RUN provide: git.weirdcat.su/weirdcat/auto-attendance/internal/ui.NewBuilder() in',
|
||||||
|
'46.723905ms',
|
||||||
|
'[Fx] BEFORE RUN provide: git.weirdcat.su/weirdcat/auto-attendance/internal/ui.NewMainWindow()',
|
||||||
|
'[Fx] RUN provide: git.weirdcat.su/weirdcat/auto-attendance/internal/ui.NewMainWindow()',
|
||||||
|
'in 11.655448ms',
|
||||||
|
'[Fx] RUNNING',
|
||||||
|
'Window()',
|
||||||
|
'[Fx] INVOKE main.main.func1()',
|
||||||
|
'[Fx] BEFORE RUN provide: git.weirdcat.su/weirdcat/auto-attendance/internal/ui.NewBuilder()',
|
||||||
|
'[Fx] RUN provide: git.weirdcat.su/weirdcat/auto-attendance/internal/ui.NewBuilder() in',
|
||||||
|
'46.723905ms',
|
||||||
|
'[Fx] BEFORE RUN provide: git.weirdcat.su/weirdcat/auto-attendance/internal/ui.NewMainWindow()',
|
||||||
|
'[Fx] RUN provide: git.weirdcat.su/weirdcat/auto-attendance/internal/ui.NewMainWindow()',
|
||||||
|
'in 11.655448ms',
|
||||||
|
'[Fx] RUNNING',
|
||||||
|
' '
|
||||||
|
];
|
||||||
|
|
||||||
|
document.addEventListener('contextmenu', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="app-window">
|
<div class="app-window">
|
||||||
@@ -24,6 +50,10 @@ let isOnline = false;
|
|||||||
<Settings />
|
<Settings />
|
||||||
{/if}
|
{/if}
|
||||||
</main>
|
</main>
|
||||||
|
<!-- Terminal Output -->
|
||||||
|
<aside class="terminal-layout">
|
||||||
|
<Terminal {terminalLines} />
|
||||||
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -47,13 +77,18 @@ let isOnline = false;
|
|||||||
--spacing-lg: 16px;
|
--spacing-lg: 16px;
|
||||||
--spacing-xl: 24px;
|
--spacing-xl: 24px;
|
||||||
|
|
||||||
--border-radius-sm: 4px;
|
--border-radius-sm: 10px;
|
||||||
--border-radius-md: 6px;
|
--border-radius-md: 6px;
|
||||||
--border-radius-lg: 8px;
|
--border-radius-lg: 8px;
|
||||||
|
|
||||||
--shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
--shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||||
--shadow-md: 0 3px 3px rgba(0, 0, 0, 0.16), 0 3px 3px rgba(0, 0, 0, 0.23);
|
--shadow-md: 0 3px 3px rgba(0, 0, 0, 0.16), 0 3px 3px rgba(0, 0, 0, 0.23);
|
||||||
--shadow-lg: 0 14px 14px rgba(0, 0, 0, 0.25), 0 10px 5px rgba(0, 0, 0, 0.22);
|
--shadow-lg: 0 14px 14px rgba(0, 0, 0, 0.25), 0 10px 5px rgba(0, 0, 0, 0.22);
|
||||||
|
touch-action: manipulation;
|
||||||
|
user-select: none; /* Standard syntax */
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
@@ -67,12 +102,15 @@ let isOnline = false;
|
|||||||
background-color: var(--bg-primary);
|
background-color: var(--bg-primary);
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-layout {
|
.main-layout {
|
||||||
padding: var(--spacing-lg);
|
padding: var(--spacing-lg);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: auto;
|
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,10 +1,55 @@
|
|||||||
<!-- components/Terminal.svelte -->
|
<!-- components/Terminal.svelte -->
|
||||||
<script>
|
<script>
|
||||||
export let terminalLines = [];
|
export let terminalLines = [];
|
||||||
|
|
||||||
|
let terminalRef;
|
||||||
|
let isResizing = false;
|
||||||
|
let startY, startHeight;
|
||||||
|
|
||||||
|
function handleMouseDown(e) {
|
||||||
|
isResizing = true;
|
||||||
|
startY = e.clientY;
|
||||||
|
startHeight = parseInt(document.defaultView.getComputedStyle(terminalRef).height, 10);
|
||||||
|
|
||||||
|
document.addEventListener('mousemove', handleMouseMove);
|
||||||
|
document.addEventListener('mouseup', handleMouseUp);
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMouseMove(e) {
|
||||||
|
if (!isResizing) return;
|
||||||
|
|
||||||
|
const height = startHeight - (e.clientY - startY);
|
||||||
|
const minHeight = 100;
|
||||||
|
const maxHeight = window.innerHeight * 0.8;
|
||||||
|
|
||||||
|
if (height >= minHeight && height <= maxHeight) {
|
||||||
|
terminalRef.style.height = `${height}px`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMouseUp() {
|
||||||
|
isResizing = false;
|
||||||
|
document.removeEventListener('mousemove', handleMouseMove);
|
||||||
|
document.removeEventListener('mouseup', handleMouseUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scroll to bottom when new lines are added
|
||||||
|
$: {
|
||||||
|
if (terminalLines.length > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
const content = terminalRef?.querySelector('.terminal-content');
|
||||||
|
if (content) {
|
||||||
|
content.scrollTop = content.scrollHeight;
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="terminal">
|
<div class="terminal" bind:this={terminalRef}>
|
||||||
<div class="terminal-header">Output</div>
|
<div class="resize-handle" on:mousedown={handleMouseDown}></div>
|
||||||
|
<div class="terminal-header">Logs</div>
|
||||||
<div class="terminal-content">
|
<div class="terminal-content">
|
||||||
{#each terminalLines as line}
|
{#each terminalLines as line}
|
||||||
<div class="terminal-line">{line}</div>
|
<div class="terminal-line">{line}</div>
|
||||||
@@ -14,19 +59,48 @@ export let terminalLines = [];
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
.terminal {
|
.terminal {
|
||||||
background-color: var(--bg-primary);
|
background-color: var(--bg-secondary);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: var(--border-radius-sm);
|
border-radius: var(--border-radius-sm);
|
||||||
|
margin: 20px;
|
||||||
|
margin-top: auto;
|
||||||
|
height: 200px; /* Default height */
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
resize: vertical;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
flex-grow: 1;
|
}
|
||||||
|
|
||||||
|
@media (max-height: 500px) {
|
||||||
|
.terminal {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 4px;
|
||||||
|
cursor: row-resize;
|
||||||
|
z-index: 10;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle:hover {
|
||||||
|
background-color: var(--accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.terminal-header {
|
.terminal-header {
|
||||||
background-color: var(--bg-secondary);
|
background-color: var(--bg-header);
|
||||||
padding: var(--spacing-sm) var(--spacing-md);
|
padding: var(--spacing-sm) var(--spacing-md);
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
|
border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.terminal-content {
|
.terminal-content {
|
||||||
@@ -35,9 +109,13 @@ export let terminalLines = [];
|
|||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
max-height: 200px;
|
flex-grow: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
user-select: text;
|
||||||
|
-webkit-user-select: text;
|
||||||
|
-moz-user-select: text;
|
||||||
|
-ms-user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
.terminal-line {
|
.terminal-line {
|
||||||
|
|||||||
Reference in New Issue
Block a user