♻️ refactor(people): improve employee card switch
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// src/components/StackedDeck.tsx
|
|
||||||
import { FC, useEffect, useState } from 'react'
|
import { FC, useEffect, useState } from 'react'
|
||||||
import { Box } from '@mui/material'
|
import { Box, IconButton } from '@mui/material'
|
||||||
import { EmplyeeCard, EmplyeeCardProps } from 'components/molecules/EmplyeeCard/index.js'
|
import { EmplyeeCard, EmplyeeCardProps } from 'components/molecules/EmplyeeCard/index.js'
|
||||||
|
import ShuffleIcon from '@mui/icons-material/NextPlan'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
items: EmplyeeCardProps[]
|
items: EmplyeeCardProps[]
|
||||||
@@ -33,18 +33,16 @@ const EmplyeeStack: FC<Props> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
onClick={handleTopClick}
|
|
||||||
sx={{
|
sx={{
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
width: 270 + offsetStep * (initialItems.length - 1),
|
width: 270 + offsetStep * Math.min(initialItems.length - 1, maxVisible),
|
||||||
height: 360 + offsetStep * (initialItems.length - 1),
|
height: 360 + offsetStep * Math.min(initialItems.length - 1, maxVisible),
|
||||||
}}>
|
}}>
|
||||||
{items.slice(0, maxVisible).map((props, idx) => (
|
{items.slice(0, maxVisible).map((props, idx) => (
|
||||||
<EmplyeeCard
|
<EmplyeeCard
|
||||||
{...props}
|
{...props}
|
||||||
key={idx}
|
key={idx}
|
||||||
sx={{
|
sx={{
|
||||||
cursor: 'pointer',
|
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: idx * offsetStep,
|
top: idx * offsetStep,
|
||||||
left: idx * offsetStep,
|
left: idx * offsetStep,
|
||||||
@@ -52,6 +50,21 @@ const EmplyeeStack: FC<Props> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
<IconButton
|
||||||
|
onClick={handleTopClick}
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
color: 'text.primary',
|
||||||
|
backgroundColor: 'background.paper',
|
||||||
|
'&:hover': { backgroundColor: 'background.paper' },
|
||||||
|
padding: 0,
|
||||||
|
right: Math.min(initialItems.length - 2, maxVisible - 1) * offsetStep,
|
||||||
|
top: -offsetStep,
|
||||||
|
zIndex: initialItems.length + 1,
|
||||||
|
rotate: '30deg',
|
||||||
|
}}>
|
||||||
|
<ShuffleIcon fontSize="large" />
|
||||||
|
</IconButton>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user