-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
related recitations from the same qari(#59)
- Loading branch information
Showing
11 changed files
with
159 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = function init(sequelize, DataTypes) { | ||
const Related = sequelize.define('related', { | ||
qari: DataTypes.INTEGER, | ||
related: { type: DataTypes.INTEGER, field: 'related', primaryKey: true } | ||
}, { | ||
timestamps: false, | ||
paranoid: true, | ||
underscored: true, | ||
tableName: 'related', | ||
instanceMethods: { | ||
toJSON: function json() { | ||
return { | ||
id: this.related | ||
}; | ||
} | ||
} | ||
|
||
}); | ||
return Related; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { arrayOf } from 'normalizr'; | ||
import { relatedSchema } from 'utils/schemas'; | ||
|
||
export const LOAD = '@@quran/related/LOAD'; | ||
export const LOAD_SUCCESS = '@@quran/related/LOAD_SUCCESS'; | ||
export const LOAD_FAIL = '@@quran/related/LOAD_FAIL'; | ||
|
||
export function load(id) { | ||
return { | ||
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL], | ||
schema: arrayOf(relatedSchema), | ||
promise: (client) => client.get(`/qaris/related/${id}`), | ||
id | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, { PropTypes } from 'react'; | ||
const styles = require('./style.scss'); | ||
import Link from 'react-router/lib/Link'; | ||
const Related = ({related = [], qaris, toggle}) => { | ||
const li = related.map((item, index) => (<li className={styles.item} key={index}><Link className={styles.link} to={`/quran/${qaris[item].id}`}>{qaris[item].name}</Link></li>)); | ||
return ( | ||
<ul className={`${styles.container} ${toggle ? styles.active : ''}`}>{li}</ul> | ||
); | ||
}; | ||
|
||
Related.PropTypes = { | ||
related: PropTypes.array.isRequired, | ||
qaris: PropTypes.any.isRequired | ||
}; | ||
|
||
export default Related; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.container { | ||
list-style: none; | ||
visibility: hidden; | ||
opacity: 0; | ||
transition: height .5s, opacity 0.5s linear; | ||
margin: 0; | ||
height: 0; | ||
position: relative; | ||
top: 10px; | ||
} | ||
|
||
.active { | ||
visibility: visible; | ||
opacity: 1; | ||
margin: 5px; | ||
height: 15px; | ||
|
||
} | ||
|
||
.item { | ||
display: inline-block; | ||
padding-right: 5px; | ||
} | ||
|
||
.link { | ||
color: white; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,5 +79,5 @@ export default asyncConnect([ | |
return dispatch(loadSurahs()); | ||
} | ||
} | ||
}, | ||
} | ||
])(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
LOAD, | ||
LOAD_SUCCESS | ||
} from 'actions/related'; | ||
|
||
const initialState = { | ||
errored: false, | ||
loaded: false, | ||
entities: {} | ||
}; | ||
|
||
export default function reducer(state = initialState, action = {}) { | ||
switch (action.type) { | ||
case LOAD: | ||
return { | ||
...state, | ||
loaded: false, | ||
loading: true | ||
}; | ||
case LOAD_SUCCESS: | ||
return { | ||
...state, | ||
loaded: true, | ||
errored: false, | ||
qaris: action.result.result | ||
}; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters