From af23717988f5711032b50cc67c8819c85228c527 Mon Sep 17 00:00:00 2001 From: Benjamin Goering Date: Tue, 28 Feb 2017 17:19:11 +0800 Subject: [PATCH] Indicate best comments. Add some aria labels --- client/coral-embed-stream/src/Comment.js | 12 ++++++++---- client/coral-plugin-best/BestButton.js | 11 +++++++++-- client/coral-plugin-best/translations.json | 6 ++++-- client/coral-plugin-tag-label/TagLabel.js | 4 ++-- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 19af229dc..679699c94 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -17,7 +17,7 @@ import PubDate from 'coral-plugin-pubdate/PubDate'; import {ReplyBox, ReplyButton} from 'coral-plugin-replies'; import FlagComment from 'coral-plugin-flags/FlagComment'; import LikeButton from 'coral-plugin-likes/LikeButton'; -import {BestButton, IfUserCanModifyBest, BEST_TAG, commentIsBest} from 'coral-plugin-best/BestButton'; +import {BestButton, IfUserCanModifyBest, BEST_TAG, commentIsBest, BestIndicator} from 'coral-plugin-best/BestButton'; import LoadMore from 'coral-embed-stream/src/LoadMore'; import styles from './Comment.css'; @@ -127,11 +127,15 @@ class Comment extends React.Component { { isStaff(comment.tags) - ? + ? Staff + : null } + + { commentIsBest(comment) + ? : null } -
+
-
+
roles && ['ADMIN', 'MODERATOR'].some(role => roles.includes(role)); +// Put this on a comment to show that it is best +export const BestIndicator = ({children = favorite}) => ( + + { children } + +); + /** * Component that only renders children if the provided user prop can modify best tags */ @@ -94,8 +101,8 @@ export class BestButton extends Component { disabled={disabled} className={classnames('comment__action-button', `${name}-button`, 'comment__action-button--nowrap', /* Can I do this to all buttons? 'comment__action-button--cursor-pointer', */ - `e2e__${isBest ? 'unset' : 'set'}-best-comment`)}> - /* {lang.t(isBest ? 'unsetBest' : 'setBest')} */ + `e2e__${isBest ? 'unset' : 'set'}-best-comment`)} + aria-label={lang.t(isBest ? 'unsetBest' : 'setBest')}> { isBest ? 'favorite' : 'favorite_border' } diff --git a/client/coral-plugin-best/translations.json b/client/coral-plugin-best/translations.json index cfdfc04a1..c7dd42be8 100644 --- a/client/coral-plugin-best/translations.json +++ b/client/coral-plugin-best/translations.json @@ -1,10 +1,12 @@ { "en": { "setBest": "Tag as Best", - "unsetBest": "Untag as Best" + "unsetBest": "Untag as Best", + "commentIsBest": "This comment is one of the best" }, "es": { "like": "Establecer como mejor", - "liked": "Desarmado como mejor" + "liked": "Desarmado como mejor", + "commentIsBest": "Este comentario es uno de los mejores" } } diff --git a/client/coral-plugin-tag-label/TagLabel.js b/client/coral-plugin-tag-label/TagLabel.js index ba7403f5c..4a5d3632f 100644 --- a/client/coral-plugin-tag-label/TagLabel.js +++ b/client/coral-plugin-tag-label/TagLabel.js @@ -1,7 +1,7 @@ import React from 'react'; -const TagLabel = ({isStaff}) =>
- {isStaff ? 'Staff' : ''} +const TagLabel = ({children}) =>
+ {children}
; export default TagLabel;