You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

  1. // Package imports.
  2. import PropTypes from 'prop-types';
  3. import React from 'react';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. import { defineMessages } from 'react-intl';
  6. // Components.
  7. import Icon from 'flavours/glitch/components/icon';
  8. // Messages.
  9. const messages = defineMessages({
  10. localOnly: {
  11. defaultMessage: 'This post is local-only',
  12. id: 'advanced_options.local-only.tooltip',
  13. },
  14. threadedMode: {
  15. defaultMessage: 'Threaded mode enabled',
  16. id: 'advanced_options.threaded_mode.tooltip',
  17. },
  18. });
  19. // We use an array of tuples here instead of an object because it
  20. // preserves order.
  21. const iconMap = [
  22. ['do_not_federate', 'home', messages.localOnly],
  23. ['threaded_mode', 'comments', messages.threadedMode],
  24. ];
  25. // The component.
  26. export default function ComposerTextareaIcons ({
  27. advancedOptions,
  28. intl,
  29. }) {
  30. // The result. We just map every active option to its icon.
  31. return (
  32. <div className='composer--textarea--icons'>
  33. {advancedOptions ? iconMap.map(
  34. ([key, icon, message]) => advancedOptions.get(key) ? (
  35. <span
  36. className='textarea_icon'
  37. key={key}
  38. title={intl.formatMessage(message)}
  39. >
  40. <Icon
  41. fullwidth
  42. icon={icon}
  43. />
  44. </span>
  45. ) : null
  46. ) : null}
  47. </div>
  48. );
  49. }
  50. // Props.
  51. ComposerTextareaIcons.propTypes = {
  52. advancedOptions: ImmutablePropTypes.map,
  53. intl: PropTypes.object.isRequired,
  54. };