Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lightbox to header, add tooltip to buttons and small styling adjustments (Meta #119) #63

Merged
merged 5 commits into from
Jul 23, 2024
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
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.de.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
araise_table:
download:
tooltip: Export
info: Was möchten Sie herunterladen?
choices: Export wählen
all: Alle Seiten
Expand Down Expand Up @@ -41,6 +42,7 @@ araise_table:
next_page: nächste Seite
last_page: letzte Seite
filter:
tooltip: Filter
show_element_when: Zeige Elemente wenn
or: oder
and: und
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ araise_table:
options: Options
no_elements: No elements available
search:
title: Search
filter: Filter
remove_search: Remove search
placeholder: Search term...
Expand Down
85 changes: 78 additions & 7 deletions src/Resources/views/tailwind_2/_header.html.twig
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{# Table Header #}
{% if table.option('title') or (view is defined and table.option('definition').hasCapability(constant('araise\\CrudBundle\\Enums\\Page::EXPORT'))) or (table.filterExtension and table.filterExtension.filters|length > 0) or (table.searchExtension and table.option('searchable')) %}
<header class="whatwedo_table:header sm:flex sm:justify-between mb-4">
<header class="whatwedo_table:header sm:flex sm:justify-between my-3">
<div class="whatwedo_table:header__title flex-1 min-w-0 whatwedo-utility-heading-1 sm:truncate">
{% if table.option('title') %}
<h1>
{{ table.option('title')|trans }}
</h1>
{% endif %}
</div>
<div class="mt-4 flex sm:mt-0 sm:ml-4 space-x-2">
<div class="mt-4 flex sm:mt-0 sm:ml-4 space-x-3 items-center {{ block is defined ? ' mr-3' : '' }}">
{% if table.exporters|length > 0 and table.option('definition') and table.option('definition').hasCapability(constant('araise\\CrudBundle\\Enums\\Page::EXPORT')) %}
<div
{{ stimulus_controller('araise/core-bundle/dropdown') }}
class="relative inline-block">
<button
{{ stimulus_action('araise/core-bundle/dropdown', 'toggle') | stimulus_action('araise/core-bundle/dropdown', 'close', 'keydown.esc') }}
class="whatwedo_table:header__button whatwedo_table:header__button--download whatwedo_table-button h-full" tabindex="-1"
{{ stimulus_controller('araise/crud-bundle/tooltip', { 'title': 'araise_table.download.tooltip'|trans } ) }}
class="whatwedo_table:header__button whatwedo_table:header__button--download whatwedo_table-button"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Still a button without a text or aria-label.

>
{{ bootstrap_icon('download', { class: 'w-4 h-4' }) }}
</button>
Expand Down Expand Up @@ -73,13 +74,18 @@
</div>
{% endif %}

{% if block is defined and content is defined %}
{{ _self.add_button(content, view, isOnShow) }}
{% endif %}

{% if table.filterExtension and table.filterExtension.filters|length > 0 %}
<button
class="whatwedo_table:header__button whatwedo_table:header__button--filter whatwedo_table-button whatwedo_table-button--filter {{ table.filterExtension.getFilterCount() > 0 ? 'araise_table-button--filter-active' : '' }} }}"
data-filter-count="{{ table.filterExtension.getFilterCount() }}"
type="button"
{{ stimulus_action('araise/table-bundle/filter', 'open') }}
{{ stimulus_target('araise/table-bundle/filter', 'triggerButton') }}
{{ stimulus_controller('araise/crud-bundle/tooltip', { 'title': 'araise_table.filter.tooltip'|trans } ) }}
>
{{ bootstrap_icon('funnel-fill', { class: 'w-4 h-4' }) }}
</button>
Expand All @@ -98,17 +104,82 @@
<input
class="whatwedo_core-input--rounded-left"
type="search"
name="{{ araise_table_parameter(table, 'query') }}" placeholder="Suchbegriff ..."
name="{{ araise_table_parameter(table, 'query') }}" placeholder="{{ 'araise_table.search.placeholder'|trans }}"
value="{{ table.searchExtension.query }}"
>
</div>
<button class="whatwedo_table-button--search" type="submit">
{{ bootstrap_icon('search', { class: 'h-4 w-4 text-neutral-400', alt: 'Suchen' }) }}
<button class="whatwedo_table-button--search" type="submit" title="{{ 'araise_table.search.title'|trans }}">
{{ bootstrap_icon('search', { class: 'h-4 w-4 text-neutral-400' }) }}
<span class="sr-only">{{ 'araise_table.search.title'|trans }}</span>
</button>
</div>
</form>
{% endif %}
</div>
</header>

{% endif %}

{% macro add_button(content, view, isOnShow) %}
{% set createUrl = content.createUrl(view.data) %}
{% if createUrl and (content.addVoterAttribute is null or is_granted(content.addVoterAttribute, view.data)) %}


{% set additionalClass = (not isOnShow) ? (content.option('attr')['class'] ?? '') : '' %}
{% set additionalAttributes = (not isOnShow) ? attr|map((value, attr) => "#{attr}=\"#{value}\"")|join(' ') : '' %}

<div
class="flex justify-end {{ additionalClass }}"
{{ additionalAttributes|raw }}
{{ stimulus_controller('araise/core-bundle/modal-form', { formUrl: createUrl }) }}>

<button
type="button"
class="whatwedo-crud-button--action whatwedo-crud-button--rounded"
{{ stimulus_action('araise/core-bundle/modal-form', 'openModal') }}
{{ stimulus_controller('araise/crud-bundle/tooltip', { 'title': 'araise_crud.relation.add'|trans } ) }}
>
{{ bootstrap_icon('plus', { class: 'w-6 h-6' }) }}
</button>

<div
{{ stimulus_target('araise/core-bundle/modal-form', 'menu') }}
class="hidden whatwedo-crud-modal whatwedo-utility-modal"
data-transition-enter-from="opacity-0"
data-transition-enter-to="opacity-100"
data-transition-leave-from="opacity-100"
data-transition-leave-to="opacity-0"
role="dialog"
aria-modal="true"
>
<div class="whatwedo-crud-modal__overlay whatwedo-utility-modal__overlay">
<div
class="whatwedo-crud-modal__backdrop whatwedo-utility-modal__backdrop"
{{ stimulus_action('araise/core-bundle/modal-form', 'close', 'click') }}
></div>

{# This element is to trick the browser into centering the modal contents. #}
<span class="hidden md:inline-block md:align-middle md:h-screen" aria-hidden="true">&#8203;</span>

<div class="whatwedo-crud-modal__wrapper whatwedo-utility-modal__wrapper">
<div class="whatwedo-utility-modal__wrapper-inner">
<button
type="button"
class="whatwedo-crud-modal__close whatwedo-utility-modal__close"
{{ stimulus_action('araise/core-bundle/modal-form', 'close') | stimulus_action('araise/core-bundle/modal-form', 'close', 'keydown.esc@window') }}
>
<span class="sr-only">Close</span>
{{ bootstrap_icon('x', { class: 'inline w-8 h-8' }) }}
</button>

<div
class="whatwedo-crud-modal__body w-full"
{{ stimulus_target('araise/core-bundle/modal-form', 'modalBody') }}
></div>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endmacro %}
Comment on lines +122 to +184

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: That macro should at least go to the bottom of the file. But the best approach would be, putting it into a separate file and importing it.

The current approach works, but is the messy one.

Another Nit is that the macro is using snake_case and the variables are using camelCase. The official coding standards of Twig say to use snake_case (See paragrpah Use lower cased and underscored variable names).

https://twig.symfony.com/doc/3.x/coding_standards.html

but this Nit is really out of scope as the overall code does not apply any coding standards and checks and is currently already mixed between snake_case and camelCase.


2 changes: 1 addition & 1 deletion src/Resources/views/tailwind_2_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
{{ stimulus_action('araise/core-bundle/modal-form', 'close', 'click') }}
></div>

{# This element is to trick the browser into centering the modal contents. #}
{# This element is to trick the browser into centering the modal contents. Code is coming from Tailwind UI #}
<span class="hidden md:inline-block md:align-middle md:h-screen" aria-hidden="true">&#8203;</span>

<div class="whatwedo-crud-modal__wrapper whatwedo-utility-modal__wrapper">
Expand Down
Loading