-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
121 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.keyboard-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.keyboard-row { | ||
display: flex; | ||
justify-content: center; | ||
margin: 5px; | ||
} | ||
|
||
button { | ||
margin: 2px; | ||
padding: 10px 15px; /* Adjust padding to ensure keys are comfortably sized */ | ||
border-radius: 8px; /* This adds rounded corners to your buttons */ | ||
border: 1px solid #000; /* Optional: Adds a border around the buttons */ | ||
transition: background-color 0.3s ease; /* Optional: Adds a smooth transition for color changes */ | ||
} | ||
|
||
button.guessed-correct { | ||
background-color: green; | ||
color: white; | ||
} | ||
|
||
button.guessed-wrong { | ||
background-color: red; | ||
color: white; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="keyboard-container"> | ||
<div *ngFor="let row of keyboardLayout" class="keyboard-row"> | ||
<button mat-button *ngFor="let key of row" | ||
[class.guessed-correct]="guessedLetters[key] === 'correct'" | ||
[class.guessed-wrong]="guessedLetters[key] === 'wrong'" | ||
(click)="guessLetter(key)" | ||
[disabled]="isLetterGuessed(key)"> | ||
{{ key }} | ||
</button> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Component, EventEmitter, Output } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-keyboard', | ||
templateUrl: './keyboard.component.html', | ||
styleUrls: ['./keyboard.component.css'] | ||
}) | ||
export class KeyboardComponent { | ||
keyboardLayout = [ | ||
['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'], | ||
['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'], | ||
['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L'], | ||
['Z', 'X', 'C', 'V', 'B', 'N', 'M'] | ||
]; | ||
|
||
guessedLetters: { [key: string]: 'correct' | 'wrong' } = {}; | ||
|
||
@Output() letterGuessed = new EventEmitter<string>(); | ||
|
||
addGuessedLetter(letter: string, reslt: boolean) { | ||
this.guessedLetters[letter] = reslt ? 'correct' : 'wrong'; | ||
} | ||
|
||
guessLetter(letter: string) { | ||
this.letterGuessed.emit(letter); | ||
} | ||
|
||
isLetterGuessed(letter: string): boolean { | ||
return letter in this.guessedLetters; | ||
} | ||
|
||
markLetterAsGuessed(letter: string, status: 'correct' | 'wrong') { | ||
this.guessedLetters[letter] = status; | ||
} | ||
|
||
reset() { | ||
this.guessedLetters = {}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters