* feed cards * frontend * preactify * preactify * . * fix * fixing things and adding dropdown * whoops. * whoops 2. * revert body bg color change * search snippet * search snippet * get rid of featured article * get rid of featured article... * cover to its own component * videos * videos * reading time * small-save-filled asset * author adjustments * adjustments * Author --> Meta * whoops. * loader * logged out state * . * dropping what's not needed for now * better name for cover * get rid of nav overflow * bringin comments placeholder back * bringing comments placeholder back * publish date * fix * date * . * save button icon * ghost button * lets skip the icon for saving for now * more buttons * counting logic * Display top comments on homepage feed * Comment list and item components * Remove 'Top Comments' title * Remove subscribe button, add reading time * Update snapshots and tests * Fix article and follower scrolling * Added reading time * (Try) to do flare tags * Button component from Pawel * More button styles from Pawel * Comment count style from Pawel * Handle empty parens for age on older articles * Dont show 'more comment' button for more than 2 comments * cover ratio * flare tag * cover fix * fix buttons * more button fixes * tags fix * responsiveness fix * reading time + a bit of responsiveness * Reading time in more places * snapshots * default color for flare tag * Update CommentsList test snapshot with new styles * fixing search results * fixing buttons * Fix podcast card tests by updating snapshots * Line clamping for top comments * Reflect save button state after click before mouseout * Now the entire feed card is clickable. (#7638) * Now pointer cursor is only on feed posts. (#7727) * Revert podcast card styling * Update test snapshot * merge * Fix rspec on feed page * Reduce complexity of class check for feed card clicking * PR feedback/fixes * Fix featured article test and snapshot * Last minute test tweaks * clean up crayons * padding issue + empty div * Correct merge error * Fix search results tests * Test fixes and snapshot updates * themes * podcasts colors Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com> Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
115 lines
2.7 KiB
JavaScript
115 lines
2.7 KiB
JavaScript
import { h, render } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
import { Article, LoadingArticle } from '../articles';
|
|
import { Feed } from '../articles/Feed';
|
|
import { TodaysPodcasts, PodcastEpisode } from '../podcasts';
|
|
import { articlePropTypes } from '../src/components/common-prop-types';
|
|
|
|
/**
|
|
* Sends analytics about the featured article.
|
|
*
|
|
* @param {number} articleId
|
|
*/
|
|
function sendFeaturedArticleAnalytics(articleId) {
|
|
(function logFeaturedArticleImpression() {
|
|
if (!window.ga || !ga.create) {
|
|
setTimeout(logFeaturedArticleImpression, 20);
|
|
return;
|
|
}
|
|
|
|
ga(
|
|
'send',
|
|
'event',
|
|
'view',
|
|
'featured-feed-impression',
|
|
`articles-${articleId}`,
|
|
null,
|
|
);
|
|
})();
|
|
}
|
|
|
|
const FeedLoading = () => (
|
|
<div>
|
|
<LoadingArticle version="featured" />
|
|
<LoadingArticle />
|
|
<LoadingArticle />
|
|
<LoadingArticle />
|
|
<LoadingArticle />
|
|
<LoadingArticle />
|
|
<LoadingArticle />
|
|
</div>
|
|
);
|
|
|
|
const PodcastEpisodes = ({ episodes }) => (
|
|
<TodaysPodcasts>
|
|
{episodes.map((episode) => (
|
|
<PodcastEpisode episode={episode} />
|
|
))}
|
|
</TodaysPodcasts>
|
|
);
|
|
|
|
PodcastEpisodes.defaultProps = {
|
|
episodes: [],
|
|
};
|
|
|
|
PodcastEpisodes.propTypes = {
|
|
episodes: PropTypes.arrayOf(articlePropTypes),
|
|
};
|
|
|
|
/**
|
|
* Renders the main feed.
|
|
*/
|
|
export const renderFeed = (timeFrame) => {
|
|
const feedContainer = document.getElementById('homepage-feed');
|
|
|
|
render(
|
|
<Feed
|
|
timeFrame={timeFrame}
|
|
renderFeed={({
|
|
feedItems,
|
|
podcastEpisodes,
|
|
bookmarkedFeedItems,
|
|
bookmarkClick,
|
|
}) => {
|
|
if (feedItems.length === 0) {
|
|
// Fancy loading ✨
|
|
return <FeedLoading />;
|
|
}
|
|
|
|
const commonProps = {
|
|
bookmarkClick,
|
|
};
|
|
|
|
const [featuredStory, ...subStories] = feedItems;
|
|
|
|
sendFeaturedArticleAnalytics(featuredStory.id);
|
|
|
|
// 1. Show the featured story first
|
|
// 2. Podcast episodes out today
|
|
// 3. Rest of the stories for the feed
|
|
return (
|
|
<div>
|
|
<Article
|
|
{...commonProps}
|
|
article={featuredStory}
|
|
isFeatured
|
|
isBookmarked={bookmarkedFeedItems.has(featuredStory.id)}
|
|
/>
|
|
{podcastEpisodes.length > 0 && (
|
|
<PodcastEpisodes episodes={podcastEpisodes} />
|
|
)}
|
|
{(subStories || []).map((story) => (
|
|
<Article
|
|
{...commonProps}
|
|
article={story}
|
|
isBookmarked={bookmarkedFeedItems.has(story.id)}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
}}
|
|
/>,
|
|
feedContainer,
|
|
feedContainer.firstElementChild,
|
|
);
|
|
};
|