-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4449 from thematters/develop
Release: v5.0.2
- Loading branch information
Showing
49 changed files
with
678 additions
and
597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "matters-web", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "codebase of Matters' website", | ||
"author": "Matters <[email protected]>", | ||
"engines": { | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import mockRouter from 'next-router-mock' | ||
import { describe, expect, it, vi } from 'vitest' | ||
|
||
import { render, screen } from '~/common/utils/test' | ||
import { ArticleTag } from '~/components' | ||
import { MOCK_TAG } from '~/stories/mocks' | ||
|
||
describe('<ArticleTag>', () => { | ||
it('should render an ArticleTag', () => { | ||
const handleClick = vi.fn() | ||
render(<ArticleTag tag={MOCK_TAG} onClick={handleClick} />) | ||
|
||
const $name = screen.getByText(new RegExp(MOCK_TAG.content, 'i')) | ||
expect($name).toBeInTheDocument() | ||
|
||
$name.click() | ||
expect(mockRouter.asPath).toContain(MOCK_TAG.slug) | ||
expect(handleClick).toBeCalledTimes(1) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import classNames from 'classnames' | ||
import gql from 'graphql-tag' | ||
import Link from 'next/link' | ||
|
||
import { ReactComponent as IconHashTag } from '@/public/static/icons/24px/hashtag.svg' | ||
import { clampTag, toPath } from '~/common/utils' | ||
import { Icon, TextIcon, TextIconProps } from '~/components' | ||
import { DigestTagFragment } from '~/gql/graphql' | ||
|
||
import styles from './styles.module.css' | ||
|
||
interface ArticleTagProps { | ||
tag: DigestTagFragment | ||
textIconProps?: TextIconProps | ||
canClamp?: boolean | ||
onClick?: () => void | ||
} | ||
|
||
export const ArticleTag = ({ | ||
tag, | ||
textIconProps: customTextIconProps, | ||
canClamp = false, | ||
onClick, | ||
}: ArticleTagProps) => { | ||
const tagClasses = classNames({ | ||
[styles.article]: 'article', | ||
[styles.clickable]: !!onClick, | ||
}) | ||
|
||
const tagName = canClamp ? clampTag(tag.content) : tag.content | ||
|
||
const path = toPath({ | ||
page: 'tagDetail', | ||
tag, | ||
}) | ||
|
||
const textIconProps: TextIconProps = { | ||
size: 14, | ||
spacing: 0, | ||
weight: 'normal', | ||
icon: <Icon icon={IconHashTag} color="greyDarker" />, | ||
...customTextIconProps, | ||
} | ||
|
||
return ( | ||
<Link {...path} legacyBehavior> | ||
<a className={tagClasses} onClick={onClick}> | ||
<TextIcon {...textIconProps} size={textIconProps.size} allowUserSelect> | ||
<span className={styles.name}>{tagName}</span> | ||
</TextIcon> | ||
</a> | ||
</Link> | ||
) | ||
} | ||
|
||
ArticleTag.fragments = { | ||
tag: gql` | ||
fragment DigestTag on Tag { | ||
id | ||
content | ||
numArticles | ||
numAuthors | ||
} | ||
`, | ||
} |
Oops, something went wrong.