Skip to content

Commit a586f2b

Browse files
committed
feat(restrict): Restrict missing search submit button invisible text to gcweb
1 parent 17b2dee commit a586f2b

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace Drupal\wxt_bootstrap\Plugin\Preprocess;
4+
5+
use Drupal\bootstrap\Plugin\Preprocess\InputButton as BootstrapInputButton;
6+
use Drupal\bootstrap\Utility\Element;
7+
use Drupal\bootstrap\Utility\Variables;
8+
9+
/**
10+
* Pre-processes variables for the "input__button" theme hook.
11+
*
12+
* @ingroup plugins_preprocess
13+
*
14+
* @BootstrapPreprocess("input__button")
15+
*/
16+
class InputButton extends BootstrapInputButton {
17+
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public function preprocessElement(Element $element, Variables $variables) {
22+
$wxt = \Drupal::service('wxt_library.service_wxt');
23+
$wxt_active = $wxt->getLibraryName();
24+
25+
$element->colorize();
26+
$element->setButtonSize();
27+
$element->setIcon($element->getProperty('icon'));
28+
$variables['icon_only'] = $element->getProperty('icon_only');
29+
$variables['icon_position'] = $element->getProperty('icon_position');
30+
$variables['label'] = $element->getProperty('value');
31+
$variables['wxt_theme'] = $wxt_active;
32+
33+
if ($element->getProperty('split')) {
34+
$variables->map([$variables::SPLIT_BUTTON]);
35+
}
36+
37+
parent::preprocessElement($element, $variables);
38+
}
39+
40+
}

templates/input/input--button--submit.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
%}
3333
{% block input %}
3434
{% if search_submit == 'true' %}
35-
<button{{ attributes.addClass(classes) }}>{{ icon }}<span class="wb-inv">{{ 'Search'|t }}</span></button>{{ children }}
35+
{% if wxt_theme == 'gcweb' %}
36+
<button{{ attributes.addClass(classes) }}>{{ icon }}<span class="wb-inv">{{ 'Search'|t }}</span></button>{{ children }}
37+
{% else %}
38+
<button{{ attributes.addClass(classes) }}>{{ icon }}{{ 'Search'|t }}</button>{{ children }}
39+
{% endif %}
3640
{% elseif icon and icon_only %}
3741
<button{{ attributes.addClass(classes, 'icon-only') }}>
3842
<span class="sr-only">{{ label }}</span>

0 commit comments

Comments
 (0)