Commit b25d705d authored by Florent Torregrosa's avatar Florent Torregrosa Committed by Florent Torregrosa
Browse files

Issue #3292593 by Grimreaper: Bootstrap 5 : Components > Dropdowns

parent a4b9e1ef
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
<?php

declare(strict_types = 1);

namespace Drupal\ui_suite_bootstrap\HookHandler;

use Drupal\Component\Utility\Html;

/**
 * Handle variables needed for the pattern.
 */
class PreprocessPatternDropdown {

  /**
   * Handle variables needed for the pattern.
   *
   * @param array $variables
   *   The preprocessed variables.
   */
  public function preprocess(array &$variables): void {
    $variables['dropdown_id'] = Html::getUniqueId('bootstrap-dropdown');
  }

}
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ alert:
      label: "Dismissible?"
      description: "It is possible to dismiss any alert inline."
      preview: True
      allow_expose: true
  fields:
    heading:
      type: "text"
+8 −0
Original line number Diff line number Diff line
@@ -104,6 +104,8 @@ button:
      label: "Outline Light large"
    outline_dark__lg:
      label: "Outline Dark large"
    dropdown_item:
      label: "(Dropdown item)"
  settings:
    disabled:
      type: "boolean"
@@ -111,6 +113,12 @@ button:
      description: "Is the button disabled?"
      preview: true
      allow_expose: true
    label_visually_hidden:
      type: "boolean"
      label: "Hide button label?"
      description: "Is the button's label hidden?"
      preview: false
      allow_expose: true
  fields:
    label:
      type: "text"
+12 −3
Original line number Diff line number Diff line
{% if variant != '' and variant|lower != 'default' %}
{% if variant != '' and variant|lower != 'dropdown_item' %}
  {% set variants = variant|split('__') %}
  {% for variant in variants %}
    {% set attributes = attributes.addClass('btn-' ~ variant|lower|replace({'_': '-'})) %}
  {% endfor %}
  {% set attributes = attributes.addClass('btn') %}
{% endif %}

{% set attributes = attributes.addClass('btn') %}
{% set attributes = variant|lower == 'dropdown_item' ? attributes.addClass('dropdown-item') : attributes %}

{% if label_visually_hidden %}
  {% set label %}
    <span class="visually-hidden">
      {{ label }}
    </span>
  {% endset %}
{% endif %}

{% if url or attributes.href %}
  {% set url = url ?: attributes.href %}
@@ -20,5 +29,5 @@
    {% set attributes = attributes.setAttribute('disabled', '') %}
  {% endif %}

  <span{{ attributes }}>{{ label }}</span>
  <button{{ attributes.setAttribute('type', 'button') }}>{{ label }}</button>
{% endif %}
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ card:
        top: "Top (Default)"
        bottom: "Bottom"
      preview: "top"
      allow_expose: true
  fields:
    image:
      type: "render"
Loading