* Admin-configurable display locale * Add i18n-js and namespacing * Basic tests and clean up * A few test adjustments * Update vendor cache * Fix a few tests * Fix a few tests * Update app/views/articles/_actions.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/articles/_comments_actions.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/articles/_single_story.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/articles/_single_story.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/comments/_comment_header.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/layouts/_sidebar_tags.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/listings/index.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update spec/system/homepage/user_visits_homepage_articles_spec.rb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update spec/system/user/view_user_index_spec.rb Co-authored-by: Michael Kohl <citizen428@dev.to> * Alphabetical locale page * Add activerecord custom validation error translations * Add i18n to webpacker * Fix a few tests * Adjust error messages * Add i18n-tasks * Adjust JS to get working with jest * Adjust the way translations are pulled in * Adjust jest tests * Remove time localization * Remove superfluous public js * Add basic tests for i18n application controller * Remove unnecessary content Co-authored-by: Michael Kohl <citizen428@dev.to>
68 lines
1.7 KiB
JavaScript
68 lines
1.7 KiB
JavaScript
import { h } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
import { Button } from '../../crayons/Button';
|
|
import { locale } from '../../utilities/locale';
|
|
|
|
|
|
export const CommentsCount = ({ count, articlePath }) => {
|
|
const commentsSVG = () => (
|
|
<svg
|
|
className="crayons-icon"
|
|
width="24"
|
|
height="24"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<path d="M10.5 5h3a6 6 0 110 12v2.625c-3.75-1.5-9-3.75-9-8.625a6 6 0 016-6zM12 15.5h1.5a4.501 4.501 0 001.722-8.657A4.5 4.5 0 0013.5 6.5h-3A4.5 4.5 0 006 11c0 2.707 1.846 4.475 6 6.36V15.5z" />
|
|
</svg>
|
|
);
|
|
|
|
if (count > 0) {
|
|
return (
|
|
<Button
|
|
variant="ghost"
|
|
size="s"
|
|
contentType="icon-left"
|
|
url={`${articlePath}#comments`}
|
|
icon={commentsSVG}
|
|
tagName="a"
|
|
>
|
|
<span title="Number of comments">
|
|
{count}
|
|
<span className="hidden s:inline">
|
|
|
|
{`${count > 1 ? `${locale('core.comment')}s` : locale('core.comment') }`}
|
|
</span>
|
|
</span>
|
|
</Button>
|
|
);
|
|
}
|
|
if (count === 0) {
|
|
return (
|
|
<Button
|
|
variant="ghost"
|
|
size="s"
|
|
contentType="icon-left"
|
|
url={`${articlePath}#comments`}
|
|
icon={commentsSVG}
|
|
tagName="a"
|
|
data-testid="add-a-comment"
|
|
>
|
|
<span className="inline s:hidden">0</span>
|
|
<span className="hidden s:inline">{locale('core.add_comment')}</span>
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
CommentsCount.defaultProps = {
|
|
count: 0,
|
|
};
|
|
|
|
CommentsCount.propTypes = {
|
|
count: PropTypes.number,
|
|
articlePath: PropTypes.string.isRequired,
|
|
};
|
|
|
|
CommentsCount.displayName = 'CommentsCount';
|