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
Show all changes
36 commits
Select commit Hold shift + click to select a range
1faeb76
initial commit
mmahalwy Jul 25, 2018
4b69a52
initial commit2
mmahalwy Jul 25, 2018
f50353d
more changes
mmahalwy Jul 27, 2018
7e1552f
deps
mmahalwy Jul 27, 2018
d71ff5e
remove uneeded files
mmahalwy Jul 27, 2018
c7793ee
audioplayer working
mmahalwy Aug 2, 2018
439e959
more work
mmahalwy Aug 7, 2018
e21e141
many great updates
mmahalwy Aug 9, 2018
251d2b3
more changes
mmahalwy Aug 10, 2018
32d97ce
doing great
mmahalwy Aug 10, 2018
a08fbfc
improve circle
mmahalwy Aug 10, 2018
923c36c
work
mmahalwy Aug 10, 2018
0b7a4bc
make verse happy
mmahalwy Aug 10, 2018
ee928ba
tsc
mmahalwy Aug 10, 2018
5cc0b9e
Tests, changes and additions
mmahalwy Aug 13, 2018
fa2ab4b
added many tests
mmahalwy Aug 29, 2018
cbbcc64
fixed all ts problems
mmahalwy Aug 29, 2018
bda58b0
fix tests
mmahalwy Aug 30, 2018
f42c4e7
fix tests
mmahalwy Aug 30, 2018
d81bbe5
Remove classNames
mmahalwy Aug 30, 2018
203888b
jobs 1
mmahalwy Aug 30, 2018
44b8107
make precommit work
mmahalwy Aug 30, 2018
000f4ce
separate helmet for chapter
mmahalwy Aug 30, 2018
8f3c11f
decrease size further
mmahalwy Aug 30, 2018
805eb8e
fix bundle size
mmahalwy Aug 30, 2018
6a0c104
update
mmahalwy Aug 30, 2018
b6f0f5e
decrease bundle size drastically
mmahalwy Aug 30, 2018
57cd326
fixes https://github.com/quran/quran.com-frontend/issues/990
mmahalwy Aug 30, 2018
3f95eeb
Remove home from bundle check
mmahalwy Aug 30, 2018
4bf690b
remove jobs
mmahalwy Aug 30, 2018
d7a9b6d
wrote docs
mmahalwy Aug 30, 2018
cd35ff0
more docs
mmahalwy Aug 30, 2018
6ffb2de
work jest
mmahalwy Aug 30, 2018
f95a0c3
change config
mmahalwy Aug 30, 2018
a141f8a
change config
mmahalwy Aug 30, 2018
b16ea42
change config
mmahalwy Aug 30, 2018
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
separate helmet for chapter
  • Loading branch information
mmahalwy committed Aug 30, 2018
commit 000f4ce4f7e097c8dfad1640b6c4dd5642f4fc87
11 changes: 8 additions & 3 deletions src/components/AyatulKursi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import { NUMBER_OF_CHAPTERS } from '../constants';
import AudioplayerContainer from '../containers/AudioplayerContainer';
import ChapterInfoPanelContainer from '../containers/ChapterInfoPanelContainer';

const title = 'Ayatul Kursi';
const description =
'Ayatul Kursi is verse 255 of the second chapter, ' +
'Surah al-Baqarah (The Chapter of the Cow), in the ' +
'Holy Quran. It is also known as the Throne Verse.';

const propTypes = {
chapter: ChapterShape.isRequired,
chapters: PropTypes.objectOf(ChapterShape).isRequired,
Expand Down Expand Up @@ -157,9 +163,8 @@ class AyatulKursi extends Component<Props> {
<Fragment>
<Helmet
{...makeHelmetTags({
// TODO: add this
// title: this.getTitle(),
// description: this.getDescription(),
title,
description,
})}
script={chapterLdJson(chapter)}
style={[
Expand Down
28 changes: 9 additions & 19 deletions src/components/Chapter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import qs from 'qs';
import last from 'lodash/last';
import isEmpty from 'lodash/isEmpty';
Expand All @@ -13,8 +12,6 @@ import {
LineShape,
ChapterInfoShape,
} from '../shapes';
import makeHelmetTags from '../helpers/makeHelmetTags';
import { chapterLdJson } from '../helpers/ldJson';
import { determinePage } from '../helpers/determinePage';
import PageContainer from './dls/PageContainer';
import Bismillah from './Bismillah';
Expand All @@ -29,6 +26,7 @@ import { FetchChapterInfo } from '../redux/actions/chapterInfos';
import { NUMBER_OF_CHAPTERS } from '../constants';
import AudioplayerContainer from '../containers/AudioplayerContainer';
import ChapterInfoPanelContainer from '../containers/ChapterInfoPanelContainer';
import ChapterHelmet from './chapter/ChapterHelmet';

const propTypes = {
chapter: ChapterShape.isRequired,
Expand Down Expand Up @@ -209,11 +207,13 @@ class Chapter extends Component<Props> {
render() {
const {
chapter,
chapterInfo,
verses,
lines,
settings,
match,
isVersesLoading,
match: { params },
} = this.props;

const versesArray = Object.values(verses);
Expand All @@ -229,22 +229,12 @@ class Chapter extends Component<Props> {

return (
<Fragment>
<Helmet
{...makeHelmetTags({
// TODO: add this
// title: this.getTitle(),
// description: this.getDescription(),
})}
script={chapterLdJson(chapter)}
style={[
{
cssText: `.text-arabic{font-size: ${
settings.fontSize.arabic
}rem;} .text-translation{font-size: ${
settings.fontSize.translation
}rem;}`,
},
]}
<ChapterHelmet
chapter={chapter}
chapterInfo={chapterInfo}
settings={settings}
verses={verses}
params={params}
/>
<PageContainer className="container-fluid">
<div className="row">
Expand Down
109 changes: 109 additions & 0 deletions src/components/chapter/ChapterHelmet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import makeHelmetTags from '../../helpers/makeHelmetTags';
import { chapterLdJson } from '../../helpers/ldJson';
import {
ChapterShape,
ChapterInfoShape,
VerseShape,
SettingsShape,
} from '../../shapes';

const makeTitle = ({
chapter,
params,
}: {
chapter: ChapterShape;
params: $TsFixMe;
}) => {
if (params.range) {
return `Surah ${chapter.nameSimple} [${chapter.chapterNumber}:${
params.range
}]`;
}

return `Surah ${chapter.nameSimple} [${chapter.chapterNumber}] - ${
chapter.translatedName.name
}`;
};

const makeDescription = ({
chapter,
verses,
chapterInfo,
params,
}: {
chapter: ChapterShape;
chapterInfo: ChapterInfoShape;
verses: { [verseKey: string]: VerseShape };
params: $TsFixMe;
}) => {
if (params.range) {
if (params.range.includes('-')) {
return `Surah ${chapter.nameSimple} [verse ${params.range}]`;
}

const verse = verses[`${chapter.chapterNumber}:${params.range}`];

if (verse && verse.translations && verse.translations[0]) {
return `Surah ${chapter.nameSimple} [verse ${params.range}] - ${
verse.translations[0].text
}`;
}

return `Surah ${chapter.nameSimple} [verse ${params.range}]`;
}

return `${chapterInfo ? chapterInfo.shortText : ''} This Surah has ${
chapter.versesCount
} ayah and resides between pages ${chapter.pages[0]} to ${
chapter.pages[1]
} in the Holly Quran.`;
};

const propTypes = {
chapter: ChapterShape.isRequired,
chapterInfo: ChapterInfoShape.isRequired,
settings: SettingsShape.isRequired,
verses: PropTypes.objectOf(VerseShape).isRequired,
params: PropTypes.object.isRequired,
};

type Props = {
chapter: ChapterShape;
chapterInfo: ChapterInfoShape;
settings: SettingsShape;
verses: { [verseKey: string]: VerseShape };
params: $TsFixMe;
};

const ChapterHelmet: React.SFC<Props> = ({
chapter,
settings,
chapterInfo,
verses,
params,
}: Props) => (
<Helmet
{...makeHelmetTags({
// TODO: add this
title: makeTitle({ chapter, params }),
description: makeDescription({ chapter, chapterInfo, verses, params }),
})}
script={chapterLdJson(chapter)}
style={[
{
cssText: `.text-arabic{font-size: ${
settings.fontSize.arabic
}rem;} .text-translation{font-size: ${
settings.fontSize.translation
}rem;}`,
},
]}
/>
);

ChapterHelmet.propTypes = propTypes;

export default ChapterHelmet;