Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Nov 8, 2024
1 parent 95ddb7e commit ca02618
Show file tree
Hide file tree
Showing 7 changed files with 1,224 additions and 232 deletions.
12 changes: 12 additions & 0 deletions app/Feature/Trial/TrialService.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
<?php
namespace Coyote\Feature\Trial;

use Coyote\Services\Guest;

readonly class TrialService
{
public function __construct(private Guest $guest)
{
}

public function isChoiceModern(): bool
{
return $this->guest->getSetting('isHomepageNew', 'false') === 'true';
}

public function setChoice(string $choice): void
{
$this->guest->setSetting('isHomepageNew', 'true');
}

public function setStage(string $stage): void
Expand Down
19 changes: 13 additions & 6 deletions app/Feature/Trial/TrialServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ public function boot(): void

private function add(Factory $viewFactory): void
{
$viewFactory->composer('home', $this->addViewField(...));
$viewFactory->composer('home', function (View $view) {
$view->with(['isHomepageModern' => false]);
});
$viewFactory->composer('home_modern', function (View $view) {
$view->with([
'isHomepageModern' => true,
'homepageMembers' => $this->members(),
]);
});
$viewFactory->composer(['home', 'home_modern'], $this->addViewField(...));
}

private function addViewField(View $view): void
{
$view->with([
'isHomepageModern' => true,
'homepageMembers' => $this->members(),
'survey' => [
'survey' => [
'trial' => [
'title' => 'Wygląd strony głównej.',
'reason' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras velit metus, egestas id facilisis vel, consectetur sit amet magna. Praesent auctor arcu augue, ut efficitur dui rhoncus et.',
Expand All @@ -60,8 +67,8 @@ private function addViewField(View $view): void
],
],
'userSession' => [
'stage' => 'stage-none',
'choice' => 'choice-modern', 'choice-legacy', 'choice-pending',
'stage' => 'stage-invited',
'choice' => 'choice-pending', // 'choice-legacy', 'choice-pending',
'badgeLong' => true,
'assortment' => 'assortment-legacy', // 'assortment-modern'
],
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Coyote\Http\Controllers;

use Coyote\Domain\DiscreetDate;
use Coyote\Feature\Trial\TrialService;
use Coyote\Http\Resources\ActivityResource;
use Coyote\Http\Resources\Api\MicroblogResource;
use Coyote\Http\Resources\FlagResource;
Expand Down Expand Up @@ -35,13 +36,14 @@ public function __construct(
parent::__construct();
}

public function index(): View
public function index(TrialService $service): View
{
$cache = app(Cache\Repository::class);
$this->topic->pushCriteria(new OnlyThoseTopicsWithAccess());
$this->topic->pushCriteria(new SkipHiddenCategories($this->userId));
$date = new DiscreetDate(date('Y-m-d H:i:s'));
return $this->view('home', [

return $this->view(!$service->isChoiceModern() ? 'home' : 'home_modern', [
'flags' => $this->flags(),
'microblogs' => $this->getMicroblogs(),
'interesting' => $this->topic->interesting(),
Expand Down
1 change: 1 addition & 0 deletions resources/sass/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
@import "pages/guide";
@import "pages/help";
@import "pages/homepage";
@import "pages/homepage_modern";
@import "pages/job";
@import "pages/microblog";
@import "pages/pm";
Expand Down
Loading

0 comments on commit ca02618

Please sign in to comment.