icon.js 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React from 'react';
  2. export default class extends React.Component {
  3. getClassName() {
  4. if (this.props.thread.is_read) {
  5. return 'read-status item-read';
  6. } else {
  7. return 'read-status item-new';
  8. }
  9. }
  10. getTitle() {
  11. if (this.props.thread.is_read) {
  12. return gettext("This thread has no new posts.");
  13. } else {
  14. return gettext("This thread has new posts.");
  15. }
  16. }
  17. getIcon() {
  18. if (this.props.thread.is_read) {
  19. return 'chat_bubble_outline';
  20. } else {
  21. return 'chat_bubble';
  22. }
  23. }
  24. getUrl() {
  25. if (this.props.thread.is_read) {
  26. return this.props.thread.last_post_url;
  27. } else {
  28. return this.props.thread.new_post_url;
  29. }
  30. }
  31. render() {
  32. /* jshint ignore:start */
  33. return <a className={this.getClassName()} href={this.getUrl()} title={this.getTitle()}>
  34. <span className="material-icon">
  35. {this.getIcon()}
  36. </span>
  37. </a>;
  38. /* jshint ignore:end */
  39. }
  40. }