about summary refs log tree commit diff
path: root/app/assets
diff options
context:
space:
mode:
authorusagi-f <usagi.f@gmail.com>2017-04-17 17:34:33 +0900
committerEugen <eugen@zeonfederated.com>2017-04-17 10:34:33 +0200
commitb87a08e16004221f27996007c241bcc80470c33f (patch)
tree4aba1277472329b552651ea93f404236b68efaf0 /app/assets
parentbe6cabb3159d55ded386d43096fe2fe58af657dc (diff)
Add function color remaining text (#1980)
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/components/features/compose/components/character_counter.jsx13
1 files changed, 8 insertions, 5 deletions
diff --git a/app/assets/javascripts/components/features/compose/components/character_counter.jsx b/app/assets/javascripts/components/features/compose/components/character_counter.jsx
index e6b675354..fc64f94a5 100644
--- a/app/assets/javascripts/components/features/compose/components/character_counter.jsx
+++ b/app/assets/javascripts/components/features/compose/components/character_counter.jsx
@@ -9,14 +9,17 @@ const CharacterCounter = React.createClass({
 
   mixins: [PureRenderMixin],
 
+  checkRemainingText (diff) {
+    if (diff <= 0) {
+      return <span style={{ fontSize: '16px', cursor: 'default', color: '#ff5050' }}>{diff}</span>;
+    }
+    return <span style={{ fontSize: '16px', cursor: 'default' }}>{diff}</span>;
+  },
+
   render () {
     const diff = this.props.max - this.props.text.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "_").length;
 
-    return (
-      <span style={{ fontSize: '16px', cursor: 'default' }}>
-        {diff}
-      </span>
-    );
+    return this.checkRemainingText(diff);
   }
 
 });