File size: 1,825 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Avatar, Grid, Typography } from '@mui/material';
import React from 'react';
import {
  useFocusCell,
  useOption,
  usePluginOfCell,
  useUiTranslator,
} from '../../core/components/hooks';
import MoveActions from './MoveActions';
import { BottomToolbarTools } from './Tools';

export type BottomToolbarMainBarProps = {
  nodeId: string;
  actionsLeft?: React.ReactNode;
};
export const BottomToolbarMainBar: React.FC<BottomToolbarMainBarProps> =
  React.memo(({ nodeId, actionsLeft }) => {
    const { title, icon } = usePluginOfCell(nodeId) ?? {};
    const { t } = useUiTranslator();
    const focus = useFocusCell(nodeId);
    const showMoveButtons = useOption('showMoveButtonsInBottomToolbar');
    return (
      <div>
        <Grid container={true} direction="row" alignItems="center">
          {icon || title ? (
            <Grid item={true}>
              <Avatar
                onClick={() => focus(true)}
                children={icon || (title ? title[0] : '')}
                style={{
                  cursor: 'pointer',
                  marginRight: 16,
                }}
              />
            </Grid>
          ) : null}
          <Grid item={true}>
            <Typography variant="subtitle1">{t(title)}</Typography>
          </Grid>
          {actionsLeft &&
            React.Children.map(actionsLeft, (action, index) => (
              <Grid item={true} key={index}>
                {action}
              </Grid>
            ))}
          {showMoveButtons ? (
            <Grid item={true} style={{ marginLeft: 'auto' }}>
              <MoveActions nodeId={nodeId} />
            </Grid>
          ) : null}

          <Grid item={true} style={{ marginLeft: 'auto' }}>
            <BottomToolbarTools nodeId={nodeId} />
          </Grid>
        </Grid>
      </div>
    );
  });