-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.tsx
130 lines (127 loc) · 3.84 KB
/
index.tsx
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import * as React from 'react';
import Button from '@akashaorg/design-system-core/lib/components/Button';
import Stack from '@akashaorg/design-system-core/lib/components/Stack';
import Text from '@akashaorg/design-system-core/lib/components/Text';
import Tooltip from '@akashaorg/design-system-core/lib/components/Tooltip';
import { AddBlockButtonProps, AddBlock } from './add-block-button';
import { EditorUIState } from '../types';
export type TFooterProps = AddBlockButtonProps & {
uiState: EditorUIState;
tagsLabel: string;
blocksLabel: string;
publishLabel: string;
saveTagsLabel: string;
cancelLabel: string;
maxBlocksWarningLabel: string;
maxTags: number;
maxBlocks: number;
tagsNumber: number;
blocksNumber: number;
disableAddBlock: boolean;
disableTagsSave: boolean;
disableBeamPublishing: boolean;
handleClickTags: () => void;
handleClickSave: () => void;
handleClickCancel: () => void;
handleBeamPublish: () => void;
};
export const Footer: React.FC<TFooterProps> = props => {
const {
uiState,
tagsLabel,
blocksLabel,
publishLabel,
saveTagsLabel,
cancelLabel,
addBlockLabel,
maxBlocksWarningLabel,
maxTags,
maxBlocks,
tagsNumber,
blocksNumber,
disableAddBlock,
disableTagsSave,
disableBeamPublishing,
handleClickTags,
handleClickSave,
handleClickCancel,
handleBeamPublish,
handleClickAddBlock,
} = props;
return (
<Stack
padding={16}
fullWidth
justify="between"
align="center"
direction="row"
customStyle="rounded-b-2xl"
>
{/* render content based on the value of uiState */}
{uiState === 'blocks' && (
<>
<Text
variant="footnotes2"
color="grey7"
>{`${blocksNumber}/${maxBlocks} ${blocksLabel}`}</Text>
<Button variant="secondary" label={cancelLabel} onClick={handleClickCancel} />
</>
)}
{uiState === 'tags' && (
<>
<Text variant="footnotes2" color="grey7">{`${tagsNumber}/${maxTags} ${tagsLabel}`}</Text>
<Stack direction="row" spacing="gap-2">
<Button variant="text" label={cancelLabel} onClick={handleClickCancel} />
<Button
variant="primary"
disabled={disableTagsSave}
label={saveTagsLabel}
onClick={handleClickSave}
/>
</Stack>
</>
)}
{uiState === 'editor' && (
<>
{disableAddBlock && (
<Tooltip
placement="top"
content={maxBlocksWarningLabel}
trigger="hover"
contentCustomStyle="w-75"
>
<AddBlock disabled={disableAddBlock} addBlockLabel={addBlockLabel} />
</Tooltip>
)}
{!disableAddBlock && (
<AddBlock addBlockLabel={addBlockLabel} handleClickAddBlock={handleClickAddBlock} />
)}
<Stack direction="row" spacing="gap-4" align="center">
<Stack direction="row" spacing="gap-2" align="center">
<Stack
align="center"
justify="center"
customStyle="w-[18px] h-[18px] rounded-[3px]"
background={{ light: 'grey9', dark: 'grey5' }}
>
<Text
variant="footnotes2"
color={{ light: 'secondaryLight', dark: 'secondaryDark' }}
>
{tagsNumber}
</Text>
</Stack>
<Button variant="text" label={tagsLabel} onClick={handleClickTags} />
</Stack>
<Button
variant="primary"
disabled={disableBeamPublishing}
label={publishLabel}
onClick={handleBeamPublish}
/>
</Stack>
</>
)}
</Stack>
);
};