Skip to content

Commit

Permalink
feat: reuse <Label>
Browse files Browse the repository at this point in the history
refs:
- 2024-05-dev-1#RB-003
  • Loading branch information
robertu7 committed May 3, 2024
1 parent 6f3dee9 commit 717be57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
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);
}
}

0 comments on commit 717be57

Please sign in to comment.