Skip to content

Commit

Permalink
Merge pull request #391 from guardian/dina/create-new-test-template-f…
Browse files Browse the repository at this point in the history
…or-public-good

Create new test template for Public Good
  • Loading branch information
deedeeh authored Jul 9, 2024
2 parents 41c5de6 + ac8426a commit f6e8c95
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/templates/csr/public-good-test/ad.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nativeStyleId": "844854"
}
63 changes: 63 additions & 0 deletions src/templates/csr/public-good-test/index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<script lang="ts">
import { getUSPData, isCcpaOptedOut } from '$lib/cmp';
import { post } from '$lib/messenger';
import { getPageURL } from '$lib/messenger/get-page-url';
import { create, type PgmApiOptions } from '$lib/public-good';
let container: HTMLElement;
const refresh = () =>
post({
type: 'passback-refresh',
value: 'public-good',
});
const onload = async () => {
let url = await getPageURL();
const consentState = await getUSPData();
if (!consentState || isCcpaOptedOut(consentState)) {
!consentState && console.error('No consent');
return refresh();
}
if (!url) {
console.error('No URL found');
return refresh();
}
const options: PgmApiOptions = {
partnerId: 'gmg-guardian',
attributes: {
url,
},
onHide: refresh,
};
create(container, options);
};
</script>

<svelte:head>
<script
type="text/javascript"
src="https://assets.publicgood.com/pgm/v1/dpg.js"
on:load={onload}
></script>
</svelte:head>
<div
id="public-good"
class="pgs-dpg-flex"
data-pgs-partner-id="gmg"
data-pgs-target-id="db973434-8db2-4293-9485-45ba5b591416"
data-pgs-target-type="campaign"
bind:this={container}
/>

<style lang="scss">
#public-good {
width: 100%;
height: 465px;
}
</style>

0 comments on commit f6e8c95

Please sign in to comment.