Skip to content

Commit

Permalink
fix(analytics): 🐛 it navigates to the right chart but jumps
Browse files Browse the repository at this point in the history
Hard code fake height for each chart

see: commit 4638043
  • Loading branch information
jalezi committed Nov 8, 2024
1 parent fd70f07 commit f39fa59
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/pages/Analytics/Data/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const COLUMN = {
section: 'examples 1',
order: 2,
componentName: 'ChartCard',
fakeHeight: '570px',
options: {
accessibility: {
typeDescription: 'Column chart with 6 series.',
Expand Down Expand Up @@ -47,6 +48,7 @@ export const Line = {
section: 'examples 2',
order: 2,
componentName: 'ChartCard',
fakeHeight: '570px',
options: {
chart: { type: 'line' },
title: { text: 'Line' },
Expand Down Expand Up @@ -75,6 +77,7 @@ export const DRILLDOWN = {
section: 'examples 2',
order: 3,
componentName: 'ChartCard',
fakeHeight: '541px',
options: {
chart: { type: 'column' },
title: { text: 'Drilldown' },
Expand Down Expand Up @@ -253,6 +256,7 @@ export const SLO_UE_MAP = {
order: 4,
section: 'examples 1',
componentName: 'MapCard',
fakeHeight: '662px',
options: {
chart: { map: sloUEMap },
title: { text: 'Slo UE Map' },
Expand Down Expand Up @@ -337,6 +341,7 @@ const SLO_OB_MAP = {
order: 1,
section: 'examples 1',
componentName: 'MapCard',
fakeHeight: '662px',
options: {
chart: { map: sloOBMap },
title: { text: 'Slo OB Map' },
Expand Down
6 changes: 0 additions & 6 deletions src/pages/Analytics/Layout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,3 @@
.CardWrapper:not(:last-child) {
margin-bottom: 2rem;
}

.FakeChartTitlesWrapper {
background: #ffffff;
border-radius: 6px;
min-height: 600px;
}
15 changes: 12 additions & 3 deletions src/pages/Analytics/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import Footer from './Footer';
import Sidebar from './Sidebar';

import styles from './Layout.module.css';
import stylesCard from './Cards/Card.module.css';

import { SECTIONS } from './Data/sections';
import { createChartDataProxy } from './Data/create-chart-data-proxy';
import RichInfoClick from './RichInfoClick';
import TouchdeviceNotification from './TouchDeviceNotification';
import { CardHeader } from './Cards/CardHeader';

const ChartCard = lazy(() => import('./Cards/ChartCard'));
const MapCard = lazy(() => import('./Cards/MapCard'));
Expand Down Expand Up @@ -47,16 +50,22 @@ const Analytics = function Analytics() {
{section.charts.map(chart => {
const CardComponent = CARDS[chart.componentName];
const chartProxy = createChartDataProxy(chart);

return (
<RenderOnViewportEntry
key={chartProxy.id}
srOnlyComponentsBeforeEntered={
<div className={styles.FakeChartTitlesWrapper}>
<h3 id={chartProxy.id}>{chartProxy.options.title.text}</h3>
<p>{chartProxy.options.subtitle.text}</p>
<div className={`${stylesCard.Card} `} style={{ minHeight: chart.fakeHeight }}>
<CardHeader>
<div>
<h3 id={chartProxy.id}>{chartProxy.options.title.text}</h3>
<p>{chartProxy.options.subtitle.text}</p>
</div>
</CardHeader>
</div>
}
className={styles.CardWrapper}
style={{ minHeight: chart.fakeHeight }}
>
<CardComponent id={chartProxy.id} options={chartProxy.options} />
</RenderOnViewportEntry>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Analytics/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @property {string} id
* @property {"ChartCard" } componentName
* @property {HighchartsOptions} options
* @property {React.CSSProperties["minHeight"] fakeHeight
*/
/**
* @typedef {Object} MapData
Expand Down

0 comments on commit f39fa59

Please sign in to comment.