Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@props(['partners' => null])

@php
$partners = [
$partners ??= [
[
'url' => 'https://nexcalia.com/?ref=nativephp',
'name' => 'Nexcalia',
Expand All @@ -22,54 +24,44 @@
'imageDark' => '/img/sponsors/synergi-dark.svg',
'class' => 'w-full',
],
[
'url' => 'https://laradevs.com/?ref=nativephp',
'name' => 'Laradevs',
'tagline' => 'Hire the best Laravel developers anywhere',
'component' => 'sponsors.logos.laradevs',
'class' => 'w-full text-black dark:text-white',
],
[
'url' => 'https://beyondco.de/?utm_source=nativephp&utm_medium=logo&utm_campaign=nativephp',
'name' => 'BeyondCode',
'tagline' => 'Essential tools for web developers',
'image' => '/img/sponsors/beyondcode.webp',
'imageDark' => '/img/sponsors/beyondcode-dark.webp',
'class' => 'w-full',
],
];

$partner = $partners[array_rand($partners)];
@endphp

<a
href="{{ $partner['url'] }}"
title="Learn more about {{ $partner['name'] }}"
aria-label="Visit {{ $partner['name'] }} website"
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"
rel="noopener sponsored"
>
<div class="flex w-full items-center justify-center px-2">
@if (isset($partner['component']))
<x-dynamic-component
:component="$partner['component']"
class="{{ $partner['class'] }}"
aria-hidden="true"
/>
@else
<img
src="{{ $partner['image'] }}"
alt="{{ $partner['name'] }} logo"
class="{{ $partner['class'] }} dark:hidden"
loading="lazy"
/>
<img
src="{{ $partner['imageDark'] }}"
alt="{{ $partner['name'] }} logo"
class="{{ $partner['class'] }} hidden dark:block"
loading="lazy"
/>
@endif
</div>
<span class="text-xs text-gray-500 dark:text-gray-400">{{ $partner['tagline'] }}</span>
</a>
<div x-data="{ partner: Math.floor(Math.random() * {{ count($partners) }}) }">
@foreach ($partners as $index => $partner)
<a
wire:key="partner-{{ $index }}"
x-show="partner === {{ $index }}"
x-cloak
href="{{ $partner['url'] }}"
title="Learn more about {{ $partner['name'] }}"
aria-label="Visit {{ $partner['name'] }} website"
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"
rel="noopener sponsored"
>
<div class="flex w-full items-center justify-center px-2">
@if (isset($partner['component']))
<x-dynamic-component
:component="$partner['component']"
class="{{ $partner['class'] }}"
aria-hidden="true"
/>
@else
<img
src="{{ $partner['image'] }}"
alt="{{ $partner['name'] }} logo"
class="{{ $partner['class'] }} dark:hidden"
loading="lazy"
/>
<img
src="{{ $partner['imageDark'] }}"
alt="{{ $partner['name'] }} logo"
class="{{ $partner['class'] }} hidden dark:block"
loading="lazy"
/>
@endif
</div>
<span class="text-xs text-gray-500 dark:text-gray-400">{{ $partner['tagline'] }}</span>
</a>
@endforeach
</div>
84 changes: 52 additions & 32 deletions resources/views/components/sponsors/lists/docs/sponsors.blade.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,63 @@
@props(['sponsors' => null])

@php
$sponsors = [
$sponsors ??= [
[
'url' => 'https://artisan.build/?utm_source=nativephp&utm_medium=logo&utm_campaign=nativephp',
'name' => 'Artisan Build',
'image' => '/img/sponsors/artisan-build.webp',
'imageDark' => '/img/sponsors/artisan-build-dark.webp',
'class' => 'w-full',
],
[
'url' => 'https://beyondco.de/?utm_source=nativephp&utm_medium=logo&utm_campaign=nativephp',
'name' => 'BeyondCode',
'image' => '/img/sponsors/beyondcode.webp',
'imageDark' => '/img/sponsors/beyondcode-dark.webp',
'class' => 'w-full',
],
[
'url' => 'https://laradevs.com/?ref=nativephp',
'name' => 'Laradevs',
'component' => 'sponsors.logos.laradevs',
'class' => 'w-full text-black dark:text-white',
],
];

$sponsor = $sponsors[array_rand($sponsors)];
@endphp

<a
href="{{ $sponsor['url'] }}"
title="Learn more about {{ $sponsor['name'] }}"
aria-label="Visit {{ $sponsor['name'] }} website"
target="_blank"
rel="noopener sponsored"
class="mx-auto flex w-full max-w-40 items-center justify-center px-2 opacity-70 transition duration-200 hover:opacity-100"
>
@if (isset($sponsor['component']))
<x-dynamic-component
:component="$sponsor['component']"
class="{{ $sponsor['class'] }}"
aria-hidden="true"
/>
@else
<img
src="{{ $sponsor['image'] }}"
alt="{{ $sponsor['name'] }} logo"
class="{{ $sponsor['class'] }} dark:hidden"
loading="lazy"
/>
<img
src="{{ $sponsor['imageDark'] }}"
alt="{{ $sponsor['name'] }} logo"
class="{{ $sponsor['class'] }} hidden dark:block"
loading="lazy"
/>
@endif
</a>
<div x-data="{ sponsor: Math.floor(Math.random() * {{ count($sponsors) }}) }">
@foreach ($sponsors as $index => $sponsor)
<a
wire:key="sponsor-{{ $index }}"
x-show="sponsor === {{ $index }}"
x-cloak
href="{{ $sponsor['url'] }}"
title="Learn more about {{ $sponsor['name'] }}"
aria-label="Visit {{ $sponsor['name'] }} website"
target="_blank"
rel="noopener sponsored"
class="mx-auto flex w-full max-w-40 items-center justify-center px-2 opacity-70 transition duration-200 hover:opacity-100"
>
@if (isset($sponsor['component']))
<x-dynamic-component
:component="$sponsor['component']"
class="{{ $sponsor['class'] }}"
aria-hidden="true"
/>
@else
<img
src="{{ $sponsor['image'] }}"
alt="{{ $sponsor['name'] }} logo"
class="{{ $sponsor['class'] }} dark:hidden"
loading="lazy"
/>
<img
src="{{ $sponsor['imageDark'] }}"
alt="{{ $sponsor['name'] }} logo"
class="{{ $sponsor['class'] }} hidden dark:block"
loading="lazy"
/>
@endif
</a>
@endforeach
</div>
57 changes: 27 additions & 30 deletions tests/Feature/SponsorsAndPartnersPlacementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,42 @@ class SponsorsAndPartnersPlacementTest extends TestCase
use RefreshDatabase;

#[Test]
public function the_partners_section_no_longer_lists_beyondcode_or_laradevs()
public function the_partners_page_renders_the_partners_section()
{
$this->blade('<x-home.partners />')
->assertSee('Nexcalia')
->assertSee('Web Mavens')
->assertDontSee('Laradevs')
->assertDontSee('BeyondCode')
->assertDontSee('Need a freelancer or engineer?')
->assertDontSee('From local full stack development');
$this->get(route('partners'))
->assertOk()
->assertSee('Meet Our Partners');
}

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

#[Test]
public function the_homepage_drops_the_partner_descriptions_for_beyondcode_and_laradevs()
{
$this->get('/')
->assertOk()
->assertDontSee('Need a freelancer or engineer?')
->assertDontSee('From local full stack development');
$this->blade('<x-sponsors.lists.docs.featured-sponsors :partners="$partners" />', compact('partners'))
->assertSee('Math.random() * 2', false)
->assertSee('x-show="partner === 0"', false)
->assertSee('x-show="partner === 1"', false)
->assertSee('https://partner-one.test')
->assertSee('https://partner-two.test');
}

#[Test]
public function the_partners_page_lists_the_current_partners()
public function the_sidebar_sponsors_list_rotates_through_every_entry_it_is_given()
{
$this->get(route('partners'))
->assertOk()
->assertSee('Meet Our Partners')
->assertSee('Nexcalia')
->assertSee('Web Mavens')
->assertSee('Synergi Tech');
$sponsors = [
['url' => 'https://sponsor-one.test', 'name' => 'Sponsor One', 'image' => '/img/one.svg', 'imageDark' => '/img/one-dark.svg', 'class' => ''],
['url' => 'https://sponsor-two.test', 'name' => 'Sponsor Two', 'image' => '/img/two.svg', 'imageDark' => '/img/two-dark.svg', 'class' => ''],
];

$this->blade('<x-sponsors.lists.docs.sponsors :sponsors="$sponsors" />', compact('sponsors'))
->assertSee('Math.random() * 2', false)
->assertSee('x-show="sponsor === 0"', false)
->assertSee('x-show="sponsor === 1"', false)
->assertSee('https://sponsor-one.test')
->assertSee('https://sponsor-two.test');
}
}
Loading