diff --git a/CHANGELOG.md b/CHANGELOG.md index fc5b6a7f93e8e30126a117b92c436de3e777042a..b39942b1c906e4fda7f5f80a2007a19ec75adee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,3 @@ -<<<<<<< CHANGELOG.md # Changelog All notable changes to this project will be documented in this file. @@ -6,31 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.2.0] - 26-02-2019 -### Fixed -- Error in views that use Horizontal Boxes [provided default value] -- Fixed default-row-class value being kept even after overriden -### Added -- Collision display format -- Countdown display format -- Teaser List display format +## [1.3.0] - 24-04-2019 +- Added Vertical Boxes display format +- Added Featured Banner display format +- Fixed issue of Accordion display format grouped rows -### Changed +## [1.2.0] - 26-02-2019 +- Fixed error in views that use Horizontal Boxes [provided default value] +- Fixed default-row-class value being kept even after overriden +- Added Collision display format +- Added Countdown display format +- Added Teaser List display format - Improved code by changing format conditionals (name to ID) -- Font-size of Teaser List +- Changed font-size of Teaser List ## [1.1.0] - 22-11-2018 -### Added -- Accordion as display format - -### Changed -- Conditions for Horizontal Boxes - -### Removed -- Debugging conditions +- Added Accordion as display format +- Changed conditions for Horizontal Boxes +- Removed debugging conditions ## [1.0.0] - 04-10-2018 -### Added -- Horizontal Boxes as display format - +- Added Horizontal Boxes as display format \ No newline at end of file diff --git a/README.md b/README.md index ee989ee1029d705e9e508d8c2f20f7adbf53c57e..9c4a00e494223835dcc61c8fffd5f31d053acd9e 100755 --- a/README.md +++ b/README.md @@ -2,14 +2,16 @@ Provides a set of display formats designed for the needs of the CERN users. -Until v1.2.0 the implemented display formats are: - -* Accordion: Renders the content in an accordion type style. -* Horizontal Boxes: Renders the content in a style of cards with the option to use carousel to navigate. -* Accordion: Renders the view rows in the style of an accordion -* Teaser List: Renders the view rows the one under the other with appropriate spacing -* Collision: Renders the view rows creating a "collision" effect -* Countdown: Renders the view row with a countdown effect +Until v1.3.0 the implemented display formats are: + +* **Accordion**: Renders the content in an accordion type style. +* **Horizontal Boxes**: Renders the content in a style of cards with the option to use carousel to navigate. +* **Accordion**: Renders the view rows in the style of an accordion +* **Teaser List**: Renders the view rows the one under the other with appropriate spacing +* **Collision**: Renders the view rows creating a "collision" effect +* **Countdown**: Renders the view row with a countdown effect +* **Vertical Boxes**: Renders the view rows in a vertical position +* **Featured Banner**: Renders the view using the Featured Banner template ## Getting Started diff --git a/assets/css/featured-banner.css b/assets/css/featured-banner.css new file mode 100644 index 0000000000000000000000000000000000000000..da00fbd2fb1ef3bf86b39025419bfbaf596e5c95 --- /dev/null +++ b/assets/css/featured-banner.css @@ -0,0 +1,4 @@ +.featured-banner .component-preview-cards a, .featured-banner .component-preview-cards .preview-card__category, .featured-banner .component-preview-cards .preview-card__date { + text-shadow: none !important; } + +/*# sourceMappingURL=featured-banner.css.map */ diff --git a/assets/scss/featured-banner.scss b/assets/scss/featured-banner.scss new file mode 100644 index 0000000000000000000000000000000000000000..9f8a70a7a96713fa4ff9cac5d49261d6efbe94d6 --- /dev/null +++ b/assets/scss/featured-banner.scss @@ -0,0 +1,7 @@ +.featured-banner{ + .component-preview-cards{ + a, .preview-card__category, .preview-card__date{ + text-shadow: none !important; + } + } +} \ No newline at end of file diff --git a/cern_display_formats.info.yml b/cern_display_formats.info.yml index 1eebee33b3ca7bc94c58a0b722a3fb3e2c929730..2f8327d087e8bafc643a7bb21ab40f63abc1d8de 100755 --- a/cern_display_formats.info.yml +++ b/cern_display_formats.info.yml @@ -2,8 +2,8 @@ name: CERN Display Formats type: module description: 'Provides a set of display formats designed for the needs of the CERN users.' package: Web Team Drupal Library -version: 1.2.0 +version: 1.3.0 core: '8.x' dependencies: - drupal:views - - cern_components (>=8.x-2.4.0) + - cern_components (>=8.x-2.4.0) \ No newline at end of file diff --git a/cern_display_formats.libraries.yml b/cern_display_formats.libraries.yml index 16655f195a3bd8ca7f2aea436727d3d59d644ef5..bf19ffe6381519196701513b9de0dbd79e7ffb1e 100644 --- a/cern_display_formats.libraries.yml +++ b/cern_display_formats.libraries.yml @@ -2,4 +2,10 @@ teaser-list-stylesheets: version: 1.x css: layout: - assets/css/teaser-list.css: {} \ No newline at end of file + assets/css/teaser-list.css: {} + +featured-banner-stylesheets: + version: 1.x + css: + layout: + assets/css/featured-banner.css: {} \ No newline at end of file diff --git a/cern_display_formats.module b/cern_display_formats.module index e624130f9775be92a1d6dff0747819f5dcf89f91..06102e960ee65aaef93891881c51412c9c2cc001 100755 --- a/cern_display_formats.module +++ b/cern_display_formats.module @@ -16,9 +16,6 @@ function cern_display_formats_theme($existing, $type, $theme, $path) { 'horizontal_boxes' => array( 'file' => 'display_formats.theme.inc', ), - 'accordion' => array( - 'file' => 'display_formats.theme.inc', - ), 'collision' => array( 'file' => 'display_formats.theme.inc', ), @@ -28,6 +25,9 @@ function cern_display_formats_theme($existing, $type, $theme, $path) { 'teaser_list' => array( 'file' => 'display_formats.theme.inc', ), + 'vertical_boxes' => array( + 'file' => 'display_formats.theme.inc', + ), ); } @@ -46,5 +46,12 @@ function cern_display_formats_views_post_render(ViewExecutable $view, &$output, $view->display_handler->setOption('css_class', 'events-countdown'); } elseif ($view->display_handler->view->style_plugin->getPluginId() == "teaser_list") { $view->display_handler->setOption('css_class', 'teaser-list'); + } elseif ($view->display_handler->view->style_plugin->getPluginId() == "featured_banner") { + $view->display_handler->setOption('css_class', 'featured-banner'); + $output['#attached']['library'][] = "cern_display_formats/featured-banner-stylesheets"; //attaches the stylesheet + } elseif ($view->display_handler->view->style_plugin->getPluginId() == "vertical_boxes") { + $view->display_handler->setOption('css_class', 'vertical-boxes'); + } elseif ($view->display_handler->view->style_plugin->getPluginId() == "accordion") { + $view->display_handler->setOption('css_class', 'accordion-cern'); } } \ No newline at end of file diff --git a/display_formats.theme.inc b/display_formats.theme.inc index c5997d679bc9b26b5c8cc50cbdd8bdbc93953812..61ae8b7ada2a87f052bca8d68b425b2b5507990e 100755 --- a/display_formats.theme.inc +++ b/display_formats.theme.inc @@ -22,31 +22,9 @@ function template_preprocess_views_view_horizontal_boxes(&$variables) { $variables['rows'][$id]['attributes']->addClass($row_class); } } -// $variables['css_class'] = 'horizontal-boxes'; } -/** - * @file - * - */ -function template_preprocess_views_view_accordion(&$variables) { - $view = $variables['view']; - $rows = $variables['rows']; - $style = $view->style_plugin; - $options = $style->options; - - $variables['default_row_class'] = !empty($options['default_row_class']); - foreach ($rows as $id => $row) { - $variables['rows'][$id] = []; - $variables['rows'][$id]['content'] = $row; - $variables['rows'][$id]['attributes'] = new Attribute(); - if ($row_class = $view->style_plugin->getRowClass($id)) { - $variables['rows'][$id]['attributes']->addClass($row_class); - } - } -} - /** * Preprocess function of the Events Collision template. * diff --git a/src/Plugin/views/style/Accordion.php b/src/Plugin/views/style/Accordion.php index edebeeff7d83ecc4edb6ad9115c6ba4e520f47eb..a2ae76c9f486f72f27dada24d74a3090425e7a45 100644 --- a/src/Plugin/views/style/Accordion.php +++ b/src/Plugin/views/style/Accordion.php @@ -13,15 +13,12 @@ use Drupal\views\Plugin\views\style\DefaultStyle; * id = "accordion", * title = @Translation("Accordion"), * help = @Translation("Displays content in an accordion style"), - * theme = "views_view_accordion", + * theme = "views_view_unformatted", * display_types = {"normal"} * ) */ -class Accordion extends DefaultStyle -{ - /** - * {@inheritdoc} - */ +class Accordion extends DefaultStyle { + protected $usesRowPlugin = true; /** @@ -33,12 +30,34 @@ class Accordion extends DefaultStyle protected $usesoptions = true; - protected $renderFields = true; + /** + * Defines the initial options of the Horizontal Boxes. + * + * @return mixed + */ protected function defineOptions(){ $options = parent::defineOptions(); + $options['row_class'] = array('default'=> 'carousel-cern-item') ; return $options; } + /** + * Overrides the options form of Accordion + * + * @param $form + * @param FormStateInterface $form_state + */ + public function buildOptionsForm(&$form, FormStateInterface $form_state) { + parent::buildOptionsForm($form, $form_state); + + $form['row_class'] = array( + '#type' => 'textfield', + '#title' => t('Row Class'), + '#description' => t('For Accordion, make sure you have set carousel-cern-item as one of the row classes'), + '#default_value' => (!empty($this->options['row_class'])) ? $this->options['row_class'] : 'carousel-cern-item', + ); + } + } \ No newline at end of file diff --git a/src/Plugin/views/style/FeaturedBanner.php b/src/Plugin/views/style/FeaturedBanner.php new file mode 100644 index 0000000000000000000000000000000000000000..32f830325c1f0f532b54bb8149e28fdf6c79b047 --- /dev/null +++ b/src/Plugin/views/style/FeaturedBanner.php @@ -0,0 +1,39 @@ +<?php + + +namespace Drupal\cern_display_formats\Plugin\views\style; + + +use Drupal\views\Plugin\views\style\DefaultStyle; + +/** + * Implements the Featured Banner display format + * + * + * @ingroup views_style_plugins + * + * @ViewsStyle( + * id = "featured_banner", + * title = @Translation("Featured Banner"), + * help = @Translation("Displays content as a featured banner."), + * theme = "views_view_unformatted", + * display_types = {"normal"} + * ) + */ +class FeaturedBanner extends DefaultStyle { + + protected $usesoptions = true; + + + /** + * Defines the initial options for the Featured Banner format + * + * @return mixed + */ + protected function defineOptions(){ + $options = parent::defineOptions(); + return $options; + } + + +} \ No newline at end of file diff --git a/src/Plugin/views/style/HorizontalBoxes.php b/src/Plugin/views/style/HorizontalBoxes.php index 5c87ca832f280aba2c279e382172980321b34c4e..afb842e603f768514a9f5b4f2a683a18a11bdb03 100755 --- a/src/Plugin/views/style/HorizontalBoxes.php +++ b/src/Plugin/views/style/HorizontalBoxes.php @@ -61,7 +61,7 @@ class HorizontalBoxes extends DefaultStyle '#description' => t('For Horizontal Boxes, make sure you have set horizontal-boxes-row as one of the row classes'), '#default_value' => (!empty($this->options['row_class'])) ? $this->options['row_class'] : 'horizontal-boxes-row', ); - } + } } \ No newline at end of file diff --git a/src/Plugin/views/style/VerticalBoxes.php b/src/Plugin/views/style/VerticalBoxes.php new file mode 100644 index 0000000000000000000000000000000000000000..2ca695fb37eaa9ac71e2aed8400a4a82393bf171 --- /dev/null +++ b/src/Plugin/views/style/VerticalBoxes.php @@ -0,0 +1,39 @@ +<?php + + +namespace Drupal\cern_display_formats\Plugin\views\style; + + +use Drupal\views\Plugin\views\style\DefaultStyle; + +/** + * Implements the "Vertical Boxes" display format + * + * + * @ingroup views_style_plugins + * + * @ViewsStyle( + * id = "vertical_boxes", + * title = @Translation("Vertical Boxes"), + * help = @Translation("Displays content in a format of Vertical Boxes"), + * theme = "views_view_unformatted", + * display_types = {"normal"} + * ) + */ +class VerticalBoxes extends DefaultStyle { + + protected $usesoptions = true; + + + /** + * Defines the initial options for Countdown format + * + * @return mixed + */ + protected function defineOptions(){ + $options = parent::defineOptions(); + return $options; + } + + +} \ No newline at end of file diff --git a/templates/views-view-accordion.html.twig b/templates/views-view-accordion.html.twig deleted file mode 100644 index 555c4e62d171c2438953f1627ffb00ba14fbfe7b..0000000000000000000000000000000000000000 --- a/templates/views-view-accordion.html.twig +++ /dev/null @@ -1,16 +0,0 @@ -<div class="panel-group accordion-cern"> - - {% for row in rows %} - {% set row_classes = [default_row_class ? 'views-row ',] %} - {% if loop.first != true and loop.index0 is divisible by(3) %} - </div> - {% endif %} - {% if loop.index0 is divisible by(3) %} - <div class="carousel-cern-item row"> - {% endif %} - <div{{ row.attributes.addClass(row_classes) }}>{{ row.content }}</div> - {% if loop.last == true %} - </div> - {% endif %} - {% endfor %} -</div> \ No newline at end of file