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

style: Improved dashboard embed style & Overlapping Axis Title for Single Line Charts #1745

Merged
merged 5 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion app/components/chart-footnotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const ChartFootnotesComboLineSingle = ({
) : null;
};

const VisualizeLink = () => {
export const VisualizeLink = () => {
const locale = useLocale();
return (
<Typography variant="caption" color="grey.600">
Expand Down
41 changes: 31 additions & 10 deletions app/components/chart-published.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { extractChartConfigsComponentIris } from "@/charts/shared/chart-helpers"
import { LoadingStateProvider } from "@/charts/shared/chart-loading-state";
import { isUsingImputation } from "@/charts/shared/imputation";
import { ChartErrorBoundary } from "@/components/chart-error-boundary";
import { ChartFootnotes } from "@/components/chart-footnotes";
import { ChartFootnotes, VisualizeLink } from "@/components/chart-footnotes";
import { ChartPanelLayout, ChartWrapper } from "@/components/chart-panel";
import {
ChartControls,
Expand Down Expand Up @@ -107,6 +107,9 @@ export const ChartPublished = (props: ChartPublishedProps) => {
const { dataSource } = state;
const locale = useLocale();
const metadataPanelStore = useMemo(() => createMetadataPanelStore(), []);

const publishedChartClasses = usePublishedChartStyles({ shrink: true });

const renderChart = useCallback(
(chartConfig: ChartConfig) => (
<ChartPublishedIndividualChart
Expand All @@ -125,7 +128,7 @@ export const ChartPublished = (props: ChartPublishedProps) => {
<MetadataPanelStoreContext.Provider value={metadataPanelStore}>
<InteractiveFiltersProvider chartConfigs={state.chartConfigs}>
{state.layout.type === "dashboard" ? (
<>
<Box className={publishedChartClasses.dashboardBoxWrapper}>
<Box
sx={{
mb:
Expand All @@ -142,13 +145,15 @@ export const ChartPublished = (props: ChartPublishedProps) => {
<Description text={state.layout.meta.description[locale]} />
)}
</Box>

<ChartPanelLayout
layoutType={state.layout.layout}
chartConfigs={state.chartConfigs}
renderChart={renderChart}
/>
</>
<Flex sx={{ flexDirection: "column", gap: 4 }}>
<ChartPanelLayout
layoutType={state.layout.layout}
chartConfigs={state.chartConfigs}
renderChart={renderChart}
/>
<VisualizeLink />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only add link when we are previewing a dashboard, see that it's already shown in footnotes in case we look at a single chart:

showVisualizeLink={state.chartConfigs.length === 1}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't state.layout.type === "dashboard" checking if it's dashboard?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my bad, I didn't see that there's code below that renders non-dashboard charts 😅 Still, we could have a situation of a dashboard with one chart, e.g. when we edit a layout with two charts, and then remove one while in layouting step (see that in the screenshot below the chart already contains a link).

Screenshot 2024-09-13 at 14 20 06

So maybe in fact, there should be a safe-guard added to showVisualizeLink={state.chartConfigs.length === 1}, like:

showVisualizeLink={state.chartConfigs.length === 1 && state.layout.type !== "dashboard"}

so in such cases we only show the text link that you added in this PR, outside of the chart itself?

Copy link
Contributor Author

@noahonyejese noahonyejese Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it accordingly like this there should be no duplications

</Flex>
</Box>
) : (
<>
<Flex
Expand Down Expand Up @@ -199,6 +204,19 @@ const usePublishedChartStyles = makeStyles<Theme, { shrink: boolean }>(
`calc(${theme.spacing(5)} + ${shrink ? DRAWER_WIDTH : 0}px)`,
transition: "padding 0.25s ease",
},
dashboardBoxWrapper: {
[theme.breakpoints.up("xs")]: {
padding: theme.spacing(5, 4, 2, 4),
},
[theme.breakpoints.up("md")]: {
padding: theme.spacing(5),
},
[theme.breakpoints.up("lg")]: {
padding: theme.spacing(6),
},

backgroundColor: theme.palette.grey[200],
},
})
);

Expand Down Expand Up @@ -418,7 +436,10 @@ const ChartPublishedInnerImpl = (props: ChartPublishInnerProps) => {
chartConfig={chartConfig}
dashboardFilters={state.dashboardFilters}
components={allComponents}
showVisualizeLink={state.chartConfigs.length === 1}
showVisualizeLink={
state.chartConfigs.length === 1 &&
state.layout.type !== "dashboard"
}
/>
</InteractiveFiltersChartProvider>
</LoadingStateProvider>
Expand Down
Loading