Skip to content

Commit

Permalink
Merge pull request #4701 from thematters/feat/update-bookmarked-arich…
Browse files Browse the repository at this point in the history
…ived-article

feat(Bookmarks): Update archived article styles
  • Loading branch information
wlliaml authored Aug 1, 2024
2 parents dc69930 + c426e99 commit c5eb0fb
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 18 deletions.
3 changes: 3 additions & 0 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,9 @@
"defaultMessage": "New followers",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
},
"Jmg5do": {
"defaultMessage": "Archived Work"
},
"JpS59y": {
"defaultMessage": "Accepted",
"description": "src/views/Circle/Settings/ManageInvitation/Invites/index.tsx"
Expand Down
3 changes: 3 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,9 @@
"defaultMessage": "New followers",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
},
"Jmg5do": {
"defaultMessage": "Archived Work"
},
"JpS59y": {
"defaultMessage": "Accepted",
"description": "src/views/Circle/Settings/ManageInvitation/Invites/index.tsx"
Expand Down
3 changes: 3 additions & 0 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,9 @@
"defaultMessage": "被追踪",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
},
"Jmg5do": {
"defaultMessage": "作品已归档"
},
"JpS59y": {
"defaultMessage": "已接受",
"description": "src/views/Circle/Settings/ManageInvitation/Invites/index.tsx"
Expand Down
3 changes: 3 additions & 0 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,9 @@
"defaultMessage": "被追蹤",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
},
"Jmg5do": {
"defaultMessage": "作品已封存"
},
"JpS59y": {
"defaultMessage": "已接受",
"description": "src/views/Circle/Settings/ManageInvitation/Invites/index.tsx"
Expand Down
19 changes: 14 additions & 5 deletions src/components/ArticleDigest/Feed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type ArticleDigestFeedControls = {
hasCircle?: boolean
hasAuthor?: boolean
isFirstFold?: boolean
disabledArchived?: boolean
}

export type ArticleDigestFeedProps = {
Expand All @@ -52,6 +53,7 @@ const BaseArticleDigestFeed = ({
onClickAuthor,

isFirstFold = false,
disabledArchived = false,

hasReadTime,
hasDonationCount,
Expand All @@ -61,8 +63,9 @@ const BaseArticleDigestFeed = ({
}: ArticleDigestFeedProps) => {
const { author, summary } = article
const isBanned = article.articleState === 'banned'
const cover = !isBanned ? article.cover : null
const cleanedSummary = isBanned ? '' : makeSummary(summary)
const isArchived = article.articleState === 'archived'
const cover = !isBanned && !isArchived ? article.cover : null
const cleanedSummary = isBanned && !isArchived ? '' : makeSummary(summary)

const path = toPath({
page: 'articleDetail',
Expand Down Expand Up @@ -98,6 +101,9 @@ const BaseArticleDigestFeed = ({
user={author}
avatarSize={20}
textSize={12}
nameColor={
author.status?.state === 'archived' ? 'grey' : undefined
}
hasAvatar
hasDisplayName
onClick={onClickAuthor}
Expand All @@ -120,13 +126,16 @@ const BaseArticleDigestFeed = ({
textSize={16}
lineClamp={2}
onClick={onClick}
disabledArchived={disabledArchived}
/>
</section>
</section>

<LinkWrapper {...path} onClick={onClick}>
<p className={styles.description}>{cleanedSummary}</p>
</LinkWrapper>
{!(isArchived && disabledArchived) && (
<LinkWrapper {...path} onClick={onClick}>
<p className={styles.description}>{cleanedSummary}</p>
</LinkWrapper>
)}

<Media greaterThan="sm">{footerActions}</Media>
</section>
Expand Down
49 changes: 37 additions & 12 deletions src/components/ArticleDigest/Title/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl'

import { TEST_ID } from '~/common/enums'
import { capitalizeFirstLetter, toPath } from '~/common/utils'
import { LinkWrapper, LinkWrapperProps } from '~/components'
import { LinkWrapper, LinkWrapperProps, toast } from '~/components'
import { ArticleDigestTitleArticleFragment } from '~/gql/graphql'

import styles from './styles.module.css'
Expand All @@ -21,6 +21,7 @@ type ArticleDigestTitleProps = {
textWeight?: ArticleDigestTitleTextWeight
lineClamp?: boolean | 1 | 2 | 3
is?: ArticleDigestTitleIs
disabledArchived?: boolean

disabled?: boolean
onClick?: () => void
Expand Down Expand Up @@ -52,6 +53,7 @@ export const ArticleDigestTitle = ({
is = 'h2',

disabled,
disabledArchived,
onClick,

...restProps
Expand All @@ -63,6 +65,7 @@ export const ArticleDigestTitle = ({
collectionId,
})
const isBanned = state === 'banned'
const isArchived = state === 'archived'
const title = isBanned ? (
<FormattedMessage
defaultMessage="The article has been archived due to violation of terms"
Expand All @@ -77,9 +80,41 @@ export const ArticleDigestTitle = ({
[styles[`font${capitalizeFirstLetter(textWeight)}`]]: !!textWeight,
[styles.lineClamp]: !!lineClamp,
[styles[`lineClampLine${lineClamp}`]]: lineClamp === 1 || lineClamp === 3,
[styles.archived]: isArchived && disabledArchived,
})
const isClickable = !disabled && !isBanned

const Title = () => (
<>
{is === 'h2' ? (
<h2 className={titleClasses}>{title}</h2>
) : is === 'h3' ? (
<h3 className={titleClasses}>{title}</h3>
) : is === 'h4' ? (
<h4 className={titleClasses}>{title}</h4>
) : (
<h5 className={titleClasses}>{title}</h5>
)}
</>
)

if (isArchived && disabledArchived) {
return (
<section
role="button"
onClick={() => {
toast.success({
message: (
<FormattedMessage defaultMessage="Archived Work" id="Jmg5do" />
),
})
}}
>
<Title />
</section>
)
}

return (
<LinkWrapper
{...path}
Expand All @@ -89,17 +124,7 @@ export const ArticleDigestTitle = ({
testId={TEST_ID.DIGEST_ARTICLE_TITLE}
{...restProps}
>
<>
{is === 'h2' ? (
<h2 className={titleClasses}>{title}</h2>
) : is === 'h3' ? (
<h3 className={titleClasses}>{title}</h3>
) : is === 'h4' ? (
<h4 className={titleClasses}>{title}</h4>
) : (
<h5 className={titleClasses}>{title}</h5>
)}
</>
<Title />
</LinkWrapper>
)
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/ArticleDigest/Title/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@
.lineClampLine3 {
-webkit-line-clamp: 3;
}

.archived {
color: var(--color-grey);
cursor: pointer;
}
2 changes: 1 addition & 1 deletion src/views/Me/Bookmarks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const BaseMeBookmarks = () => {
<List>
{edges.map(({ node, cursor }) => (
<List.Item key={node.id}>
<ArticleDigestFeed article={node} />
<ArticleDigestFeed article={node} disabledArchived />
</List.Item>
))}
</List>
Expand Down

0 comments on commit c5eb0fb

Please sign in to comment.