Skip to content

Commit d581819

Browse files
committed
add active Tile indicator, update delete prompt
1 parent 68b2565 commit d581819

File tree

2 files changed

+94
-34
lines changed

2 files changed

+94
-34
lines changed

packages/frontend/src/pages/Tiles/components/TileList.tsx

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ import { toPrettyDateString } from '@/helpers/dateTime'
3737

3838
import { TileConnections } from '..'
3939

40+
import {
41+
flexStyles,
42+
linkStyles,
43+
pulsingDotStyles,
44+
tagStyles,
45+
textStyles,
46+
} from './style'
47+
4048
const TileListItem = ({
4149
isConnectionsLoading,
4250
numConnections,
@@ -87,46 +95,32 @@ const TileListItem = ({
8795

8896
return (
8997
<Link to={URLS.TILE(table.id)}>
90-
<Flex
91-
px={8}
92-
py={6}
93-
w="100%"
94-
justifyContent="space-between"
95-
alignItems="center"
96-
_hover={{
97-
bg: 'interaction.muted.neutral.hover',
98-
'& .hover-remove-button': {
99-
visibility: 'visible',
100-
},
101-
}}
102-
_active={{
103-
bg: 'interaction.muted.neutral.active',
104-
}}
105-
>
98+
<Flex {...linkStyles}>
10699
<Box>
107-
<Text textStyle="h6">{table.name}</Text>
108-
<Flex gap={1} textStyle="body-2" color="base.content.medium">
109-
<Text>Last opened {toPrettyDateString(+table.lastAccessedAt)}</Text>
110-
{table.role !== 'viewer' && numConnections && (
111-
<>
112-
<Icon as={BsDot} fontSize="1.5em" />
113-
<Skeleton isLoaded={!isConnectionsLoading}>
100+
<Flex alignItems="center">
101+
<Text textStyle="h6">{table.name}</Text>
102+
</Flex>
103+
<Flex {...flexStyles.container}>
104+
<Text {...textStyles.lastOpened}>
105+
Last opened {toPrettyDateString(+table.lastAccessedAt)}
106+
</Text>
107+
{table.role !== 'viewer' && numConnections > 0 && (
108+
<Skeleton isLoaded={!isConnectionsLoading}>
109+
<Flex {...flexStyles.usedInPipes}>
110+
<Icon
111+
as={BsDot}
112+
color="interaction.success.default"
113+
sx={pulsingDotStyles}
114+
/>
114115
<Text>Used in {numConnections} pipes</Text>
115-
</Skeleton>
116-
</>
116+
</Flex>
117+
</Skeleton>
117118
)}
118119
</Flex>
119120
</Box>
120121
<Flex alignItems="center" gap={4}>
121122
{table.role === 'viewer' && (
122-
<Tag
123-
colorScheme="secondary"
124-
size="xs"
125-
variant="subtle"
126-
py={2}
127-
gap={1}
128-
pointerEvents="none"
129-
>
123+
<Tag {...tagStyles}>
130124
<TagLeftIcon as={MdOutlineRemoveRedEye} />
131125
<TagLabel>View only</TagLabel>
132126
</Tag>
@@ -153,7 +147,9 @@ const TileListItem = ({
153147
<AlertDialogHeader>Delete Tile</AlertDialogHeader>
154148

155149
<AlertDialogBody>
156-
{"Are you sure? You can't undo this action afterwards."}
150+
{numConnections > 0
151+
? `Are you sure? This Tile is used in ${numConnections} pipe(s). You can't undo this action afterwards.`
152+
: "Are you sure? You can't undo this action afterwards."}
157153
</AlertDialogBody>
158154

159155
<AlertDialogFooter>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { FlexProps } from '@chakra-ui/react'
2+
3+
export const flexStyles = {
4+
container: {
5+
color: 'base.content.medium',
6+
direction: {
7+
base: 'column',
8+
md: 'row',
9+
} as FlexProps['direction'],
10+
textStyle: 'body-2',
11+
},
12+
usedInPipes: {
13+
alignItems: 'center',
14+
marginLeft: { base: 0, md: '-0.25em' },
15+
},
16+
}
17+
18+
export const linkStyles = {
19+
px: 8,
20+
py: 6,
21+
w: '100%',
22+
justifyContent: 'space-between',
23+
alignItems: 'center',
24+
_hover: {
25+
bg: 'interaction.muted.neutral.hover',
26+
'& .hover-remove-button': {
27+
visibility: 'visible',
28+
},
29+
},
30+
_active: {
31+
bg: 'interaction.muted.neutral.active',
32+
},
33+
}
34+
35+
export const pulsingDotStyles = {
36+
animation: 'pulse 2s infinite',
37+
fontSize: '3em',
38+
marginLeft: { base: '-0.4em', md: 0 },
39+
marginTop: '-0.5em',
40+
marginBottom: '-0.5em',
41+
'@keyframes pulse': {
42+
'0%': { opacity: 0.4 },
43+
'50%': { opacity: 1 },
44+
'100%': { opacity: 0.4 },
45+
},
46+
}
47+
48+
export const tagStyles = {
49+
colorScheme: 'secondary',
50+
size: 'xs',
51+
variant: 'subtle',
52+
py: 2,
53+
gap: 1,
54+
pointerEvents: 'none' as const,
55+
}
56+
57+
export const textStyles = {
58+
lastOpened: {
59+
width: {
60+
base: 'full',
61+
md: '17.5em',
62+
},
63+
},
64+
}

0 commit comments

Comments
 (0)