Skip to content

Commit b5d797c

Browse files
committed
fix round headword buttons on desktop + error
1 parent a575dfa commit b5d797c

File tree

2 files changed

+65
-60
lines changed

2 files changed

+65
-60
lines changed

app/components/RoundHeadword.js

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,63 @@ import { getRomanizations } from '../utils';
66
import Circle from './Circle';
77
import BigSyllable from './BigSyllable';
88

9-
const RoundHeadword = ({params, round, shapes}) => {
10-
let syllables = round.headword.split('');
11-
let slides = round.text.word;
12-
let text = slides[params.headword] || slides[0];
13-
let next = (parseFloat(params.headword) || 0) + 1;
14-
let prev = (parseFloat(params.headword) || 0) - 1;
15-
let lastLetter = (round.jamo || []).length - 1;
16-
let hasMoreText = next < slides.length;
17-
let continuePath = (
18-
hasMoreText ? `/level/${params.level}/round/${params.round}/headword/${next}`
19-
: `/level/${params.level}/round/${params.round}/ready`
20-
);
21-
let backPath = (
22-
prev >= 0 ? `/level/${params.level}/round/${params.round}/headword${prev > 0 ? `/${prev}` : ''}`
23-
: round.jamo ? `/level/${params.level}/round/${params.round}/letter${lastLetter > 0 ? `/${lastLetter}` : ''}`
24-
: `/level/${params.level}/round/${params.round}/intro${round.text.intro.length ? `/${round.text.intro.length - 1}` : ''}`
25-
);
26-
let phonetics = getRomanizations(round.headword, true);
27-
return (
28-
<div className={classNames("round__headword", {
29-
'one-syllable': syllables.length === 1,
30-
})}>
31-
<div className="round__headword__word">
32-
<Circle />
33-
<label>Round Keyword</label>
34-
<div className="round__headword__syllables">
35-
{syllables.map((syllable, i) =>
36-
<div className="round__headword__syllable" key={syllable}>
37-
<BigSyllable syllable={syllable} shapes={shapes} />
38-
<p className="round__headword__syllable__phonetics">
39-
{phonetics.syllables[i].ideal}
40-
</p>
41-
</div>
42-
)}
9+
class RoundHeadword extends React.Component {
10+
render() {
11+
let {params, round, shapes} = this.props;
12+
let syllables = round.headword.split('');
13+
let slides = round.text.word;
14+
let text = slides[params.headword] || slides[0];
15+
let next = (parseFloat(params.headword) || 0) + 1;
16+
let prev = (parseFloat(params.headword) || 0) - 1;
17+
let lastLetter = (round.jamo || []).length - 1;
18+
let hasMoreText = next < slides.length;
19+
let continuePath = (
20+
hasMoreText ? `/level/${params.level}/round/${params.round}/headword/${next}`
21+
: `/level/${params.level}/round/${params.round}/ready`
22+
);
23+
let backPath = (
24+
prev >= 0 ? `/level/${params.level}/round/${params.round}/headword${prev > 0 ? `/${prev}` : ''}`
25+
: round.jamo ? `/level/${params.level}/round/${params.round}/letter${lastLetter > 0 ? `/${lastLetter}` : ''}`
26+
: `/level/${params.level}/round/${params.round}/intro${round.text.intro.length ? `/${round.text.intro.length - 1}` : ''}`
27+
);
28+
let phonetics = getRomanizations(round.headword, true);
29+
return (
30+
<div className={classNames("round__headword", {
31+
'one-syllable': syllables.length === 1,
32+
})}>
33+
<div className="round__headword__word">
34+
<Circle />
35+
<label>Round Keyword</label>
36+
<div className="round__headword__syllables">
37+
{syllables.map((syllable, i) =>
38+
<div className="round__headword__syllable" key={syllable}>
39+
<BigSyllable syllable={syllable} shapes={shapes} />
40+
<p className="round__headword__syllable__phonetics">
41+
{phonetics.syllables[i].ideal}
42+
</p>
43+
</div>
44+
)}
45+
</div>
4346
</div>
44-
</div>
4547

46-
<div className="round__headword__content">
47-
<Circle />
48-
<div className="round__headword__content__inner">
49-
<Markdown source={text} />
50-
</div>
48+
<div className="round__headword__content">
49+
<Circle />
50+
<div className="round__headword__content__inner">
51+
<Markdown source={text} />
52+
</div>
5153

52-
<div className="round__headword__buttons back-forward-buttons">
53-
<Link className="button button--back button--link" to={backPath}>
54-
Back
55-
</Link>
56-
<Link className="button button--forward" to={continuePath} data-autofocus="true">
57-
Continue
58-
</Link>
54+
<div className="round__headword__content__buttons back-forward-buttons">
55+
<Link className="button button--back button--link" to={backPath}>
56+
Back
57+
</Link>
58+
<Link className="button button--forward" to={continuePath} data-autofocus="true">
59+
Continue
60+
</Link>
61+
</div>
5962
</div>
6063
</div>
61-
</div>
62-
);
63-
};
64+
);
65+
}
66+
}
6467

6568
export default RoundHeadword;

app/styles/components/_RoundHeadword.scss

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,17 @@
133133
}
134134
}
135135

136-
// .button {
137-
// position: absolute;
138-
// bottom: 42px;
139-
// left: 50%;
140-
// white-space: nowrap;
141-
// }
142-
143-
// .button--back {
144-
// margin-left: -110px;
145-
// }
136+
&__buttons {
137+
position: absolute;
138+
bottom: 42px;
139+
left: 50%;
140+
141+
.button--back {
142+
position: absolute;
143+
left: -20px;
144+
top: 0;
145+
transform: translateX(-100%);
146+
}
147+
}
146148
}
147149
}

0 commit comments

Comments
 (0)