about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/composer/hashtag_warning/index.js
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-01-20 16:37:52 -0600
committerGitHub <noreply@github.com>2018-01-20 16:37:52 -0600
commite7a0840f8cfcc199665db43e28af74ec56ffe734 (patch)
tree1d73ff938eb5b184eee16e01768cd901d57ebe3f /app/javascript/flavours/glitch/features/composer/hashtag_warning/index.js
parent24b6e4121f656d24adc5676e8a207ded610a7ea7 (diff)
parent1287b2782b8e8a1d2c7a3684ebf1327fc5647f51 (diff)
Merge pull request #336 from ThibG/glitch-soc/features/tag-warning
Display a warning when composing unlisted toots with something looking like a hashtag
Diffstat (limited to 'app/javascript/flavours/glitch/features/composer/hashtag_warning/index.js')
-rw-r--r--app/javascript/flavours/glitch/features/composer/hashtag_warning/index.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/composer/hashtag_warning/index.js b/app/javascript/flavours/glitch/features/composer/hashtag_warning/index.js
new file mode 100644
index 000000000..716028e4c
--- /dev/null
+++ b/app/javascript/flavours/glitch/features/composer/hashtag_warning/index.js
@@ -0,0 +1,49 @@
+import React from 'react';
+import Motion from 'flavours/glitch/util/optional_motion';
+import spring from 'react-motion/lib/spring';
+import { defineMessages, FormattedMessage } from 'react-intl';
+
+//  This is the spring used with our motion.
+const motionSpring = spring(1, { damping: 35, stiffness: 400 });
+
+//  Messages.
+const messages = defineMessages({
+  disclaimer: {
+    defaultMessage: 'This toot won\'t be listed under any hashtag as it is unlisted. Only public toots can be searched by hashtag.',
+    id: 'compose_form.hashtag_warning',
+  },
+});
+
+//  The component.
+export default function ComposerHashtagWarning () {
+  return (
+    <Motion
+      defaultStyle={{
+        opacity: 0,
+        scaleX: 0.85,
+        scaleY: 0.75,
+      }}
+      style={{
+        opacity: motionSpring,
+        scaleX: motionSpring,
+        scaleY: motionSpring,
+      }}
+    >
+      {({ opacity, scaleX, scaleY }) => (
+        <div
+          className='composer--warning'
+          style={{
+            opacity: opacity,
+            transform: `scale(${scaleX}, ${scaleY})`,
+          }}
+        >
+          <FormattedMessage
+            {...messages.disclaimer}
+          />
+        </div>
+      )}
+    </Motion>
+  );
+}
+
+ComposerHashtagWarning.propTypes = {};