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.

109 lines
2.8 KiB

  1. // Package imports.
  2. import PropTypes from 'prop-types';
  3. import React from 'react';
  4. import {
  5. FormattedMessage,
  6. defineMessages,
  7. } from 'react-intl';
  8. import spring from 'react-motion/lib/spring';
  9. // Utils.
  10. import Motion from 'flavours/glitch/util/optional_motion';
  11. import { searchEnabled } from 'flavours/glitch/util/initial_state';
  12. // Messages.
  13. const messages = defineMessages({
  14. format: {
  15. defaultMessage: 'Advanced search format',
  16. id: 'search_popout.search_format',
  17. },
  18. hashtag: {
  19. defaultMessage: 'hashtag',
  20. id: 'search_popout.tips.hashtag',
  21. },
  22. status: {
  23. defaultMessage: 'status',
  24. id: 'search_popout.tips.status',
  25. },
  26. text: {
  27. defaultMessage: 'Simple text returns matching display names, usernames and hashtags',
  28. id: 'search_popout.tips.text',
  29. },
  30. full_text: {
  31. defaultMessage: 'Simple text returns statuses you have written, favourited, boosted, or have been mentioned in, as well as matching usernames, display names, and hashtags.',
  32. id: 'search_popout.tips.full_text',
  33. },
  34. user: {
  35. defaultMessage: 'user',
  36. id: 'search_popout.tips.user',
  37. },
  38. });
  39. // The spring used by our motion.
  40. const motionSpring = spring(1, { damping: 35, stiffness: 400 });
  41. // The component.
  42. export default function DrawerSearchPopout ({ style }) {
  43. // The result.
  44. return (
  45. <div
  46. className='drawer--search--popout'
  47. style={{
  48. ...style,
  49. position: 'absolute',
  50. width: 285,
  51. }}
  52. >
  53. <Motion
  54. defaultStyle={{
  55. opacity: 0,
  56. scaleX: 0.85,
  57. scaleY: 0.75,
  58. }}
  59. style={{
  60. opacity: motionSpring,
  61. scaleX: motionSpring,
  62. scaleY: motionSpring,
  63. }}
  64. >
  65. {({ opacity, scaleX, scaleY }) => (
  66. <div
  67. style={{
  68. opacity: opacity,
  69. transform: `scale(${scaleX}, ${scaleY})`,
  70. }}
  71. >
  72. <h4><FormattedMessage {...messages.format} /></h4>
  73. <ul>
  74. <li>
  75. <em>#example</em>
  76. {' '}
  77. <FormattedMessage {...messages.hashtag} />
  78. </li>
  79. <li>
  80. <em>@username@domain</em>
  81. {' '}
  82. <FormattedMessage {...messages.user} />
  83. </li>
  84. <li>
  85. <em>URL</em>
  86. {' '}
  87. <FormattedMessage {...messages.user} />
  88. </li>
  89. <li>
  90. <em>URL</em>
  91. {' '}
  92. <FormattedMessage {...messages.status} />
  93. </li>
  94. </ul>
  95. { searchEnabled ? <FormattedMessage {...messages.full_text} /> : <FormattedMessage {...messages.text} /> }
  96. </div>
  97. )}
  98. </Motion>
  99. </div>
  100. );
  101. }
  102. // Props.
  103. DrawerSearchPopout.propTypes = { style: PropTypes.object };