Skip to content

Commit

Permalink
Merge pull request #46 from skedwards88/more-games
Browse files Browse the repository at this point in the history
Display images of more games
  • Loading branch information
skedwards88 authored Sep 7, 2024
2 parents 253cf89 + 7668a86 commit 127805d
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Bump version
run: npm version patch

- name: Install webp compression tool
run: sudo apt-get install -y webp

- name: Install requirements
run: npm ci

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ To run locally with live reloading and no service worker, run `npm run dev`. (If

To run locally and register the service worker, run `npm start`.

To deploy, push to `main` or manually trigger the GitHub Actions `deploy.yml` workflow.
To deploy, push to `main` or manually trigger the GitHub Actions `deploy.yml` workflow. During deployment, the prebuild script will compress some png images into the webp format. You can also compress these images by running `npm run compressImages` if you have the [webp compression tool](https://developers.google.com/speed/webp/docs/precompiled) installed.
17 changes: 17 additions & 0 deletions compressImages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Directories that include images to compress
declare -a dirs=("src/images/moreGames")

# Loop over the directories
for dir in "${dirs[@]}"; do
# Loop over the files in the directory
for file in $dir/*; do
# Get the file extension
extension="${file##*.}"
# Compress the file if it is a png
if [ "$extension" = "png" ]; then
cwebp -q 75 $file -o ${dir/compressed}/$(basename $file '.png').webp
fi
done
done
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"main": "index.js",
"scripts": {
"test": "jest",
"compressImages": "./compressImages.sh",
"prebuild": "npm run compressImages",
"build": "webpack",
"dev": "webpack-dev-server --mode development",
"start": "webpack-dev-server",
Expand Down
31 changes: 26 additions & 5 deletions src/components/MoreGames.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
import React from "react";

export default function MoreGames({setDisplay}) {
// To add a new game:
// - add it to the list here
// - add a png screenshot under images/moreGames
// - to preview locally, run `npm run compressImages` to generate a webp version of the png (this will also be done during deployment)
// - reference the webp screenshot in src/styles/MoreGames.css
const games = {
lexlet: "https://lexlet.com",
blobble: "https://skedwards88.github.io/blobble/",
wordfall: "https://skedwards88.github.io/wordfall/",
gribbles: "https://skedwards88.github.io/gribbles/",
logicGrid: "https://skedwards88.github.io/logic-grid/",
};

const gameElements = Object.keys(games).map((game, index) => (
<a
key={index}
href={games[game]}
className={`game-image ${game}`}
role="img"
aria-label={`Screenshot of the ${game} game.`}
></a>
));

return (
<div className="App info">
<div className="infoText">
{`Want more games? Check out `}
<a href="https://lexlet.com">Lexlet</a>
{" and "}
<a href="https://skedwards88.github.io/blobble/">Blobble</a>
{" or see all of our puzzle games "}
{`Want more games? Check these out, or see all of our puzzle games `}
<a href="https://skedwards88.github.io/">here</a>
{`. `}

<div id="moreGames">{gameElements}</div>
</div>
<button className="close" onClick={() => setDisplay("game")}>
Close
Expand Down
Binary file added src/images/moreGames/blobble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/moreGames/blobble.webp
Binary file not shown.
Binary file added src/images/moreGames/gribbles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/moreGames/gribbles.webp
Binary file not shown.
Binary file added src/images/moreGames/lexlet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/moreGames/lexlet.webp
Binary file not shown.
Binary file added src/images/moreGames/logicGrid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/moreGames/logicGrid.webp
Binary file not shown.
Binary file added src/images/moreGames/wordfall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/moreGames/wordfall.webp
Binary file not shown.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "./styles/ControlBar.css";
import "./styles/Settings.css";
import "./styles/Rules.css";
import "./styles/Stats.css";
import "./styles/MoreGames.css";
import "./styles/LargeScreen.css";

if (process.env.NODE_ENV !== "development" && "serviceWorker" in navigator) {
Expand Down
12 changes: 12 additions & 0 deletions src/styles/LargeScreen.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
#rulesText {
width: 50vw;
}

#moreGames .game-image {
margin: 2vw;
width: 20vw;
height: 35vw;
}
}

/* Large screen, portrait */
Expand All @@ -112,4 +118,10 @@
max-width: 80vw;
justify-self: center;
}

#moreGames .game-image {
margin: 2vw;
width: 20vw;
height: 35vw;
}
}
36 changes: 36 additions & 0 deletions src/styles/MoreGames.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#moreGames {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
}

.game-image {
margin: 2vw;
width: 40vw;
height: 70vw;
background-size: cover;
background-position: center;
border: 1px solid var(--light-color);
border-radius: 5%;
}

.blobble {
background-image: url("../images/moreGames/blobble.webp");
}

.lexlet {
background-image: url("../images/moreGames/lexlet.webp");
}

.wordfall {
background-image: url("../images/moreGames/wordfall.webp");
}

.gribbles {
background-image: url("../images/moreGames/gribbles.webp");
}

.logicGrid {
background-image: url("../images/moreGames/logicGrid.webp");
}

0 comments on commit 127805d

Please sign in to comment.