made some slight improvements to the terminal emulator
This commit is contained in:
1 parent
a57a27e4a3
commit
79ab1285c5
5 files changed
+170
-78
No files matched your search
@@ -14,21 +14,13 @@ a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.height-container {
|
||||
min-height: 100vh;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content-bg {
|
||||
position: relative;
|
||||
display: block;
|
||||
|
||||
}
|
||||
|
||||
.about-header {
|
||||
.landing-container {
|
||||
display: flex;
|
||||
color: white;
|
||||
width: 100%;
|
||||
@@ -38,11 +30,7 @@ a {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title-box {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.about-header h1 {
|
||||
.landing-container h1 {
|
||||
margin-bottom: 0;
|
||||
font-weight: 700;
|
||||
background: linear-gradient(45deg, #c3acff 0%, #a6ffb0 100%);
|
||||
@@ -51,7 +39,7 @@ a {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.about-header .subtitle {
|
||||
.landing-container .subtitle {
|
||||
font-size: 1.2rem;
|
||||
font-style: italic;
|
||||
margin-top: 5px;
|
||||
@@ -105,11 +93,10 @@ a {
|
||||
}
|
||||
.about-container {
|
||||
max-width: 100%;
|
||||
height: 100%;
|
||||
overflow: clip;
|
||||
min-height: calc(100vh - 80px);
|
||||
color: white;
|
||||
background: #2e2940;
|
||||
padding: 80px 0 80px 0;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
@@ -125,30 +112,31 @@ a {
|
||||
}
|
||||
|
||||
|
||||
.terminal-title {
|
||||
.titlebar {
|
||||
background: #26242e;
|
||||
max-width: 900px;
|
||||
padding: 4px 8px 2px 8px;
|
||||
margin: auto 0;
|
||||
border-radius: 20px 20px 0 0;
|
||||
border-radius: 15px 15px 0 0;
|
||||
}
|
||||
|
||||
.window-title {
|
||||
display: inline-flex;
|
||||
width: calc(100% - 85px);
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.window-title p {
|
||||
margin: 0 0 0 85px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.window-buttons {
|
||||
.window-actions {
|
||||
display: inline-flex;
|
||||
width: 85px;
|
||||
}
|
||||
|
||||
.window-buttons p {
|
||||
.window-actions p {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
@@ -156,11 +144,12 @@ a {
|
||||
|
||||
.terminal-window {
|
||||
background: #1b1920;
|
||||
height: 540px;
|
||||
height: 520px;
|
||||
max-width: 900px;
|
||||
margin: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
border-radius: 0 0 20px 20px;
|
||||
border-radius: 0 0 15px 15px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
||||
@@ -5,26 +5,24 @@
|
||||
'linear-gradient(180deg,#1b172c 0%, #0b0b0f 100%);'
|
||||
">
|
||||
</app-parallax>
|
||||
<div class="height-container">
|
||||
<div class="about-header">
|
||||
<div class="title-box">
|
||||
<h1 [ngStyle]="{'font-size': isMobile ? '4rem' : '5rem'}"><code>itzMiney</code></h1>
|
||||
<p class="subtitle">{{ 'ABOUT_SUB' | translate}}</p>
|
||||
</div>
|
||||
<div class="down-arrow" (click)="scrollDown()">
|
||||
<i class="fa-solid fa-angle-down"></i>
|
||||
</div>
|
||||
<div class="landing-container">
|
||||
<div class="title-box">
|
||||
<h1 [ngStyle]="{'font-size': isMobile ? '4rem' : '5rem'}"><code>itzMiney</code></h1>
|
||||
<p class="subtitle">{{ 'ABOUT_SUB' | translate}}</p>
|
||||
</div>
|
||||
<div class="separator"></div>
|
||||
<section id="content" #contentTrigger></section>
|
||||
<div class="about-container">
|
||||
<div class="about-content" [ngStyle]="{'padding': isMobile ? '0 10px;' : '0 25px'}">
|
||||
<div class="terminal-title">
|
||||
<div class="window-title"><p><code>Konsole</code></p></div> <div class="window-buttons"><p>🟡 🟣 🔴</p></div>
|
||||
</div>
|
||||
<div class="terminal-window" [ngStyle]="{'width': isMobile ? '100%' : '900px' }">
|
||||
<app-terminal-emulator [bootOnVisible]="terminalShouldBoot"></app-terminal-emulator>
|
||||
</div>
|
||||
<div class="down-arrow" (click)="scrollDown()">
|
||||
<i class="fa-solid fa-angle-down"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="separator"></div>
|
||||
<section id="content" #contentTrigger></section>
|
||||
<div class="about-container">
|
||||
<div class="terminal" [ngStyle]="{'margin': isMobile ? '10px;' : '25px'}">
|
||||
<div class="titlebar">
|
||||
<div class="window-title"><p><code>Konsole</code></p></div> <div class="window-actions"><p>🟡 🟣 🔴</p></div>
|
||||
</div>
|
||||
<div class="terminal-window" [ngStyle]="{'width': isMobile ? '100%' : '900px' }">
|
||||
<app-terminal-emulator [bootOnVisible]="terminalShouldBoot"></app-terminal-emulator>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
.terminal-container {
|
||||
padding: 0 22px;
|
||||
height: 526px;
|
||||
height: 498px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
scroll-behavior: smooth;
|
||||
@@ -23,23 +23,19 @@ h2 {
|
||||
.input-shell {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.input-mirror {
|
||||
display: inline-block;
|
||||
white-space: none;
|
||||
font: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.input-placeholder {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.terminal-field {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: none;
|
||||
@@ -51,21 +47,39 @@ h2 {
|
||||
letter-spacing: inherit;
|
||||
}
|
||||
|
||||
.cursorblink {
|
||||
margin-left: -12px;
|
||||
animation: cursorBlink 1.25s infinite;
|
||||
.input-mirror,
|
||||
.terminal-field {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.cursor-block {
|
||||
display: inline-block;
|
||||
width: 1ch;
|
||||
height: 1.2em;
|
||||
background: white;
|
||||
color: #1b1920;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
.cursor-block.blink {
|
||||
animation: cursorBlink 1.05s steps(1) infinite;
|
||||
}
|
||||
|
||||
@keyframes cursorBlink {
|
||||
0%, 50% {
|
||||
background: white;
|
||||
color: #1b1920;
|
||||
}
|
||||
50.01%, 100% {
|
||||
background: transparent;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.terminal-error {
|
||||
color: #ff7a7a;
|
||||
}
|
||||
|
||||
@keyframes cursorBlink {
|
||||
0% { opacity: 1; }
|
||||
50% { opacity: 0; }
|
||||
100% { opacity: 1; }
|
||||
}
|
||||
|
||||
.category {
|
||||
max-width: 200px;
|
||||
}
|
||||
@@ -106,7 +120,8 @@ a.green {
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 30%;
|
||||
width: 30%;
|
||||
height: auto;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
@@ -125,6 +140,7 @@ img {
|
||||
}
|
||||
|
||||
.tech-stack li {
|
||||
font-size: 1rem;
|
||||
color: #649aff;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
@@ -43,23 +43,30 @@
|
||||
<span class="prompt">$ </span>
|
||||
|
||||
<span class="input-shell">
|
||||
<span class="input-mirror">
|
||||
{{ command }}
|
||||
@if (!command) {
|
||||
<span class="input-placeholder"> </span>
|
||||
}
|
||||
<span class="cursorblink">█</span>
|
||||
</span>
|
||||
<input
|
||||
#terminalInput
|
||||
type="text"
|
||||
[(ngModel)]="command"
|
||||
(keydown.enter)="runCommand()"
|
||||
class="terminal-field"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<span class="input-mirror" aria-hidden="true">
|
||||
<span>{{ beforeCursor }}</span>
|
||||
|
||||
<span class="cursor-block" [class.blink]="isFocused && shouldBlink">
|
||||
{{ cursorChar || '\u00A0' }}
|
||||
</span>
|
||||
|
||||
<span>{{ afterCursor }}</span>
|
||||
</span>
|
||||
|
||||
<input
|
||||
#terminalInput
|
||||
type="text"
|
||||
[(ngModel)]="command"
|
||||
(input)="handleCursorActivity()"
|
||||
(click)="handleCursorActivity()"
|
||||
(keyup)="handleCursorActivity()"
|
||||
(keydown)="onKeydown($event)"
|
||||
(keydown.enter)="onEnter($event)"
|
||||
(focus)="onFocus()"
|
||||
(blur)="onBlur()"
|
||||
class="terminal-field"
|
||||
/>
|
||||
</span>
|
||||
</h2>
|
||||
</code>
|
||||
}
|
||||
@@ -69,7 +76,13 @@
|
||||
</ng-template>
|
||||
|
||||
<ng-template #catTemplate>
|
||||
<img alt="cat" class="fade-in" src="https://files.itz.sh/itzmineydev/lilguy.jpg">
|
||||
<img
|
||||
alt="cat"
|
||||
class="fade-in"
|
||||
src="https://files.itz.sh/itzmineydev/lilguy.jpg"
|
||||
(load)="scrollToBottom()"
|
||||
/>
|
||||
<p>lil goober</p>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #toolsTemplate>
|
||||
|
||||
@@ -42,6 +42,11 @@ export class TerminalEmulatorComponent implements OnInit, OnChanges {
|
||||
booting = true;
|
||||
private hasBooted = false;
|
||||
|
||||
caretIndex = 0;
|
||||
isFocused = false;
|
||||
shouldBlink = true;
|
||||
private blinkResumeTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
private rootEntries: TerminalEntry[] = [
|
||||
{ name: 'about.txt', type: 'file' },
|
||||
{ name: 'tools', type: 'dir' },
|
||||
@@ -108,6 +113,11 @@ export class TerminalEmulatorComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
onEnter(event: Event): void {
|
||||
event.preventDefault();
|
||||
this.runCommand();
|
||||
}
|
||||
|
||||
runCommand() {
|
||||
const cmd = this.command.trim();
|
||||
if (!cmd || this.booting) return;
|
||||
@@ -185,6 +195,7 @@ export class TerminalEmulatorComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
this.command = '';
|
||||
this.caretIndex = 0;
|
||||
this.scrollToBottom();
|
||||
}
|
||||
|
||||
@@ -261,13 +272,78 @@ export class TerminalEmulatorComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
get beforeCursor(): string {
|
||||
return this.command.slice(0, this.caretIndex);
|
||||
}
|
||||
|
||||
get cursorChar(): string {
|
||||
const ch = this.command[this.caretIndex];
|
||||
|
||||
if (ch === ' ') return '\u00A0';
|
||||
return ch ?? '\u00A0';
|
||||
}
|
||||
|
||||
get afterCursor(): string {
|
||||
return this.command.slice(this.caretIndex + (this.caretIndex < this.command.length ? 1 : 0));
|
||||
}
|
||||
|
||||
handleCursorActivity(): void {
|
||||
this.syncCursor();
|
||||
this.restartBlink();
|
||||
}
|
||||
|
||||
focusInput() {
|
||||
if (!this.booting && this.terminalInput) {
|
||||
this.terminalInput.nativeElement.focus();
|
||||
this.syncCursor();
|
||||
}
|
||||
}
|
||||
|
||||
private scrollToBottom() {
|
||||
onFocus(): void {
|
||||
this.isFocused = true;
|
||||
this.restartBlink();
|
||||
this.syncCursor();
|
||||
}
|
||||
|
||||
onBlur(): void {
|
||||
this.isFocused = false;
|
||||
this.shouldBlink = false;
|
||||
|
||||
if (this.blinkResumeTimer) {
|
||||
clearTimeout(this.blinkResumeTimer);
|
||||
this.blinkResumeTimer = null;
|
||||
}
|
||||
|
||||
this.syncCursor();
|
||||
}
|
||||
|
||||
onKeydown(_: KeyboardEvent): void {
|
||||
queueMicrotask(() => {
|
||||
this.syncCursor();
|
||||
this.restartBlink();
|
||||
});
|
||||
}
|
||||
|
||||
syncCursor(): void {
|
||||
const input = this.terminalInput?.nativeElement;
|
||||
if (!input) return;
|
||||
|
||||
this.caretIndex = input.selectionStart ?? this.command.length;
|
||||
}
|
||||
|
||||
private restartBlink(): void {
|
||||
this.shouldBlink = false;
|
||||
|
||||
if (this.blinkResumeTimer) {
|
||||
clearTimeout(this.blinkResumeTimer);
|
||||
}
|
||||
|
||||
this.blinkResumeTimer = setTimeout(() => {
|
||||
this.shouldBlink = true;
|
||||
}, 10);
|
||||
}
|
||||
|
||||
protected scrollToBottom() {
|
||||
setTimeout(() => {
|
||||
if (!this.terminalOutput) return;
|
||||
const el = this.terminalContainer.nativeElement;
|
||||
|
||||
Reference in new issue
Block a user