Skip to content

Commit

Permalink
Style button groups in forms (#268)
Browse files Browse the repository at this point in the history
Additionally, set default retry to 3 in acceptance tests.
  • Loading branch information
marein authored Mar 2, 2025
1 parent abcfcf6 commit ad86a44
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,11 @@ notification-list {
[data-bs-theme=dark] .gp-game__field {
border-color: var(--tblr-blue);
}

/** Fix specificity for checked buttons on hover */
.btn-check:checked + .btn:hover {
color: var(--tblr-btn-active-color);
background-color: var(--tblr-btn-active-bg);
border-color: var(--tblr-btn-active-border-color);
box-shadow: var(--tblr-btn-active-shadow)
}
1 change: 1 addition & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ monolog:
formatter: 'monolog.formatter.json'

twig:
form_themes: ['tabler_form_layout.html.twig']
strict_variables: '%kernel.debug%'

services:
Expand Down
24 changes: 24 additions & 0 deletions templates/tabler_form_layout.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% use "bootstrap_5_layout.html.twig" %}

{# Override to ignore label_attr for expanded choices, allowing them to be rendered as buttons. #}
{%- block choice_label -%}
{% if expanded is defined and expanded %}
<legend class="form-label{{ required ? ' required' }}">{{ label }}</legend>
{% else %}
{{- parent() -}}
{% endif %}
{%- endblock choice_label %}

{# Override to ensure choices don't inherit the required attribute, removing the asterisk from each choice. #}
{%- block choice_widget_expanded -%}
<div {{ block('widget_container_attributes') }}>
{%- for child in form %}
{{- form_widget(child, {
required: false,
parent_label_class: label_attr.class|default(''),
translation_domain: choice_translation_domain,
valid: valid,
}) -}}
{% endfor -%}
</div>
{%- endblock choice_widget_expanded %}
8 changes: 8 additions & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Codeception\Actor;
use Codeception\Lib\Actor\Shared\Friend;
use Codeception\Lib\Actor\Shared\Retry;
use Codeception\Scenario;

/**
* Inherited Methods
Expand All @@ -26,4 +27,11 @@ class AcceptanceTester extends Actor
use _generated\AcceptanceTesterActions;
use Friend;
use Retry;

public function __construct(Scenario $scenario)
{
parent::__construct($scenario);

$this->retry(3);
}
}

0 comments on commit ad86a44

Please sign in to comment.