Skip to content

Commit

Permalink
refactor: Pass createdWith to VisualizeLink
Browse files Browse the repository at this point in the history
...in order so we don't have to use i18n provider when making a screenshot.
  • Loading branch information
bprusinowski committed Dec 4, 2024
1 parent 59e2be3 commit af03396
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/components/chart-footnotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ export const ChartFootnotes = ({
) : null}
</div>
))}
{showVisualizeLink ? <VisualizeLink /> : null}
{showVisualizeLink ? (
<VisualizeLink createdWith={t({ id: "metadata.link.created.with" })} />
) : null}
</Box>
);
};
Expand Down Expand Up @@ -281,11 +283,12 @@ const ChartFootnotesComboLineSingle = ({
) : null;
};

export const VisualizeLink = () => {
export const VisualizeLink = ({ createdWith }: { createdWith: ReactNode }) => {
const locale = useLocale();

return (
<Typography variant="caption" color="grey.600">
<Trans id="metadata.link.created.with">Created with</Trans>
{createdWith}
<Link
href={`https://visualize.admin.ch/${locale}/`}
target="_blank"
Expand Down
8 changes: 6 additions & 2 deletions app/components/chart-published.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { DashboardInteractiveFilters } from "@/components/dashboard-interactive-
import Flex from "@/components/flex";
import { HintBlue, HintRed, HintYellow } from "@/components/hint";
import {
MetadataPanelStoreContext,
createMetadataPanelStore,
MetadataPanelStoreContext,
} from "@/components/metadata-panel-store";
import {
ChartConfig,
Expand Down Expand Up @@ -155,7 +155,11 @@ export const ChartPublished = ({
chartConfigs={state.chartConfigs}
renderChart={renderChart}
/>
{state.chartConfigs.length !== 1 && <VisualizeLink />}
{state.chartConfigs.length !== 1 && (
<VisualizeLink
createdWith={t({ id: "metadata.link.created.with" })}
/>
)}
</Box>
) : (
<>
Expand Down

0 comments on commit af03396

Please sign in to comment.