-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathAction.tsx
167 lines (153 loc) · 4.69 KB
/
Action.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import AutoFixHighIcon from '@mui/icons-material/AutoFixHigh'
import CheckIcon from '@mui/icons-material/Check'
import ElectricBoltIcon from '@mui/icons-material/ElectricBolt'
import FileDownloadIcon from '@mui/icons-material/FileDownload'
import SaveAltIcon from '@mui/icons-material/SaveAlt'
import Box from '@mui/material/Box'
import Toolbar from '@mui/material/Toolbar'
import noop from 'lodash/noop'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import IconButton from '../../Parts/Buttons/Icon'
import Columns from '../Grids/Columns'
export interface ActionBarProps {}
export function ActionBar(props: React.PropsWithChildren<ActionBarProps>) {
return (
<Toolbar
disableGutters
sx={{ borderTop: 'solid 1px #ddd', backgroundColor: '#fafafa', paddingX: 2 }}
>
<ActionBarItems {...props} />
</Toolbar>
)
}
function ActionBarItems(props: React.PropsWithChildren<ActionBarProps>) {
return <Columns spacing={2}>{props.children}</Columns>
}
export interface ButtonProps {
label?: string
color?: 'success' | 'warning' | 'error' | 'info'
updated?: boolean
disabled?: boolean
onClick?: () => void
}
export function SaveAsButton(props: ButtonProps) {
const onClick = props.onClick || noop
const { t } = useTranslation()
return (
<Box>
<IconButton
label={props.label || t('save-changes')}
Icon={SaveAltIcon}
variant="outlined"
disabled={props.disabled}
onClick={() => onClick()}
sx={{
backgroundColor: 'white',
color: (theme) => theme.palette.OKFNCoolGray.main,
borderColor: (theme) => theme.palette.OKFNCoolGray.main,
'&:hover': {
borderColor: (theme) => theme.palette.OKFNCoolGray.main,
},
}}
/>
</Box>
)
}
export function AssistantButton(props: ButtonProps) {
const onClick = props.onClick || noop
const { t } = useTranslation()
return (
<Box sx={{ marginRight: '20px' }}>
<IconButton
label={props.label || t('ai')}
Icon={AutoFixHighIcon}
variant="outlined"
disabled={props.disabled}
onClick={() => onClick()}
sx={{
backgroundColor: 'white',
textTransform: 'none',
color: (theme) => theme.palette.OKFNCoolGray.main,
borderColor: (theme) => theme.palette.OKFNCoolGray.main,
'&:hover': {
borderColor: (theme) => theme.palette.OKFNCoolGray.main,
},
}}
/>
</Box>
)
}
export function ExportButton(props: ButtonProps) {
const onClick = props.onClick || noop
const { t } = useTranslation()
return (
<Box sx={{ marginRight: '20px' }}>
<IconButton
label={props.label || t('export')}
Icon={FileDownloadIcon}
variant="outlined"
disabled={props.disabled}
onClick={() => onClick()}
sx={{
backgroundColor: 'white',
textTransform: 'none',
color: (theme) => theme.palette.OKFNCoolGray.main,
borderColor: (theme) => theme.palette.OKFNCoolGray.main,
'&:hover': {
borderColor: (theme) => theme.palette.OKFNCoolGray.main,
},
}}
/>
</Box>
)
}
export function PublishButton(props: ButtonProps) {
const onClick = props.onClick || noop
const { t } = useTranslation()
return (
<Box sx={{ marginRight: '20px' }}>
<IconButton
label={props.label || t('publish')}
Icon={ElectricBoltIcon}
variant={!props.disabled ? 'contained' : 'outlined'}
disabled={props.disabled}
onClick={() => onClick()}
sx={{
backgroundColor: (theme) =>
props.disabled ? 'white' : theme.palette.OKFNBlack.main,
textTransform: 'none',
color: (theme) => theme.palette.OKFNWhite.main,
'&:hover': {
color: (theme) => theme.palette.OKFNWhite.main,
borderColor: (theme) => theme.palette.OKFNBlue.main,
backgroundColor: (theme) => theme.palette.OKFNBlue.main,
},
}}
/>
</Box>
)
}
export function SaveButton(props: ButtonProps) {
const onClick = props.onClick || noop
const { t } = useTranslation()
return (
<Box>
<IconButton
label={props.label || t('save-changes')}
Icon={CheckIcon}
variant={props.updated ? 'contained' : 'outlined'}
disabled={!props.updated}
onClick={() => onClick()}
sx={{
backgroundColor: (theme) =>
!props.updated ? 'white' : theme.palette.OKFNBlack.main,
'&:hover': {
backgroundColor: (theme) => theme.palette.OKFNBlue.main,
},
textTransform: 'none',
}}
/>
</Box>
)
}