mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: release plan hover buttons (#9703)
This commit is contained in:
		
							parent
							
								
									4130e06d17
								
							
						
					
					
						commit
						58d123e998
					
				@ -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>
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user