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

feat: Update minimal embed mode chart footnotes #1026

Merged
merged 2 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
46 changes: 28 additions & 18 deletions app/components/chart-footnotes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Trans } from "@lingui/macro";
import { Box, Button, Link, Theme, Typography } from "@mui/material";
import { makeStyles } from "@mui/styles";
import { useEffect, useMemo, useState } from "react";
import { PropsWithChildren, useEffect, useMemo, useState } from "react";

import { useChartTablePreview } from "@/components/chart-table-preview";
import { DataDownloadMenu, RunSparqlQuery } from "@/components/data-download";
Expand Down Expand Up @@ -174,6 +174,12 @@ export const ChartFootnotes = ({
dangerouslySetInnerHTML={{ __html: dataCubeByIri.publisher }}
></Box>
)}
{configKey && shareUrl && visualizeLinkText && (
<>
{" "}
/ <LinkButton href={shareUrl}> {visualizeLinkText}</LinkButton>
</>
)}
bprusinowski marked this conversation as resolved.
Show resolved Hide resolved
</Typography>
) : null}

Expand Down Expand Up @@ -238,23 +244,12 @@ export const ChartFootnotes = ({
{sparqlEditorUrl && showSparqlQuery !== false && (
<RunSparqlQuery url={sparqlEditorUrl as string} />
)}
{configKey && shareUrl && (
<Button
component="a"
variant="text"
color="primary"
size="small"
sx={{ p: 0, typography: "caption" }}
href={shareUrl}
target="_blank"
rel="noopener noreferrer"
>
{visualizeLinkText ?? (
<Trans id="metadata.link.created.with.visualize">
Created with visualize.admin.ch
</Trans>
)}
</Button>
{configKey && shareUrl && !visualizeLinkText && (
<LinkButton href={shareUrl}>
<Trans id="metadata.link.created.with.visualize">
Created with visualize.admin.ch
</Trans>
</LinkButton>
)}
</Box>
</Box>
Expand All @@ -263,3 +258,18 @@ export const ChartFootnotes = ({
return null;
}
};

const LinkButton = (props: PropsWithChildren<{ href: string }>) => {
bprusinowski marked this conversation as resolved.
Show resolved Hide resolved
return (
<Button
component="a"
variant="text"
color="primary"
size="small"
sx={{ p: 0, typography: "caption", verticalAlign: "unset" }}
target="_blank"
rel="noopener noreferrer"
{...props}
/>
);
};
2 changes: 1 addition & 1 deletion app/components/chart-published.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const ChartPublishedInner = ({
visualizeLinkText={
showDownload === false ? (
<Trans id="metadata.link.created.with.visualize.alternate">
More information
visualize.admin.ch
</Trans>
) : undefined
}
Expand Down
6 changes: 4 additions & 2 deletions app/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ msgstr "Kategorien"
msgid "columnStyle.heatmap"
msgstr "Heatmap"

#: app/configurator/table/table-chart-options.tsx
#: app/configurator/table/table-chart-options.tsx
#: app/configurator/table/table-chart-options.tsx
msgid "columnStyle.text"
Expand Down Expand Up @@ -874,6 +875,8 @@ msgstr "Koordinaten-Ladefehler"
msgid "hint.create.your.own.chart"
msgstr "Kopieren Sie diese Visualisierung oder erstellen Sie eine neue Visualisierung mit Swiss Open Government Data."

#: app/components/data-download.tsx
#: app/components/data-download.tsx
#: app/components/hint.tsx
msgid "hint.dataloadingerror.message"
msgstr "Die Daten konnten nicht geladen werden."
Expand All @@ -892,7 +895,6 @@ msgstr "Sie können diese Visualisierung teilen oder sie einbetten. Zudem könne

#: app/components/form.tsx
#: app/components/hint.tsx
#: app/components/hint.tsx
msgid "hint.loading.data"
msgstr "Lade Daten …"

Expand Down Expand Up @@ -943,7 +945,7 @@ msgstr "Erstellt mit visualize.admin.ch"

#: app/components/chart-published.tsx
msgid "metadata.link.created.with.visualize.alternate"
msgstr "Mehr Informationen"
msgstr "visualize.admin.ch"

#: app/components/chart-footnotes.tsx
msgid "metadata.source"
Expand Down
6 changes: 4 additions & 2 deletions app/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ msgstr "Categories"
msgid "columnStyle.heatmap"
msgstr "Heat Map"

#: app/configurator/table/table-chart-options.tsx
#: app/configurator/table/table-chart-options.tsx
#: app/configurator/table/table-chart-options.tsx
msgid "columnStyle.text"
Expand Down Expand Up @@ -874,6 +875,8 @@ msgstr "Coordinates loading error"
msgid "hint.create.your.own.chart"
msgstr "Copy this visualization or make a new visualization using Swiss Open Government Data."

#: app/components/data-download.tsx
#: app/components/data-download.tsx
#: app/components/hint.tsx
msgid "hint.dataloadingerror.message"
msgstr "The data could not be loaded."
Expand All @@ -892,7 +895,6 @@ msgstr "You can share this visualization by copying the URL or by embedding it o

#: app/components/form.tsx
#: app/components/hint.tsx
#: app/components/hint.tsx
msgid "hint.loading.data"
msgstr "Loading data..."

Expand Down Expand Up @@ -943,7 +945,7 @@ msgstr "Created with visualize.admin.ch"

#: app/components/chart-published.tsx
msgid "metadata.link.created.with.visualize.alternate"
msgstr "More information"
msgstr "visualize.admin.ch"

#: app/components/chart-footnotes.tsx
msgid "metadata.source"
Expand Down
6 changes: 4 additions & 2 deletions app/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ msgstr "Catégories"
msgid "columnStyle.heatmap"
msgstr "Heatmap"

#: app/configurator/table/table-chart-options.tsx
#: app/configurator/table/table-chart-options.tsx
#: app/configurator/table/table-chart-options.tsx
msgid "columnStyle.text"
Expand Down Expand Up @@ -874,6 +875,8 @@ msgstr "Erreur de chargement des coordonnées"
msgid "hint.create.your.own.chart"
msgstr "Copiez cette visualisation ou créez une nouvelle visualisation à partir des données ouvertes de l’administration publique suisse."

#: app/components/data-download.tsx
#: app/components/data-download.tsx
#: app/components/hint.tsx
msgid "hint.dataloadingerror.message"
msgstr "Les données n'ont pas pu être téléchargées."
Expand All @@ -892,7 +895,6 @@ msgstr "Vous pouvez partager cette visualisation en copiant l'URL ou en l'intég

#: app/components/form.tsx
#: app/components/hint.tsx
#: app/components/hint.tsx
msgid "hint.loading.data"
msgstr "Chargement des données..."

Expand Down Expand Up @@ -943,7 +945,7 @@ msgstr "Créé avec visualize.admin.ch"

#: app/components/chart-published.tsx
msgid "metadata.link.created.with.visualize.alternate"
msgstr "Plus d'informations"
msgstr "visualize.admin.ch"

#: app/components/chart-footnotes.tsx
msgid "metadata.source"
Expand Down
6 changes: 4 additions & 2 deletions app/locales/it/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ msgstr "Categorie"
msgid "columnStyle.heatmap"
msgstr "Mappa di calore"

#: app/configurator/table/table-chart-options.tsx
#: app/configurator/table/table-chart-options.tsx
#: app/configurator/table/table-chart-options.tsx
msgid "columnStyle.text"
Expand Down Expand Up @@ -874,6 +875,8 @@ msgstr "Errore di caricamento delle coordinate"
msgid "hint.create.your.own.chart"
msgstr "Copia questa visualizzazione o crea una nuova visualizzazione usando «dati aperti» dell’amministrazione pubblica svizzera"

#: app/components/data-download.tsx
#: app/components/data-download.tsx
#: app/components/hint.tsx
msgid "hint.dataloadingerror.message"
msgstr "I dati non possono essere caricati."
Expand All @@ -892,7 +895,6 @@ msgstr "È possibile condividere questa visualizzazione copiando l'URL o incorpo

#: app/components/form.tsx
#: app/components/hint.tsx
#: app/components/hint.tsx
msgid "hint.loading.data"
msgstr "Caricamento dei dati..."

Expand Down Expand Up @@ -943,7 +945,7 @@ msgstr "Creato con visualize.admin.ch"

#: app/components/chart-published.tsx
msgid "metadata.link.created.with.visualize.alternate"
msgstr "Più informazioni"
msgstr "visualize.admin.ch"

#: app/components/chart-footnotes.tsx
msgid "metadata.source"
Expand Down