Skip to content

Commit

Permalink
Merge pull request #27 from openeuropa/OEL-543
Browse files Browse the repository at this point in the history
OEL-543: Styling components.
  • Loading branch information
drishu authored Oct 18, 2021
2 parents e34072c + 0ecc9d0 commit 2aec087
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 25 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
"drupal/core": "^8.9 || ^9.1",
"drupal/ui_patterns": "^1.0",
"drupal/ui_patterns_settings": "^1.0",
"openeuropa/oe_bootstrap_theme": "0.011020211805"
"openeuropa/oe_bootstrap_theme": "0.181020211745"
},
"require-dev": {
"composer/installers": "^1.11",
"drupal/core-composer-scaffold": "^8.9 || ^9.1",
"drupal/config_devel": "~1.2",
"drupal/better_exposed_filters": "^5.0@beta",
"drupal/drupal-extension": "~4.1",
"drush/drush": "^10.3",
"openeuropa/code-review": "1.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types = 1);

namespace Drupal\oe_whitelabel_helper\Plugin\better_exposed_filters\sort;

use Drupal\better_exposed_filters\Plugin\better_exposed_filters\sort\DefaultWidget;
use Drupal\Core\Form\FormStateInterface;

/**
* OpenEuropa custom better exposed filters widget implementation.
*
* @BetterExposedFiltersSortWidget(
* id = "oe_whitelabel_float_end_sort",
* label = @Translation("Float End Sort"),
* )
*/
class FloatEndSortWidget extends DefaultWidget {

/**
* {@inheritdoc}
*/
public function exposedFormAlter(array &$form, FormStateInterface $form_state) {
parent::exposedFormAlter($form, $form_state);
$form['#attributes']['class'][] = 'float-lg-end';
$form['#attributes']['class'][] = 'd-md-block';
}

}
27 changes: 27 additions & 0 deletions oe_whitelabel.theme
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare(strict_types = 1);

use Drupal\Core\Form\FormStateInterface;

/**
* Implements hook__preprocess_links__language_block().
*/
Expand Down Expand Up @@ -64,3 +66,28 @@ function oe_whitelabel_preprocess_links__language_block(&$variables) {
],
];
}

/**
* Implements hook_form_FORM_ID_alter() for facets_forms.
*/
function oe_whitelabel_form_facets_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (isset($form['actions'])) {
$form['actions']['#attributes']['class'][] = 'mt-4';
}
if (isset($form['actions']['submit'])) {
$submit_classes = ['me-2', 'btn', 'btn-primary'];
foreach ($submit_classes as $submit_class) {
if (!isset($submit_class, $form['actions']['submit']['#attributes']['class']) || !in_array($submit_class, $form['actions']['submit']['#attributes']['class'], TRUE)) {
$form['actions']['submit']['#attributes']['class'][] = $submit_class;
}
}
}
if (isset($form['actions']['reset'])) {
$reset_classes = ['btn', 'btn-secondary'];
foreach ($reset_classes as $reset_class) {
if (!isset($form['actions']['reset']['#attributes']['class']) || !in_array($reset_class, $form['actions']['reset']['#attributes']['class'], TRUE)) {
$form['actions']['reset']['#attributes']['class'][] = $reset_class;
}
}
}
}
24 changes: 0 additions & 24 deletions templates/overrides/search/form--views-exposed-form.html.twig

This file was deleted.

0 comments on commit 2aec087

Please sign in to comment.