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

✨ Add wizard link for chart animation #4407

Merged
merged 4 commits into from
Jan 9, 2025
Merged
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
51 changes: 46 additions & 5 deletions adminSiteClient/EditorExportTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import {
GrapherStaticFormat,
} from "@ourworldindata/utils"
import { AbstractChartEditor } from "./AbstractChartEditor.js"
import { ETL_WIZARD_URL } from "../settings/clientSettings.js"
import { faHatWizard, faDownload } from "@fortawesome/free-solid-svg-icons"
import { Button } from "antd"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"

type ExportSettings = Required<
Pick<
Expand Down Expand Up @@ -227,6 +231,18 @@ export class EditorExportTab<
}

render() {
const chartAnimationUrl = new URL(`${ETL_WIZARD_URL}chart-animation`)
if (this.grapher.canonicalUrl)
chartAnimationUrl.searchParams.set(
"animation_chart_url",
this.grapher.canonicalUrl
)
chartAnimationUrl.searchParams.set("animation_skip_button", "True")
// chartAnimationUrl.searchParams.set(
// "animation_chart_tab",
// this.grapher.tab ?? ""
// )

return (
<div className="EditorExportTab">
<Section name="Displayed elements">
Expand Down Expand Up @@ -309,40 +325,65 @@ export class EditorExportTab<
/>
)}
</Section>

<Section name="Export static chart">
<div className="DownloadButtons">
<button
className="btn btn-primary"
onClick={this.onDownloadDesktopPNG}
>
Download Desktop PNG
{<FontAwesomeIcon icon={faDownload} />} Download
Desktop PNG
</button>
<button
className="btn btn-primary"
onClick={this.onDownloadDesktopSVG}
>
Download Desktop SVG
{<FontAwesomeIcon icon={faDownload} />} Download
Desktop SVG
</button>
<button
className="btn btn-primary"
onClick={this.onDownloadMobilePNG}
>
Download Mobile PNG
{<FontAwesomeIcon icon={faDownload} />} Download
Mobile PNG
</button>
<button
className="btn btn-primary"
onClick={this.onDownloadMobileSVG}
>
Download Mobile SVG
{<FontAwesomeIcon icon={faDownload} />} Download
Mobile SVG
</button>
<button
className="btn btn-primary"
onClick={this.onDownloadMobileSVGForSocialMedia}
>
Download Mobile SVG for Social Media
{<FontAwesomeIcon icon={faDownload} />} Download
Mobile SVG for Social Media
</button>
</div>
</Section>

{/* Link to Wizard dataset preview */}
{this.grapher.isPublished && (
<Section name="Animate chart">
<a
href={chartAnimationUrl.toString()}
target="_blank"
className="btn btn-tertiary"
rel="noopener"
>
<Button
type="default"
icon={<FontAwesomeIcon icon={faHatWizard} />}
>
Animate with Wizard
</Button>
</a>
</Section>
)}
</div>
)
}
Expand Down
Loading