1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: Signals preview img (#7993)

This commit is contained in:
Mateusz Kwasniewski 2024-08-28 08:24:12 +02:00 committed by GitHub
parent 09e619ee25
commit c8f20196e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 72 additions and 12 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -15,6 +15,7 @@ import Signals from '@mui/icons-material/Sensors';
import type { NavigationMode } from 'component/layout/MainLayout/NavigationSidebar/NavigationMode'; import type { NavigationMode } from 'component/layout/MainLayout/NavigationSidebar/NavigationMode';
import { NewInUnleashItem } from './NewInUnleashItem'; import { NewInUnleashItem } from './NewInUnleashItem';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { ReactComponent as SignalsPreview } from 'assets/img/signals.svg';
const StyledNewInUnleash = styled('div')(({ theme }) => ({ const StyledNewInUnleash = styled('div')(({ theme }) => ({
margin: theme.spacing(2, 0, 1, 0), margin: theme.spacing(2, 0, 1, 0),
@ -73,6 +74,7 @@ type NewItem = {
docsLink: string; docsLink: string;
show: boolean; show: boolean;
longDescription: ReactNode; longDescription: ReactNode;
preview?: ReactNode;
}; };
interface INewInUnleashProps { interface INewInUnleashProps {
@ -98,6 +100,7 @@ export const NewInUnleash = ({
{ {
label: 'Signals & Actions', label: 'Signals & Actions',
icon: <StyledSignalsIcon />, icon: <StyledSignalsIcon />,
preview: <SignalsPreview />,
link: '/integrations/signals', link: '/integrations/signals',
docsLink: 'https://docs.getunleash.io/reference/signals', docsLink: 'https://docs.getunleash.io/reference/signals',
show: isEnterprise() && signalsEnabled, show: isEnterprise() && signalsEnabled,
@ -164,7 +167,14 @@ export const NewInUnleash = ({
</StyledNewInUnleashHeader> </StyledNewInUnleashHeader>
<StyledNewInUnleashList> <StyledNewInUnleashList>
{visibleItems.map( {visibleItems.map(
({ label, icon, link, longDescription, docsLink }) => ( ({
label,
icon,
link,
longDescription,
docsLink,
preview,
}) => (
<NewInUnleashItem <NewInUnleashItem
onClick={() => { onClick={() => {
trackEvent('new-in-unleash-click', { trackEvent('new-in-unleash-click', {
@ -184,6 +194,7 @@ export const NewInUnleash = ({
label={label} label={label}
icon={icon} icon={icon}
link={link} link={link}
preview={preview}
longDescription={longDescription} longDescription={longDescription}
docsLink={docsLink} docsLink={docsLink}
/> />

View File

@ -36,6 +36,7 @@ interface INewInUnleashItemProps {
longDescription: ReactNode; longDescription: ReactNode;
link: string; link: string;
docsLink: string; docsLink: string;
preview?: ReactNode;
} }
const useTooltip = () => { const useTooltip = () => {
@ -60,6 +61,7 @@ export const NewInUnleashItem = ({
longDescription, longDescription,
link, link,
docsLink, docsLink,
preview,
}: INewInUnleashItemProps) => { }: INewInUnleashItemProps) => {
const { open, handleTooltipOpen, handleTooltipClose } = useTooltip(); const { open, handleTooltipOpen, handleTooltipClose } = useTooltip();
@ -83,6 +85,7 @@ export const NewInUnleashItem = ({
longDescription={longDescription} longDescription={longDescription}
link={link} link={link}
docsLink={docsLink} docsLink={docsLink}
preview={preview}
> >
<StyledItemButton> <StyledItemButton>
<StyledItemButtonContent> <StyledItemButtonContent>

View File

@ -17,12 +17,7 @@ const Header = styled(Box)(({ theme }) => ({
backgroundColor: theme.palette.primary.light, backgroundColor: theme.palette.primary.light,
color: theme.palette.primary.contrastText, color: theme.palette.primary.contrastText,
borderRadius: `${theme.shape.borderRadiusMedium}px ${theme.shape.borderRadiusMedium}px 0 0`, // has to match the parent tooltip container borderRadius: `${theme.shape.borderRadiusMedium}px ${theme.shape.borderRadiusMedium}px 0 0`, // has to match the parent tooltip container
margin: theme.spacing(-1, -1.5), // has to match the parent tooltip container margin: theme.spacing(-1, -1.5, 0, -1.5), // has to match the parent tooltip container
padding: theme.spacing(2, 3),
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
minHeight: '120px',
})); }));
const Body = styled(Box)(({ theme }) => ({ const Body = styled(Box)(({ theme }) => ({
@ -45,7 +40,21 @@ const StyledOpenInNew = styled(OpenInNew)(({ theme }) => ({
fontSize: theme.spacing(2.25), fontSize: theme.spacing(2.25),
})); }));
const StyledUnleashLogo = styled(UnleashLogo)({ width: '150px' }); const BottomPreview = styled(Box)(({ theme }) => ({
padding: theme.spacing(3, 2, 0, 2),
display: 'flex',
justifyContent: 'center',
alignItems: 'flex-end',
'> svg': { display: 'block', width: '100%', height: 'auto' },
}));
const CenteredPreview = styled(Box)(({ theme }) => ({
padding: theme.spacing(4),
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
'> svg': { display: 'block', width: '70%', height: 'auto' },
}));
const LongDescription = styled(Box)(({ theme }) => ({ const LongDescription = styled(Box)(({ theme }) => ({
ul: { ul: {
@ -54,11 +63,11 @@ const LongDescription = styled(Box)(({ theme }) => ({
})); }));
const Title = styled(Typography)(({ theme }) => ({ const Title = styled(Typography)(({ theme }) => ({
margin: theme.spacing(2, 0), padding: theme.spacing(1, 0, 2, 0),
})); }));
const ReadMore = styled(Box)(({ theme }) => ({ const ReadMore = styled(Box)(({ theme }) => ({
margin: theme.spacing(3, 0), padding: theme.spacing(2, 0, 4, 0),
})); }));
export const NewInUnleashTooltip: FC<{ export const NewInUnleashTooltip: FC<{
@ -68,8 +77,18 @@ export const NewInUnleashTooltip: FC<{
docsLink: string; docsLink: string;
link: string; link: string;
open: boolean; open: boolean;
preview?: ReactNode;
onClose: () => void; onClose: () => void;
}> = ({ children, title, longDescription, link, docsLink, open, onClose }) => { }> = ({
children,
title,
longDescription,
link,
docsLink,
preview,
open,
onClose,
}) => {
const navigate = useNavigate(); const navigate = useNavigate();
return ( return (
@ -88,7 +107,13 @@ export const NewInUnleashTooltip: FC<{
<ClickAwayListener onClickAway={onClose}> <ClickAwayListener onClickAway={onClose}>
<Box> <Box>
<Header> <Header>
<StyledUnleashLogo /> {preview ? (
<BottomPreview>{preview}</BottomPreview>
) : (
<CenteredPreview>
<UnleashLogo />
</CenteredPreview>
)}
</Header> </Header>
<Body> <Body>
<Title>{title}</Title> <Title>{title}</Title>