fixes for Ad types that were overlapping the component names and a bug in the Framer Resizer

This commit is contained in:
hobbes7878 2025-04-24 12:50:05 +01:00
parent 114e08a6be
commit ac5f591835
Failed to extract signature
6 changed files with 33 additions and 51 deletions

View file

@ -1,4 +1,4 @@
export type LeaderboardAd = {
export type LeaderboardAdType = {
mobile: {
adType: 'leaderboard';
placementName: 'reuters_mobile_leaderboard';
@ -8,8 +8,7 @@ export type LeaderboardAd = {
placementName: 'reuters_desktop_leaderboard_atf';
};
};
export type SponsorshipAd = {
export type SponsorshipAdType = {
mobile: {
adType: 'sponsorlogo';
placementName: 'reuters_sponsorlogo';
@ -19,40 +18,35 @@ export type SponsorshipAd = {
placementName: 'reuters_sponsorlogo';
};
};
export type InlineAd = {
export type InlineAdType = {
mobile: {
adType: 'mpu' | 'native' | 'mpu2';
placementName:
| 'reuters_mobile_mpu_1'
| 'reuters_mobile_mpu_2'
| 'reuters_mobile_mpu_3';
| 'reuters_mobile_mpu_1'
| 'reuters_mobile_mpu_2'
| 'reuters_mobile_mpu_3';
};
desktop: {
adType: 'native' | 'canvas' | 'flex';
placementName:
| 'reuters_desktop_native_1'
| 'reuters_desktop_native_2'
| 'reuters_desktop_native_3';
| 'reuters_desktop_native_1'
| 'reuters_desktop_native_2'
| 'reuters_desktop_native_3';
};
};
export type DesktopPlacementName =
| LeaderboardAd['desktop']['placementName']
| SponsorshipAd['desktop']['placementName']
| InlineAd['desktop']['placementName'];
| LeaderboardAdType['desktop']['placementName']
| SponsorshipAdType['desktop']['placementName']
| InlineAdType['desktop']['placementName'];
export type MobilePlacementName =
| LeaderboardAd['mobile']['placementName']
| SponsorshipAd['mobile']['placementName']
| InlineAd['mobile']['placementName'];
| LeaderboardAdType['mobile']['placementName']
| SponsorshipAdType['mobile']['placementName']
| InlineAdType['mobile']['placementName'];
export type DesktopAdType =
| LeaderboardAd['desktop']['adType']
| SponsorshipAd['desktop']['adType']
| InlineAd['desktop']['adType'];
| LeaderboardAdType['desktop']['adType']
| SponsorshipAdType['desktop']['adType']
| InlineAdType['desktop']['adType'];
export type MobileAdType =
| LeaderboardAd['mobile']['adType']
| SponsorshipAd['mobile']['adType']
| InlineAd['mobile']['adType'];
| LeaderboardAdType['mobile']['adType']
| SponsorshipAdType['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) -->
<script lang="ts">
import Block from '../Block/Block.svelte';
import type { InlineAd } from './@types/ads';
import type { InlineAdType } from './@types/ads';
import ResponsiveAd from './ResponsiveAd.svelte';
interface Props {
@ -16,7 +16,7 @@
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>
<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) -->
<script lang="ts">
import type { LeaderboardAd } from './@types/ads';
import type { LeaderboardAdType } from './@types/ads';
import ResponsiveAd from './ResponsiveAd.svelte';
import { onMount } from 'svelte';
@ -16,7 +16,7 @@
let windowWidth = $state(1200);
let adSize = $derived(windowWidth < 1024 ? 110 : 275);
const desktopPlacementName: LeaderboardAd['desktop']['placementName'] =
const desktopPlacementName: LeaderboardAdType['desktop']['placementName'] =
'reuters_desktop_leaderboard_atf';
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) -->
<script lang="ts">
import Block from '../Block/Block.svelte';
import type { SponsorshipAd } from './@types/ads';
import type { SponsorshipAdType } from './@types/ads';
import ResponsiveAd from './ResponsiveAd.svelte';
interface Props {
@ -18,7 +18,7 @@
let { id = '', class: cls = 'my-12', adLabel = '' }: Props = $props();
const desktopPlacementName: SponsorshipAd['desktop']['placementName'] =
const desktopPlacementName: SponsorshipAdType['desktop']['placementName'] =
'reuters_sponsorlogo';
</script>

View file

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