Skip to content

Commit 716a42a

Browse files
authored
Merge pull request #17 from texttree/develop
Develop
2 parents 801824e + b06c22a commit 716a42a

17 files changed

Lines changed: 252 additions & 205 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
### demo-bsa-reference-rcl
1+
### @texttree/tt-reference-rcl
22

3-
### This is the component library used in the project BSA.
3+
This library of components was made as part of the development of the Bible Study App and helps to display books and chapters from the books of the Bible.
4+
5+
![Book example](/images/1.png)
6+
7+
![Chapter example](/images/2.png)

images/1.png

41.8 KB
Loading

images/2.png

50.6 KB
Loading

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "@texttree/demo-bsa-reference-rcl",
2+
"name": "@texttree/tt-reference-rcl",
33
"version": "0.3.4",
44
"main": "dist/index.js",
55
"license": "MIT",
6-
"url": "https://github.com/gecraft/demo-bsa-reference-rcl",
6+
"url": "https://github.com/texttree/tt-reference-rcl",
77
"scripts": {
88
"start": "styleguidist server",
99
"build": "styleguidist build",
@@ -31,11 +31,11 @@
3131
"description": "",
3232
"repository": {
3333
"type": "git",
34-
"url": "git+https://github.com/gecraft/tt-reference-rcl.git"
34+
"url": "git+https://github.com/texttree/tt-reference-rcl.git"
3535
},
3636
"author": "",
3737
"bugs": {
38-
"url": "https://github.com/gecraft/tt-reference-rcl/issues"
38+
"url": "https://github.com/texttree/tt-reference-rcl/issues"
3939
},
40-
"homepage": "https://github.com/gecraft/tt-reference-rcl#readme"
40+
"homepage": "https://github.com/texttree/tt-reference-rcl#readme"
4141
}

src/components/BibleBookList/BibleBookList.js

Lines changed: 28 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function BibleBookList({
1818
BibleBookListClasses,
1919
bookClasses,
2020
testaments,
21-
showTitle,
2221
sortFirstNT,
2322
}) {
2423
const [checkState, setCheckState] = useState(!showInactive);
@@ -99,7 +98,7 @@ function BibleBookList({
9998
{testamentList.map((el, index) => {
10099
return (
101100
<BookList
102-
title={showTitle ? el.title : ''}
101+
title={el.title}
103102
bookList={el.bookList}
104103
showInactive={!checkState}
105104
onClickBook={onClickBook}
@@ -119,71 +118,52 @@ function BibleBookList({
119118
}
120119

121120
BibleBookList.defaultProps = {
122-
showCheckbox: false,
121+
showCheckbox: true,
122+
sortFirstNT: false,
123123
testaments: 'all',
124-
titleOT: 'Old Testament',
125-
titleNT: 'New Testament',
124+
titleOT: '',
125+
titleNT: '',
126126
showInactive: true,
127-
onClickBook: () => {},
127+
onClickBook: (bookId) => {},
128128
labelForCheckbox: 'Show only existing books',
129129
titleBooks: {},
130-
BibleBookListClasses: {},
131130
availableBookList: [],
132131
};
133132

134133
BibleBookList.propTypes = {
135134
testaments: PropTypes.oneOf(['all', 'nt', 'ot']),
136-
/**
137-
* Block header of "New Testament"
138-
*/
135+
/** block header of "New Testament" */
139136
titleNT: PropTypes.string,
140-
/**
141-
* Block header of "New Testament"
142-
*/
137+
/** block header of "Old Testament" */
143138
titleOT: PropTypes.string,
144-
/**
145-
* Show block header
146-
*/
147-
showTitle: PropTypes.bool,
148-
/**
149-
* When true, show first New Testament, second - Old Testament
150-
*/
139+
/** when true, show first New Testament, second - Old Testament */
151140
sortFirstNT: PropTypes.bool,
152-
/**
153-
* Array of existing bookId's
154-
*/
141+
/** array of existing bookId's */
155142
availableBookList: PropTypes.array,
156-
/**
157-
* Array of bookId with the titles to be translated. If not set - get the default value in English
158-
*/
143+
/** Array of bookId with the titles to be translated. If not set - get the default value in English */
159144
titleBooks: PropTypes.object,
160-
/**
161-
* show or hide checkbox that show only existing books
162-
*/
145+
/** show or hide checkbox that show only existing books */
163146
showCheckbox: PropTypes.bool,
164-
/** Whether to display inactive books */
147+
/** whether to display inactive books */
165148
showInactive: PropTypes.bool,
166-
/**
167-
* label of checkbox
168-
*/
149+
/** label of checkbox */
169150
labelForCheckbox: PropTypes.string,
170-
171-
BibleBookListClasses: PropTypes.objectOf(
172-
PropTypes.shape({
173-
/** title className */
174-
title: PropTypes.string,
175-
/** book className */
176-
book: PropTypes.string,
177-
/** bookList className */
178-
bookList: PropTypes.string,
179-
/** className for label of checkbox */
180-
label: PropTypes.string,
181-
})
182-
),
151+
/** object of className */
152+
BibleBookListClasses: PropTypes.shape({
153+
/** title className */
154+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
155+
/** book className */
156+
book: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
157+
/** bookList className */
158+
bookList: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
159+
/** className for label of checkbox */
160+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
161+
}),
162+
/** override the style of the Button mui component */
183163
bookClasses: PropTypes.object,
184-
/** An open book, a different style will be applied to it */
164+
/** an open book, a different style will be applied to it */
185165
selectedBookId: PropTypes.string,
186-
/** Event by clicking on the book. Receives a book ID at the entrance. */
166+
/** Event by clicking on the book. Receives a bookId at the entrance. */
187167
onClickBook: PropTypes.func,
188168
};
189169

src/components/BibleBookList/BibleBookList.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ Show 2 Testaments
22

33
```jsx
44
import React from "react";
5-
import { BibleBookList } from "demo-bsa-reference-rcl";
5+
import { BibleBookList } from "@texttree/tt-reference-rcl";
66

77
const titleBooks = {
8-
mat: "Матфей", mrk: "Марк",
9-
luk: "Лука", tit: "Титу",
8+
mat: "Матфей", mrk: "Марк", luk: "Лука", tit: "Титу",
109
};
1110

1211
const [selectedBookId, setSelectedBookId] = React.useState("exo");
@@ -19,25 +18,23 @@ const availableBookList = [
1918
];
2019

2120
<BibleBookList
22-
titleBooks={titleBooks}
21+
testaments="all"
22+
sortFirstNT={true}
2323
showInactive={false}
24+
titleOT="Old Testament"
25+
titleNT="New Testament"
26+
titleBooks={titleBooks}
2427
availableBookList={availableBookList}
25-
labelForCheckbox="show existing book"
26-
showCheckbox={true}
2728
selectedBookId={selectedBookId}
2829
onClickBook={onClickBook}
29-
testaments="all"
30-
titleOT="Ветхий завет"
31-
showTitle={true}
32-
sortFirstNT={true}
3330
/>;
3431
```
3532

3633
Show 1 Testament
3734

3835
```jsx
3936
import React from "react";
40-
import { BibleBookList } from "demo-bsa-reference-rcl";
37+
import { BibleBookList } from "@texttree/tt-reference-rcl";
4138

4239
const titleBooks = {
4340
mat: "Матфей", mrk: "Марк",
@@ -49,21 +46,21 @@ const availableBookList = [
4946
"mat", "1ko", "rev", "tit",
5047
];
5148

52-
<BibleBookList
53-
titleBooks={titleBooks}
54-
availableBookList={availableBookList}
55-
showCheckbox={true}
49+
<BibleBookList
5650
testaments="ot"
5751
titleOT="OT"
5852
titleNT="NT"
59-
showTitle={true}/>;
53+
showCheckbox={false}
54+
titleBooks={titleBooks}
55+
availableBookList={availableBookList}
56+
/>;
6057
```
6158

6259
Use styles
6360

6461
```jsx
6562
import React from "react";
66-
import { BibleBookList } from "demo-bsa-reference-rcl";
63+
import { BibleBookList } from "@texttree/tt-reference-rcl";
6764
import { makeStyles } from "@material-ui/core/styles";
6865

6966
const useStyles = makeStyles((theme) => ({
@@ -90,12 +87,10 @@ const availableBookList = [
9087
];
9188

9289
<BibleBookList
90+
testaments="ot"
91+
titleOT="Ветхий завет"
9392
availableBookList={availableBookList}
9493
selectedBookId="exo"
9594
BibleBookListClasses={classes}
96-
showCheckbox={true}
97-
testaments="ot"
98-
titleOT="Ветхий завет"
99-
showTitle={true}
10095
/>;
10196
```

src/components/BibleChapterList/BibleChapterList.js

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,51 @@
1-
import React from "react";
2-
import ChapterList from "../ChapterList";
3-
import { ChaptersConfig } from "./config";
4-
import PropTypes from "prop-types";
1+
import React from 'react';
2+
import ChapterList from '../ChapterList';
3+
import { BOOK_CHAPTERS } from './config';
4+
import PropTypes from 'prop-types';
55

66
function BibleChapterList({
7-
text,
7+
chapterPrefix,
88
bookId,
99
chapterListClasses,
1010
chapterClasses,
1111
selectedChapter,
1212
onClickChapter,
13-
1413
}) {
15-
16-
const chapters = bookId?(Object.keys(ChaptersConfig[bookId])):[];
14+
const chapters = bookId ? Object.keys(BOOK_CHAPTERS[bookId]) : [];
1715

1816
return (
19-
<ChapterList
20-
text={text}
21-
chapterListClasses={chapterListClasses}
22-
chapterClasses={chapterClasses}
23-
selectedChapter={selectedChapter}
24-
chapterList={chapters}
25-
onClickChapter={onClickChapter}
26-
/>
17+
<ChapterList
18+
chapterPrefix={chapterPrefix}
19+
chapterListClasses={chapterListClasses}
20+
chapterClasses={chapterClasses}
21+
selectedChapter={selectedChapter}
22+
chapterList={chapters}
23+
onClickChapter={onClickChapter}
24+
/>
2725
);
2826
}
2927

3028
BibleChapterList.defaultProps = {
31-
chapterListClasses: {},
3229
onClickChapter: (chapterId) => {},
3330
};
3431

3532
BibleChapterList.propTypes = {
36-
/** chapter's title */
37-
text: PropTypes.string,
38-
/** bookId*/
39-
bookId: PropTypes.string,
40-
chapterListClasses: PropTypes.objectOf(
41-
PropTypes.shape({
42-
/** chapter className */
43-
chapter: PropTypes.string,
44-
/** chapterList className */
45-
chapterList: PropTypes.string,
46-
})
47-
),
33+
/** chapter prefix (chapter, psalm, etc. ) */
34+
chapterPrefix: PropTypes.string,
35+
/** unique three-letter identifier of book from which the chapters are shown */
36+
bookId: PropTypes.string.isRequired,
37+
/** object of className */
38+
chapterListClasses: PropTypes.shape({
39+
/** chapter className */
40+
chapter: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
41+
/** chapterList className */
42+
chapterList: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
43+
}),
44+
/** override the style of the Button mui component */
4845
chapterClasses: PropTypes.object,
49-
/** An open chapter, a different style will be applied to it */
50-
selectedChapter: PropTypes.string,
46+
/** an open chapter, a different style will be applied to it */
47+
selectedChapter: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
48+
.isRequired,
5149
/** Event by clicking on the chapter. Receives a chapter ID at the entrance. */
5250
onClickChapter: PropTypes.func,
5351
};

src/components/BibleChapterList/BibleChapterList.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
Array of buttons - selected current chapter
1+
Show chapters from a specific book
22

33
```jsx
44
import React from "react";
5-
import { BibleChapterList } from "demo-bsa-reference-rcl";
5+
import { BibleChapterList } from "@texttree/tt-reference-rcl";
66
import { makeStyles } from "@material-ui/core/styles";
77

88
const useStyles = makeStyles((theme) => ({
99
chapterList: {
1010
margin: theme.spacing(1),
1111
},
12+
chapter: {
13+
margin: 2,
14+
padding: 2,
15+
fontSize: 12,
16+
width:72,
17+
textTransform:"inherit",
18+
border:"1px solid #ccc",
19+
},
1220
}));
21+
1322
const classes = useStyles();
23+
24+
const [selectedChapter, setSelectedChapter] = React.useState(1);
25+
1426
<BibleChapterList
15-
selectedChapter="3"
16-
bookId="gen"
17-
text="Ch."
27+
selectedChapter={selectedChapter}
28+
bookId="psa"
29+
chapterPrefix="Psalm"
1830
onClickChapter={(chapterId) => {
19-
alert("chapterId " + chapterId);
31+
setSelectedChapter(chapterId);
2032
}}
2133
chapterListClasses={classes}
2234
/>;

src/components/BibleChapterList/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const ChaptersConfig = {
1+
export const BOOK_CHAPTERS = {
22
gen: {
33
'1': '31',
44
'2': '25',

0 commit comments

Comments
 (0)