12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import React from 'react';
- import dayjs from 'dayjs';
- import Icon from '../Icon';
- import Divider from '../Divider';
- import { scrollIntoView } from '../../helpers/utility';
- import data from './data';
- import { PageNumber, AnnotationBox, Group } from './styled';
- type Props = {
- type: string;
- page?: number;
- title?: string;
- date?: string;
- showPageNum?: boolean;
- };
- const AnnotationItem = ({
- type,
- title,
- date,
- page,
- showPageNum,
- }: Props): React.ReactElement => {
- const handleClick = (): void => {
- const ele: HTMLElement = document.getElementById(
- `page_${page}`
- ) as HTMLElement;
- scrollIntoView(ele);
- };
- return (
- <>
- {showPageNum ? (
- <>
- <Divider orientation="horizontal" />
- <PageNumber>{`Page ${page}`}</PageNumber>
- </>
- ) : null}
- <AnnotationBox onClick={handleClick}>
- <Group>
- <Icon glyph={data[type].icon} />
- {data[type].text}
- </Group>
- <Group>
- <span>{title || ''}</span>
- <span>
- {date && dayjs(date?.replace('_', ' ')).format('YYYY/MM/DD HH:mm')}
- </span>
- </Group>
- </AnnotationBox>
- </>
- );
- };
- export default AnnotationItem;
|