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: reuse <Label> #4321

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 5 additions & 8 deletions src/components/CommentBeta/RoleLabel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import gql from 'graphql-tag'
import { FormattedMessage } from 'react-intl'

import { Label } from '~/components/Label'
import { RoleLabelCommentFragment } from '~/gql/graphql'

import styles from './styles.module.css'

const fragments = {
comment: gql`
fragment RoleLabelComment on Comment {
Expand All @@ -25,33 +24,31 @@ const fragments = {
`,
}

// TODO: reuse <Label> component
// https://github.com/thematters/matters-web/pull/4192#discussion_r1495549659
const RoleLabel = ({ comment }: { comment: RoleLabelCommentFragment }) => {
if (
comment.node.__typename === 'Article' &&
comment.author.id === comment.node.author.id
) {
return (
<span className={`${styles.label} ${styles.authorLabel}`}>
<Label color="green">
<FormattedMessage
defaultMessage="Author"
id="78qsg6"
description="src/components/Comment/RoleLabel/index.tsx"
/>
</span>
</Label>
)
}

if (comment.fromDonator) {
return (
<span className={`${styles.label} ${styles.supporterLabel}`}>
<Label color="gold">
<FormattedMessage
defaultMessage="Supporter"
id="jc3mW/"
description="src/components/Comment/RoleLabel/index.tsx"
/>
</span>
</Label>
)
}

Expand Down
23 changes: 0 additions & 23 deletions src/components/CommentBeta/RoleLabel/styles.module.css

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/Label/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
user-select: none;
border-style: solid;
border-width: 1px;
border-radius: 2px;
border-radius: 4px;

&.gold {
color: var(--color-matters-gold);
background: var(--color-yellow-lighter);
border-color: var(--color-matters-gold);
border-color: var(--color-line-matters-gold-light);
}

&.green {
color: var(--color-matters-green);
background: var(--color-green-lighter);
border-color: var(--color-matters-green);
border-color: var(--color-line-matters-green-light);
}
}
Loading