Skip to content
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

feat(TagDetail): Hide tag feed tabs when no hottest articles #4961

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/views/TagDetail/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const tagFragment = gql`
}
...ArticleCountTag
...TagBookmarkButtonTagPrivate
hottestArticles: articles(input: { first: 10, sortBy: byHottestDesc }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use first: 0 instead

totalCount
}
recommended(input: { first: 10 }) {
edges {
cursor
Expand Down
3 changes: 2 additions & 1 deletion src/views/TagDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const TagDetail = ({ tag }: { tag: TagFragmentFragment }) => {
const isHottest = feedType === 'hottest'
const isLatest = feedType === 'latest'
const hasArticles = tag.numArticles > 0
const hasHottestArticles = tag.hottestArticles.totalCount > 0

useEffect(() => {
// backward compatible with `/tags/:globalId:`
Expand Down Expand Up @@ -128,7 +129,7 @@ const TagDetail = ({ tag }: { tag: TagFragmentFragment }) => {
<TagBookmarkButton tag={tag} />
</section>

{hasArticles && (
{hasArticles && hasHottestArticles && (
<section className={styles.tabs}>
<SquareTabs>
<SquareTabs.Tab
Expand Down
4 changes: 2 additions & 2 deletions src/views/TagDetail/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
@mixin flex-center-space-between;

padding: var(--sp16) 0;
margin: 0 var(--sp16);
margin: 0 var(--sp16) var(--sp12);

@media (--sm-up) {
margin: 0;
margin: 0 0 var(--sp12);
}
}

Expand Down
Loading