Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
moved topoptions to navbar drawer
  • Loading branch information
mmahalwy committed Jan 17, 2017
commit 85f3fca5fbbaf8ebdc0d7f5271344899aedb716e
29 changes: 14 additions & 15 deletions src/components/Ayah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Ayah extends Component {
<h4 className="montserrat">{content.name || content.resource.name}</h4>
<h2 className={`${isArabic ? 'text-right' : 'text-left'} text-translation times-new`}>
<small
dangerouslySetInnerHTML={{__html: content.text}}
dangerouslySetInnerHTML={{ __html: content.text }}
className={`${lang || 'times-new'}`}
/>
</h2>
Expand Down Expand Up @@ -148,20 +148,19 @@ export default class Ayah extends Component {
}

renderText() {
const { ayah, tooltip, currentAyah, isPlaying, audioActions, isSearched} = this.props;

const text = ayah.words.map(word => {
return(
<Word
word={word}
currentAyah={currentAyah}
tooltip={tooltip}
isPlaying={isPlaying}
audioActions={audioActions}
isSearched={isSearched}
/>
)
});
const { ayah, tooltip, currentAyah, isPlaying, audioActions, isSearched } = this.props;

const text = ayah.words.map(word => (
<Word
word={word}
key={`${word.position}-${word.code}-${word.lineNum}`}
currentAyah={currentAyah}
tooltip={tooltip}
isPlaying={isPlaying}
audioActions={audioActions}
isSearched={isSearched}
/>
));

return (
<h1 className={`${styles.font} text-right text-arabic`}>
Expand Down
13 changes: 4 additions & 9 deletions src/components/ContentDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { Component, PropTypes } from 'react';
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
import MenuItem from 'react-bootstrap/lib/MenuItem';
import LocaleFormattedMessage from 'components/LocaleFormattedMessage';
import { optionsType } from 'types';

const style = require('./style.scss');

Expand Down Expand Up @@ -450,26 +449,22 @@ export const slugs = [
export default class ContentDropdown extends Component {
static propTypes = {
onOptionChange: PropTypes.func.isRequired,
options: optionsType.isRequired,
content: PropTypes.arrayOf(PropTypes.number).isRequired,
className: PropTypes.string
};

static defaultProps = {
className: 'col-md-3'
}

shouldComponentUpdate(nextProps) {
return this.props.options !== nextProps.options;
}

handleRemoveContent = () => {
const { onOptionChange } = this.props;

onOptionChange({ content: [] });
}

handleOptionSelected(id) {
const { onOptionChange, options: { content } } = this.props;
const { onOptionChange, content } = this.props;

if (content.find(option => option === id)) {
onOptionChange({ content: content.filter(option => option !== id) });
Expand All @@ -479,7 +474,7 @@ export default class ContentDropdown extends Component {
}

renderItems(items) {
const { options: { content } } = this.props;
const { content } = this.props;

return items.map((slug) => {
const checked = content.find(option => option === slug.id);
Expand Down Expand Up @@ -515,7 +510,7 @@ export default class ContentDropdown extends Component {
}

render() {
const { className, options: { content } } = this.props;
const { className, content } = this.props;

return (
<DropdownButton
Expand Down
28 changes: 15 additions & 13 deletions src/components/FontSizeDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ import Col from 'react-bootstrap/lib/Col';

import LocaleFormattedMessage from 'components/LocaleFormattedMessage';

import { optionsType } from 'types';

const style = require('./style.scss');

export default class FontSizeDropdown extends Component {
static propTypes = {
onOptionChange: PropTypes.func,
options: optionsType
fontSize: PropTypes.shape({
arabic: PropTypes.number,
translation: PropTypes.number
}).isRequired
}

handleOptionSelected = (type, direction) => {
const { onOptionChange, options: { fontSize } } = this.props;
const { onOptionChange, fontSize } = this.props;
const changeFactor = {
translation: 0.5,
arabic: 0.5
Expand Down Expand Up @@ -94,15 +95,16 @@ export default class FontSizeDropdown extends Component {

render() {
return (
<OverlayTrigger trigger="click" placement="bottom" overlay={this.renderPopup()} rootClose>
<a
tabIndex="-1"
className="text-color"
data-metrics-event-name="FontSizeDropdown"
>
<LocaleFormattedMessage id="setting.fontSize" defaultMessage="Font size" />
</a>
</OverlayTrigger>
<div className={style.link}>
<OverlayTrigger trigger="click" placement="bottom" overlay={this.renderPopup()} rootClose container={this} positionLeft={0}>
<a
tabIndex="-1"
data-metrics-event-name="FontSizeDropdown"
>
<LocaleFormattedMessage id="setting.fontSize" defaultMessage="Font size" />
</a>
</OverlayTrigger>
</div>
);
}
}
8 changes: 7 additions & 1 deletion src/components/FontSizeDropdown/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import '../../styles/variables.scss';

:local .popover{
.popover{
:global(.popover-title){
font-family: $font-montserrat;
text-transform: uppercase;
Expand All @@ -16,3 +16,9 @@
}
}
}

.link{
position: relative;
display: block;
cursor: pointer;
}
5 changes: 3 additions & 2 deletions src/components/Home/LastVisit/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { PropTypes } from 'react';
import debug from 'helpers/debug';
import Link from 'react-router/lib/Link';
import { surahType } from 'types';
import LocaleFormattedMessage from 'components/LocaleFormattedMessage';

const styles = require('containers/Home/style.scss');
Expand All @@ -10,7 +11,7 @@ const LastVisit = (props) => {
return (
<div>
<h4 className={`text-muted ${styles.title}`}>
<LocaleFormattedMessage id='surah.index.continue' defaultMessage={'Continue'}/>
<LocaleFormattedMessage id="surah.index.continue" defaultMessage="Continue" />
<Link to={`/${props.surah.id}/${props.ayah}`}>
<span>
{props.surah.name.simple} ({props.surah.id}:{props.ayah})
Expand All @@ -22,7 +23,7 @@ const LastVisit = (props) => {
};

LastVisit.propTypes = {
surah: PropTypes.object.isRequired,
surah: surahType.isRequired,
ayah: PropTypes.number.isRequired
};

Expand Down
46 changes: 18 additions & 28 deletions src/components/InformationToggle/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
import React, { Component, PropTypes } from 'react';
import React, { PropTypes } from 'react';

import SwitchToggle from 'components/SwitchToggle';
import LocaleFormattedMessage from 'components/LocaleFormattedMessage';

export default class InformationToggle extends Component {
static propTypes = {
isShowingSurahInfo: PropTypes.bool.isRequired,
onToggle: PropTypes.func.isRequired
};
const InformationToggle = ({ isShowingSurahInfo, onToggle }) => (
<div>
<LocaleFormattedMessage id="surah.info" defaultMessage="Surah Info" />
<SwitchToggle
checked={isShowingSurahInfo}
onToggle={() => onToggle({ isShowingSurahInfo: !isShowingSurahInfo })}
id="info-toggle"
flat
/>
</div>
);

toggleInformationMode = (event) => {
const { isShowingSurahInfo } = this.props;
InformationToggle.propTypes = {
isShowingSurahInfo: PropTypes.bool.isRequired,
onToggle: PropTypes.func.isRequired
};

event.preventDefault();

this.props.onToggle({ isShowingSurahInfo: !isShowingSurahInfo });
};

render() {
const { isShowingSurahInfo } = this.props;

return (
<a
tabIndex="-1"
title="See information for this surah"
className={`${isShowingSurahInfo ? ' text-primary' : 'text-color'} pointer`}
onClick={this.toggleInformationMode}
>
<LocaleFormattedMessage id="surah.info" defaultMessage="Surah Info" />
</a>
);
}
}
export default InformationToggle;
25 changes: 17 additions & 8 deletions src/components/Line/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ export default class Line extends React.Component {
line: PropTypes.arrayOf(wordType).isRequired,
tooltip: PropTypes.string,
currentAyah: PropTypes.string.isRequired,
audioActions: PropTypes.object.isRequired,
currentWord: PropTypes.any,
audioActions: PropTypes.shape({
pause: PropTypes.func.isRequired,
setAyah: PropTypes.func.isRequired,
play: PropTypes.func.isRequired,
setCurrentWord: PropTypes.func.isRequired,
}),
isPlaying: PropTypes.bool
};

Expand All @@ -29,11 +33,16 @@ export default class Line extends React.Component {
renderText() {
const { tooltip, currentAyah, audioActions, isPlaying, line } = this.props;

const text = line.map(word => {
return (
<Word word={word} currentAyah={currentAyah} tooltip={tooltip} isPlaying={isPlaying} audioActions={audioActions}/>
)
});
const text = line.map(word => (
<Word
word={word}
key={`${word.position}-${word.code}-${word.lineNum}`}
currentAyah={currentAyah}
tooltip={tooltip}
isPlaying={isPlaying}
audioActions={audioActions}
/>
));

return (
<span className={`${styles.line} text-center`}>
Expand All @@ -52,7 +61,7 @@ export default class Line extends React.Component {

return (
<div className={`row ${styles.font} text-justify text-arabic`}>
<div className="col-md-12 line-container" name={`ayah:${line[0].ayahKey}`}>
<div className="col-md-12 line-container" name={`ayah:${line[0].ayahKey}`}>
{this.renderText()}
</div>
</div>
Expand Down
33 changes: 9 additions & 24 deletions src/components/NightModeToggle/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
/* global document */
import React, { Component } from 'react';
import { intlShape, injectIntl } from 'react-intl';

import LocaleFormattedMessage from 'components/LocaleFormattedMessage';
import SwitchToggle from 'components/SwitchToggle';

import bindTooltip from 'utils/bindTooltip';

class NightModeToggle extends Component {
static propTypes = {
intl: intlShape.isRequired
};

state = {
isNightMode: false,
};
Expand All @@ -26,29 +22,18 @@ class NightModeToggle extends Component {
}

render() {
const { intl } = this.props;

const title = intl.formatMessage({
id: this.state.isNightMode ? 'setting.nightMode.dayTip' : 'setting.nightMode.nightTip',
defaultMessage: this.state.isNightMode ? 'Switch to day mode' : 'switch to night mode'
});

return (
<div>
<a
tabIndex="-1"
title={title}
rel="tooltip"
className={`${this.state.isNightMode ? 'text-primary' : 'text-color'} pointer`}
onClick={this.toggleNightMode}
>
<LocaleFormattedMessage id="setting.nightMode" defaultMessage="Night Mode" />
: {' '}
<i className="ss-icon ss-lightbulb" />
</a>
<LocaleFormattedMessage id="setting.nightMode" defaultMessage="Night Mode" />
<SwitchToggle
checked={this.state.isNightMode}
onToggle={this.toggleNightMode}
id="night-mode-toggle"
flat
/>
</div>
);
}
}

export default injectIntl(NightModeToggle);
export default NightModeToggle;
2 changes: 1 addition & 1 deletion src/components/ReadingModeToggle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import LocaleFormattedMessage from 'components/LocaleFormattedMessage';

const ReadingModeToggle = ({ onReadingModeToggle, isToggled }) => (
<div>
<LocaleFormattedMessage id="setting.reading" defaultMessage="Reading" />:{' '}
<LocaleFormattedMessage id="setting.reading" defaultMessage="Reading" />
<SwitchToggle
checked={isToggled}
onToggle={onReadingModeToggle}
Expand Down
10 changes: 3 additions & 7 deletions src/components/ReciterDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import DropdownButton from 'react-bootstrap/lib/DropdownButton';
import MenuItem from 'react-bootstrap/lib/MenuItem';

import LocaleFormattedMessage from 'components/LocaleFormattedMessage';
import { optionsType } from 'types';

const style = require('./style.scss');

Expand Down Expand Up @@ -194,25 +193,22 @@ export const slugs = [
export default class ReciterDropdown extends Component {
static propTypes = {
onOptionChange: PropTypes.func,
options: optionsType,
audio: PropTypes.number,
className: PropTypes.string
};

static defaultProps = {
className: 'col-md-3'
};

shouldComponentUpdate(nextProps) {
return this.props.options !== nextProps.options;
}

renderMenu() {
const { options, onOptionChange } = this.props;
const { audio, onOptionChange } = this.props;

return slugs.map(slug => (
<MenuItem
key={slug.name.english}
active={slug.id === options.audio}
active={slug.id === audio}
onClick={() => onOptionChange({ audio: slug.id })}
>
{slug.name.english}
Expand Down
Loading