123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import React from 'react';
- import { useTranslation } from 'react-i18next';
- import Button from '../components/Button';
- import ExpansionPanel from '../components/ExpansionPanel';
- import Icon from '../components/Icon';
- import HighlightTools from './HighlightTools';
- import FreehandTool from './FreehandTool';
- import TextTool from './FreeTextTool';
- import StickyNoteTool from './StickyNoteTool';
- import ShapeTools from './ShapeTools';
- import useActions from '../actions';
- import useStore from '../store';
- type Props = {
- sidebarState: string;
- onClickSidebar: (state: string) => void;
- };
- const MarkupTools: React.FC<Props> = ({
- sidebarState,
- onClickSidebar,
- }: Props) => {
- const { t } = useTranslation('sidebar');
- const [{ toolState }, dispatch] = useStore();
- const { setTool } = useActions(dispatch);
- const onClickTool = (state: string): void => {
- if (state === toolState) {
- setTool('');
- } else {
- setTool(state);
- }
- };
- const isActive = sidebarState === 'markup-tools';
- const Label = (
- <Button
- shouldFitContainer
- align="left"
- onClick={(): void => {
- onClickSidebar('markup-tools');
- }}
- >
- <Icon glyph="markup-tools" style={{ marginRight: '10px' }} />
- {t('markupTool')}
- <Icon
- glyph="dropdown-arrow"
- style={{
- transform: isActive ? 'rotate(180deg)' : 'rotate(0deg)',
- marginLeft: '10px',
- }}
- />
- </Button>
- );
- return (
- <ExpansionPanel label={Label} isActive={isActive}>
- <HighlightTools
- title={t('annotate')}
- isActive={toolState === 'highlight'}
- onClick={(): void => {
- onClickTool('highlight');
- }}
- />
- <FreehandTool
- title={t('freehand')}
- isActive={toolState === 'freehand'}
- onClick={(): void => {
- onClickTool('freehand');
- }}
- />
- <TextTool
- title={t('textBox')}
- isActive={toolState === 'text'}
- onClick={(): void => {
- onClickTool('text');
- }}
- />
- <StickyNoteTool
- title={t('stickyNote')}
- isActive={toolState === 'sticky'}
- onClick={(): void => {
- onClickTool('sticky');
- }}
- />
- <ShapeTools
- title={t('shape')}
- isActive={toolState === 'shape'}
- onClick={(): void => {
- onClickTool('shape');
- }}
- />
- </ExpansionPanel>
- );
- };
- export default MarkupTools;
|