Skip to content

Commit

Permalink
feat: Improve insights overall loading state
Browse files Browse the repository at this point in the history
This isn't very modern and it occupies a lot of space. This was prompted by it not fitting the Web Vitals UI, let's tweak it all around the app and see if it looks nicer like this.
  • Loading branch information
rafaeelaudibert committed Feb 3, 2025
1 parent df2dc69 commit 531668a
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 375 deletions.
3 changes: 2 additions & 1 deletion cypress/e2e/dashboard-shared.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ describe('Shared dashboard', () => {
})

cy.get('.InsightCard').should('have.length', 6)

// Make sure no element with text "There are no matching events for this query" exists
cy.get('.insight-empty-state').should('not.exist')
cy.get('[data-attr="insight-empty-state"]').should('not.exist')
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/insights-navigation-open-directly.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Insights', () => {

it('can open a new funnels insight', () => {
insight.newInsight('FUNNELS')
cy.get('.funnels-empty-state__title').should('exist')
cy.get('[data-attr="insight-empty-state"]').find('h2').should('exist')
})

it('can open a new paths insight', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Insights', () => {

it('can open a new funnels insight', () => {
insight.clickTab('FUNNELS')
cy.get('.funnels-empty-state__title').should('exist')
cy.get('[data-attr="insight-empty-state"]').find('h2').should('exist')
})

it('can open a new retention insight', () => {
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/insights-saved.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ describe('Insights - saved', () => {
})
cy.task('resetInsightCache').then(() => {
cy.visit(urls.insightView(newInsightId)) // Full refresh
cy.get('.insight-empty-state').should('exist') // There should be a loading state for a moment

cy.get('[data-attr="insight-empty-state"]').should('exist') // There should be a loading state for a moment
cy.wait('@getInsightsRefreshAsync').then(() => {
cy.get('[data-attr=trend-line-graph]').should('exist')
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@
padding: 0.5rem;
}

.insight-empty-state {
height: 100%; // Fix wonkiness when SpinnerOverlay is shown
padding-top: 0;
padding-bottom: 0;
font-size: 0.875rem; // Reduce font size
}

.LemonTable {
background: none;
border: none;
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/queries/nodes/InsightViz/InsightVizDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ export function InsightVizDisplay({
// Empty states that completely replace the graph
const BlockingEmptyState = (() => {
if (insightDataLoading) {
return (
<div className="flex flex-col flex-1 justify-center items-center p-2">
<InsightLoadingState queryId={queryId} key={queryId} insightProps={insightProps} />
</div>
)
return <InsightLoadingState queryId={queryId} key={queryId} insightProps={insightProps} />
}

if (validationError) {
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/queries/nodes/WebVitals/WebVitalsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ export const WebVitalsContent = ({ webVitalsQueryResponse }: WebVitalsContentPro
// NOTE: `band` will only return `none` if the value is undefined,
// so this is basically the same check twice, but we need that to make TS happy
if (value === undefined || band === 'none') {
return (
<div className="w-full border rounded p-4 md:w-[30%]">
<LemonSkeleton fade className="w-full h-40" />
</div>
)
return <LemonSkeleton fade className="w-full h-40 rounded md:w-[30%]" />
}

const grade = GRADE_PER_BAND[band]
Expand All @@ -60,7 +56,7 @@ export const WebVitalsContent = ({ webVitalsQueryResponse }: WebVitalsContentPro
const experience = EXPERIENCE_PER_BAND[band]

return (
<div className="w-full border rounded p-6 md:w-[30%] flex flex-col gap-2">
<div className="w-full border rounded p-6 md:w-[30%] flex flex-col gap-2 m-2">
<span className="text-lg">
<strong>{LONG_METRIC_NAME[webVitalsTab]}</strong>
</span>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ const Content = ({
}

return responseLoading ? (
<StatelessInsightLoadingState queryId={queryId} pollResponse={pollResponse} />
<div className="flex flex-1 p-2 w-full">
<StatelessInsightLoadingState queryId={queryId} pollResponse={pollResponse} />
</div>
) : !response ? (
<div className="flex flex-1 justify-center items-center">
<span className="text-muted mt-3">Query results will appear here</span>
Expand Down
52 changes: 3 additions & 49 deletions frontend/src/scenes/insights/EmptyStates/EmptyStates.scss
Original file line number Diff line number Diff line change
@@ -1,50 +1,4 @@
.insight-empty-state {
display: flex;
flex-direction: column;
flex-grow: 1;
align-items: center;
justify-content: center;
padding: 1rem;
font-size: 1.1em;
color: var(--muted);

&.error {
h2 {
color: var(--danger);
}
}

&.warning {
h2 {
color: var(--warning);
}
}

h2 {
font-size: 1.5rem;
font-weight: 600;
line-height: 1.6rem;
color: var(--primary-alt);
}

.empty-state-inner {
display: flex;
flex-direction: column;
align-items: center;
max-width: 600px;

.illustration-main {
font-size: 2.5rem;
}

h2 {
width: 100%;
text-align: center;
word-wrap: break-word;
}

ol {
margin: 0.5rem 0;
}
}
/* TODO: Migrate this to a CSS variable (with a `bg-` Tailwind class) once @adamleithp finishes his Tailwind work */
.insights-empty-state {
background-color: rgb(129 129 129 / 20%);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const meta: Meta = {
layout: 'fullscreen',
viewMode: 'story',
testOptions: {
waitForSelector: '.empty-state-inner',
waitForSelector: '[data-attr="insight-empty-state"]',
},
},
}
Expand Down
Loading

0 comments on commit 531668a

Please sign in to comment.