diff --git a/app/model/UI/BasePropsControl.php b/app/model/UI/BasePropsControl.php deleted file mode 100644 index 60e156b6..00000000 --- a/app/model/UI/BasePropsControl.php +++ /dev/null @@ -1,10 +0,0 @@ -addonFacade->getDetail($id))) { $this->error('Addon not found'); } diff --git a/app/modules/Front/Addon/Controls/AddonDetail/templates/header.latte b/app/modules/Front/Addon/Controls/AddonDetail/templates/header.latte index 4a7c84b3..06d1b888 100644 --- a/app/modules/Front/Addon/Controls/AddonDetail/templates/header.latte +++ b/app/modules/Front/Addon/Controls/AddonDetail/templates/header.latte @@ -1,10 +1,10 @@ {varType App\Model\Database\ORM\Addon\Addon $addon}
- {control avatar, [addon => $addon, linkToGithub => true]} + {control avatar, $addon, true}
- {control name, [addon => $addon, inverseTag => true, linkToGithub => true]} - {control description, [addon => $addon]} + {control name, $addon, true, true} + {control description, $addon}
- {control statistics, [addon => $addon]} + {control statistics, $addon}
diff --git a/app/modules/Front/Addon/Controls/FeaturedAddon/templates/default.latte b/app/modules/Front/Addon/Controls/FeaturedAddon/templates/default.latte index eecca180..672893ce 100644 --- a/app/modules/Front/Addon/Controls/FeaturedAddon/templates/default.latte +++ b/app/modules/Front/Addon/Controls/FeaturedAddon/templates/default.latte @@ -10,13 +10,13 @@
- {control avatar, [addon => $addon, small => true]} + {control avatar, $addon, false, true}
- {control name, [addon => $addon]} - {control description, [addon => $addon]} + {control name, $addon} + {control description, $addon}
- {control statistics, [addon => $addon, featured => true, inline => true]} + {control statistics, $addon, true, true}
{include _shapes.latte} diff --git a/app/modules/Front/Base/Controls/AddonList/AddonList.php b/app/modules/Front/Base/Controls/AddonList/AddonList.php index 6cd93e6b..ff0d1b0c 100644 --- a/app/modules/Front/Base/Controls/AddonList/AddonList.php +++ b/app/modules/Front/Base/Controls/AddonList/AddonList.php @@ -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; @@ -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, @@ -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; } @@ -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' : '')) + ); } } diff --git a/app/modules/Front/Base/Controls/AddonList/Avatar/templates/default.latte b/app/modules/Front/Base/Controls/AddonList/Avatar/templates/default.latte index c80f022d..85aa7696 100644 --- a/app/modules/Front/Base/Controls/AddonList/Avatar/templates/default.latte +++ b/app/modules/Front/Base/Controls/AddonList/Avatar/templates/default.latte @@ -1,7 +1,7 @@ {varType App\Model\Database\ORM\Addon\Addon $addon} -{varType bool $linkToGithub} +{varType bool $linkToGitHub} {varType bool $small} - {$addon->author} - */ - protected function define(): array - { - return [ - self::ADDON => Expect::type(Addon::class)->required(), - ]; - } - -} diff --git a/app/modules/Front/Base/Controls/AddonList/CategorizedAddonList.php b/app/modules/Front/Base/Controls/AddonList/CategorizedAddonList.php index 915f0e83..ef034c3b 100644 --- a/app/modules/Front/Base/Controls/AddonList/CategorizedAddonList.php +++ b/app/modules/Front/Base/Controls/AddonList/CategorizedAddonList.php @@ -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 { @@ -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 @@ -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')); } } diff --git a/app/modules/Front/Base/Controls/AddonList/Description/templates/default.latte b/app/modules/Front/Base/Controls/AddonList/Description/templates/default.latte index 8473d874..0d777726 100644 --- a/app/modules/Front/Base/Controls/AddonList/Description/templates/default.latte +++ b/app/modules/Front/Base/Controls/AddonList/Description/templates/default.latte @@ -1,2 +1,2 @@ {varType App\Model\Database\ORM\Addon\Addon $addon} -

{$addon->github->description|truncate:150|striptags|emojify|noescape}

+

{$addon->github->description|truncate:150|striptags|emojify|noescape}

diff --git a/app/modules/Front/Base/Controls/AddonList/Name/Control.php b/app/modules/Front/Base/Controls/AddonList/Name/Control.php index 69d8409a..f0285a25 100644 --- a/app/modules/Front/Base/Controls/AddonList/Name/Control.php +++ b/app/modules/Front/Base/Controls/AddonList/Name/Control.php @@ -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(); } diff --git a/app/modules/Front/Base/Controls/AddonList/templates/list.latte b/app/modules/Front/Base/Controls/AddonList/templates/list.latte index cd8b2a6a..eb630ae1 100644 --- a/app/modules/Front/Base/Controls/AddonList/templates/list.latte +++ b/app/modules/Front/Base/Controls/AddonList/templates/list.latte @@ -3,7 +3,7 @@ {if count($addons)}
- {control heading, [content => $title]} + {control heading, $title}
Expect::arrayOf(Expect::string())->default([]), - self::CLASS_NAMES => Expect::arrayOf(Expect::string())->default([]), - self::CONTENT => PropTypes::html()->nullable(), - ]; - } - -} diff --git a/app/modules/Front/Base/Controls/Layout/Box/Control.php b/app/modules/Front/Base/Controls/Layout/Box/Control.php index 80e20271..ef59e42e 100644 --- a/app/modules/Front/Base/Controls/Layout/Box/Control.php +++ b/app/modules/Front/Base/Controls/Layout/Box/Control.php @@ -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(); } } diff --git a/app/modules/Front/Base/Controls/Layout/Box/templates/default.latte b/app/modules/Front/Base/Controls/Layout/Box/templates/default.latte index e1bf28c6..1d00485c 100644 --- a/app/modules/Front/Base/Controls/Layout/Box/templates/default.latte +++ b/app/modules/Front/Base/Controls/Layout/Box/templates/default.latte @@ -1,6 +1,8 @@ -{templateType Wavevision\PropsControl\PropsControlTemplate} -
- {$props->get(App\Modules\Front\Base\Controls\Layout\Box\BoxProps::CONTENT)} + {$content}
diff --git a/app/modules/Front/Base/Controls/Layout/Footer/Heading/Control.php b/app/modules/Front/Base/Controls/Layout/Footer/Heading/Control.php index 215b96ff..5f4a9f8a 100644 --- a/app/modules/Front/Base/Controls/Layout/Footer/Heading/Control.php +++ b/app/modules/Front/Base/Controls/Layout/Footer/Heading/Control.php @@ -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 diff --git a/app/modules/Front/Base/Controls/Layout/Footer/SocialLinks/Icon.php b/app/modules/Front/Base/Controls/Layout/Footer/SocialLinks/Icon.php index ae4be5f0..12484730 100644 --- a/app/modules/Front/Base/Controls/Layout/Footer/SocialLinks/Icon.php +++ b/app/modules/Front/Base/Controls/Layout/Footer/SocialLinks/Icon.php @@ -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 diff --git a/app/modules/Front/Base/Controls/Layout/Footer/SocialLinks/SocialLinksProps.php b/app/modules/Front/Base/Controls/Layout/Footer/SocialLinks/SocialLinksProps.php deleted file mode 100644 index 2a5b4f27..00000000 --- a/app/modules/Front/Base/Controls/Layout/Footer/SocialLinks/SocialLinksProps.php +++ /dev/null @@ -1,24 +0,0 @@ - Expect::listOf(SocialLink::class), - ]; - } - -} diff --git a/app/modules/Front/Base/Controls/Layout/Footer/templates/default.latte b/app/modules/Front/Base/Controls/Layout/Footer/templates/default.latte index d35b4aaa..c84e407b 100644 --- a/app/modules/Front/Base/Controls/Layout/Footer/templates/default.latte +++ b/app/modules/Front/Base/Controls/Layout/Footer/templates/default.latte @@ -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}