Skip to content

Commit

Permalink
feat(campaign): show featured label
Browse files Browse the repository at this point in the history
  • Loading branch information
gitwoz committed Oct 24, 2024
1 parent 8d70616 commit b9fab6d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
3 changes: 3 additions & 0 deletions public/static/icons/24px/star.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/common/styles/variables/colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
--color-free-write-green-text: #398449;
--color-free-write-green-bg: #d9f8dd;
--color-free-write-green-bg-hover: #bdf4c4;
--color-free-write-green-label: #94d09c;

/* others */
--color-noir: #000;
Expand Down
1 change: 1 addition & 0 deletions src/components/TextIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type TextIconColor =
| 'likecoinGreen'
| 'yellowLighter'
| 'freeWriteBlue'
| 'freeWriteGreenLabel'

export interface TextIconProps {
// icon
Expand Down
4 changes: 4 additions & 0 deletions src/components/TextIcon/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
color: var(--color-free-write-blue);
}

.freeWriteGreenLabel {
color: var(--color-free-write-green-label);
}

.yellowLighter {
color: var(--color-yellow-lighter);
}
Expand Down
1 change: 1 addition & 0 deletions src/views/CampaignDetail/ArticleFeeds/MainFeed/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const CAMPAIGN_ARTICLES_PUBLIC = gql`
}
edges {
cursor
featured
node {
id
campaigns {
Expand Down
42 changes: 33 additions & 9 deletions src/views/CampaignDetail/ArticleFeeds/MainFeed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useContext, useEffect, useRef } from 'react'
import { FormattedMessage } from 'react-intl'

import { ReactComponent as IconRead } from '@/public/static/icons/24px/read.svg'
import { ReactComponent as IconStar } from '@/public/static/icons/24px/star.svg'
import { analytics, mergeConnections } from '~/common/utils'
import {
ArticleDigestFeed,
Expand All @@ -13,6 +14,7 @@ import {
List,
QueryError,
SpinnerBlock,
TextIcon,
usePublicQuery,
useRoute,
ViewerContext,
Expand Down Expand Up @@ -205,20 +207,42 @@ const MainFeed = ({ feedType, camapign }: MainFeedProps) => {
return (
<InfiniteScroll hasNextPage={pageInfo.hasNextPage} loadMore={loadMore} eof>
<List>
{edges.map(({ node }, i) => (
{edges.map(({ node, featured }, i) => (
<List.Item key={`${feedType}:${i}`}>
<ArticleDigestFeed
article={node}
label={
isAll && (
<span
className={[
styles.articleLabel,
getArticleStage(node)?.id ? '' : styles.announcement,
].join(' ')}
>
{getArticleStageName(node, lang)}
</span>
<>
<span
className={[
styles.articleLabel,
getArticleStage(node)?.id ? '' : styles.announcement,
].join(' ')}
>
{getArticleStageName(node, lang)}
</span>

{featured && (
<TextIcon
icon={
<Icon
icon={IconStar}
size={12}
style={{ opacity: 0.5 }}
/>
}
spacing={2}
color="freeWriteGreenLabel"
size={12}
>
<FormattedMessage
defaultMessage="Featured"
id="CnPG8j"
/>
</TextIcon>
)}
</>
)
}
onClick={() => {
Expand Down

0 comments on commit b9fab6d

Please sign in to comment.