From ad4ecb2270760169e85ba766dc46ad93ba521006 Mon Sep 17 00:00:00 2001 From: Hannah Park Date: Tue, 1 Feb 2022 04:40:58 -0500 Subject: [PATCH] generic branding --- README.md | 28 +++------------------------- package-lock.json | 4 ++-- public/index.html | 4 ++-- public/manifest.json | 4 ++-- src/App.test.tsx | 4 ++-- src/App.tsx | 6 ++---- src/components/alerts/Alert.tsx | 2 +- src/components/grid/Cell.tsx | 4 ++-- src/components/keyboard/Key.tsx | 4 ++-- src/components/modals/AboutModal.tsx | 11 ++--------- src/components/modals/InfoModal.tsx | 4 ++-- src/constants/strings.ts | 2 +- src/lib/share.ts | 4 ++-- 13 files changed, 25 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 96df800..247ed30 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,8 @@ -# Wordle Clone - -- Go play the real Wordle [here](https://www.powerlanguage.co.uk/wordle/) -- Read the story behind it [here](https://www.nytimes.com/2022/01/03/technology/wordle-word-game-creator.html) -- Try a demo of this clone project [here](https://wordle.hannahmariepark.com) - -_Inspiration:_ -This game is an open source clone of the immensely popular online word guessing game Wordle. Like many others all over the world, I saw the signature pattern of green, yellow, and white squares popping up all over social media and the web and had to check it out. After a few days of play, I decided it would be great for my learning to try to rebuild Wordle in React! - -_Design Decisions:_ -I used a combination of React, Typescript, and Tailwind to build this Wordle Clone. When examining the original Wordle, I assumed the list might come from an external API or database, but after investigating in chrome dev tools I found that the list of words is simply stored in an array on the front end. I'm using the same list as the OG Wordle uses, but watch out for spoilers if you go find the file in this repo! The word match functionality is simple: the word array index increments each day from a fixed game epoch timestamp (only one puzzle per day!) roughly like so: - -``` -WORDS[Math.floor((NOW_IN_MS - GAME_EPOCH_IN_MS) / ONE_DAY_IN_MS)] -``` - -React enabled me to componentize the littlest parts of the game - keys and letter cells - and use them as the building blocks for the keyboard, word grid, and winning solution graphic. As for handling state, I used the built in useState and useEffect hooks to track guesses, whether the game is won, and to conditionally render popups. - -In addition to other things, Typescript helped ensure type safety for the statuses of each guessed letter, which were used in many areas of the app and needed to be accurate for the game to work correctly. - -I implemented Tailwind mostly because I wanted to learn how to use Tailwind CSS, but I also took advantage of [Tailwind UI](https://tailwindui.com/) with their [headless package](https://headlessui.dev/) to build the modals and notifications. This was such an easy way to build simple popups for how to play, winning the game, and invalid words. - _To Run Locally:_ Clone the repository and perform the following command line actions: ```bash -$ cd wordle +$ cd game $ npm install $ npm run start ``` @@ -32,8 +10,8 @@ $ npm run start _To build/run docker container:_ ```bash -$ docker build -t notwordle . -$ docker run -d -p 3000:3000 notwordle +$ docker build -t game . +$ docker run -d -p 3000:3000 game ``` open http://localhost:3000 in browser. diff --git a/package-lock.json b/package-lock.json index da4af7b..1c572d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "wordle", + "name": "game", "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "wordle", + "name": "game", "version": "0.1.0", "dependencies": { "@headlessui/react": "^1.4.2", diff --git a/public/index.html b/public/index.html index e8d8565..ad09ab6 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,7 @@ - + - Not Wordle + Game diff --git a/public/manifest.json b/public/manifest.json index 71aba26..4bd5675 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,6 +1,6 @@ { - "short_name": "Not Wordle", - "name": "Not Wordle", + "short_name": "Game", + "name": "Game", "icons": [ { "src": "favicon.ico", diff --git a/src/App.test.tsx b/src/App.test.tsx index 9ae34a6..f06675f 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -1,7 +1,7 @@ import React from 'react' import { render, screen } from '@testing-library/react' import App from './App' -import { WORDLE_TITLE } from './constants/strings' +import { GAME_TITLE } from './constants/strings' beforeEach(() => { Object.defineProperty(window, 'matchMedia', { @@ -21,6 +21,6 @@ beforeEach(() => { test('renders App component', () => { render() - const linkElement = screen.getByText(WORDLE_TITLE) + const linkElement = screen.getByText(GAME_TITLE) expect(linkElement).toBeInTheDocument() }) diff --git a/src/App.tsx b/src/App.tsx index aab1663..5735745 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,7 +11,7 @@ import { AboutModal } from './components/modals/AboutModal' import { InfoModal } from './components/modals/InfoModal' import { StatsModal } from './components/modals/StatsModal' import { - WORDLE_TITLE, + GAME_TITLE, WIN_MESSAGES, GAME_COPIED_MESSAGE, ABOUT_GAME_MESSAGE, @@ -151,9 +151,7 @@ function App() { return (
-

- {WORDLE_TITLE} -

+

{GAME_TITLE}

handleDarkMode(!isDarkMode)} diff --git a/src/components/alerts/Alert.tsx b/src/components/alerts/Alert.tsx index 6d11e4e..c5a56cb 100644 --- a/src/components/alerts/Alert.tsx +++ b/src/components/alerts/Alert.tsx @@ -13,7 +13,7 @@ export const Alert = ({ isOpen, message, variant = 'warning' }: Props) => { 'fixed top-5 left-1/2 transform -translate-x-1/2 max-w-sm w-full shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden', { 'bg-rose-200': variant === 'warning', - 'bg-green-200 z-20': variant === 'success', + 'bg-blue-200 z-20': variant === 'success', } ) diff --git a/src/components/grid/Cell.tsx b/src/components/grid/Cell.tsx index 4aa8bdd..54bffd2 100644 --- a/src/components/grid/Cell.tsx +++ b/src/components/grid/Cell.tsx @@ -15,8 +15,8 @@ export const Cell = ({ value, status }: Props) => { 'border-black dark:border-slate-100': value && !status, 'bg-slate-400 dark:bg-slate-700 text-white border-slate-400 dark:border-slate-700': status === 'absent', - 'bg-green-500 text-white border-green-500': status === 'correct', - 'bg-yellow-500 dark:bg-yellow-700 text-white border-yellow-500 dark:border-yellow-700': + 'bg-blue-500 text-white border-blue-500': status === 'correct', + 'bg-orange-500 dark:bg-orange-700 text-white border-orange-500 dark:border-orange-700': status === 'present', 'cell-animation': !!value, } diff --git a/src/components/keyboard/Key.tsx b/src/components/keyboard/Key.tsx index 21eb067..938d615 100644 --- a/src/components/keyboard/Key.tsx +++ b/src/components/keyboard/Key.tsx @@ -24,9 +24,9 @@ export const Key = ({ 'bg-slate-200 dark:bg-slate-600 hover:bg-slate-300 active:bg-slate-400': !status, 'bg-slate-400 text-white': status === 'absent', - 'bg-green-500 hover:bg-green-600 active:bg-green-700 text-white': + 'bg-blue-500 hover:bg-blue-600 active:bg-blue-700 text-white': status === 'correct', - 'bg-yellow-500 hover:bg-yellow-600 active:bg-yellow-700 dark:bg-yellow-700 text-white': + 'bg-orange-500 hover:bg-orange-600 active:bg-orange-700 dark:bg-orange-700 text-white': status === 'present', } ) diff --git a/src/components/modals/AboutModal.tsx b/src/components/modals/AboutModal.tsx index 1d3345a..fcc7bff 100644 --- a/src/components/modals/AboutModal.tsx +++ b/src/components/modals/AboutModal.tsx @@ -9,20 +9,13 @@ export const AboutModal = ({ isOpen, handleClose }: Props) => { return (

- This is an open source clone of the game Wordle -{' '} + This is an open source word guessing game -{' '} check out the code here {' '} - and{' '} - - play the original here -

) diff --git a/src/components/modals/InfoModal.tsx b/src/components/modals/InfoModal.tsx index 4cecba5..5202fb8 100644 --- a/src/components/modals/InfoModal.tsx +++ b/src/components/modals/InfoModal.tsx @@ -10,8 +10,8 @@ export const InfoModal = ({ isOpen, handleClose }: Props) => { return (

- Guess the WORDLE in 6 tries. After each guess, the color of the tiles - will change to show how close your guess was to the word. + Guess the word in 6 tries. After each guess, the color of the tiles will + change to show how close your guess was to the word.

diff --git a/src/constants/strings.ts b/src/constants/strings.ts index 48318c0..9106d21 100644 --- a/src/constants/strings.ts +++ b/src/constants/strings.ts @@ -1,4 +1,4 @@ -export const WORDLE_TITLE = 'Not Wordle' +export const GAME_TITLE = 'GAME' export const WIN_MESSAGES = ['Great Job!', 'Awesome', 'Well done!'] export const GAME_COPIED_MESSAGE = 'Game copied to clipboard' diff --git a/src/lib/share.ts b/src/lib/share.ts index 80b7986..0c80282 100644 --- a/src/lib/share.ts +++ b/src/lib/share.ts @@ -1,10 +1,10 @@ import { getGuessStatuses } from './statuses' import { solutionIndex } from './words' -import { WORDLE_TITLE } from '../constants/strings' +import { GAME_TITLE } from '../constants/strings' export const shareStatus = (guesses: string[], lost: boolean) => { navigator.clipboard.writeText( - `${WORDLE_TITLE} ${solutionIndex} ${lost ? 'X' : guesses.length}/6\n\n` + + `${GAME_TITLE} ${solutionIndex} ${lost ? 'X' : guesses.length}/6\n\n` + generateEmojiGrid(guesses) ) }