Skip to content

Commit

Permalink
Highlight yesterday's words which were guessed correctly
Browse files Browse the repository at this point in the history
Previously, yesterday's word list did not indicate which words were
guessed correctly. With this change, yesterday's correct guesses are
kept around, and a subtle green background is used for each word in
yesterday's word list that was guessed correctly.
  • Loading branch information
stelcodes committed Jul 10, 2024
1 parent 196388f commit 16d8cba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ h2 span {
font-weight: bold;
}
.guessed-yesterday {
background-color: #d4e7d4;
}
.toast-message {
max-width: 80%;
margin: 0, 1em;
Expand All @@ -258,6 +262,9 @@ html.dark {
.pangram {
color: $bl-yellow;
}
.guessed-yesterday {
background-color: #1e321e;
}
}
@media only screen and (max-height: 500px) {
Expand Down
14 changes: 11 additions & 3 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const useMainStore = defineStore({
"" as string
),
yesterdaysMiddleLetter: useStorage("yesterdaysMiddleLetter", "" as string),
yesterdaysCorrectGuesses: useStorage("yesterdaysCorrectGuesses", new Set([]) as Set<string>),
theme: useStorage("theme", "light" as string),
// don't need to be in local storage because they doesn't change
pointsMessages: {
Expand Down Expand Up @@ -158,8 +159,6 @@ export const useMainStore = defineStore({

// set gameDate to clear guesses tomorrow
this.gameDate = now;
// new game so reset guesses
this.correctGuesses = new Set([]);

const { todaysAnswerObj, yesterdaysAnswerObj } = generateAnswerObjs({
allAnswers,
Expand All @@ -173,6 +172,9 @@ export const useMainStore = defineStore({
this.answers = answers;
this.availableLetters = availableLetters;
this.middleLetter = middleLetter;

// new game so reset guesses
this.correctGuesses = new Set([]);
},
setYesterdaysAnswersAndLastGameDate({
yesterdaysAnswerObj,
Expand All @@ -188,6 +190,7 @@ export const useMainStore = defineStore({
this.yesterdaysAnswers = this.answers;
this.yesterdaysAvailableLetters = this.availableLetters;
this.yesterdaysMiddleLetter = this.middleLetter;
this.yesterdaysCorrectGuesses = this.correctGuesses;
return "local-storage-cache";
} else {
const {
Expand Down Expand Up @@ -223,10 +226,15 @@ export const useMainStore = defineStore({
return `${$t(`points.${message}`)}! +${points}`;
},
cellClassName({ row, columnIndex }: { row: any; columnIndex: number }) {
let className = "";
const word = row[columnIndex + 1];
if (word && this.isPangram({ word })) {
return "pangram";
className += "pangram ";
}
if (word && this.yesterdaysCorrectGuesses.has(word)) {
className += "guessed-yesterday "
}
return className
},
},
});

0 comments on commit 16d8cba

Please sign in to comment.