Newer
Older
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
import React from 'react'
import { Animation, Pattern } from 'src/models'
import { animations, patterns } from '../patterns'
import {
Table,
TableCaption,
TableContainer,
Tbody,
Td,
Th,
Text,
Thead,
Tooltip,
Tr,
HStack,
IconButton,
Icon,
} from '@chakra-ui/react'
import { FaPlay, FaTrash } from 'react-icons/fa'
const tableHeaders = ['Titulo', 'Descripcion', 'Fecha de creacion', '']
export type AnimationsProps = {
patternId: Pattern['id']
}
export const Animations: React.FC<AnimationsProps> = ({ patternId }) => {
const pattern = patterns.find((p) => p.id === patternId)
const patternAnimations = animations.filter(
(animation) => animation.patternId === patternId
)
if (!pattern || !patternAnimations) {
return null
}
return (
<TableContainer>
<Table variant="simple" size="lg">
<TableCaption>Animaciones disponibles de {pattern.title}</TableCaption>
<Thead>
<Tr>
{tableHeaders.map((header, index) => (
<Th key={`th-${index}`}>{header}</Th>
))}
</Tr>
</Thead>
<Tbody>
{patternAnimations.map((animation, index) => (
<Tr key={`animation-${animation.title}-${index}`}>
<Td>{animation.title}</Td>
<Td>
<Tooltip label={animation.description} hasArrow>
<Text isTruncated maxW="sm">
{animation.description}
</Text>
</Tooltip>
</Td>
<Td>{new Date(animation.creationDate).toUTCString()}</Td>
<Td>
<ActionsRow _animation={animation} />
</Td>
</Tr>
))}
</Tbody>
</Table>
</TableContainer>
)
}
type ActionsRowProps = {
_animation: Animation
}
const ActionsRow: React.FC<ActionsRowProps> = ({ _animation }) => {
return (
<HStack>
<IconButton
aria-label="view animation"
variant="unstyled"
icon={<Icon as={FaPlay} />}
/>
<IconButton
aria-label="delete animation"
variant="unstyled"
icon={<Icon as={FaTrash} />}
/>
</HStack>
)
}