fix: NCWF-2 bugs and desing fixes (#7)
Co-authored-by: Lala, Shahd <Shahd.Lala@sybit.de> Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
.card {
|
||||
background: var(--nc-surface);
|
||||
border: 1px solid var(--nc-border);
|
||||
backdrop-filter: blur(8px);
|
||||
-webkit-backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
.disclose summary {
|
||||
list-style: none;
|
||||
cursor: pointer;
|
||||
padding: 14px 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.disclose summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.panel-title {
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.22em;
|
||||
text-transform: uppercase;
|
||||
color: var(--nc-text-muted);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.chev {
|
||||
color: var(--nc-text-dim);
|
||||
display: flex;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.disclose[open] .chev {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.disclose[open] summary {
|
||||
border-bottom: 1px solid var(--nc-border);
|
||||
}
|
||||
|
||||
.panel-body {
|
||||
padding: 14px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* Segmented control */
|
||||
.seg {
|
||||
display: flex;
|
||||
border: 1px solid var(--nc-border);
|
||||
padding: 2px;
|
||||
background: var(--nc-seg-bg, rgba(0, 0, 0, 0.2));
|
||||
}
|
||||
|
||||
.seg-btn {
|
||||
flex: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--nc-text-muted);
|
||||
padding: 7px 10px;
|
||||
font-size: 11px;
|
||||
font-family: var(--nc-sans);
|
||||
letter-spacing: 0.08em;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
.seg-btn.active {
|
||||
background: var(--nc-neon);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.export-out {
|
||||
width: 100%;
|
||||
background: var(--nc-clock-bg);
|
||||
border: 1px solid var(--nc-border);
|
||||
color: var(--nc-text);
|
||||
font-family: var(--nc-mono);
|
||||
font-size: 11px;
|
||||
padding: 10px;
|
||||
resize: vertical;
|
||||
min-height: 70px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.export-out:focus {
|
||||
outline: none;
|
||||
border-color: var(--nc-neon-soft);
|
||||
}
|
||||
|
||||
.export-row {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
flex: 1;
|
||||
font-family: var(--nc-sans);
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.18em;
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
padding: 8px 10px;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--nc-border-strong);
|
||||
background: var(--nc-btn-bg, rgba(255, 255, 255, 0.03));
|
||||
color: var(--nc-text);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: var(--nc-btn-hover-bg, rgba(255, 255, 255, 0.07));
|
||||
border-color: var(--nc-text-muted);
|
||||
}
|
||||
|
||||
.copy-notice {
|
||||
margin: 0;
|
||||
font-size: 11px;
|
||||
color: var(--nc-success);
|
||||
font-family: var(--nc-mono);
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<details class="card disclose">
|
||||
<summary>
|
||||
<span class="panel-title">Export Position</span>
|
||||
<span class="chev" aria-hidden="true">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<polyline points="6 9 12 15 18 9"/>
|
||||
</svg>
|
||||
</span>
|
||||
</summary>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="seg" role="tablist" aria-label="Export format">
|
||||
<button
|
||||
class="seg-btn"
|
||||
[class.active]="exportKind === 'fen'"
|
||||
role="tab"
|
||||
[attr.aria-selected]="exportKind === 'fen'"
|
||||
(click)="setKind('fen')">FEN</button>
|
||||
<button
|
||||
class="seg-btn"
|
||||
[class.active]="exportKind === 'pgn'"
|
||||
role="tab"
|
||||
[attr.aria-selected]="exportKind === 'pgn'"
|
||||
(click)="setKind('pgn')">PGN</button>
|
||||
</div>
|
||||
|
||||
<textarea class="export-out" [value]="exportValue" [placeholder]="exportPlaceholder" rows="4" readonly></textarea>
|
||||
|
||||
<div class="export-row">
|
||||
<button class="btn" type="button" (click)="copy()">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="9" y="9" width="13" height="13" rx="2"/>
|
||||
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
|
||||
</svg>
|
||||
Copy
|
||||
</button>
|
||||
<button class="btn" type="button" (click)="download()">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
||||
<polyline points="7 10 12 15 17 10"/>
|
||||
<line x1="12" y1="15" x2="12" y2="3"/>
|
||||
</svg>
|
||||
Download
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (copyNotice) {
|
||||
<p class="copy-notice">{{ copyNotice }}</p>
|
||||
}
|
||||
</div>
|
||||
</details>
|
||||
@@ -0,0 +1,79 @@
|
||||
import { Component, Input, OnChanges } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
type ExportKind = 'fen' | 'pgn';
|
||||
|
||||
@Component({
|
||||
selector: 'app-export-panel',
|
||||
standalone: true,
|
||||
imports: [FormsModule],
|
||||
templateUrl: './export-panel.component.html',
|
||||
styleUrl: './export-panel.component.css'
|
||||
})
|
||||
export class ExportPanelComponent implements OnChanges {
|
||||
@Input() fen = '';
|
||||
@Input() pgn = '';
|
||||
|
||||
exportKind: ExportKind = 'fen';
|
||||
exportValue = '';
|
||||
copyNotice = '';
|
||||
private copyNoticeTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
get exportPlaceholder(): string {
|
||||
return this.exportKind === 'fen' ? 'FEN will appear here' : 'PGN will appear here';
|
||||
}
|
||||
|
||||
ngOnChanges(): void {
|
||||
this.syncValue();
|
||||
}
|
||||
|
||||
setKind(kind: ExportKind): void {
|
||||
this.exportKind = kind;
|
||||
this.syncValue();
|
||||
}
|
||||
|
||||
copy(): void {
|
||||
if (!this.exportValue.trim()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!navigator.clipboard?.writeText) {
|
||||
this.showNotice('Ready in the text box.');
|
||||
return;
|
||||
}
|
||||
|
||||
void navigator.clipboard
|
||||
.writeText(this.exportValue)
|
||||
.then(() => this.showNotice('Copied!'))
|
||||
.catch(() => this.showNotice('Ready in the text box.'));
|
||||
}
|
||||
|
||||
download(): void {
|
||||
if (!this.exportValue.trim()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ext = this.exportKind === 'pgn' ? 'pgn' : 'txt';
|
||||
const blob = new Blob([this.exportValue], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `game.${ext}`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
private syncValue(): void {
|
||||
this.exportValue = this.exportKind === 'fen' ? this.fen : this.pgn;
|
||||
}
|
||||
|
||||
private showNotice(msg: string): void {
|
||||
this.copyNotice = msg;
|
||||
if (this.copyNoticeTimer !== null) {
|
||||
clearTimeout(this.copyNoticeTimer);
|
||||
}
|
||||
this.copyNoticeTimer = setTimeout(() => {
|
||||
this.copyNotice = '';
|
||||
}, 1800);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user