You are here

protected function ResponsiveTrait::buildBreakpointsFields in Bootstrap Styles 1.0.x

Build the breakpoints style form elements.

Parameters

array $form: An associative array containing the structure of the form.

string $group_name: The name of group that we like to add responsive to its plugins.

3 calls to ResponsiveTrait::buildBreakpointsFields()
Background::buildStyleFormElements in src/Plugin/BootstrapStyles/StylesGroup/Background.php
Spacing::buildStyleFormElements in src/Plugin/BootstrapStyles/StylesGroup/Spacing.php
Typography::buildStyleFormElements in src/Plugin/BootstrapStyles/StylesGroup/Typography.php

File

src/ResponsiveTrait.php, line 71

Class

ResponsiveTrait
A Trait for responsive methods.

Namespace

Drupal\bootstrap_styles

Code

protected function buildBreakpointsFields(array &$form, $group_name) {
  $icon_path = drupal_get_path('module', 'bootstrap_styles') . '/images/';
  $form['bs_responsive_' . $group_name] = [
    '#type' => 'radios',
    '#options' => [
      'all' => $this
        ->getSvgIconMarkup($icon_path . 'responsive/device-all.svg'),
    ],
    '#title' => $this
      ->t('Responsive'),
    '#title_display' => 'invisible',
    '#default_value' => 'all',
    '#validated' => TRUE,
    '#attributes' => [
      'class' => [
        'bs_col--full',
        'bs_responsive',
        'bs_responsive_' . $group_name,
      ],
    ],
    '#disable_live_preview' => TRUE,
  ];

  // Loop through the breakpoints.
  foreach ($this
    ->getBreakpoints() as $breakpoint_key => $breakpoint_value) {
    $form['bs_responsive_' . $group_name]['#options'][$breakpoint_key] = $this
      ->getSvgIconMarkup($icon_path . 'responsive/device-' . $breakpoint_key . '.svg');
  }
}