about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/drawer/search/popout/index.js
blob: 6219f46ca23789458b7b4e2d645bcd350363f4db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//  Package imports.
import PropTypes from 'prop-types';
import React from 'react';
import {
  FormattedMessage,
  defineMessages,
} from 'react-intl';
import spring from 'react-motion/lib/spring';

//  Utils.
import Motion from 'flavours/glitch/util/optional_motion';

//  Messages.
const messages = defineMessages({
  format: {
    defaultMessage: 'Advanced search format',
    id: 'search_popout.search_format',
  },
  hashtag: {
    defaultMessage: 'hashtag',
    id: 'search_popout.tips.hashtag',
  },
  status: {
    defaultMessage: 'status',
    id: 'search_popout.tips.status',
  },
  text: {
    defaultMessage: 'Simple text returns matching display names, usernames and hashtags',
    id: 'search_popout.tips.text',
  },
  user: {
    defaultMessage: 'user',
    id: 'search_popout.tips.user',
  },
});

//  The spring used by our motion.
const motionSpring = spring(1, { damping: 35, stiffness: 400 });

//  The component.
export default function DrawerSearchPopout ({ style }) {

  //  The result.
  return (
    <div
      className='drawer--search--popout'
      style={{
        ...style,
        position: 'absolute',
        width: 285,
      }}
    >
      <Motion
        defaultStyle={{
          opacity: 0,
          scaleX: 0.85,
          scaleY: 0.75,
        }}
        style={{
          opacity: motionSpring,
          scaleX: motionSpring,
          scaleY: motionSpring,
        }}
      >
        {({ opacity, scaleX, scaleY }) => (
          <div
            style={{
              opacity: opacity,
              transform: `scale(${scaleX}, ${scaleY})`,
            }}
          >
            <h4><FormattedMessage {...messages.format} /></h4>
            <ul>
              <li>
                <em>#example</em>
                {' '}
                <FormattedMessage {...messages.hashtag} />
              </li>
              <li>
                <em>@username@domain</em>
                {' '}
                <FormattedMessage {...messages.user} />
              </li>
              <li>
                <em>URL</em>
                {' '}
                <FormattedMessage {...messages.user} />
              </li>
              <li>
                <em>URL</em>
                {' '}
                <FormattedMessage {...messages.status} />
              </li>
            </ul>
            <FormattedMessage {...messages.text} />
          </div>
        )}
      </Motion>
    </div>
  );
}

//  Props.
DrawerSearchPopout.propTypes = { style: PropTypes.object };