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
Prev Previous commit
Next Next commit
ui
  • Loading branch information
mmahalwy committed Jul 10, 2016
commit c78bbafba193728f81fad3d2eb4a6044abe59a72
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"raven": "^0.11.0",
"raw-loader": "^0.5.1",
"react": "^0.14.8",
"react-bootstrap": "^0.28.4",
"react-bootstrap": "^0.29.5",
"react-cookie": "^0.3.4",
"react-dom": "^0.14.0",
"react-helmet": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import Popover from 'react-bootstrap/lib/Popover';
import Nav from 'react-bootstrap/lib/Nav';
import NavItem from 'react-bootstrap/lib/NavItem';
import FormControl from 'react-bootstrap/lib/FormControl';
import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col';

Expand Down Expand Up @@ -64,10 +65,11 @@ export default class RepeatButton extends Component {

return (
<Col md={12} style={{paddingTop: 15}}>
<ul className="list-inline">
From - To: <br />
<ul className="list-inline" style={{marginBottom: 0}}>
<li>
<select
className="form-control"
<FormControl
componentClass="select"
value={repeat.from}
onChange={(event) => setRepeat({
...repeat,
Expand All @@ -82,12 +84,12 @@ export default class RepeatButton extends Component {
</option>
))
}
</select>
</FormControl>
</li>
<li> - </li>
<li>
<select
className="form-control"
<FormControl
componentClass="select"
value={repeat.to}
onChange={(event) => setRepeat({ ...repeat, to: parseInt(event.target.value, 10)})}
>
Expand All @@ -98,21 +100,37 @@ export default class RepeatButton extends Component {
</option>
))
}
</select>
</FormControl>
</li>
</ul>
</Col>
);
}

renderSingleAyah() {
const { current } = this.props;
const { repeat, setRepeat, surah } = this.props;
const array = Array(surah.ayat).join().split(',');

return (
<Col md={12}>
<h5>
Repeating Ayah: {current}
</h5>
<Col md={12} style={{paddingTop: 15}}>
Ayah: <br />
Copy link
Contributor

@thabti thabti Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: place Ayah in a <p> tag

<FormControl
componentClass="select"
value={repeat.from}
onChange={(event) => setRepeat({
...repeat,
from: parseInt(event.target.value, 10),
to: parseInt(event.target.value, 10)
})}
>
{
array.map((ayah, index) => (
<option key={index} value={index + 1}>
{index + 1}
</option>
))
}
</FormControl>
</Col>
);
}
Expand All @@ -129,7 +147,7 @@ export default class RepeatButton extends Component {
onSelect={this.handleNavChange}
>
<NavItem eventKey={1} title="Single Ayah" className={style.pill}>
Single Ayah
Single
</NavItem>
<NavItem eventKey={2} title="Range" className={style.pill}>
Range
Expand All @@ -141,7 +159,8 @@ export default class RepeatButton extends Component {
}

render() {
const { repeat } = this.props;
const { repeat, setRepeat } = this.props;
const times = Array(10).join().split(',');

const popover = (
<Popover
Expand All @@ -162,9 +181,33 @@ export default class RepeatButton extends Component {
}
>
{this.renderOptions()}
<Row>
<Row className={!repeat.from && style.disabled}>
{this.state.nav === 1 ? this.renderSingleAyah() : this.renderRangeAyahs()}
</Row>
<Row className={!repeat.from && style.disabled}>
<Col md={12} style={{paddingTop: 15}}>
Times: <br />
<FormControl
componentClass="select"
value={repeat.times}
onChange={(event) => setRepeat({
...repeat,
times: parseInt(event.target.value, 10)
})}
>
<option value={null}>
Loop
</option>
{
times.map((ayah, index) => (
<option key={index} value={index + 1}>
{index + 1}
</option>
))
}
</FormControl>
</Col>
</Row>
</Popover>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
import React from 'react';
import { mount } from 'enzyme';

import RepeatButton from './index';
import RepeatDropdown from './index';

let makeComponent, component, onRepeatToggle;
let makeComponent, component, setRepeat;
const surah = {
ayat: 10
};

describe('<RepeatButton />', () => {
describe('<RepeatDropdown />', () => {
beforeEach(() => {
makeComponent = (shouldRepeat) => {
onRepeatToggle = sinon.stub();
makeComponent = (repeat) => {
setRepeat = sinon.stub();

component = mount(
<RepeatButton shouldRepeat={shouldRepeat} onRepeatToggle={onRepeatToggle} />
<RepeatDropdown
repeat={repeat}
setRepeat={setRepeat}
current={1}
surah={surah}
/>
);
}
});

it('should indicate that shouldRepeat', () => {
makeComponent(true);
it('should indicate repeating', () => {
makeComponent({from: 1, to: 10});

expect(component.find('label').first().props().className).to.contain('repeat');
});

it('should not indicate that shouldRepeat', () => {
makeComponent(false);
makeComponent({});

expect(component.find('label').first().props().className).not.to.contain('repeat');
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/Audioplayer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import Track from './Track';
import Segments from './Segments';
import ScrollButton from './ScrollButton';
import RepeatButton from './RepeatButton';
import RepeatDropdown from './RepeatDropdown';

// Helpers
import debug from '../../helpers/debug';
Expand Down Expand Up @@ -400,7 +400,7 @@ export default class Audioplayer extends Component {
{this.renderNextButton()}
</li>
<li>
<RepeatButton
<RepeatDropdown
repeat={repeat}
setRepeat={setRepeat}
current={parseInt(currentAyah.split(':')[1], 10)}
Expand Down