1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-27 01:19:00 +02:00

feat: release plan hover buttons (#9703)

This commit is contained in:
Jaanus Sellin 2025-04-07 11:32:31 +03:00 committed by GitHub
parent 4130e06d17
commit 58d123e998
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,7 +20,20 @@ const StyledName = styled(StringTruncator)(({ theme }) => ({
marginBottom: theme.spacing(0.5), marginBottom: theme.spacing(0.5),
})); }));
const StyledCard = styled(Button)(({ theme }) => ({ const CardContent = styled('div')(({ theme }) => ({
width: '100%',
transition: 'opacity 0.2s ease-in-out',
}));
const HoverButtonsContainer = styled('div')(({ theme }) => ({
position: 'absolute',
right: theme.spacing(2),
display: 'flex',
gap: theme.spacing(1),
opacity: 0,
}));
const StyledCard = styled('div')(({ theme }) => ({
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
width: '100%', width: '100%',
@ -35,8 +48,13 @@ const StyledCard = styled(Button)(({ theme }) => ({
borderRadius: theme.spacing(1), borderRadius: theme.spacing(1),
textAlign: 'left', textAlign: 'left',
overflow: 'hidden', overflow: 'hidden',
'&:hover, &:focus': { position: 'relative',
borderColor: theme.palette.primary.main, [`&:hover ${CardContent}, &:focus-within ${CardContent}`]: {
opacity: 0.5,
},
[`&:hover ${HoverButtonsContainer}, &:focus-within ${HoverButtonsContainer}`]:
{
opacity: 1,
}, },
})); }));
@ -50,16 +68,31 @@ const StyledTopRow = styled('div')(({ theme }) => ({
interface IFeatureReleasePlanCardProps { interface IFeatureReleasePlanCardProps {
template: IReleasePlanTemplate; template: IReleasePlanTemplate;
onClick: () => void; onClick: () => void;
onPreviewClick?: (e: React.MouseEvent) => void;
} }
export const FeatureReleasePlanCard = ({ export const FeatureReleasePlanCard = ({
template: { name, description }, template: { name, description },
onClick, onClick,
onPreviewClick,
}: IFeatureReleasePlanCardProps) => { }: IFeatureReleasePlanCardProps) => {
const Icon = getFeatureStrategyIcon('releasePlanTemplate'); const Icon = getFeatureStrategyIcon('releasePlanTemplate');
const handleUseClick = (e: React.MouseEvent) => {
e.stopPropagation();
onClick();
};
const handlePreviewClick = (e: React.MouseEvent) => {
e.stopPropagation();
if (onPreviewClick) {
onPreviewClick(e);
}
};
return ( return (
<StyledCard onClick={onClick}> <StyledCard>
<CardContent>
<StyledTopRow> <StyledTopRow>
<StyledIcon> <StyledIcon>
<Icon /> <Icon />
@ -72,12 +105,32 @@ export const FeatureReleasePlanCard = ({
arrow arrow
sx={{ sx={{
fontSize: (theme) => theme.typography.caption.fontSize, fontSize: (theme) => theme.typography.caption.fontSize,
fontWeight: (theme) => theme.typography.fontWeightRegular, fontWeight: (theme) =>
theme.typography.fontWeightRegular,
width: '100%', width: '100%',
}} }}
> >
{description} {description}
</Truncator> </Truncator>
</CardContent>
<HoverButtonsContainer>
<Button
variant='contained'
size='small'
onClick={handleUseClick}
tabIndex={0}
>
Use
</Button>
<Button
variant='outlined'
size='small'
onClick={handlePreviewClick}
>
Preview
</Button>
</HoverButtonsContainer>
</StyledCard> </StyledCard>
); );
}; };