You are here

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

Overrides StylePluginBase::buildConfigurationForm

File

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

Class

ScrollEffects
Class Effect.

Namespace

Drupal\bootstrap_styles\Plugin\BootstrapStyles\Style

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config();

  // Library assets.
  $form['animation']['scroll_effects_library_type'] = [
    '#type' => 'select',
    '#default_value' => $config
      ->get('scroll_effects_library_type'),
    '#title' => $this
      ->t('How should we load the animation library?'),
    '#required' => TRUE,
    '#options' => [
      'local' => $this
        ->t('Do nothing, my theme handle it'),
      'external' => $this
        ->t('Add the library for me please'),
    ],
    '#description' => $this
      ->t('<p>Default uses the AOS library: <a href="https://michalsnik.github.io/aos" target="_blank">https://michalsnik.github.io/aos</a><br/> You can override the animation library in your theme by using <br /><code>libraries-override:<br />&nbsp;&nbsp;bootstrap_styles/plugin.scroll_effects.build: your_theme/your_new_library_definition</code><br /><small>For more information, please check: <a href="https://www.drupal.org/node/2497313" target="_blank">https://www.drupal.org/node/2497313</a></small></p>'),
  ];
  $form['animation']['scroll_effects'] = [
    '#type' => 'textarea',
    '#default_value' => $config
      ->get('scroll_effects'),
    '#title' => $this
      ->t('Scroll Effects'),
    '#description' => $this
      ->t('<p>Enter one value per line, in the format <b>key|label</b> where <em>key</em> is the attribute\'s value, and <em>label</em> is the human readable name of the effect.</p>'),
    '#cols' => 60,
    '#rows' => 5,
  ];
  $form['animation']['scroll_effects_attr_type'] = [
    '#type' => 'checkbox',
    '#default_value' => $config
      ->get('scroll_effects_attr_type'),
    '#title' => $this
      ->t('Use data attribute instead of class.'),
  ];
  $form['animation']['scroll_effects_data_key'] = [
    '#type' => 'textfield',
    '#default_value' => $config
      ->get('scroll_effects_data_key'),
    '#title' => $this
      ->t('Data Key'),
    '#description' => $this
      ->t('<p>The <strong>data_key</strong> will be used as the data attribute. Example: <code>data_key="key"</code></p>'),
    '#states' => [
      'visible' => [
        [
          [
            ':input[name="scroll_effects_attr_type"]' => [
              'checked' => TRUE,
            ],
          ],
        ],
      ],
    ],
  ];
  return $form;
}