This repository has been archived by the owner on Dec 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
globals.tsx
70 lines (63 loc) · 1.57 KB
/
globals.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
import { styled, Icon, faCopy, faTrashAlt } from '@edtr-io/editor-ui'
import { StateTypeReturnType } from '@edtr-io/plugin'
import * as React from 'react'
import { createRowPluginTheme, rowsState } from '../..'
const StyledGlobals = styled.div({
display: 'flex',
alignItems: 'center'
})
const IconContainer = styled.div<{ disabled?: boolean; name: string }>(
({ disabled, name, ...props }) => {
const theme = createRowPluginTheme(name, props.theme)
return {
margin: '0 5px 0 15px',
padding: '5px',
cursor: disabled ? 'not-allowed' : 'pointer',
color: disabled ? theme.menu.secondary.color : theme.menu.primary.color,
'&:hover': {
color: disabled ? theme.menu.secondary.color : theme.highlightColor
}
}
}
)
const Copy = ({ duplicateRow, close, name }: GlobalsProps) => {
return (
<IconContainer
name={name}
onClick={() => {
duplicateRow()
close()
}}
>
<Icon icon={faCopy} /> Kopieren
</IconContainer>
)
}
const Remove = ({ rows, index, close, name }: GlobalsProps) => {
return (
<IconContainer
name={name}
onClick={() => {
rows.remove(index)
close()
}}
>
<Icon icon={faTrashAlt} /> Löschen
</IconContainer>
)
}
interface GlobalsProps {
name: string
index: number
rows: StateTypeReturnType<typeof rowsState>
close: () => void
duplicateRow: () => void
}
export const Globals = (props: GlobalsProps) => {
return (
<StyledGlobals>
<Copy {...props} />
<Remove {...props} />
</StyledGlobals>
)
}