From 3e0bb37abf72d1c2293d9bf378d5748d512c03fb Mon Sep 17 00:00:00 2001 From: Mohamed Date: Mon, 2 Jan 2023 00:30:41 +0100 Subject: [PATCH 1/2] Adding french rebuses --- src/js/frenchRebuses.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/js/frenchRebuses.js b/src/js/frenchRebuses.js index 342aba8c..d9dfb727 100644 --- a/src/js/frenchRebuses.js +++ b/src/js/frenchRebuses.js @@ -2,16 +2,36 @@ export const frenchRebuses = [ { symbols: ['Re', '+', '🚌'], words: ['Rebus'], - hint: 'You´re solving one right now' + hint: 'Tu as résolu le premier maintenant' }, { symbols: ['🍲', '+', '🧓'], words: ['Potager'], - hint: 'You´re solving one right now' + hint: 'jardin de légumes et fruits' }, { - symbols: ['⭐', '+', '🐠'], - words: ['Starfish'], - hint: 'Say the two emojis out loud' + symbols: ['🥬', '+', '🌹'], + words: ['Choufleur'], + hint: 'Légume vert' + }, + { + symbols: ['🥖', '+', '🪣'], + words: ['Pinceau'], + hint: 'outil utilisé par les peintres' + }, + { + symbols: ['🎲', '+', '🪚', '+', '👃'], + words: ['Dessiner'], + hint: 'action de faire un dessin' + }, + { + symbols: ['🚌', '+', '🐟'], + words: ['Carton'], + hint: 'un contenant' + }, + { + symbols: ['&', '+', '🥛', '+', '🧤'], + words: ['Elegant'], + hint: 'etre elegant' } ]; From 0d1ed838122ba94b88a695d9ba9f06db92fd1e10 Mon Sep 17 00:00:00 2001 From: Mohamed Date: Mon, 6 Feb 2023 23:16:44 +0100 Subject: [PATCH 2/2] manage the choice of game language --- src/css/main.css | 10 +++++++ src/js/components/Rebus.js | 27 ++++++++++++++----- src/js/rebuses.js | 6 ++--- .../{ => rebusesLanguages}/englishRebuses.js | 0 .../{ => rebusesLanguages}/frenchRebuses.js | 0 5 files changed, 34 insertions(+), 9 deletions(-) rename src/js/{ => rebusesLanguages}/englishRebuses.js (100%) rename src/js/{ => rebusesLanguages}/frenchRebuses.js (100%) diff --git a/src/css/main.css b/src/css/main.css index 6e1b24b9..dcdba203 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -248,6 +248,16 @@ body, left: 30px; } +.no-rebus { + background-color: #1542e642; + grid-column-start: 3; + align-self: center; + grid-row-start: 2; + font-size: 2em; + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); + transition: 0.3s; +} + .rebus { background-color: #1542e642; grid-column-start: 3; diff --git a/src/js/components/Rebus.js b/src/js/components/Rebus.js index 9adaefe8..47c1be9a 100644 --- a/src/js/components/Rebus.js +++ b/src/js/components/Rebus.js @@ -19,9 +19,11 @@ export function Rebus(props, ...children) { const rebus = this.props.rebuses[this.props.current]; /* If history API isn't available, we shouldn't revert to the more widely available `window.location.href`, as it incurs a new HTTP request and thus results in an infinite loop (and breaks SPAs). */ + const params = new URLSearchParams(window.location.search); + const lang = params.get('lang'); if (window.history) { // Adds 'rebus' query parameter to end of URL. Should be endpoint-agnostic. - window.history.pushState('', '', `?rebus=${rebus.id}`); + window.history.pushState('', '', `?rebus=${rebus.id}&lang=${lang}`); } if (rebus.isAnswered) { this.$parent.querySelector('.change-button--next').focus(); @@ -30,11 +32,12 @@ export function Rebus(props, ...children) { } }, render({ current, rebuses, animation }) { - const rebus = rebuses[current]; - this.children = rebus.words.map((word, wordIndex) => - Word({ word, wordIndex, current, rebuses, charInput: props.charInput }) - ); - return ` + if (rebuses.length !== 0) { + const rebus = rebuses[current]; + this.children = rebus.words.map((word, wordIndex) => + Word({ word, wordIndex, current, rebuses, charInput: props.charInput }) + ); + return `
${current + 1}/${rebuses.length} @@ -45,6 +48,18 @@ export function Rebus(props, ...children) {
`; + } + + return ` +
+ There are no rebuses yet for this language. +
+ + Return to home page + +
+
+ `; } }) ); diff --git a/src/js/rebuses.js b/src/js/rebuses.js index c66b0489..b779d9bd 100644 --- a/src/js/rebuses.js +++ b/src/js/rebuses.js @@ -1,5 +1,5 @@ -import { englishRebuses } from './englishRebuses'; -import { frenchRebuses } from './frenchRebuses'; +import { englishRebuses } from './rebusesLanguages/englishRebuses'; +import { frenchRebuses } from './rebusesLanguages/frenchRebuses'; export function isRebusAnswered(id) { const answeredRebuses = window.localStorage.getItem('answeredRebuses'); @@ -33,7 +33,7 @@ export function getRebuses() { chosenRebuses = frenchRebuses; break; default: - chosenRebuses = englishRebuses; + chosenRebuses = []; } return chosenRebuses.map((rebus, index) => { const id = index + 1; diff --git a/src/js/englishRebuses.js b/src/js/rebusesLanguages/englishRebuses.js similarity index 100% rename from src/js/englishRebuses.js rename to src/js/rebusesLanguages/englishRebuses.js diff --git a/src/js/frenchRebuses.js b/src/js/rebusesLanguages/frenchRebuses.js similarity index 100% rename from src/js/frenchRebuses.js rename to src/js/rebusesLanguages/frenchRebuses.js