Skip to content

Commit a996073

Browse files
simonhampclaude
andcommitted
Move BeyondCode & Laradevs to sponsors in docs sidebar rotation
Move the two entries from the partners rotation to the sponsors rotation, and render both docs sidebar lists client-side (Alpine render-all + random pick) via an injectable pool prop, mirroring the ad-rotation component. Tests now cover the rotation mechanism with injected fixtures instead of asserting specific sponsor/partner names. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7aa6c6e commit a996073

3 files changed

Lines changed: 120 additions & 111 deletions

File tree

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
@props(['partners' => null])
2+
13
@php
2-
$partners = [
4+
$partners ??= [
35
[
46
'url' => 'https://nexcalia.com/?ref=nativephp',
57
'name' => 'Nexcalia',
@@ -22,54 +24,44 @@
2224
'imageDark' => '/img/sponsors/synergi-dark.svg',
2325
'class' => 'w-full',
2426
],
25-
[
26-
'url' => 'https://laradevs.com/?ref=nativephp',
27-
'name' => 'Laradevs',
28-
'tagline' => 'Hire the best Laravel developers anywhere',
29-
'component' => 'sponsors.logos.laradevs',
30-
'class' => 'w-full text-black dark:text-white',
31-
],
32-
[
33-
'url' => 'https://beyondco.de/?utm_source=nativephp&utm_medium=logo&utm_campaign=nativephp',
34-
'name' => 'BeyondCode',
35-
'tagline' => 'Essential tools for web developers',
36-
'image' => '/img/sponsors/beyondcode.webp',
37-
'imageDark' => '/img/sponsors/beyondcode-dark.webp',
38-
'class' => 'w-full',
39-
],
4027
];
41-
42-
$partner = $partners[array_rand($partners)];
4328
@endphp
4429

45-
<a
46-
href="{{ $partner['url'] }}"
47-
title="Learn more about {{ $partner['name'] }}"
48-
aria-label="Visit {{ $partner['name'] }} website"
49-
class="mx-auto flex w-full max-w-64 shrink-0 flex-col items-center gap-2 rounded-2xl bg-gray-100 px-5 py-4 transition duration-200 hover:bg-gray-200/70 hover:ring-1 hover:ring-black/60 dark:bg-mirage dark:hover:bg-haiti dark:hover:ring-cloud"
50-
rel="noopener sponsored"
51-
>
52-
<div class="flex w-full items-center justify-center px-2">
53-
@if (isset($partner['component']))
54-
<x-dynamic-component
55-
:component="$partner['component']"
56-
class="{{ $partner['class'] }}"
57-
aria-hidden="true"
58-
/>
59-
@else
60-
<img
61-
src="{{ $partner['image'] }}"
62-
alt="{{ $partner['name'] }} logo"
63-
class="{{ $partner['class'] }} dark:hidden"
64-
loading="lazy"
65-
/>
66-
<img
67-
src="{{ $partner['imageDark'] }}"
68-
alt="{{ $partner['name'] }} logo"
69-
class="{{ $partner['class'] }} hidden dark:block"
70-
loading="lazy"
71-
/>
72-
@endif
73-
</div>
74-
<span class="text-xs text-gray-500 dark:text-gray-400">{{ $partner['tagline'] }}</span>
75-
</a>
30+
<div x-data="{ partner: Math.floor(Math.random() * {{ count($partners) }}) }">
31+
@foreach ($partners as $index => $partner)
32+
<a
33+
wire:key="partner-{{ $index }}"
34+
x-show="partner === {{ $index }}"
35+
x-cloak
36+
href="{{ $partner['url'] }}"
37+
title="Learn more about {{ $partner['name'] }}"
38+
aria-label="Visit {{ $partner['name'] }} website"
39+
class="mx-auto flex w-full max-w-64 shrink-0 flex-col items-center gap-2 rounded-2xl bg-gray-100 px-5 py-4 transition duration-200 hover:bg-gray-200/70 hover:ring-1 hover:ring-black/60 dark:bg-mirage dark:hover:bg-haiti dark:hover:ring-cloud"
40+
rel="noopener sponsored"
41+
>
42+
<div class="flex w-full items-center justify-center px-2">
43+
@if (isset($partner['component']))
44+
<x-dynamic-component
45+
:component="$partner['component']"
46+
class="{{ $partner['class'] }}"
47+
aria-hidden="true"
48+
/>
49+
@else
50+
<img
51+
src="{{ $partner['image'] }}"
52+
alt="{{ $partner['name'] }} logo"
53+
class="{{ $partner['class'] }} dark:hidden"
54+
loading="lazy"
55+
/>
56+
<img
57+
src="{{ $partner['imageDark'] }}"
58+
alt="{{ $partner['name'] }} logo"
59+
class="{{ $partner['class'] }} hidden dark:block"
60+
loading="lazy"
61+
/>
62+
@endif
63+
</div>
64+
<span class="text-xs text-gray-500 dark:text-gray-400">{{ $partner['tagline'] }}</span>
65+
</a>
66+
@endforeach
67+
</div>
Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,63 @@
1+
@props(['sponsors' => null])
2+
13
@php
2-
$sponsors = [
4+
$sponsors ??= [
35
[
46
'url' => 'https://artisan.build/?utm_source=nativephp&utm_medium=logo&utm_campaign=nativephp',
57
'name' => 'Artisan Build',
68
'image' => '/img/sponsors/artisan-build.webp',
79
'imageDark' => '/img/sponsors/artisan-build-dark.webp',
810
'class' => 'w-full',
911
],
12+
[
13+
'url' => 'https://beyondco.de/?utm_source=nativephp&utm_medium=logo&utm_campaign=nativephp',
14+
'name' => 'BeyondCode',
15+
'image' => '/img/sponsors/beyondcode.webp',
16+
'imageDark' => '/img/sponsors/beyondcode-dark.webp',
17+
'class' => 'w-full',
18+
],
19+
[
20+
'url' => 'https://laradevs.com/?ref=nativephp',
21+
'name' => 'Laradevs',
22+
'component' => 'sponsors.logos.laradevs',
23+
'class' => 'w-full text-black dark:text-white',
24+
],
1025
];
11-
12-
$sponsor = $sponsors[array_rand($sponsors)];
1326
@endphp
1427

15-
<a
16-
href="{{ $sponsor['url'] }}"
17-
title="Learn more about {{ $sponsor['name'] }}"
18-
aria-label="Visit {{ $sponsor['name'] }} website"
19-
target="_blank"
20-
rel="noopener sponsored"
21-
class="mx-auto flex w-full max-w-40 items-center justify-center px-2 opacity-70 transition duration-200 hover:opacity-100"
22-
>
23-
@if (isset($sponsor['component']))
24-
<x-dynamic-component
25-
:component="$sponsor['component']"
26-
class="{{ $sponsor['class'] }}"
27-
aria-hidden="true"
28-
/>
29-
@else
30-
<img
31-
src="{{ $sponsor['image'] }}"
32-
alt="{{ $sponsor['name'] }} logo"
33-
class="{{ $sponsor['class'] }} dark:hidden"
34-
loading="lazy"
35-
/>
36-
<img
37-
src="{{ $sponsor['imageDark'] }}"
38-
alt="{{ $sponsor['name'] }} logo"
39-
class="{{ $sponsor['class'] }} hidden dark:block"
40-
loading="lazy"
41-
/>
42-
@endif
43-
</a>
28+
<div x-data="{ sponsor: Math.floor(Math.random() * {{ count($sponsors) }}) }">
29+
@foreach ($sponsors as $index => $sponsor)
30+
<a
31+
wire:key="sponsor-{{ $index }}"
32+
x-show="sponsor === {{ $index }}"
33+
x-cloak
34+
href="{{ $sponsor['url'] }}"
35+
title="Learn more about {{ $sponsor['name'] }}"
36+
aria-label="Visit {{ $sponsor['name'] }} website"
37+
target="_blank"
38+
rel="noopener sponsored"
39+
class="mx-auto flex w-full max-w-40 items-center justify-center px-2 opacity-70 transition duration-200 hover:opacity-100"
40+
>
41+
@if (isset($sponsor['component']))
42+
<x-dynamic-component
43+
:component="$sponsor['component']"
44+
class="{{ $sponsor['class'] }}"
45+
aria-hidden="true"
46+
/>
47+
@else
48+
<img
49+
src="{{ $sponsor['image'] }}"
50+
alt="{{ $sponsor['name'] }} logo"
51+
class="{{ $sponsor['class'] }} dark:hidden"
52+
loading="lazy"
53+
/>
54+
<img
55+
src="{{ $sponsor['imageDark'] }}"
56+
alt="{{ $sponsor['name'] }} logo"
57+
class="{{ $sponsor['class'] }} hidden dark:block"
58+
loading="lazy"
59+
/>
60+
@endif
61+
</a>
62+
@endforeach
63+
</div>

tests/Feature/SponsorsAndPartnersPlacementTest.php

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,42 @@ class SponsorsAndPartnersPlacementTest extends TestCase
1111
use RefreshDatabase;
1212

1313
#[Test]
14-
public function the_partners_section_no_longer_lists_beyondcode_or_laradevs()
14+
public function the_partners_page_renders_the_partners_section()
1515
{
16-
$this->blade('<x-home.partners />')
17-
->assertSee('Nexcalia')
18-
->assertSee('Web Mavens')
19-
->assertDontSee('Laradevs')
20-
->assertDontSee('BeyondCode')
21-
->assertDontSee('Need a freelancer or engineer?')
22-
->assertDontSee('From local full stack development');
16+
$this->get(route('partners'))
17+
->assertOk()
18+
->assertSee('Meet Our Partners');
2319
}
2420

2521
#[Test]
26-
public function the_sponsors_section_lists_beyondcode_and_laradevs_without_descriptions()
22+
public function the_sidebar_partners_list_rotates_through_every_entry_it_is_given()
2723
{
28-
$this->blade('<x-home.sponsors />')
29-
->assertSee('Artisan Build')
30-
->assertSee('BeyondCode')
31-
->assertSee('Laradevs')
32-
->assertDontSee('Need a freelancer or engineer?')
33-
->assertDontSee('From local full stack development');
34-
}
24+
$partners = [
25+
['url' => 'https://partner-one.test', 'name' => 'Partner One', 'tagline' => 'First', 'image' => '/img/one.svg', 'imageDark' => '/img/one-dark.svg', 'class' => ''],
26+
['url' => 'https://partner-two.test', 'name' => 'Partner Two', 'tagline' => 'Second', 'image' => '/img/two.svg', 'imageDark' => '/img/two-dark.svg', 'class' => ''],
27+
];
3528

36-
#[Test]
37-
public function the_homepage_drops_the_partner_descriptions_for_beyondcode_and_laradevs()
38-
{
39-
$this->get('/')
40-
->assertOk()
41-
->assertDontSee('Need a freelancer or engineer?')
42-
->assertDontSee('From local full stack development');
29+
$this->blade('<x-sponsors.lists.docs.featured-sponsors :partners="$partners" />', compact('partners'))
30+
->assertSee('Math.random() * 2', false)
31+
->assertSee('x-show="partner === 0"', false)
32+
->assertSee('x-show="partner === 1"', false)
33+
->assertSee('https://partner-one.test')
34+
->assertSee('https://partner-two.test');
4335
}
4436

4537
#[Test]
46-
public function the_partners_page_lists_the_current_partners()
38+
public function the_sidebar_sponsors_list_rotates_through_every_entry_it_is_given()
4739
{
48-
$this->get(route('partners'))
49-
->assertOk()
50-
->assertSee('Meet Our Partners')
51-
->assertSee('Nexcalia')
52-
->assertSee('Web Mavens')
53-
->assertSee('Synergi Tech');
40+
$sponsors = [
41+
['url' => 'https://sponsor-one.test', 'name' => 'Sponsor One', 'image' => '/img/one.svg', 'imageDark' => '/img/one-dark.svg', 'class' => ''],
42+
['url' => 'https://sponsor-two.test', 'name' => 'Sponsor Two', 'image' => '/img/two.svg', 'imageDark' => '/img/two-dark.svg', 'class' => ''],
43+
];
44+
45+
$this->blade('<x-sponsors.lists.docs.sponsors :sponsors="$sponsors" />', compact('sponsors'))
46+
->assertSee('Math.random() * 2', false)
47+
->assertSee('x-show="sponsor === 0"', false)
48+
->assertSee('x-show="sponsor === 1"', false)
49+
->assertSee('https://sponsor-one.test')
50+
->assertSee('https://sponsor-two.test');
5451
}
5552
}

0 commit comments

Comments
 (0)