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/wunderkind smart tag #184

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/components/AdSlot/WunderkindAd.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script lang="ts">
import { Template, Story, Meta } from '@storybook/addon-svelte-csf';

// @ts-ignore raw
import adDocs from './stories/docs/wunderkind.md?raw';

import AdScripts from './AdScripts.svelte';
import WunderkindAd from './WunderkindAd.svelte';

import { withComponentDocs } from './../../docs/utils/withParams';

const meta = {
...withComponentDocs(adDocs),
};
</script>

<Meta title="Components/WunderkindAd" component="{WunderkindAd}" {...meta} />

<Template>
<div>
<AdScripts />
<WunderkindAd />
</div>
</Template>

<Story name="Default" />
22 changes: 22 additions & 0 deletions src/components/AdSlot/WunderkindAd.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script lang="ts">
import { onMount } from 'svelte';

onMount(() => {
// Check user login status
let isLoggedIn = localStorage.getItem('ArcId.USER_PROFILE') !== null;
if (!isLoggedIn) {
const script = document.createElement('script');
script.textContent = `
freestar.config.enabled_slots.push({
placementName: 'reuters_1x1_bouncex',
slotId: 'reuters_1x1_bouncex',
});
`;
script.setAttribute('data-cfasync', 'false');
script.type = 'text/javascript';
document.head.appendChild(script);
}
});
</script>

<div id="reuters_1x1_bouncex"></div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain if this div displays an ad, how that behaves and how this ad unit interplays with our existing InlineAd component, if at all? E.g., should we prefer this ad unit and fallback to an InlineAd if the user is not logged in? Something else?

27 changes: 27 additions & 0 deletions src/components/AdSlot/stories/docs/wunderkind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Add a wunderkind ad to your page.

> **IMPORTANT!** Make sure ads are only used on dotcom pages, never on embeds.

```svelte
<!-- +page.svelte -->
<script>
import { AdScripts } from '@reuters-graphics/graphics-components';
</script>

<!-- Include AdScripts only ONCE per page for any type of ad -->
<AdScripts />
```

```svelte
<!-- App.svelte -->
<script>
import { WunderkindAd } from '@reuters-graphics/graphics-components';

export let embedded = false;
</script>

<!-- Check if in an embed context! -->
{#if !embedded}
<WunderkindAd />
{/if}
```
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export { default as Theme, themes } from './components/Theme/Theme.svelte';
export { default as ToolsHeader } from './components/ToolsHeader/ToolsHeader.svelte';
export { default as Video } from './components/Video/Video.svelte';
export { default as Visible } from './components/Visible/Visible.svelte';
export { default as WunderkindAd } from './components/AdSlot/WunderkindAd.svelte';

// Utilities
export { getEndNotesPropsFromDoc } from './components/EndNotes/docProps.js';
Expand Down