~cytrogen/masto-fe

ref: 7336f3648b7d590c10f77cb5587ebfd6142087d8 masto-fe/app/javascript/mastodon/components/load_gap.tsx -rw-r--r-- 854 bytes
7336f364 — たいち ひ Rewrite `<LoadGap />` as FC and TS (#25042) 2 years ago
                                                                                
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
import { useCallback } from 'react';

import type { InjectedIntl } from 'react-intl';
import { injectIntl, defineMessages } from 'react-intl';

import { Icon } from 'mastodon/components/icon';

const messages = defineMessages({
  load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
});

interface Props {
  disabled: boolean;
  maxId: string;
  onClick: (maxId: string) => void;
  intl: InjectedIntl;
}

export const LoadGap = injectIntl<Props>(
  ({ disabled, maxId, onClick, intl }) => {
    const handleClick = useCallback(() => {
      onClick(maxId);
    }, [maxId, onClick]);

    return (
      <button
        className='load-more load-gap'
        disabled={disabled}
        onClick={handleClick}
        aria-label={intl.formatMessage(messages.load_more)}
      >
        <Icon id='ellipsis-h' />
      </button>
    );
  }
);