From 5497997455e640a02a6e860e8c5ca2ddeedb8468 Mon Sep 17 00:00:00 2001 From: shahdlala66 Date: Sun, 19 Apr 2026 01:00:14 +0200 Subject: [PATCH] feat: more components --- .../chess-piece/chess-piece.component.css | 2 +- .../input-card/input-card.component.css | 63 ++++++++ .../input-card/input-card.component.html | 31 ++++ .../input-card/input-card.component.ts | 33 ++++ src/app/pages/game/game.component.css | 144 +----------------- src/app/pages/game/game.component.html | 67 ++++---- src/app/pages/game/game.component.ts | 3 +- 7 files changed, 170 insertions(+), 173 deletions(-) create mode 100644 src/app/components/input-card/input-card.component.css create mode 100644 src/app/components/input-card/input-card.component.html create mode 100644 src/app/components/input-card/input-card.component.ts diff --git a/src/app/components/chess-piece/chess-piece.component.css b/src/app/components/chess-piece/chess-piece.component.css index 2655455..4a364f3 100644 --- a/src/app/components/chess-piece/chess-piece.component.css +++ b/src/app/components/chess-piece/chess-piece.component.css @@ -1,6 +1,6 @@ .piece { width: clamp(50px, 11cqh, 160px); - height: clamp(50px, 11cqh, 160px); + height: clamp(40px, 8cqh, 120px); display: block; object-fit: contain; pointer-events: none; diff --git a/src/app/components/input-card/input-card.component.css b/src/app/components/input-card/input-card.component.css new file mode 100644 index 0000000..b4cb7a4 --- /dev/null +++ b/src/app/components/input-card/input-card.component.css @@ -0,0 +1,63 @@ +.input-card { + background: var(--color-bg-card); + border: var(--border-width) solid var(--color-border); + border-radius: var(--border-radius-md); + padding: var(--size-lg-padding); + display: flex; + flex-direction: column; + gap: var(--size-lg-gap); +} + +.move-card { + padding: var(--size-sm-padding); + gap: var(--size-sm-gap); +} + +.move-card input { + min-height: 45px; + padding: var(--size-md-padding); +} + +.input-card label { + color: var(--color-text-primary); + font-weight: 700; + margin-bottom: var(--size-xs); +} + +.input-card textarea { + resize: vertical; + height: 40px; + background-color:lightcyan; + border: 3px solid var(--color-border); + border-radius: var(--border-radius-sm); +} + +.input-card input { + min-width: unset; + background-color:lightcyan; + border: 3px solid var(--color-border); + border-radius: var(--border-radius-sm); + +} + +.input-card .btn { + border: var(--button-border); + border-radius: var(--border-radius-sm); + background: var(--color-bg-button); + color: var(--color-text-primary); + padding: var(--button-padding); + cursor: pointer; + font-weight: 600; + transition: background-color 0.2s, color 0.2s; +} + +.input-card .btn:hover { + background: var(--color-bg-button-hover); + color: var(--color-text-button-hover); +} + +.hint-text { + margin: 0; + color: var(--color-text-primary); + font-size: 0.9rem; +} diff --git a/src/app/components/input-card/input-card.component.html b/src/app/components/input-card/input-card.component.html new file mode 100644 index 0000000..34b9d1a --- /dev/null +++ b/src/app/components/input-card/input-card.component.html @@ -0,0 +1,31 @@ +
+ + + @if (inputType === 'textarea') { + + } @else { + + } + + + + @if (hintText) { +

{{ hintText }}

+ } +
diff --git a/src/app/components/input-card/input-card.component.ts b/src/app/components/input-card/input-card.component.ts new file mode 100644 index 0000000..45bf28b --- /dev/null +++ b/src/app/components/input-card/input-card.component.ts @@ -0,0 +1,33 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +@Component({ + selector: 'app-input-card', + standalone: true, + imports: [CommonModule, FormsModule], + templateUrl: './input-card.component.html', + styleUrl: './input-card.component.css', +}) +export class InputCardComponent { + @Input() label: string = ''; + @Input() placeholder: string = ''; + @Input() buttonLabel: string = 'Send'; + @Input() inputType: 'input' | 'textarea' = 'input'; + @Input() value: string = ''; + @Input() cardClass: string = ''; + @Input() hintText: string = ''; + @Input() rows: number = 4; + + @Output() valueChange = new EventEmitter(); + @Output() buttonClick = new EventEmitter(); + + onValueChange(newValue: string): void { + this.value = newValue; + this.valueChange.emit(newValue); + } + + onButtonClick(): void { + this.buttonClick.emit(); + } +} diff --git a/src/app/pages/game/game.component.css b/src/app/pages/game/game.component.css index 909dc86..2f5903c 100644 --- a/src/app/pages/game/game.component.css +++ b/src/app/pages/game/game.component.css @@ -44,56 +44,17 @@ h2 { .top-section { display: grid; gap: var(--size-md); - margin-bottom: var(--size-sm); + margin-top: var(--size-sm); flex: 0 0 auto; } -.move-form { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: var(--size-lg); +.move-card { + padding: var(--size-lg-padding); } -.move-form label { - color: var(--color-text-primary); - font-weight: 600; -} - -.board-hint { - margin: 0; - color: var(--color-text-primary); -} - -.move-form button { - border: var(--button-border); - border-radius: var(--border-radius-md); - background: var(--color-bg-button); - color: var(--color-text-primary); - padding: var(--button-padding); - cursor: pointer; - font-weight: 600; -} - -.move-form button:hover { - background: var(--color-bg-button-hover); - color: var(--color-text-button-hover); -} - -/* Unified form input class for all text inputs and textareas */ -.form-input { - border: var(--form-input-border); - border-radius: var(--form-input-radius); - background: var(--color-bg-input); - padding: var(--form-input-padding); - font-family: inherit; - min-width: 180px; -} - -.form-input:focus { - outline: none; - background: var(--color-bg-input-focus); - border-color: var(--color-primary); +.move-card .btn { + align-self: flex-start; + width: auto; } .center-column { @@ -109,47 +70,6 @@ h2 { container-type: size; } -.import-card { - background: var(--color-bg-card); - border: var(--border-width) solid var(--color-border); - border-radius: var(--border-radius-md); - padding: var(--size-lg-padding); - display: flex; - flex-direction: column; - gap: var(--size-lg-gap); -} - -.import-card label { - color: var(--color-text-primary); - font-weight: 700; - margin-bottom: var(--size-xs); -} - -.import-card textarea { - resize: vertical; - min-height: 100px; -} - -.import-card input { - min-width: unset; -} - -.btn { - border: var(--button-border); - border-radius: var(--border-radius-sm); - background: var(--color-bg-button); - color: var(--color-text-primary); - padding: var(--button-padding); - cursor: pointer; - font-weight: 600; - transition: background-color 0.2s, color 0.2s; -} - -.btn:hover { - background: var(--color-bg-button-hover); - color: var(--color-text-button-hover); -} - .alert { border-radius: var(--border-radius-sm); border: var(--border-width) solid var(--color-border); @@ -197,49 +117,9 @@ h2 { margin-bottom: var(--size-xs); } - .move-form { - flex-direction: column; - gap: var(--size-md); - } - - .move-form label { - align-self: flex-start; - } - - .move-form input { - width: 100%; - min-width: unset; - } - - .move-form button { - width: 100%; - padding: var(--size-sm-padding); - } - .board-section { min-height: 300px; } - - .import-card { - padding: var(--size-md-padding); - gap: var(--size-md-gap); - } - - .import-card label { - font-size: 0.9rem; - } - - .import-card textarea, - .import-card input { - min-height: 70px; - font-size: 0.9rem; - padding: var(--size-sm-padding); - } - - .btn { - padding: var(--size-sm-padding); - font-size: 0.9rem; - } } @media (max-width: 480px) { @@ -272,16 +152,4 @@ h2 { .board-section { min-height: 250px; } - - .import-card { - padding: var(--size-sm-padding); - gap: var(--size-sm-gap); - } - - .import-card textarea, - .import-card input { - min-height: 50px; - font-size: 0.8rem; - padding: var(--size-xs-padding); - } } diff --git a/src/app/pages/game/game.component.html b/src/app/pages/game/game.component.html index ba7d691..02677d9 100644 --- a/src/app/pages/game/game.component.html +++ b/src/app/pages/game/game.component.html @@ -13,32 +13,21 @@
- +
-
-
- - - -
-

Click your piece to highlight legal targets.

-
-
+ +
+ +
- +
diff --git a/src/app/pages/game/game.component.ts b/src/app/pages/game/game.component.ts index d269243..0a1fb94 100644 --- a/src/app/pages/game/game.component.ts +++ b/src/app/pages/game/game.component.ts @@ -4,12 +4,13 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormsModule } from '@angular/forms'; import { ActivatedRoute, RouterLink } from '@angular/router'; import { ChessBoardComponent } from '../../components/chess-board/chess-board.component'; +import { InputCardComponent } from '../../components/input-card/input-card.component'; import { GameFacade } from './game.facade'; @Component({ selector: 'app-game', standalone: true, - imports: [CommonModule, FormsModule, RouterLink, ChessBoardComponent], + imports: [CommonModule, FormsModule, RouterLink, ChessBoardComponent, InputCardComponent], providers: [GameFacade], templateUrl: './game.component.html', styleUrl: './game.component.css'