Skip to content

Commit 87fe255

Browse files
authored
Merge pull request #3 from mamadou-niakate/feature/rebuseInOtherLangage
Feature/rebuse in other langage
2 parents 0e6f20a + 0d1ed83 commit 87fe255

File tree

6 files changed

+71
-26
lines changed

6 files changed

+71
-26
lines changed

src/css/main.css

+10
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,16 @@ body,
304304
left: 30px;
305305
}
306306

307+
.no-rebus {
308+
background-color: #1542e642;
309+
grid-column-start: 3;
310+
align-self: center;
311+
grid-row-start: 2;
312+
font-size: 2em;
313+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
314+
transition: 0.3s;
315+
}
316+
307317
.rebus {
308318
background-color: #1542e642;
309319
grid-column-start: 3;

src/js/components/Rebus.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export function Rebus(props, ...children) {
1919
const rebus = this.props.rebuses[this.props.current];
2020
/* If history API isn't available, we shouldn't revert to the more widely available `window.location.href`,
2121
as it incurs a new HTTP request and thus results in an infinite loop (and breaks SPAs). */
22+
const params = new URLSearchParams(window.location.search);
23+
const lang = params.get('lang');
2224
if (window.history) {
2325
// Adds 'rebus' query parameter to end of URL. Should be endpoint-agnostic.
24-
window.history.pushState('', '', `?rebus=${rebus.id}`);
26+
window.history.pushState('', '', `?rebus=${rebus.id}&lang=${lang}`);
2527
}
2628
if (rebus.isAnswered) {
2729
this.$parent.querySelector('.change-button--next').focus();
@@ -30,11 +32,12 @@ export function Rebus(props, ...children) {
3032
}
3133
},
3234
render({ current, rebuses, animation }) {
33-
const rebus = rebuses[current];
34-
this.children = rebus.words.map((word, wordIndex) =>
35-
Word({ word, wordIndex, current, rebuses, charInput: props.charInput })
36-
);
37-
return `
35+
if (rebuses.length !== 0) {
36+
const rebus = rebuses[current];
37+
this.children = rebus.words.map((word, wordIndex) =>
38+
Word({ word, wordIndex, current, rebuses, charInput: props.charInput })
39+
);
40+
return `
3841
<div class="rebus ${rebus.isAnswered ? 'rebus--answered' : ''} animation--${animation}">
3942
<div class="rebus__header">
4043
<span>${current + 1}/${rebuses.length}</span>
@@ -45,6 +48,18 @@ export function Rebus(props, ...children) {
4548
</div>
4649
</div>
4750
`;
51+
}
52+
53+
return `
54+
<div class="no-rebus">
55+
<span>There are no rebuses yet for this language.</span>
56+
<div>
57+
<a href="${window.location.origin}">
58+
<span>Return to home page</span>
59+
</a>
60+
</div>
61+
</div>
62+
`;
4863
}
4964
})
5065
);

src/js/frenchRebuses.js

-17
This file was deleted.

src/js/rebuses.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { englishRebuses } from './englishRebuses';
2-
import { frenchRebuses } from './frenchRebuses';
1+
import { englishRebuses } from './rebusesLanguages/englishRebuses';
2+
import { frenchRebuses } from './rebusesLanguages/frenchRebuses';
33

44
export function isRebusAnswered(id) {
55
const answeredRebuses = window.localStorage.getItem('answeredRebuses');
@@ -33,7 +33,7 @@ export function getRebuses() {
3333
chosenRebuses = frenchRebuses;
3434
break;
3535
default:
36-
chosenRebuses = englishRebuses;
36+
chosenRebuses = [];
3737
}
3838
return chosenRebuses.map((rebus, index) => {
3939
const id = index + 1;
File renamed without changes.
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export const frenchRebuses = [
2+
{
3+
symbols: ['Re', '+', '🚌'],
4+
words: ['Rebus'],
5+
hint: 'Tu as résolu le premier maintenant'
6+
},
7+
{
8+
symbols: ['🍲', '+', '🧓'],
9+
words: ['Potager'],
10+
hint: 'jardin de légumes et fruits'
11+
},
12+
{
13+
symbols: ['🥬', '+', '🌹'],
14+
words: ['Choufleur'],
15+
hint: 'Légume vert'
16+
},
17+
{
18+
symbols: ['🥖', '+', '🪣'],
19+
words: ['Pinceau'],
20+
hint: 'outil utilisé par les peintres'
21+
},
22+
{
23+
symbols: ['🎲', '+', '🪚', '+', '👃'],
24+
words: ['Dessiner'],
25+
hint: 'action de faire un dessin'
26+
},
27+
{
28+
symbols: ['🚌', '+', '🐟'],
29+
words: ['Carton'],
30+
hint: 'un contenant'
31+
},
32+
{
33+
symbols: ['&', '+', '🥛', '+', '🧤'],
34+
words: ['Elegant'],
35+
hint: 'etre elegant'
36+
}
37+
];

0 commit comments

Comments
 (0)