about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/components/poll.js
diff options
context:
space:
mode:
authorSasha Sorokin <10401817+Brawaru@users.noreply.github.com>2021-10-13 09:59:31 +0700
committerClaire <claire.github-309c@sitedethib.com>2021-10-13 15:53:33 +0200
commit5169b374c64ee48a820c04d7c6e7f1f9235d2417 (patch)
treeb393f2b0e0f5735338e495b1efe769ef97265e8c /app/javascript/flavours/glitch/components/poll.js
parent1665b842856811c16b904c3b99be6b141a0e1c7b (diff)
[Glitch] Add single option votes tooltip in polls
Port 89b5071fde2f111eaa53ce404712423de25a593d to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/components/poll.js')
-rw-r--r--app/javascript/flavours/glitch/components/poll.js27
1 files changed, 22 insertions, 5 deletions
diff --git a/app/javascript/flavours/glitch/components/poll.js b/app/javascript/flavours/glitch/components/poll.js
index f230823cc..970b00705 100644
--- a/app/javascript/flavours/glitch/components/poll.js
+++ b/app/javascript/flavours/glitch/components/poll.js
@@ -12,8 +12,18 @@ import RelativeTimestamp from './relative_timestamp';
 import Icon from 'flavours/glitch/components/icon';
 
 const messages = defineMessages({
-  closed: { id: 'poll.closed', defaultMessage: 'Closed' },
-  voted: { id: 'poll.voted', defaultMessage: 'You voted for this answer', description: 'Tooltip of the "voted" checkmark in polls' },
+  closed: {
+    id: 'poll.closed',
+    defaultMessage: 'Closed',
+  },
+  voted: {
+    id: 'poll.voted',
+    defaultMessage: 'You voted for this answer',
+  },
+  votes: {
+    id: 'poll.votes',
+    defaultMessage: '{votes, plural, one {# vote} other {# votes}}',
+  },
 });
 
 const makeEmojiMap = record => record.get('emojis').reduce((obj, emoji) => {
@@ -148,9 +158,16 @@ class Poll extends ImmutablePureComponent {
               data-index={optionIndex}
             />
           )}
-          {showResults && <span className='poll__number'>
-            {Math.round(percent)}%
-          </span>}
+          {showResults && (
+            <span
+              className='poll__number'
+              title={intl.formatMessage(messages.votes, {
+                votes: option.get('votes_count'),
+              })}
+            >
+              {Math.round(percent)}%
+            </span>
+          )}
 
           <span
             className='poll__option__text translate'