Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(insights): Placeholders for Web Vitals boxes #80769

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,54 @@ export default function WebVitalMeters({
</Fragment>
);
return (
<MeterBarContainer
<VitalContainer
key={webVital}
onClick={() => webVitalExists && onClick?.(webVital)}
clickable={webVitalExists}
>
{webVitalExists && <InteractionStateLayer />}
{webVitalExists && meterBody}
{!webVitalExists && (
<StyledTooltip
title={tct('No [webVital] data found in this project.', {
webVital: webVital.toUpperCase(),
})}
>
{meterBody}
</StyledTooltip>
)}
</MeterBarContainer>
webVital={webVital}
webVitalExists={webVitalExists}
meterBody={meterBody}
onClick={onClick}
/>
);
})}
</Flex>
</Container>
);
}

type VitalContainerProps = {
meterBody: React.ReactNode;
webVital: WebVitals;
webVitalExists: boolean;
onClick?: (webVital: WebVitals) => void;
};

function VitalContainer({
webVital,
webVitalExists,
meterBody,
onClick,
}: VitalContainerProps) {
return (
<MeterBarContainer
key={webVital}
onClick={() => webVitalExists && onClick?.(webVital)}
clickable={webVitalExists}
>
{webVitalExists && <InteractionStateLayer />}
{webVitalExists && meterBody}
{!webVitalExists && (
<StyledTooltip
title={tct('No [webVital] data found in this project.', {
webVital: webVital.toUpperCase(),
})}
>
{meterBody}
</StyledTooltip>
)}
</MeterBarContainer>
);
}

export const getFormattedDuration = (value: number) => {
return getDuration(value, value < 1 ? 0 : 2, true);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import {
type SubregionCode,
} from 'sentry/views/insights/types';

const WEB_VITALS_COUNT = 5;

export function WebVitalsLandingPage() {
const location = useLocation();
const {isInDomainView} = useDomainViewFilters();
Expand Down Expand Up @@ -135,6 +137,7 @@ export function WebVitalsLandingPage() {
/>
</PerformanceScoreChartContainer>
<WebVitalMetersContainer>
{(isPending || isProjectScoresLoading) && <WebVitalMetersPlaceholder />}
<WebVitalMeters
projectData={projectData}
projectScore={projectScore}
Expand Down Expand Up @@ -188,6 +191,16 @@ export function WebVitalsLandingPage() {
);
}

function WebVitalMetersPlaceholder() {
return (
<LoadingBoxContainer>
{[...Array(WEB_VITALS_COUNT)].map((_, index) => (
<LoadingBox key={index} />
))}
</LoadingBoxContainer>
);
}

function PageWithProviders() {
return (
<ModulePageProviders
Expand Down Expand Up @@ -219,6 +232,26 @@ const WebVitalMetersContainer = styled('div')`
margin-bottom: ${space(2)};
`;

const LoadingBoxContainer = styled('div')`
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
gap: ${space(1)};
align-items: center;
flex-wrap: wrap;

margin-bottom: ${space(1)};
`;

const LoadingBox = styled('div')`
flex: 1;
min-width: 140px;
height: 90px;
background-color: ${p => p.theme.gray100};
border-radius: ${p => p.theme.borderRadius};
`;

export const AlertContent = styled('div')`
display: grid;
grid-template-columns: 1fr max-content;
Expand Down
Loading