You are here

public function Border::buildConfigurationForm in Bootstrap Styles 1.0.x

Same name in this branch
  1. 1.0.x src/Plugin/BootstrapStyles/Style/Border.php \Drupal\bootstrap_styles\Plugin\BootstrapStyles\Style\Border::buildConfigurationForm()
  2. 1.0.x src/Plugin/BootstrapStyles/StylesGroup/Border.php \Drupal\bootstrap_styles\Plugin\BootstrapStyles\StylesGroup\Border::buildConfigurationForm()

Overrides StylePluginBase::buildConfigurationForm

File

src/Plugin/BootstrapStyles/Style/Border.php, line 25

Class

Border
Class Border.

Namespace

Drupal\bootstrap_styles\Plugin\BootstrapStyles\Style

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config();
  $directions = [
    'left',
    'top',
    'right',
    'bottom',
  ];

  // Border style.
  $form['border']['style_description'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('Border style'),
    '#markup' => $this
      ->t('<p>Enter one value per line, in the format <b>key|label</b> where <em>key</em> is the CSS class name (without the .), and <em>label</em> is the human readable name of the border style.</p>'),
  ];
  $form['border']['style_group'] = [
    '#type' => 'container',
    '#title' => $this
      ->t('Border style group'),
    '#title_display' => 'invisible',
    '#tree' => FALSE,
    '#attributes' => [
      'class' => [
        'bs-admin-d-lg-flex',
        'bs-admin-group-form-item-lg-ml',
      ],
    ],
  ];
  $form['border']['style_group']['border_style'] = [
    '#type' => 'textarea',
    '#default_value' => $config
      ->get('border_style'),
    '#title' => $this
      ->t('Border style (classes)'),
    '#cols' => 60,
    '#rows' => 5,
  ];
  for ($i = 0; $i < 4; $i++) {
    $form['border']['style_group']['border_' . $directions[$i] . '_style'] = [
      '#type' => 'textarea',
      '#default_value' => $config
        ->get('border_' . $directions[$i] . '_style'),
      '#title' => $this
        ->t('Border @direction style (classes)', [
        '@direction' => $directions[$i],
      ]),
      '#cols' => 60,
      '#rows' => 5,
    ];
  }

  // Border width.
  $form['border']['width_description'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('Border width'),
    '#markup' => $this
      ->t('<p>Enter one value per line, in the format <b>key|label</b> where <em>key</em> is the CSS class name (without the .), and <em>label</em> is the human readable name of the border width. <br /> <b>Note:</b> These options will be reflected on the range slider at the Layout Builder form, so make sure to sort them from lowest to greatest.</p>'),
  ];
  $form['border']['width_group'] = [
    '#type' => 'container',
    '#title' => $this
      ->t('Border width group'),
    '#title_display' => 'invisible',
    '#tree' => FALSE,
    '#attributes' => [
      'class' => [
        'bs-admin-d-lg-flex',
        'bs-admin-group-form-item-lg-ml',
      ],
    ],
  ];
  $form['border']['width_group']['border_width'] = [
    '#type' => 'textarea',
    '#default_value' => $config
      ->get('border_width'),
    '#title' => $this
      ->t('Border width (classes)'),
    '#cols' => 60,
    '#rows' => 5,
  ];
  for ($i = 0; $i < 4; $i++) {
    $form['border']['width_group']['border_' . $directions[$i] . '_width'] = [
      '#type' => 'textarea',
      '#default_value' => $config
        ->get('border_' . $directions[$i] . '_width'),
      '#title' => $this
        ->t('Border @direction width (classes)', [
        '@direction' => $directions[$i],
      ]),
      '#cols' => 60,
      '#rows' => 5,
    ];
  }

  // Border colors.
  $form['border']['color_description'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('Border color'),
    '#markup' => $this
      ->t('<p>Enter one value per line, in the format <b>key|label</b> where <em>key</em> is the CSS class name (without the .), and <em>label</em> is the human readable name of the border color.</p>'),
  ];
  $form['border']['color_group'] = [
    '#type' => 'container',
    '#title' => $this
      ->t('Border color group'),
    '#title_display' => 'invisible',
    '#tree' => FALSE,
    '#attributes' => [
      'class' => [
        'bs-admin-d-lg-flex',
        'bs-admin-group-form-item-lg-ml',
      ],
    ],
  ];
  $form['border']['color_group']['border_color'] = [
    '#type' => 'textarea',
    '#default_value' => $config
      ->get('border_color'),
    '#title' => $this
      ->t('Border colors (classes)'),
    '#cols' => 60,
    '#rows' => 5,
  ];
  for ($i = 0; $i < 4; $i++) {
    $form['border']['color_group']['border_' . $directions[$i] . '_color'] = [
      '#type' => 'textarea',
      '#default_value' => $config
        ->get('border_' . $directions[$i] . '_color'),
      '#title' => $this
        ->t('Border @direction colors (classes)', [
        '@direction' => $directions[$i],
      ]),
      '#cols' => 60,
      '#rows' => 5,
    ];
  }

  // Border rounded corners.
  $form['border']['rounded_corners_description'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('Rounded Corners'),
    '#markup' => $this
      ->t('<p>Enter one value per line, in the format <b>key|label</b> where <em>key</em> is the CSS class name (without the .), and <em>label</em> is the human readable name of the rounded corner. <br /> <b>Note:</b> These options will be reflected on the range slider at the Layout Builder form, so make sure to sort them from lowest to greatest.</p>'),
  ];
  $form['border']['rounded_corners'] = [
    '#type' => 'container',
    '#title' => $this
      ->t('Rounded cornerns'),
    '#title_display' => 'invisible',
    '#tree' => FALSE,
    '#attributes' => [
      'class' => [
        'bs-admin-d-lg-flex',
        'bs-admin-group-form-item-lg-ml',
      ],
    ],
  ];
  $form['border']['rounded_corners']['rounded_corners'] = [
    '#type' => 'textarea',
    '#default_value' => $config
      ->get('rounded_corners'),
    '#title' => $this
      ->t('Rounded corners (classes)'),
    '#cols' => 60,
    '#rows' => 5,
  ];
  $corners = [
    'top_left' => 'Top Left',
    'top_right' => 'Top Right',
    'bottom_left' => 'Bottom Left',
    'bottom_right' => 'Bottom Right',
  ];
  foreach ($corners as $corner_key => $corner_value) {
    $form['border']['rounded_corners']['rounded_corner_' . $corner_key] = [
      '#type' => 'textarea',
      '#default_value' => $config
        ->get('rounded_corner_' . $corner_key),
      '#title' => $this
        ->t('@corner rounded corner (classes)', [
        '@corner' => $corner_value,
      ]),
      '#cols' => 60,
      '#rows' => 5,
    ];
  }
  return $form;
}