@@ -12,14 +12,15 @@ import MarkdownRenderer from './MarkdownRenderer';
12
12
import formatDate from 'date-fns/format' ;
13
13
import EmojiIcon from './emojiIcon' ;
14
14
import AddIcon from './addIcon' ;
15
- import Tippy from '@tippy.js/react' ;
15
+ import Tippy , { TippyGroup } from '@tippy.js/react' ;
16
16
import 'tippy.js/themes/light-border.css' ;
17
17
import { Link } from 'react-router-dom' ;
18
18
import { postRootQuery } from './App' ;
19
19
import GitHubLoginButton from './GitHubLoginButton' ;
20
20
import { NotificationContext } from './Notifications' ;
21
21
import { Box , Heading , Text } from 'grommet' ;
22
22
import UserContext from './UserContext' ;
23
+ import { lowerCase , sentenceCase } from 'change-case' ;
23
24
24
25
import type { Post_post } from './__generated__/Post_post.graphql' ;
25
26
@@ -269,26 +270,61 @@ const Post = ({relay, post}: Props) => {
269
270
) }
270
271
</ Box >
271
272
) : null }
273
+
272
274
< Box
273
275
pad = "xsmall"
274
276
direction = "row"
275
277
wrap = { true }
276
278
border = { { size : 'xsmall' , side : 'top' , color : 'rgba(0,0,0,0.1)' } } >
277
- { usedReactions . map ( g => (
278
- < Text
279
- key = { g . content }
280
- style = { {
281
- padding : '0 16px' ,
282
- borderRight : '1px solid rgba(0,0,0,0.12)' ,
283
- display : 'flex' ,
284
- alignItems : 'center' ,
285
- } } >
286
- { emojiForContent ( g . content ) } { ' ' }
287
- < Text size = "small" style = { { marginLeft : 8 } } >
288
- { g . users . totalCount }
289
- </ Text >
290
- </ Text >
291
- ) ) }
279
+ < TippyGroup delay = { 500 } >
280
+ { usedReactions . map ( g => {
281
+ const total = g . users . totalCount ;
282
+ const reactors = g . users . nodes . map ( x => x . login ) ;
283
+ if ( total > 11 ) {
284
+ reactors . push ( `${ total - 11 } more` ) ;
285
+ }
286
+
287
+ const reactorsSentence = [
288
+ ...reactors . slice ( 0 , reactors . length - 2 ) ,
289
+ reactors . slice ( - 2 ) . join ( reactors . length > 2 ? ', and ' : ' and ' ) ,
290
+ ] . join ( ', ' ) ;
291
+
292
+ return (
293
+ < Tippy
294
+ key = { g . content }
295
+ arrow = { true }
296
+ trigger = "mouseenter focus click"
297
+ placement = "bottom"
298
+ flipBehavior = { [ 'bottom' , 'right' ] }
299
+ theme = "light-border"
300
+ inertia = { true }
301
+ interactive = { true }
302
+ animateFill = { false }
303
+ interactiveBorder = { 10 }
304
+ duration = { [ 75 , 75 ] }
305
+ content = {
306
+ < div >
307
+ { reactorsSentence } reacted with{ ' ' }
308
+ { lowerCase ( sentenceCase ( g . content ) ) } emoji
309
+ </ div >
310
+ } >
311
+ < span
312
+ key = { g . content }
313
+ style = { {
314
+ padding : '0 16px' ,
315
+ borderRight : '1px solid rgba(0,0,0,0.12)' ,
316
+ display : 'flex' ,
317
+ alignItems : 'center' ,
318
+ } } >
319
+ < Text > { emojiForContent ( g . content ) } </ Text >
320
+ < Text size = "small" style = { { marginLeft : 8 } } >
321
+ { g . users . totalCount }
322
+ </ Text >
323
+ </ span >
324
+ </ Tippy >
325
+ ) ;
326
+ } ) }
327
+ </ TippyGroup >
292
328
< Tippy
293
329
onCreate = { instance => ( popoverInstance . current = instance ) }
294
330
arrow = { true }
@@ -368,8 +404,11 @@ export default createFragmentContainer(Post, {
368
404
reactionGroups {
369
405
content
370
406
viewerHasReacted
371
- users {
407
+ users(first: 11) {
372
408
totalCount
409
+ nodes {
410
+ login
411
+ }
373
412
}
374
413
}
375
414
comments {
@@ -378,114 +417,3 @@ export default createFragmentContainer(Post, {
378
417
}
379
418
` ,
380
419
} ) ;
381
-
382
- const WORDS = [
383
- 'people' ,
384
- 'see' ,
385
- 'one' ,
386
- 'make' ,
387
- 'day' ,
388
- 'it’s' ,
389
- 'man' ,
390
- 'old' ,
391
- 'out' ,
392
- 'dog' ,
393
- 'guy' ,
394
- 'new' ,
395
- 'video' ,
396
- 'things' ,
397
- 'life' ,
398
- 'made' ,
399
- 'year' ,
400
- 'never' ,
401
- 'facebook' ,
402
- 'awesome' ,
403
- 'girl' ,
404
- 'look' ,
405
- 'photos' ,
406
- 'love' ,
407
- 'know' ,
408
- 'best' ,
409
- 'way' ,
410
- 'thing' ,
411
- 'beautiful' ,
412
- 'time' ,
413
- 'little' ,
414
- 'more' ,
415
- 'first' ,
416
- 'happened' ,
417
- 'heart' ,
418
- 'now' ,
419
- 'you’ll' ,
420
- 'being' ,
421
- 'ways' ,
422
- 'want' ,
423
- 'think' ,
424
- 'something' ,
425
- 'years' ,
426
- 'found' ,
427
- 'better' ,
428
- 'seen' ,
429
- 'baby' ,
430
- 'really' ,
431
- 'world' ,
432
- 'actually' ,
433
- 'valentine’s' ,
434
- 'down' ,
435
- 'reasons' ,
436
- 'watch' ,
437
- 'need' ,
438
- 'here' ,
439
- 'good' ,
440
- 'media' ,
441
- 'makes' ,
442
- 'boy' ,
443
- 'mind' ,
444
- 'right' ,
445
- 'social' ,
446
- ] ;
447
-
448
- function blockWord ( size : number ) : string {
449
- let res = '' ;
450
- for ( let i = 0 ; i < size ; i ++ ) {
451
- res += '█' ;
452
- }
453
- return res ;
454
- }
455
-
456
- function randInt ( x : number ) : number {
457
- return Math . floor ( Math . random ( ) * x ) ;
458
- }
459
-
460
- function randomWord ( ) {
461
- // return WORDS[randInt(WORDS.length)];
462
- return blockWord ( randInt ( 4 ) + 1 ) ;
463
- }
464
-
465
- function capitalize ( s : string ) : string {
466
- return s . charAt ( 0 ) . toUpperCase ( ) + s . slice ( 1 ) ;
467
- }
468
-
469
- export class LoadingPost extends React . PureComponent < * , * > {
470
- render ( ) {
471
- return (
472
- < PostBox >
473
- < Box pad = "medium" style = { { opacity : '0.6' } } className = "shimmer" >
474
- < Heading level = { 3 } margin = "none" >
475
- ██ ██ ██
476
- </ Heading >
477
- < Text size = "xsmall" > █ █ ██</ Text >
478
- < Text size = "small" >
479
- < MarkdownRenderer
480
- source = { `█ ██ █ █ ██ ██ █ ██ ██ ██ ██ █ █ ██ █ ██ █ ██ █ █ █ █ ██ ██ ██ ██ █ █ ██ █ ██ ██ █ █ ██ █ █ █ ██ █ ██ █ ██ ██ ██ █ ██ ██ █ ██ ██ █ █ ██ █ █ ██ ██ ██ █ █ ██ █ █ █ █ █ █ ██ ██ █ ██ ██ █ ██ ██ ██ ██ █ ██ █ █ █ ██ █ █ ██ ██ ██ ██ █ █ ██ █ █ ██ █ ██ █ █ ██ ██ █ █ █ █ ██ █ ██ █ ██ █ █ █ ██ ██ █ █ █ █ ██ ██
481
-
482
- ██ ██ ██ █ █ █ █ █ ██ ██ ██ █ ██ ██ ██ ██ █ ██ █ █ █ █ ██ █ ██ █ █ █ █ █ █ █ ██ ██ █ █ █ █ █ █ ██ ██ █ █ ██ ██ ██ █ ██ ██ █ █ █ ██ █ █ █ ██ █ █ ██ ██ █ █ █ ██ ██ █ █ █ █ ██ ██ ██ ██ █ █ ██ ██ ██ █ █ █ █ █ █ ██ █ ██ █ █ ██ █ █ █ █ █ ██ █ ██ ██ ██ ██ █ ██ ██ ██ █ █ █ ██ █ ██ █ ██ █ ██ █ ██ ██ ██ █ █ ██ ██ █ ██ ██ ██ ██ █ ██ █ █ ██ ██ █ ██ ██ █ ██ █ █ ██ █ █ ██ █ █ █ ██ █ ██ █ ██ █ █ █ █ █ ██ █ █ ██ █ ██ ██ ██ █ █ █ ██ █ ██ ██ ██ █ ██ █ █ ██ ██ ██ █ █ █ █ ██ ██ █ ██ ██ █ ██ ██ ██ █ ██ █
483
-
484
- ██ █ █ █ ██ ██ ██ █ ██ ██ ██ ██ █ ██ ██ ██ ██ █ ██ ██ █ ██ █ ██ ██ ██ ██ ██ ██ ██ █ ██ ██ █ ██ ██ ██ ██ ██ █ █ ██ ██ █ █ ██ █ ██ █ ██ █ ██ █ █ ██ ██ █ ██ ██ █ ██ ██ █ ██ █ ██ ██ ██ █ █ █ ██ ██ ██ ██ ██ ██ █ █ ██ █ ██ █ ██ █ ██ █ ██ █ █ ██ ██ ██ ██ ██ ██ ██ █ █ █ █ ██ █ █ █ █ █ █ ██ █ █ ██ █ █ ██ █ ██ █ ██ ██ ██ █ █ █ █ █ ██ ██ █ █ ██ █ █ █ █ ██ ██ █ █` }
485
- />
486
- </ Text >
487
- </ Box >
488
- </ PostBox >
489
- ) ;
490
- }
491
- }
0 commit comments