-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
337 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
live_component: | ||
resource: '@LiveComponentBundle/config/routes.php' | ||
prefix: '/_components' | ||
# adjust prefix to add localization to your components | ||
#prefix: '/{_locale}/_components' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Twig\Components; | ||
|
||
use App\Repository\QotdRepository; | ||
use Knp\Component\Pager\Pagination\PaginationInterface; | ||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent; | ||
use Symfony\UX\LiveComponent\Attribute\LiveProp; | ||
use Symfony\UX\LiveComponent\DefaultActionTrait; | ||
|
||
#[AsLiveComponent('search')] | ||
final class SearchComponent | ||
{ | ||
use DefaultActionTrait; | ||
|
||
#[LiveProp(writable: true)] | ||
public ?string $query = ''; | ||
|
||
public function __construct( | ||
private QotdRepository $qotdRepository, | ||
) { | ||
} | ||
|
||
/** | ||
* @return PaginationInterface<string, Qotd> | ||
*/ | ||
public function getPagination(): PaginationInterface | ||
{ | ||
return $this->qotdRepository->search($this->query); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div{{ attributes }}> | ||
<form> | ||
<div class="mb-3"> | ||
<label for="query" class="form-label d-none">Search</label> | ||
<input type="search" name="query" data-model="query" class="form-control" id="query"> | ||
</div> | ||
</form> | ||
|
||
{{ include("qotd/_qotds.html.twig", { pagination: this.pagination, with_pagination: false }, with_context = false) }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{% for qotd in pagination %} | ||
<turbo-frame id="qotd-{{ qotd.id }}" data-delete-if-missing="true"> | ||
<div class="card mb-2"> | ||
<div class="card-body"> | ||
{{ qotd.message|replace_emoji|replace_username|markdown_to_html }} | ||
</div> | ||
<div class="card-footer text-muted"> | ||
<div class="d-flex justify-content-between"> | ||
<div class="me-auto"> | ||
{% cache qotd.id %} | ||
{{ qotd.date|format_date() }} by {{ qotd.username }} | ||
{% endcache %} | ||
</div> | ||
<div class="mx-1"> | ||
<a href="{{ qotd.permalink }}" class="btn btn-sm btn-outline-secondary">🔗 view in Slack</a> | ||
</div> | ||
<form action="{{ url(qotd.hasVotedDown(app.user) ? 'qotd_vote_null' : 'qotd_vote_down', { id: qotd.id }) }}" method="POST" class="mx-1"> | ||
<input type="hidden" name="page" value="{{ pagination.page }}"> | ||
<input type="hidden" name="token" value="{{ csrf_token('vote') }}"> | ||
<button type="submit" class="{{ html_classes('btn', 'btn-sm', { 'btn-outline-primary': qotd.hasVotedDown(app.user) }) }}">👎</button> | ||
</form> | ||
<div class="mx-1"> | ||
<span class="badge bg-primary"> | ||
{{ qotd.vote }} | ||
</span> | ||
</div> | ||
<form action="{{ url(qotd.hasVotedUp(app.user) ? 'qotd_vote_null' : 'qotd_vote_up', { id: qotd.id }) }}" method="POST"> | ||
<input type="hidden" name="page" value="{{ pagination.page }}"> | ||
<input type="hidden" name="token" value="{{ csrf_token('vote') }}"> | ||
<button type="submit" class="{{ html_classes('btn', 'btn-sm', { 'btn-outline-primary': qotd.hasVotedUp(app.user) }) }}">👍</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</turbo-frame> | ||
{% else %} | ||
<div class="card mb-2"> | ||
<div class="card-body"> | ||
No QOTD found. | ||
</div> | ||
</div> | ||
{% endfor %} | ||
|
||
{% if with_pagination ?? true %} | ||
<div class="navigation"> | ||
{{ knp_pagination_render(pagination) }} | ||
</div> | ||
{% endif %} |
Oops, something went wrong.