Skip to content

Commit 4c8ef96

Browse files
committed
Link to all templates in the frontend
1 parent 51b4683 commit 4c8ef96

File tree

2 files changed

+75
-17
lines changed

2 files changed

+75
-17
lines changed

frontend/src/components/DatawrapperLink.tsx

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import type { ComponentChildren } from "preact";
22
import type { MouseEventHandler } from "preact/compat";
3-
import type { VotePositionCounts } from "../api";
3+
import type { Vote, VotePositionCounts } from "../api";
4+
import List from "../components/List";
5+
import ListItem from "../components/ListItem";
46
import { formatDate } from "../lib/dates";
7+
import { Island } from "../lib/islands";
58

69
type EmbedType = "members" | "groups" | "countries";
710

@@ -66,6 +69,71 @@ function DatawrapperLink({
6669
);
6770
}
6871

72+
function DataWrapperLinkList({ vote }: { vote: Vote }) {
73+
return (
74+
<List space="xxs">
75+
<ListItem
76+
title={
77+
<Island>
78+
<DatawrapperLink
79+
type="members"
80+
voteId={vote.id}
81+
title={vote.display_title || vote.id.toString()}
82+
timestamp={vote.timestamp}
83+
reference={vote.reference}
84+
description={vote.description}
85+
stats={vote.stats.total}
86+
>
87+
Individual votes
88+
</DatawrapperLink>
89+
</Island>
90+
}
91+
subtitle={"A searchable table containing each individual MEPs vote."}
92+
/>
93+
<ListItem
94+
title={
95+
<Island>
96+
<DatawrapperLink
97+
type="groups"
98+
voteId={vote.id}
99+
title={vote.display_title || vote.id.toString()}
100+
timestamp={vote.timestamp}
101+
reference={vote.reference}
102+
description={vote.description}
103+
stats={vote.stats.total}
104+
>
105+
Votes by groups
106+
</DatawrapperLink>
107+
</Island>
108+
}
109+
subtitle={
110+
"An interactive barchart showing how members of each group voted."
111+
}
112+
/>
113+
<ListItem
114+
title={
115+
<Island>
116+
<DatawrapperLink
117+
type="countries"
118+
voteId={vote.id}
119+
title={vote.display_title || vote.id.toString()}
120+
timestamp={vote.timestamp}
121+
reference={vote.reference}
122+
description={vote.description}
123+
stats={vote.stats.total}
124+
>
125+
Votes by countries
126+
</DatawrapperLink>
127+
</Island>
128+
}
129+
subtitle={
130+
"An interactive barchart showing how MEPs from the different member states voted."
131+
}
132+
/>
133+
</List>
134+
);
135+
}
136+
69137
const GREEN = "rgb(0, 144, 118)";
70138
const RED = "rgb(199, 30, 29)";
71139
const BLUE = "rgb(29, 129, 162)";
@@ -288,3 +356,4 @@ function getPresetConfig(
288356
}
289357

290358
export default DatawrapperLink;
359+
export { DataWrapperLinkList };

frontend/src/pages/VotePage.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import App from "../components/App";
33
import BaseLayout from "../components/BaseLayout";
44
import Callout from "../components/Callout";
55
import CopyrightLink from "../components/CopyrightLink";
6-
import DatawrapperLink from "../components/DatawrapperLink";
6+
import { DataWrapperLinkList } from "../components/DatawrapperLink";
77
import ExternalLinks from "../components/ExternalLinks";
88
import Footer from "../components/Footer";
99
import PageNav from "../components/PageNav";
@@ -149,22 +149,11 @@ export const VotePage: Page<Vote> = ({ data }) => {
149149
<h2 id="embed" class="delta mb--xs">
150150
Embed
151151
</h2>
152-
<p>
153-
Want to embed the results of this vote on your website? Use our{" "}
154-
<Island>
155-
<DatawrapperLink
156-
voteId={data.id}
157-
title={data.display_title || data.id.toString()}
158-
timestamp={data.timestamp}
159-
reference={data.reference}
160-
description={data.description}
161-
stats={data.stats.total}
162-
>
163-
Datawrapper template
164-
</DatawrapperLink>
165-
</Island>{" "}
166-
to create an interactive table in just a few clicks.
152+
<p class="mb--xs">
153+
Want to embed the results of this vote on your website? Use one
154+
of our Datawrapper templates:
167155
</p>
156+
<DataWrapperLinkList vote={data} />
168157
</Wrapper>
169158
</div>
170159
<div class="px">

0 commit comments

Comments
 (0)