Skip to content

Commit

Permalink
refactor: get rid of remainin wavevision deps
Browse files Browse the repository at this point in the history
  • Loading branch information
rozsival authored and f3l1x committed Sep 20, 2024
1 parent 8d9cdf2 commit 92039df
Show file tree
Hide file tree
Showing 27 changed files with 63 additions and 394 deletions.
10 changes: 0 additions & 10 deletions app/model/UI/BasePropsControl.php

This file was deleted.

1 change: 1 addition & 0 deletions app/modules/Front/Addon/AddonPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function createComponentAddon(): AddonDetail

private function getAddon(int $id): Addon
{
bdump($id);
if (!($addon = $this->addonFacade->getDetail($id))) {
$this->error('Addon not found');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{varType App\Model\Database\ORM\Addon\Addon $addon}
<div class="w-full flex flex-wrap justify-between">
<div class="flex items-center w-full px-5 pt-2 md:pt-0 lg:px-8 mb-3 lg:mb-6 lg:w-1/2">
{control avatar, [addon => $addon, linkToGithub => true]}
{control avatar, $addon, true}
<div class="flex flex-col flex-1">
{control name, [addon => $addon, inverseTag => true, linkToGithub => true]}
{control description, [addon => $addon]}
{control name, $addon, true, true}
{control description, $addon}
</div>
</div>
<div n:if="$addon->isComposer && $addon->github->masterComposer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
</div>
<div class="bg-white rounded shadow-md relative z-10 mb-4">
{control statistics, [addon => $addon]}
{control statistics, $addon}
</div>
<div class="bg-white rounded shadow-md relative z-10 mb-4">
<div class="flex flex-wrap items-center justify-start px-5 pt-3 lg:px-8 lg:pt-4 min-h-16">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
</div>
<div class="flex flex-wrap items-center justify-between px-5 pt-3 border-t lg:px-8 lg:pt-4">
<div class="flex items-start w-full mb-3 lg:mb-5">
{control avatar, [addon => $addon, small => true]}
{control avatar, $addon, false, true}
<div class="flex flex-col flex-1">
{control name, [addon => $addon]}
{control description, [addon => $addon]}
{control name, $addon}
{control description, $addon}
</div>
</div>
{control statistics, [addon => $addon, featured => true, inline => true]}
{control statistics, $addon, true, true}
</div>
</div>
{include _shapes.latte}
Expand Down
26 changes: 12 additions & 14 deletions app/modules/Front/Base/Controls/AddonList/AddonList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
use App\Model\Database\Query\LatestAddedAddonsQuery;
use App\Model\Database\Query\QueryObject;
use App\Model\Database\Query\SearchAddonsQuery;
use App\Model\UI\BaseControl;
use App\Model\UI\BaseRenderControl;
use App\Modules\Front\Base\Controls\AddonList\Avatar\AvatarComponent;
use App\Modules\Front\Base\Controls\AddonList\Description\DescriptionComponent;
use App\Modules\Front\Base\Controls\AddonList\Name\NameComponent;
use App\Modules\Front\Base\Controls\AddonList\Statistics\StatisticsComponent;
use App\Modules\Front\Base\Controls\AddonMeta\AddonMeta;
use App\Modules\Front\Base\Controls\Layout\Box\BoxComponent;
use App\Modules\Front\Base\Controls\Layout\Box\BoxProps;
use App\Modules\Front\Base\Controls\Layout\Heading\HeadingComponent;
use Nette\Utils\Html;
use Wavevision\PropsControl\Helpers\Render;

class AddonList extends BaseControl
class AddonList extends BaseRenderControl
{

use AvatarComponent;
Expand Down Expand Up @@ -50,13 +48,13 @@ protected function createComponentMeta(): AddonMeta

public function render(): void
{
$this->getBoxComponent()->render(new BoxProps([BoxProps::CONTENT => $this->renderContent()]));
$this->getBoxComponent()->render($this->renderContent());
}

private function renderContent(): Html
{
$addons = $this->addonRepository->fetchEntities($this->queryObject);
return Render::toHtml(
return Html::el()->setHtml(
$this->template
->setParameters([
'addons' => $addons,
Expand All @@ -71,14 +69,11 @@ private function renderTitle(int $addonsCount): ?Html
switch ($query) {
case LatestActivityAddonsQuery::class:
return Html::el()->setText('Latest updated addons');

case LatestAddedAddonsQuery::class:
return Html::el()->setText('Latest indexed addons');

case SearchAddonsQuery::class:
return $this->renderSearchTitle($addonsCount);
}

return null;
}

Expand All @@ -91,19 +86,22 @@ private function renderSearchTitle(int $addonsCount): Html
->addHtml(Html::el()->setText('By '))
->addHtml(Html::el('strong')->setText($author));
}

if ($tag = $query->getTag()) {
return Html::el()
->addHtml(Html::el()->setText('Tagged by #'))
->addHtml(Html::el('strong')->setText($tag));
}

return Html::el()
->addHtml(Html::el()->setText('Searched for $'))
->addHtml(Html::el('strong')->setText($query->getQuery()))
->addHtml(Html::el('i')
->setAttribute('class', 'ml-2 relative inline-block px-2 text-sm font-normal text-blue-700 bg-blue-100 rounded-full align-middle')
->setText(sprintf('%d result%s', $addonsCount, $addonsCount > 1 ? 's' : '')));
->addHtml(
Html::el('i')
->setAttribute(
'class',
'ml-2 relative inline-block px-2 text-sm font-normal text-blue-700 bg-blue-100 rounded-full align-middle'
)
->setText(sprintf('%d result%s', $addonsCount, $addonsCount > 1 ? 's' : ''))
);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{varType App\Model\Database\ORM\Addon\Addon $addon}
{varType bool $linkToGithub}
{varType bool $linkToGitHub}
{varType bool $small}
<a href="{if $linkToGithub}{$addon->github->linker->getRepoUrl()}{else}{plink Addon:detail, slug => $addon->id}{/if}"
<a href="{if $linkToGitHub}{$addon->github->linker->getRepoUrl()}{else}{plink Addon:detail, slug => $addon->id}{/if}"
class="flex-shrink-0 mr-4"
>
<img loading="lazy" alt="{$addon->author}"
Expand Down
24 changes: 0 additions & 24 deletions app/modules/Front/Base/Controls/AddonList/BaseAddonProps.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
use App\Modules\Front\Base\Controls\AddonList\Statistics\StatisticsComponent;
use App\Modules\Front\Base\Controls\AddonMeta\AddonMeta;
use App\Modules\Front\Base\Controls\Layout\Box\BoxComponent;
use App\Modules\Front\Base\Controls\Layout\Box\BoxProps;
use Nette\Utils\Html;
use Nextras\Orm\Collection\ICollection;
use Wavevision\PropsControl\Helpers\Render;

final class CategorizedAddonList extends BaseControl
{
Expand Down Expand Up @@ -77,7 +75,7 @@ protected function getAddons(): ICollection

public function render(): void
{
$this->getBoxComponent()->render(new BoxProps([BoxProps::CONTENT => $this->renderContent()]));
$this->getBoxComponent()->render($this->renderContent());
}

private function renderContent(): Html
Expand Down Expand Up @@ -127,7 +125,7 @@ private function renderContent(): Html
$this->template->list = $list;
$this->template->title = null;
// Render
return Render::toHtml($this->template->renderToString(__DIR__ . '/templates/categorized.list.latte'));
return Html::el()->setHtml($this->template->renderToString(__DIR__ . '/templates/categorized.list.latte'));
}

}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{varType App\Model\Database\ORM\Addon\Addon $addon}
<p class="text-sm text-gray-700">{$addon->github->description|truncate:150|striptags|emojify|noescape}</p>
<p n:if="$addon->github" class="text-sm text-gray-700">{$addon->github->description|truncate:150|striptags|emojify|noescape}</p>
2 changes: 2 additions & 0 deletions app/modules/Front/Base/Controls/AddonList/Name/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function render(Addon $addon, bool $linkToGitHub = false, bool $inverseTa
/** @var GithubRelease|null $release */
$release = $github->releases->get()->orderBy(['crawledAt' => ICollection::DESC])->fetch();
$this->template->setParameters(['release' => $release]);
} else {
$this->template->setParameters(['release' => null]);
}
$this->template->render();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{if count($addons)}
<div n:if="$title" class="flex flex-wrap items-center justify-between px-5 pt-3 lg:px-8 lg:pt-4">
<div class="mb-3 lg:mb-5">
{control heading, [content => $title]}
{control heading, $title}
</div>
<a href="{plink :Front:Index:all}"
class="inline-flex px-4 py-2 mb-3 font-medium text-teal-900 uppercase border rounded lg:mb-4 hover:bg-blue-100 transition duration-150 ease-in-out"
Expand Down
31 changes: 0 additions & 31 deletions app/modules/Front/Base/Controls/Layout/Box/BoxProps.php

This file was deleted.

17 changes: 13 additions & 4 deletions app/modules/Front/Base/Controls/Layout/Box/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

namespace App\Modules\Front\Base\Controls\Layout\Box;

use App\Model\UI\BasePropsControl;
use App\Model\UI\BaseRenderControl;
use Nette\Utils\Html;

class Control extends BasePropsControl
class Control extends BaseRenderControl
{

protected function getPropsClass(): string
/**
* @param Html $content
* @param string[] $attributes
* @param string[] $classNames
*/
public function render(Html $content, array $attributes = [], array $classNames = []): void
{
return BoxProps::class;
$this->template->content = $content;
$this->template->attributes = $attributes;
$this->template->classNames = $classNames;
$this->template->render();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{templateType Wavevision\PropsControl\PropsControlTemplate}
<div n:class="bg-white, rounded, shadow-md, 'z-10', relative, ...$props->get(App\Modules\Front\Base\Controls\Layout\Box\BoxProps::CLASS_NAMES)"
n:attr="$props->get(App\Modules\Front\Base\Controls\Layout\Box\BoxProps::ATTRIBUTES)"
{varType Nette\Utils\Html $content}
{varType array $attributes}
{varType array $classNames}
<div n:class="bg-white, rounded, shadow-md, 'z-10', relative, ...$classNames"
n:attr="$attributes"
>
{$props->get(App\Modules\Front\Base\Controls\Layout\Box\BoxProps::CONTENT)}
{$content}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Modules\Front\Base\Controls\Layout\Footer\Heading;

use App\Model\UI\BasePropsControl;
use App\Model\UI\BaseRenderControl;

class Control extends BaseRenderControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Modules\Front\Base\Controls\Layout\Footer\SocialLinks;

use App\Modules\Front\Base\Controls\Svg\SvgProps;
use Nette\SmartObject;

final class Icon
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{varType App\Modules\Front\Base\Controls\Layout\Footer\SocialLinks\SocialLinksProps $socialLinks}
{varType App\Modules\Front\Base\Controls\Layout\Footer\SocialLinks\SocialLink[] $socialLinks}
<footer class="bg-white px-2 md:px-4 py-12 lg:py-16 relative overflow-hidden">
<div class="container mx-auto">
<div class="xl:grid xl:grid-cols-3 px-5 lg:px-8 xl:gap-8">
Expand Down
8 changes: 3 additions & 5 deletions app/modules/Front/Base/Controls/Layout/Heading/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
class Control extends BaseRenderControl
{

/**
* @param array<string, mixed> $props
*/
public function render(array $props): void

public function render(string $content, string $type = 'h2'): void
{
$this->template->setParameters(['props' => $props])->render();
$this->template->setParameters(['content' => $content, 'type' => $type])->render();
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{varType array $props}
<{$props['type']} class="text-xl font-bold text-gray-800 lg:text-3xl font-headers">
{$props['content']}
</{$props['type']}>
{varType string $content}
{varType string $type}
<{$type} class="text-xl font-bold text-gray-800 lg:text-3xl font-headers">
{$content}
</{$type}>
1 change: 0 additions & 1 deletion app/modules/Front/Base/Controls/Search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Model\Services\Search\Search as Searching;
use App\Model\UI\BaseControl;
use App\Modules\Front\Base\Controls\Svg\SvgComponent;
use App\Modules\Front\Base\Controls\Svg\SvgProps;
use Nette\Application\UI\Form;

final class Search extends BaseControl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{varType App\Modules\Front\Base\Controls\Svg\SvgProps $searchIcon}
{varType array $searchIcon}
<div class="px-2 -mb-4 md:px-4 md:-mb-1 lg:-mb-0">
<form n:name="form" class="container flex mx-auto bg-white rounded shadow-xl transform -translate-y-1/2">
<input n:name="q"
Expand Down
Loading

0 comments on commit 92039df

Please sign in to comment.