-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Create FeaturedTopic and FeaturedTopicsRow Components #2237
Open
yonadavGit
wants to merge
11
commits into
topic-landing
Choose a base branch
from
feature/sc-30162/create-featuredtopic-and-featuredtopicsrow
base: topic-landing
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6d85d79
fix(topic admin): add necessary import statement
yonadavGit 425266f
feat(topic landing page): skeleton of the TopicMonte component
yonadavGit 5b5d1fc
feat(topic landing page): change name of component and arranging prop…
yonadavGit 4a79cb9
feat(topic landing random cards): add link at the bottom of card
yonadavGit 439c099
merge
yonadavGit c497c66
feat(topic landing random cards): fetch more topics to increase chanc…
yonadavGit b558723
feat(topic landing random cards): fix style
yonadavGit cfb13fe
feat(topic landing random cards): fix style of cards
yonadavGit fd2466e
refactor(random topic cards): turn bottom links into props of Card co…
yonadavGit 6ecdc2a
refactor(topic landing): use color vars properly
yonadavGit 6d35f9d
refactor(topic landing): remove comments from css
yonadavGit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why a decimal point? |
||
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; | ||
|
57 changes: 57 additions & 0 deletions
57
static/js/TopicLandingPage/RandomTopicCardWithDescriptionRow.jsx
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,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(<a href={`/topics/${item.slug}`} className="topic-salad-item"> | ||
<InterfaceText text={item.text}/> | ||
</a>) | ||
} | ||
|
||
const fetchRandomTopicDeck = async () => { | ||
const poolName = Sefaria.getLangSpecificTopicPoolName('general'); | ||
const topics = await Sefaria.getTopicsByPool(poolName, Math.pow(numTopics, 3)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you explain why x^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 ( | ||
<> | ||
<div className='topic-card-with-description-row'> | ||
{deck.map(topic=><div className='topic-card-with-description'> | ||
<Card | ||
cardTitleHref={`topics/${topic.slug}`} | ||
cardTitle={topic.title} | ||
cardText={topic.description} | ||
bottomLinkText = {{en: `Explore ${topic.title?.en} ›`, he:`${Sefaria._("Explore")} ${topic.title?.he} ›`}} | ||
bottomLinkUrl = {`topics/${topic.slug}`}/> | ||
</div>)} | ||
</div> | ||
</> | ||
|
||
); | ||
}; |
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 |
---|---|---|
@@ -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 <div className="card"> | ||
<a href={cardTitleHref} className="cardTitle" onClick={oncardTitleClick}> | ||
<InterfaceText text={cardTitle}/> | ||
</a> | ||
<div className="cardDescription"> | ||
<InterfaceText text={cardText}/> | ||
<InterfaceText markdown={cardText}/> | ||
</div> | ||
{bottomLinkText && | ||
<div className="bottomCardLink"> | ||
<a href={bottomLinkUrl}> | ||
<InterfaceText text={bottomLinkText}/> | ||
</a> | ||
</div> | ||
} | ||
</div> | ||
} | ||
} | ||
|
||
export { Card } | ||
export {Card} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these numbers for width and height seem pretty random, also on top seems like there are very specific numbers. ideally the cards wont have a strict width and height but rather a min-width min-height. Sefaria in general tries to stick to multiples of 5 for margins and width/height