Skip to content

Commit

Permalink
Merge branch 'develop' into feat/indent
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 authored Aug 27, 2024
2 parents 85b6b54 + fa4d42b commit b44c419
Show file tree
Hide file tree
Showing 27 changed files with 511 additions and 308 deletions.
8 changes: 4 additions & 4 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
"0Om2Kl": {
"defaultMessage": "Remove from collection"
},
"0SQatS": {
"defaultMessage": "View all",
"description": "src/views/CampaignDetail/SideParticipants/index.tsx"
},
"0ThOw1": {
"defaultMessage": "Create collection",
"description": "src/views/User/Collections/UserCollections.tsx"
Expand Down Expand Up @@ -2580,10 +2584,6 @@
"defaultMessage": "are following",
"description": "src/views/TagDetail/Followers/index.tsx"
},
"hfRsLB": {
"defaultMessage": "Writers {count}",
"description": "src/views/CampaignDetail/InfoHeader/Participants/Dialog/index.tsx"
},
"hgtWIO": {
"defaultMessage": "Articles have been collected",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
Expand Down
8 changes: 4 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
"0Om2Kl": {
"defaultMessage": "Remove from collection"
},
"0SQatS": {
"defaultMessage": "View all",
"description": "src/views/CampaignDetail/SideParticipants/index.tsx"
},
"0ThOw1": {
"defaultMessage": "Create collection",
"description": "src/views/User/Collections/UserCollections.tsx"
Expand Down Expand Up @@ -2580,10 +2584,6 @@
"defaultMessage": "are following",
"description": "src/views/TagDetail/Followers/index.tsx"
},
"hfRsLB": {
"defaultMessage": "Writers {count}",
"description": "src/views/CampaignDetail/InfoHeader/Participants/Dialog/index.tsx"
},
"hgtWIO": {
"defaultMessage": "Articles have been collected",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
Expand Down
8 changes: 4 additions & 4 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
"0Om2Kl": {
"defaultMessage": "移出选集"
},
"0SQatS": {
"defaultMessage": "看全部",
"description": "src/views/CampaignDetail/SideParticipants/index.tsx"
},
"0ThOw1": {
"defaultMessage": "新建选集",
"description": "src/views/User/Collections/UserCollections.tsx"
Expand Down Expand Up @@ -2580,10 +2584,6 @@
"defaultMessage": "人追踪",
"description": "src/views/TagDetail/Followers/index.tsx"
},
"hfRsLB": {
"defaultMessage": "作者 {count}",
"description": "src/views/CampaignDetail/InfoHeader/Participants/Dialog/index.tsx"
},
"hgtWIO": {
"defaultMessage": "作品被关联",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
Expand Down
8 changes: 4 additions & 4 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
"0Om2Kl": {
"defaultMessage": "移出選集"
},
"0SQatS": {
"defaultMessage": "看全部",
"description": "src/views/CampaignDetail/SideParticipants/index.tsx"
},
"0ThOw1": {
"defaultMessage": "新建選集",
"description": "src/views/User/Collections/UserCollections.tsx"
Expand Down Expand Up @@ -2580,10 +2584,6 @@
"defaultMessage": "人追蹤",
"description": "src/views/TagDetail/Followers/index.tsx"
},
"hfRsLB": {
"defaultMessage": "作者 {count}",
"description": "src/views/CampaignDetail/InfoHeader/Participants/Dialog/index.tsx"
},
"hgtWIO": {
"defaultMessage": "作品被關聯",
"description": "src/views/Me/Settings/Notifications/GeneralSettings/index.tsx"
Expand Down
10 changes: 10 additions & 0 deletions src/common/utils/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ interface CampaignArgs {
shortHash: string
}

interface CampaignStageArgs {
id: string
}

interface CommentArgs {
id: string
type: 'article' | 'circleDiscussion' | 'circleBroadcast' | 'moment' // comment type: article/discussion/broadcast
Expand Down Expand Up @@ -88,6 +92,7 @@ type ToPathArgs =
| {
page: 'campaignDetail'
campaign: CampaignArgs
stage?: CampaignStageArgs
}
| {
page: 'userProfile' | 'userCollections'
Expand Down Expand Up @@ -237,6 +242,11 @@ export const toPath = (
}
case 'campaignDetail': {
href = `/e/${args.campaign.shortHash}`
if (args.stage) {
href = `${href}?type=${args.stage.id}`
} else {
href = `${href}?type=announcement`
}
break
}
case 'userProfile': {
Expand Down
1 change: 1 addition & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type ButtonTextActiveColor = Extract<
export type ButtonBgColor = Extract<
ButtonColor,
| 'greyDarkest'
| 'greyDarker'
| 'grey'
| 'greyLighter'
| 'greenLighter'
Expand Down
6 changes: 6 additions & 0 deletions src/components/Button/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ span.container {
}
}

.bgGreyDarker {
& .hotarea {
background: var(--color-grey-darker);
}
}

.bgGrey {
& .hotarea {
background: var(--color-grey);
Expand Down
26 changes: 26 additions & 0 deletions src/views/ArticleDetail/Header/gql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import gql from 'graphql-tag'

export const fragments = {
article: gql`
fragment HeaderArticle on Article {
id
campaigns {
campaign {
id
shortHash
... on WritingChallenge {
nameZhHant: name(input: { language: zh_hant })
nameZhHans: name(input: { language: zh_hans })
nameEn: name(input: { language: en })
}
}
stage {
id
nameZhHant: name(input: { language: zh_hant })
nameZhHans: name(input: { language: zh_hans })
nameEn: name(input: { language: en })
}
}
}
`,
}
87 changes: 87 additions & 0 deletions src/views/ArticleDetail/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { useContext } from 'react'

import { analytics, toPath } from '~/common/utils'
import {
BackToHomeMobileButton,
Button,
DotDivider,
LanguageContext,
Media,
TextIcon,
} from '~/components'
import { HeaderArticleFragment } from '~/gql/graphql'

import { fragments } from './gql'
import styles from './styles.module.css'

type HeaderProps = {
article: HeaderArticleFragment
}

const Header = ({ article }: HeaderProps) => {
const campaign = article.campaigns[0]?.campaign
const campaignStage = article.campaigns[0]?.stage
const { lang } = useContext(LanguageContext)

return (
<section className={styles.header}>
<Media at="sm" className={styles.mobileLogo}>
<BackToHomeMobileButton />
</Media>
{campaign && (
<section className={styles.campaign}>
<Button
href={
toPath({
page: 'campaignDetail',
campaign,
stage: campaignStage || undefined,
}).href
}
onClick={() => {
analytics.trackEvent('click_button', {
type: 'campaign_detail_entrance',
pageType: 'article_detail',
pageComponent: 'article_meta',
})
}}
>
<TextIcon size={12} color="freeWriteBlue">
<span>
{
campaign[
lang === 'zh_hans'
? 'nameZhHans'
: lang === 'zh_hant'
? 'nameZhHant'
: 'nameEn'
]
}
</span>
{campaignStage && (
<>
&nbsp;
<DotDivider />
&nbsp;
{
campaignStage[
lang === 'zh_hans'
? 'nameZhHans'
: lang === 'zh_hant'
? 'nameZhHant'
: 'nameEn'
]
}
</>
)}
</TextIcon>
</Button>
</section>
)}
</section>
)
}

Header.fragments = fragments

export default Header
22 changes: 22 additions & 0 deletions src/views/ArticleDetail/Header/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.header {
@mixin flex-start-start;

& .mobileLogo {
display: inline-flex;
align-items: center;
justify-content: flex-start;
}

& .campaign {
display: inline-flex;
align-items: center;
justify-content: flex-start;
height: 1.125rem;
margin-left: var(--sp16);

@media (--sm-up) {
margin-bottom: var(--ar17-100);
margin-left: 0;
}
}
}
17 changes: 0 additions & 17 deletions src/views/ArticleDetail/MetaInfo/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ export const fragments = {
id
userName
}
campaigns {
campaign {
id
shortHash
... on WritingChallenge {
nameZhHant: name(input: { language: zh_hant })
nameZhHans: name(input: { language: zh_hans })
nameEn: name(input: { language: en })
}
}
stage {
id
nameZhHant: name(input: { language: zh_hant })
nameZhHans: name(input: { language: zh_hans })
nameEn: name(input: { language: en })
}
}
}
`,
articleVersion: gql`
Expand Down
34 changes: 0 additions & 34 deletions src/views/ArticleDetail/MetaInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DateTime,
DotDivider,
Icon,
LanguageContext,
TextIcon,
UserDigest,
useRoute,
Expand Down Expand Up @@ -44,15 +43,12 @@ const MetaInfo = ({
editable,
}: MetaInfoProps) => {
const viewer = useContext(ViewerContext)
const { lang } = useContext(LanguageContext)
const authorId = article.author.id
const isAuthor = viewer.id === authorId
const originalLanguage = article?.language ? article.language : ''
const editPath = toPath({ page: 'articleEdit', article })
const isExceedRevision = article.revisionCount >= MAX_ARTICLE_REVISION_COUNT

const campaign = article.campaigns[0]?.campaign

const { router, isInPath } = useRoute()
const { shortHash, ...qs } = router.query
const isInArticleDetailHistory = isInPath('ARTICLE_DETAIL_HISTORY')
Expand All @@ -65,36 +61,6 @@ const MetaInfo = ({

return (
<section className={styles.info}>
{campaign && (
<>
<Button
href={toPath({ page: 'campaignDetail', campaign }).href}
onClick={() => {
analytics.trackEvent('click_button', {
type: 'campaign_detail_entrance',
pageType: 'article_detail',
pageComponent: 'article_meta',
})
}}
>
<TextIcon size={12} color="freeWriteBlue">
{
campaign[
lang === 'zh_hans'
? 'nameZhHans'
: lang === 'zh_hant'
? 'nameZhHant'
: 'nameEn'
]
}
</TextIcon>
</Button>
<section className={styles.dot}>
<DotDivider />
</section>
</>
)}

<section className={styles.author}>
<UserDigest.Plain user={article.author} />
<section className={styles.dot}>
Expand Down
4 changes: 4 additions & 0 deletions src/views/ArticleDetail/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import gql from 'graphql-tag'
import { UserDigest } from '~/components/UserDigest'

import { AuthorSidebar } from './AuthorSidebar'
import Header from './Header'
import MetaInfo from './MetaInfo'
import StickyTopBanner from './StickyTopBanner'
import { fragments as supportWidgetFragments } from './Support/SupportWidget/gql'
Expand Down Expand Up @@ -64,6 +65,8 @@ const articlePublicFragment = gql`
contents {
html
}
...HeaderArticle
...AuthorSidebarArticle
...MetaInfoArticle
...TagListArticle
Expand All @@ -73,6 +76,7 @@ const articlePublicFragment = gql`
...SupportWidgetArticlePublic
...SupportWidgetArticlePrivate
}
${Header.fragments.article}
${AuthorSidebar.fragments.article}
${MetaInfo.fragments.article}
${TagList.fragments.article}
Expand Down
Loading

0 comments on commit b44c419

Please sign in to comment.