Skip to content

Commit 973ace0

Browse files
committed
* quran#372 colon separated surah/ayah
* quran#372 colon separated surah/ayah * quran#372 colon separated surah/ayah Re-output fonts with Apple option enabled This probably doesn't matter for web, but it may matter for apps in the future, plus wanted to keep in sync with the versions of the fonts used by quran/quran.com-images. Tooltip options for translation and transliteration (quran#376) Reading mode single line (quran#377)
1 parent 1a21634 commit 973ace0

File tree

15 files changed

+130
-30
lines changed

15 files changed

+130
-30
lines changed

src/components/Ayah/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default class Ayah extends Component {
2020
ayah: PropTypes.object.isRequired,
2121
match: PropTypes.array,
2222
isSearch: PropTypes.bool,
23+
tooltip: PropTypes.string,
2324
currentWord: PropTypes.any, // gets passed in an integer, null by default
2425
onWordClick: PropTypes.func.isRequired
2526
};
@@ -32,6 +33,7 @@ export default class Ayah extends Component {
3233
shouldComponentUpdate(nextProps) {
3334
const conditions = [
3435
this.props.ayah !== nextProps.ayah,
36+
this.props.tooltip !== nextProps.tooltip,
3537
this.props.currentWord !== nextProps.currentWord
3638
];
3739

@@ -73,7 +75,7 @@ export default class Ayah extends Component {
7375
}
7476

7577
renderText() {
76-
const { ayah, onWordClick } = this.props;
78+
const { ayah, onWordClick, tooltip } = this.props;
7779

7880
if (!ayah.words[0].code) {
7981
return false;
@@ -92,8 +94,8 @@ export default class Ayah extends Component {
9294
id = `${word.className}-${word.codeDec}`; // just don't include id
9395
}
9496

95-
if (word.translation) {
96-
let tooltip = word.translation;
97+
if (word.translation || word.transliteration) {
98+
let tooltipContent = word[tooltip];
9799

98100
return (
99101
<b
@@ -104,7 +106,9 @@ export default class Ayah extends Component {
104106
className={`${className} pointer`}
105107
data-toggle="tooltip"
106108
data-trigger="hover"
107-
data-placement="top" title={tooltip}
109+
data-placement="top"
110+
data-original-title={tooltipContent}
111+
title={tooltipContent}
108112
dangerouslySetInnerHTML={{__html: word.code}}
109113
/>
110114
);

src/components/Ayah/style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
.line{
104104
b{
105105
float: none;
106+
display: inline;
106107
}
107108
}
108109

src/components/Line/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
import React from 'react';
1+
import React, { PropTypes } from 'react';
22
import debug from '../../helpers/debug';
33

44
const styles = require('../Ayah/style.scss');
55

66
export default class Line extends React.Component {
77
static propTypes = {
8-
line: React.PropTypes.array.isRequired
8+
line: PropTypes.array.isRequired,
9+
tooltip: PropTypes.string
910
};
1011

1112
renderText() {
12-
const { line } = this.props;
13+
const { line, tooltip } = this.props;
1314

1415
if (!line[0].code) { // TODO shouldn't be possible, remove this clause
1516
return false;
1617
}
1718

1819
let text = line.map(word => {
1920
if (word.translation) {
20-
let tooltip = word.translation;
21+
let tooltipContent = word[tooltip];
2122

2223
return (
2324
<b
@@ -28,7 +29,9 @@ export default class Line extends React.Component {
2829
data-line={word.lineNun}
2930
data-page={word.pageNum}
3031
data-position={word.position}
31-
data-placement="top" title={tooltip}
32+
data-placement="top"
33+
data-origin-title={tooltipContent}
34+
title={tooltipContent}
3235
dangerouslySetInnerHTML={{__html: word.code}}
3336
/>
3437
);

src/components/ReadingModeToggle/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import SwitchToggle from '../SwitchToggle';
55
const ReadingModeToggle = ({ onReadingModeToggle, isToggled }) => (
66
<div>
77
Reading:{' '}
8-
<SwitchToggle checked={isToggled} onToggle={onReadingModeToggle} flat />
8+
<SwitchToggle
9+
checked={isToggled}
10+
onToggle={onReadingModeToggle}
11+
id="reading-mode-toggle"
12+
flat
13+
/>
914
</div>
1015
);
1116

src/components/SwitchToggle/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ SwitchToggle.propTypes = {
2323
};
2424

2525
SwitchToggle.defaultProps = {
26-
id: 'toggle',
2726
flat: false,
2827
checked: false
2928
};

src/components/SwitchToggle/style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ $width: 50px;
2121
cursor: pointer;
2222
outline: none;
2323
user-select: none;
24+
margin-bottom: 0px;
2425
}
2526

2627
.toggleRound + .label {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React, { Component, PropTypes } from 'react';
2+
3+
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
4+
import Popover from 'react-bootstrap/lib/Popover';
5+
import Row from 'react-bootstrap/lib/Row';
6+
import Col from 'react-bootstrap/lib/Col';
7+
8+
import SwitchToggle from '../SwitchToggle';
9+
10+
const style = require('./style.scss');
11+
12+
export default class TooltipDropdown extends Component {
13+
static propTypes = {
14+
onOptionChange: PropTypes.func,
15+
options: PropTypes.object
16+
}
17+
18+
handleOptionSelected = ({ target: { checked } }) => {
19+
const { onOptionChange } = this.props;
20+
21+
return onOptionChange({
22+
tooltip: checked ? 'transliteration' : 'translation'
23+
});
24+
}
25+
26+
renderPopup() {
27+
const { options: { tooltip }} = this.props;
28+
29+
return (
30+
<Popover id="TooltipDropdown" title="Tooltip display" className={style.popover}>
31+
<Row>
32+
<Col xs={12}>
33+
Translation{' '}
34+
<SwitchToggle
35+
checked={tooltip === 'transliteration'}
36+
onToggle={this.handleOptionSelected}
37+
id="tooltip-toggle"
38+
flat
39+
/>
40+
{' '}Transliteration
41+
</Col>
42+
</Row>
43+
</Popover>
44+
);
45+
}
46+
47+
render() {
48+
return (
49+
<OverlayTrigger trigger="click" placement="bottom" overlay={this.renderPopup()} rootClose>
50+
<a
51+
href="#"
52+
className="text-color"
53+
data-metrics-event-name="TooltipDropdown"
54+
>
55+
Tooltip
56+
</a>
57+
</OverlayTrigger>
58+
);
59+
}
60+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@import '../../styles/variables.scss';
2+
3+
:local .popover{
4+
:global(.popover-title){
5+
font-family: $font-montserrat;
6+
text-transform: uppercase;
7+
color: $cream;
8+
padding-top: 15px;
9+
padding-bottom: 15px;
10+
font-size: 0.75em;
11+
}
12+
13+
:global(.popover-content){
14+
:global(a){
15+
font-size: 0.8em;
16+
}
17+
}
18+
}

src/containers/Surah/index.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import ReciterDropdown from 'components/ReciterDropdown';
1616
import SurahsDropdown from 'components/SurahsDropdown';
1717
import VersesDropdown from 'components/VersesDropdown';
1818
import FontSizeDropdown from 'components/FontSizeDropdown';
19+
import TooltipDropdown from 'components/TooltipDropdown';
1920
import InformationToggle from 'components/InformationToggle';
2021
import SurahInfo from 'components/SurahInfo';
2122
import Header from './Header';
@@ -186,18 +187,6 @@ export default class Surah extends Component {
186187
return loadAyahs(surah.id, from, to, Object.assign({}, options, payload));
187188
}
188189

189-
handleFontSizeChange = (payload) => {
190-
const { setOption } = this.props; // eslint-disable-line no-shadow
191-
192-
return setOption(payload);
193-
}
194-
195-
handleSurahInfoToggle = (payload) => {
196-
const { setOption } = this.props; // eslint-disable-line no-shadow
197-
198-
return setOption(payload);
199-
}
200-
201190
handleNavbar = () => {
202191
// TODO: This should be done with react!
203192
if (window.pageYOffset > lastScroll) {
@@ -338,19 +327,20 @@ export default class Surah extends Component {
338327
}
339328

340329
renderAyahs() {
341-
const { ayahs, setCurrentWord } = this.props; // eslint-disable-line no-shadow
330+
const { ayahs, setCurrentWord, options } = this.props; // eslint-disable-line no-shadow
342331

343332
return Object.values(ayahs).map(ayah => (
344333
<Ayah
345334
ayah={ayah}
335+
tooltip={options.tooltip}
346336
onWordClick={setCurrentWord}
347337
key={`${ayah.surahId}-${ayah.ayahNum}-ayah`}
348338
/>
349339
));
350340
}
351341

352342
renderLines() {
353-
const { lines } = this.props;
343+
const { lines, options } = this.props;
354344
const keys = Object.keys(lines);
355345

356346
return keys.map((lineNum, index) => {
@@ -360,33 +350,45 @@ export default class Surah extends Component {
360350

361351
if (index + 1 !== keys.length && pageNum !== nextNum.split('-')[0]) {
362352
return [
363-
<Line line={line} key={lineNum} />,
353+
<Line line={line} key={lineNum} tooltip={options.tooltip} />,
364354
<PageBreak pageNum={parseInt(pageNum, 10) + 1} />
365355
];
366356
}
367357

368-
return <Line line={line} key={lineNum} />;
358+
return <Line line={line} key={lineNum} tooltip={options.tooltip} />;
369359
});
370360
}
371361

372362
renderTopOptions() {
373-
const { toggleReadingMode, options, surah } = this.props; // eslint-disable-line no-shadow
363+
const {
364+
toggleReadingMode, // eslint-disable-line no-shadow
365+
options,
366+
surah,
367+
setOption // eslint-disable-line no-shadow
368+
} = this.props;
374369

375370
return (
376371
<Row>
377372
<Col md={6} mdOffset={6} className="text-right">
378373
<ul className="list-inline">
379374
<li>
380375
<InformationToggle
381-
onToggle={this.handleSurahInfoToggle}
376+
onToggle={setOption}
382377
isShowingSurahInfo={options.isShowingSurahInfo}
383378
/>
384379
</li>
385380
<li>|</li>
386381
<li>
387382
<FontSizeDropdown
388383
options={options}
389-
onOptionChange={this.handleFontSizeChange}
384+
onOptionChange={setOption}
385+
/>
386+
</li>
387+
<li>|</li>
388+
<li>
389+
<TooltipDropdown
390+
options={options}
391+
onOptionChange={setOption}
390392
/>
391393
</li>
392394
<li>|</li>

src/redux/modules/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const initialState = {
99
audio: 8,
1010
quran: 1,
1111
content: [19],
12+
tooltip: 'translation',
1213
fontSize: {
1314
arabic: 3.5,
1415
translation: 2

0 commit comments

Comments
 (0)