1
1
import { Trans } from "@lingui/macro" ;
2
2
import { Box , Theme } from "@mui/material" ;
3
3
import { makeStyles } from "@mui/styles" ;
4
+ import clsx from "clsx" ;
4
5
import React , { useEffect , useMemo , useRef } from "react" ;
5
6
import { useStore } from "zustand" ;
6
7
@@ -20,8 +21,8 @@ import {
20
21
ChartTablePreviewProvider ,
21
22
useChartTablePreview ,
22
23
} from "@/components/chart-table-preview" ;
24
+ import { useChartStyles } from "@/components/chart-utils" ;
23
25
import { ChartWithFilters } from "@/components/chart-with-filters" ;
24
- import { shouldShowDebugPanel } from "@/components/debug-panel" ;
25
26
import Flex from "@/components/flex" ;
26
27
import { HintBlue , HintRed , HintYellow } from "@/components/hint" ;
27
28
import { MetadataPanel } from "@/components/metadata-panel" ;
@@ -141,22 +142,17 @@ export const ChartPublished = (props: ChartPublishedProps) => {
141
142
) ;
142
143
} ;
143
144
144
- const useStyles = makeStyles < Theme , { shrink : boolean } > ( ( theme ) => ( {
145
- root : {
146
- position : "relative" ,
147
- display : "grid" ,
148
- gridTemplateRows : "subgrid" ,
149
- gridRow : shouldShowDebugPanel ( ) ? "span 6" : "span 5" ,
150
- backgroundColor : theme . palette . background . paper ,
151
- border : "1px solid" ,
152
- borderColor : theme . palette . divider ,
153
- padding : theme . spacing ( 6 ) ,
154
- paddingLeft : ( { shrink } ) =>
155
- `calc(${ theme . spacing ( 5 ) } + ${ shrink ? DRAWER_WIDTH : 0 } px)` ,
156
- color : theme . palette . grey [ 800 ] ,
157
- transition : "padding 0.25s ease" ,
158
- } ,
159
- } ) ) ;
145
+ const usePublishedChartStyles = makeStyles < Theme , { shrink : boolean } > (
146
+ ( theme ) => ( {
147
+ root : {
148
+ // Needed for the metadata panel to be contained inside the root.
149
+ position : "relative" ,
150
+ paddingLeft : ( { shrink } ) =>
151
+ `calc(${ theme . spacing ( 5 ) } + ${ shrink ? DRAWER_WIDTH : 0 } px)` ,
152
+ transition : "padding 0.25s ease" ,
153
+ } ,
154
+ } )
155
+ ) ;
160
156
161
157
type ChartPublishInnerProps = {
162
158
dataSource : DataSource | undefined ;
@@ -203,7 +199,8 @@ const ChartPublishedInner = (props: ChartPublishInnerProps) => {
203
199
return ( ) => unsubscribe ( ) ;
204
200
} ) ;
205
201
206
- const classes = useStyles ( {
202
+ const chartClasses = useChartStyles ( ) ;
203
+ const publishedChartClasses = usePublishedChartStyles ( {
207
204
shrink : shouldShrink ,
208
205
} ) ;
209
206
const locale = useLocale ( ) ;
@@ -246,7 +243,10 @@ const ChartPublishedInner = (props: ChartPublishInnerProps) => {
246
243
247
244
return (
248
245
< MetadataPanelStoreContext . Provider value = { metadataPanelStore } >
249
- < Box className = { classes . root } ref = { rootRef } >
246
+ < Box
247
+ className = { clsx ( chartClasses . root , publishedChartClasses . root ) }
248
+ ref = { rootRef }
249
+ >
250
250
< ChartErrorBoundary resetKeys = { [ chartConfig ] } >
251
251
{ metadata ?. some (
252
252
( d ) => d . publicationStatus === DataCubePublicationStatus . Draft
@@ -329,7 +329,7 @@ const ChartPublishedInner = (props: ChartPublishInnerProps) => {
329
329
/>
330
330
) : (
331
331
// We need to have a span here to keep the space between the
332
- // title and the chart (subgrid layout)
332
+ // description and the chart (subgrid layout)
333
333
< span />
334
334
) }
335
335
< div
0 commit comments