Merge pull request #291 from reuters-graphics/jon-fixes

Fixes for Ad types and Framer Resizer
This commit is contained in:
Jon McClure 2025-04-24 12:54:21 +01:00 committed by GitHub
commit dae4dbd709
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 32 additions and 45 deletions

View file

@ -0,0 +1,5 @@
---
'@reuters-graphics/graphics-components': patch
---
fixes for Ad types that were colliding with their component names and a bug in the Framer Resizer

View file

@ -1,4 +1,4 @@
export type LeaderboardAd = { export type LeaderboardAdType = {
mobile: { mobile: {
adType: 'leaderboard'; adType: 'leaderboard';
placementName: 'reuters_mobile_leaderboard'; placementName: 'reuters_mobile_leaderboard';
@ -8,8 +8,7 @@ export type LeaderboardAd = {
placementName: 'reuters_desktop_leaderboard_atf'; placementName: 'reuters_desktop_leaderboard_atf';
}; };
}; };
export type SponsorshipAdType = {
export type SponsorshipAd = {
mobile: { mobile: {
adType: 'sponsorlogo'; adType: 'sponsorlogo';
placementName: 'reuters_sponsorlogo'; placementName: 'reuters_sponsorlogo';
@ -19,8 +18,7 @@ export type SponsorshipAd = {
placementName: 'reuters_sponsorlogo'; placementName: 'reuters_sponsorlogo';
}; };
}; };
export type InlineAdType = {
export type InlineAd = {
mobile: { mobile: {
adType: 'mpu' | 'native' | 'mpu2'; adType: 'mpu' | 'native' | 'mpu2';
placementName: placementName:
@ -36,23 +34,19 @@ export type InlineAd = {
| 'reuters_desktop_native_3'; | 'reuters_desktop_native_3';
}; };
}; };
export type DesktopPlacementName = export type DesktopPlacementName =
| LeaderboardAd['desktop']['placementName'] | LeaderboardAdType['desktop']['placementName']
| SponsorshipAd['desktop']['placementName'] | SponsorshipAdType['desktop']['placementName']
| InlineAd['desktop']['placementName']; | InlineAdType['desktop']['placementName'];
export type MobilePlacementName = export type MobilePlacementName =
| LeaderboardAd['mobile']['placementName'] | LeaderboardAdType['mobile']['placementName']
| SponsorshipAd['mobile']['placementName'] | SponsorshipAdType['mobile']['placementName']
| InlineAd['mobile']['placementName']; | InlineAdType['mobile']['placementName'];
export type DesktopAdType = export type DesktopAdType =
| LeaderboardAd['desktop']['adType'] | LeaderboardAdType['desktop']['adType']
| SponsorshipAd['desktop']['adType'] | SponsorshipAdType['desktop']['adType']
| InlineAd['desktop']['adType']; | InlineAdType['desktop']['adType'];
export type MobileAdType = export type MobileAdType =
| LeaderboardAd['mobile']['adType'] | LeaderboardAdType['mobile']['adType']
| SponsorshipAd['mobile']['adType'] | SponsorshipAdType['mobile']['adType']
| InlineAd['mobile']['adType']; | InlineAdType['mobile']['adType'];

View file

@ -2,7 +2,7 @@
<!-- @component `InlineAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytics-inlinead--docs) --> <!-- @component `InlineAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytics-inlinead--docs) -->
<script lang="ts"> <script lang="ts">
import Block from '../Block/Block.svelte'; import Block from '../Block/Block.svelte';
import type { InlineAd } from './@types/ads'; import type { InlineAdType } from './@types/ads';
import ResponsiveAd from './ResponsiveAd.svelte'; import ResponsiveAd from './ResponsiveAd.svelte';
interface Props { interface Props {
@ -16,7 +16,7 @@
let { id = '', class: cls = 'my-12', n = 1 }: Props = $props(); let { id = '', class: cls = 'my-12', n = 1 }: Props = $props();
const desktopPlacementName: InlineAd['desktop']['placementName'] = `reuters_desktop_native_${n}`; const desktopPlacementName: InlineAdType['desktop']['placementName'] = `reuters_desktop_native_${n}`;
</script> </script>
<Block {id} class="freestar-adslot {cls}"> <Block {id} class="freestar-adslot {cls}">

View file

@ -1,6 +1,6 @@
<!-- @component `LeaderboardAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytics-leaderboardad--docs) --> <!-- @component `LeaderboardAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytics-leaderboardad--docs) -->
<script lang="ts"> <script lang="ts">
import type { LeaderboardAd } from './@types/ads'; import type { LeaderboardAdType } from './@types/ads';
import ResponsiveAd from './ResponsiveAd.svelte'; import ResponsiveAd from './ResponsiveAd.svelte';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
@ -16,7 +16,7 @@
let windowWidth = $state(1200); let windowWidth = $state(1200);
let adSize = $derived(windowWidth < 1024 ? 110 : 275); let adSize = $derived(windowWidth < 1024 ? 110 : 275);
const desktopPlacementName: LeaderboardAd['desktop']['placementName'] = const desktopPlacementName: LeaderboardAdType['desktop']['placementName'] =
'reuters_desktop_leaderboard_atf'; 'reuters_desktop_leaderboard_atf';
let sticky = $state(false); let sticky = $state(false);

View file

@ -2,7 +2,7 @@
<!-- @component `SponsorshipAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytics-sponsorshipad--docs) --> <!-- @component `SponsorshipAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytics-sponsorshipad--docs) -->
<script lang="ts"> <script lang="ts">
import Block from '../Block/Block.svelte'; import Block from '../Block/Block.svelte';
import type { SponsorshipAd } from './@types/ads'; import type { SponsorshipAdType } from './@types/ads';
import ResponsiveAd from './ResponsiveAd.svelte'; import ResponsiveAd from './ResponsiveAd.svelte';
interface Props { interface Props {
@ -18,7 +18,7 @@
let { id = '', class: cls = 'my-12', adLabel = '' }: Props = $props(); let { id = '', class: cls = 'my-12', adLabel = '' }: Props = $props();
const desktopPlacementName: SponsorshipAd['desktop']['placementName'] = const desktopPlacementName: SponsorshipAdType['desktop']['placementName'] =
'reuters_sponsorlogo'; 'reuters_sponsorlogo';
</script> </script>

View file

@ -27,8 +27,7 @@
if ($width > maxWidth) width.set(maxWidth); if ($width > maxWidth) width.set(maxWidth);
}); });
// svelte-ignore state_referenced_locally let offset = $derived(($width - minWidth) / pixelRange);
let offset = $state(($width - minWidth) / pixelRange);
let sliding = $state(false); let sliding = $state(false);
let isFocused = $state(false); let isFocused = $state(false);
@ -55,7 +54,7 @@
} else if (keyCode === 37) { } else if (keyCode === 37) {
offset = Math.max(0, offset - pixelWidth / sliderWidth); offset = Math.max(0, offset - pixelWidth / sliderWidth);
} }
width.set(getPx()); $width = getPx();
}; };
const start = (e: MouseEvent) => { const start = (e: MouseEvent) => {
sliding = true; sliding = true;
@ -77,17 +76,17 @@
.filter((b) => b <= maxWidth) .filter((b) => b <= maxWidth)
.filter((b) => b > $width); .filter((b) => b > $width);
if (availableBreakpoints.length === 0) { if (availableBreakpoints.length === 0) {
width.set(maxWidth); $width = maxWidth;
} else { } else {
width.set(availableBreakpoints[0]); $width = availableBreakpoints[0];
} }
}; };
const decrement = () => { const decrement = () => {
const availableBreakpoints = breakpoints.filter((b) => b < $width); const availableBreakpoints = breakpoints.filter((b) => b < $width);
if (availableBreakpoints.length === 0) { if (availableBreakpoints.length === 0) {
width.set(minWidth); $width = minWidth;
} else { } else {
width.set(availableBreakpoints.slice(-1)[0]); $width = availableBreakpoints.slice(-1)[0];
} }
}; };
</script> </script>

View file

@ -1,11 +0,0 @@
An embed tool for development in the graphics kit.
```svelte
<script>
import { Framer } from '@reuters-graphics/graphics-components';
const embeds = ['/embeds/my-chart/index.html'];
</script>
<Framer embeds="{embeds}" />
```