-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1928 from Sefaria/feature/sc-26953/frontend-for-s…
…heets-topics-component Feature/sc 26953/frontend for sheets topics component
- Loading branch information
Showing
8 changed files
with
233 additions
and
36 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
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
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,58 @@ | ||
import React, {useEffect, useState} from "react"; | ||
import Sefaria from "../sefaria/sefaria"; | ||
import {Card} from "../shared/Card"; | ||
const SheetsTopicsTOC = ({handleClick}) => { | ||
const categoryListings = Sefaria.topic_toc.map(cat => { | ||
return <Card cardTitleHref={`/topics/category/${cat.slug}`} | ||
cardTitle={cat} | ||
cardText={cat.categoryDescription} | ||
oncardTitleClick={(e) => handleClick(e, cat.slug, cat.en, cat.he)}/>; | ||
}); | ||
return ( | ||
<div className="sheetsTopicTOC"> | ||
<SheetsWrapper title="Browse by Topic">{categoryListings}</SheetsWrapper> | ||
</div> | ||
); | ||
} | ||
|
||
const SheetsWrapper = ({title, children}) => { | ||
return <div className="sheetsWrapper table"> | ||
<div className="sheetsHomepageSectionTitle">{title}</div> | ||
{children} | ||
</div> | ||
} | ||
|
||
const SheetsParashah = ({handleClick}) => { | ||
const [parashah, setParashah] = useState({}); | ||
useEffect(() => { | ||
Sefaria.getUpcomingDay('parasha').then(setParashah); | ||
}, []); | ||
const parashahTitle = parashah.displayValue; | ||
const parashahDesc = parashah.description; | ||
return <Card cardTitleHref={`/topics/${parashah.topic}`} | ||
cardTitle={parashahTitle} | ||
cardText={parashahDesc} | ||
oncardTitleClick={(e) => handleClick(e, parashah.topic, parashahTitle.en, parashahTitle.he)}/>; | ||
} | ||
|
||
const SheetsHoliday = ({handleClick}) => { | ||
const [holiday, setHoliday] = useState({}); | ||
useEffect( () => { | ||
Sefaria.getUpcomingDay('holiday').then(setHoliday); | ||
}, []); | ||
if (Object.keys(holiday).length === 0) { | ||
return <div className="navBlock">Loading...</div> | ||
} | ||
return <Card cardTitleHref={`/topics/${holiday.slug}`} | ||
cardTitle={holiday.primaryTitle} | ||
cardText={holiday.description} | ||
oncardTitleClick={(e) => handleClick(e, holiday.slug, holiday.primaryTitle.en, holiday.primaryTitle.he)}/>; | ||
} | ||
const SheetsTopicsCalendar = ({handleClick}) => { | ||
return <div className="sheetsTopicsCalendar table"> | ||
<SheetsWrapper title="This Week's Torah Portion"><SheetsParashah handleClick={handleClick}/></SheetsWrapper> | ||
<SheetsWrapper title="Upcoming Holiday"><SheetsHoliday handleClick={handleClick}/></SheetsWrapper> | ||
</div> | ||
} | ||
|
||
export { SheetsTopicsCalendar, SheetsTopicsTOC } |