diff --git a/django_topics/admin.py b/django_topics/admin.py index 6b5106d26e..631a153a4d 100644 --- a/django_topics/admin.py +++ b/django_topics/admin.py @@ -1,6 +1,8 @@ from django.contrib import admin, messages from django_topics.models import Topic, TopicPool, FeaturedTopicEnglish, FeaturedTopicHebrew, SeasonalTopicEnglish, SeasonalTopicHebrew from django_topics.models.pool import PoolType +from django.utils.html import format_html + def create_add_to_pool_action(pool_name): diff --git a/static/css/s2.css b/static/css/s2.css index e65ac8bc8e..ad4e9bf207 100644 --- a/static/css/s2.css +++ b/static/css/s2.css @@ -5218,6 +5218,46 @@ h1.topic-landing-header { .topic-landing-parasha .navSidebarLink span{ font-family: Roboto, sans-serif; } +.topic-card-with-description-row{ + display: flex; + margin-top: 30px; + gap: 20px; +} +.topic-card-with-description .card{ + flex: 1; + border-top: 4px solid var(--sefaria-blue); + background: var(--lightest-grey); + box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25); + width: 268.395px; + height: 345.78px; +} +.topic-card-with-description .cardDescription{ + margin-inline-end: 30px; + margin-inline-start: 30px; + margin-top: 19px; + width: 207.593px; + display: -webkit-box; + -webkit-box-orient: vertical; + overflow-y: hidden; + word-wrap: break-word; +} +.topic-card-with-description .cardTitle { + margin-top: 23px; +} +.topic-card-with-description .bottomCardLink { + font-size: 14px; + line-height: 18px; + color: #666; + margin-inline-end: 20px; + --english-font: var(--english-sans-serif-font-family); + --hebrew-font: var(--hebrew-sans-serif-font-family); + position: absolute; + bottom: 41px; + margin-inline-start: 30px; +} +.topic-card-with-description .cardTitle { + margin-inline-start: 30px; +} .readerNavMenu .sheet { display: flex; justify-content: space-between; diff --git a/static/js/TopicLandingPage/RandomTopicCardWithDescriptionRow.jsx b/static/js/TopicLandingPage/RandomTopicCardWithDescriptionRow.jsx new file mode 100644 index 0000000000..926055137b --- /dev/null +++ b/static/js/TopicLandingPage/RandomTopicCardWithDescriptionRow.jsx @@ -0,0 +1,57 @@ +import React from 'react'; +import {useEffect, useState} from "react"; +import Sefaria from "../sefaria/sefaria"; +import {InterfaceText} from "../Misc"; +import {Card} from "../common/Card"; + + +export const RandomTopicCardWithDescriptionRow = () => { + const numTopics = 3; + const [deck, setDeck] = useState([]); + + const renderSaladItem = (item) => { + return( + + ) + } + + const fetchRandomTopicDeck = async () => { + const poolName = Sefaria.getLangSpecificTopicPoolName('general'); + const topics = await Sefaria.getTopicsByPool(poolName, Math.pow(numTopics, 3)); + const lang = Sefaria.interfaceLang == "hebrew"? 'he' : 'en'; + const deck = topics + .filter(topic => topic.description?.[lang]) + .slice(0, numTopics) + .map(topic => ({ + slug: topic.slug, + title: topic.primaryTitle, + description: topic.description + })); + return deck; + } + + const loadDeck = async () => { + const deck = await fetchRandomTopicDeck(); + setDeck(deck); + }; + + useEffect(() => { + loadDeck(); + }, []); + + return ( + <> +
+ {deck.map(topic=>
+ +
)} +
+ + + ); +}; \ No newline at end of file diff --git a/static/js/TopicLandingPage/TopicsLandingPage.jsx b/static/js/TopicLandingPage/TopicsLandingPage.jsx index 854bab7a28..4097874dfe 100644 --- a/static/js/TopicLandingPage/TopicsLandingPage.jsx +++ b/static/js/TopicLandingPage/TopicsLandingPage.jsx @@ -9,6 +9,7 @@ import {TopicLandingSeasonal} from "./TopicLandingSeasonal"; import {TopicLandingNewsletter} from "./TopicLandingNewsletter"; import {InterfaceText} from "../Misc"; import Sefaria from "../sefaria/sefaria"; +import {RandomTopicCardWithDescriptionRow} from "./RandomTopicCardWithDescriptionRow"; export const TopicsLandingPage = ({openTopic}) => { @@ -34,6 +35,9 @@ export const TopicsLandingPage = ({openTopic}) => {
+
+ +
diff --git a/static/js/common/Card.jsx b/static/js/common/Card.jsx index d4538ec5fa..f0a45565f9 100644 --- a/static/js/common/Card.jsx +++ b/static/js/common/Card.jsx @@ -1,14 +1,21 @@ import {InterfaceText} from "../Misc"; import React from "react"; -const Card = ({cardTitle, cardTitleHref, oncardTitleClick, cardText}) => { +const Card = ({cardTitle, cardTitleHref, oncardTitleClick, cardText, bottomLinkText, bottomLinkUrl}) => { return
- +
+ {bottomLinkText && +
+ + + +
+ }
-} + } -export { Card } +export {Card} \ No newline at end of file