flickity.theme.inc in Flickity Carousel 3.0.x
File
theme/flickity.theme.inc
View source
<?php
use Drupal\Core\Template\Attribute;
use Drupal\flickity\FlickityBuilder;
function template_preprocess_flickity(&$variables) {
$group = flickity_settings($variables['settings']);
$variables['#attached'] = array(
'drupalSettings' => array(
'flickity' => array(
$group['id'] => array(
'settings' => $group['settings'],
),
),
),
'library' => array(
'flickity/local',
'flickity/settings',
),
);
}
function theme_flickity($variables) {
$output = array(
'#output' => array(
'settings' => $variables['settings'],
'items' => $variables['items'],
),
'#pre_render' => [
[
FlickityBuilder::class,
'preRender',
],
],
);
return \Drupal::service('renderer')
->render($output);
}
function template_preprocess_flickity_item(&$variables) {
$variables['attributes'] = new Attribute($variables['attributes']);
}
function flickity_build($group, $output) {
return array(
'#output' => $output,
'#attributes' => array(
'class' => array(
$group,
'flickity',
),
),
'#theme_wrappers' => array(
'flickity_wrapper',
),
);
}
function template_preprocess_flickity_wrapper(&$variables) {
$variables['attributes'] = new Attribute($variables['attributes']);
}