Skip to content
Snippets Groups Projects
Commit b6776723 authored by Alberto Siles's avatar Alberto Siles
Browse files

Improve table configuration

parent b64b5293
No related branches found
No related tags found
No related merge requests found
......@@ -175,13 +175,13 @@ function bootstrap_barrio_preprocess_page(&$variables) {
// Calculate widths
if (theme_get_setting('bootstrap_barrio_content_offset')) {
$variables['content_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_content_offset');
$variables['content_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_content_offset');
}
if (theme_get_setting('bootstrap_barrio_sidebar_first_offset')) {
$variables['sidebar_first_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_sidebar_first_offset');
$variables['sidebar_first_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_sidebar_first_offset');
}
if (theme_get_setting('bootstrap_barrio_sidebar_second_offset')) {
$variables['sidebar_second_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_sidebar_second_offset');
$variables['sidebar_second_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_sidebar_second_offset');
}
// Define column layout classes
......@@ -232,8 +232,8 @@ function bootstrap_barrio_preprocess_page(&$variables) {
}
if (theme_get_setting('bootstrap_barrio_sidebar_collapse')) {
$variables['content_attributes']['class'][] = 'sidebar-offcanvas';
$variables['sidebar_collapse'] = TRUE;
$variables['content_attributes']['class'][] = 'sidebar-offcanvas';
$variables['sidebar_collapse'] = TRUE;
$variables['#attached']['library'][] = 'bootstrap_barrio/sidebar_collapse';
}
......@@ -341,6 +341,24 @@ function bootstrap_barrio_preprocess_menu_local_task(&$variables) {
$variables['item'] = Link::fromTextAndUrl($link['title'], $url);
}
/**
* Implements template_preprocess_table()
*/
function bootstrap_barrio_preprocess_table(&$variables) {
$variables['table_class'] = theme_get_setting('bootstrap_barrio_table_style');
$variables['hover'] = theme_get_setting('bootstrap_barrio_table_hover');
$variables['thead_class'] = theme_get_setting('bootstrap_barrio_table_head');
}
/**
* Implements template_preprocess_views_view_table()
*/
function bootstrap_barrio_preprocess_views_view_table(&$variables) {
$variables['table_class'] = theme_get_setting('bootstrap_barrio_table_style');
$variables['hover'] = theme_get_setting('bootstrap_barrio_table_hover');
$variables['thead_class'] = theme_get_setting('bootstrap_barrio_table_head');
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for region templates.
*/
......
......@@ -29,3 +29,6 @@ bootstrap_barrio_navbar_top_background: 'bg-secondary'
bootstrap_barrio_navbar_position: ''
bootstrap_barrio_navbar_color: 'navbar-dark'
bootstrap_barrio_navbar_background: 'bg-primary'
# Colors
# --------------
bootstrap_barrio_table_hover: 1
name: Bootstrap Barrio Subtheme
type: theme
description: 'Basic structure for a Bootstrap Barrio SubTheme.'
# version: VERSION
# core: 8.x
version: VERSION
core: 8.x
base theme: bootstrap_barrio
libraries:
......@@ -31,15 +31,3 @@ regions:
footer_third: 'Footer third'
footer_fourth: 'Footer fourth'
footer_fifth: 'Footer fifth'
# Information added by Drupal.org packaging script on 2015-11-29
# version: '8.x-4.0-beta1'
# core: '8.x'
# project: 'bootstrap_barrio'
# datestamp: 1448759945
# Information added by Drupal.org packaging script on 2018-04-30
version: '8.x-4.9'
core: '8.x'
project: 'bootstrap_barrio'
datestamp: 1525127885
# Library
# --------------
bootstrap_barrio_library: 'production'
# Layout
# --------------
bootstrap_barrio_sidebar_position: 'both'
......@@ -22,7 +25,10 @@ bootstrap_barrio_navbar_toggle: 1
bootstrap_barrio_navbar_container: 'navbar-toggleable-md'
bootstrap_barrio_navbar_top_position: ''
bootstrap_barrio_navbar_top_color: 'navbar-dark'
bootstrap_barrio_navbar_top_background: 'bg-dark'
bootstrap_barrio_navbar_top_background: 'bg-secondary'
bootstrap_barrio_navbar_position: ''
bootstrap_barrio_navbar_color: 'navbar-dark'
bootstrap_barrio_navbar_background: 'bg-primary'
# Colors
# --------------
bootstrap_barrio_table_hover: 1
......@@ -35,6 +35,7 @@
* any rows.
* - no_striping: A boolean indicating that the row should receive no striping.
* - header_columns: The number of columns in the header.
* - thead_class: Class for the table header
*
* @see template_preprocess_table()
*/
......@@ -43,7 +44,7 @@
{%
set table_classes = [
'table',
'table-hover',
hover ? 'table-hover',
not no_striping ? 'table-striped' : 'table-bordered',
]
%}
......@@ -66,7 +67,7 @@
{% endfor %}
{% if header %}
<thead class='thead-light'>
<thead class='{{ thead_class }}'>
<tr>
{% for cell in header %}
{%
......
......@@ -58,11 +58,13 @@
{# Now generate the actual pager piece. #}
{% for key, item in items.pages %}
<li class="page-item {{ current == key ? 'active' : '' }}">
{% if current == key %}
{% set title = 'Current page'|t %}
{% else %}
{% set title = 'Go to page @key'|t({'@key': key}) %}
{% endif %}
<span class="page-link">
{% if current == key %}
{% set title = 'Current page'|t %}
{% else %}
{% set title = 'Go to page @key'|t({'@key': key}) %}
{% endif %}
</span>
<a href="{{ item.href }}" title="{{ title }}"{{ item.attributes|without('href', 'title') }} class="page-link">
<span class="visually-hidden">
{{ current == key ? 'Current page'|t : 'Page'|t }}
......
{#
/**
* @file
* Default theme implementation for a views mini-pager.
*
* Available variables:
* - items: List of pager items.
*
* @see template_preprocess_views_mini_pager()
*
* @ingroup themeable
*/
#}
{% if items.previous or items.next %}
<nav aria-label="Page navigation">
<h4 class="visually-hidden">{{ 'Pagination'|t }}</h4>
<ul class="js-pager__items pagination">
{% if items.previous %}
<li class="page-item">
<a class="page-link" href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Previous page'|t }}</span>
<span aria-hidden="true">{{ items.previous.text|default('‹‹'|t) }}</span>
</a>
</li>
{% endif %}
{% if items.current %}
<li class="page-item">
{% trans %}
Page {{ items.current }}
{% endtrans %}
</li>
{% endif %}
{% if items.next %}
<li class="page-item">
<a class="page-link" href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('››'|t) }}</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{#
/**
* @file
* Theme override for a views mini-pager.
*
* Available variables:
* - items: List of pager items.
*
* @see template_preprocess_views_mini_pager()
*/
#}
{% if items.previous or items.next %}
<nav class="pager" role="navigation" aria-labelledby="pagination-heading">
<h4 class="pager__heading visually-hidden">{{ 'Pagination'|t }}</h4>
<ul class="pager__items js-pager__items">
{% if items.previous %}
<li class="pager__item pager__item--previous">
<a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Previous page'|t }}</span>
<span aria-hidden="true">{{ items.previous.text|default('‹‹'|t) }}</span>
</a>
</li>
{% endif %}
{% if items.current %}
<li class="pager__item is-active">
{% trans %}
Page {{ items.current }}
{% endtrans %}
</li>
{% endif %}
{% if items.next %}
<li class="pager__item pager__item--next">
<a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('››'|t) }}</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{#
/**
* @file
* Default theme implementation for a views mini-pager.
*
* Available variables:
* - items: List of pager items.
*
* @see template_preprocess_views_mini_pager()
*
* @ingroup themeable
*/
#}
{% if items.previous or items.next %}
<nav aria-label="Page navigation">
<h4 class="visually-hidden">{{ 'Pagination'|t }}</h4>
<ul class="js-pager__items pagination">
{% if items.previous %}
<li class="page-item">
<a class="page-link" href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Previous page'|t }}</span>
<span aria-hidden="true">{{ items.previous.text|default('‹‹'|t) }}</span>
</a>
</li>
{% endif %}
{% if items.current %}
<li class="page-item">
<span class="page-link">
{% trans %}
Page {{ items.current }}
{% endtrans %}
</span>
</li>
{% endif %}
{% if items.next %}
<li class="page-item">
<a class="page-link" href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }}>
<span class="visually-hidden">{{ 'Next page'|t }}</span>
<span aria-hidden="true">{{ items.next.text|default('››'|t) }}</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
......@@ -33,6 +33,8 @@
{%
set classes = [
'table',
hover ? 'table-hover',
table_class,
'views-table',
'views-view-table',
'cols-' ~ header|length,
......@@ -40,6 +42,7 @@
sticky ? 'sticky-enabled',
]
%}
<div class="table-responsive">
<table{{ attributes.addClass(classes) }}>
{% if caption_needed %}
<caption>
......@@ -61,7 +64,7 @@
</caption>
{% endif %}
{% if header %}
<thead>
<thead class='{{ thead_class }}'>
<tr>
{% for key, column in header %}
{% if column.default_classes %}
......@@ -125,3 +128,4 @@
{% endfor %}
</tbody>
</table>
</div>
......@@ -258,7 +258,6 @@ function bootstrap_barrio_form_system_theme_settings_alter(&$form, FormStateInte
'#default_value' => theme_get_setting('bootstrap_barrio_navbar_top_background'),
'#options' => array(
'bg-primary' => t('Primary'),
'bg-secondary' => t('Secondary'),
'bg-light' => t('Light'),
'bg-dark' => t('Dark'),
),
......@@ -294,7 +293,6 @@ function bootstrap_barrio_form_system_theme_settings_alter(&$form, FormStateInte
'#default_value' => theme_get_setting('bootstrap_barrio_navbar_background'),
'#options' => array(
'bg-primary' => t('Primary'),
'bg-secondary' => t('Secondary'),
'bg-light' => t('Light'),
'bg-dark' => t('Dark'),
),
......@@ -535,7 +533,7 @@ function bootstrap_barrio_form_system_theme_settings_alter(&$form, FormStateInte
'#group' => 'bootstrap',
);
// Buttons.
// Alerts.
$form['colors']['alerts'] = array(
'#type' => 'details',
'#title' => t('Colors'),
......@@ -553,4 +551,37 @@ function bootstrap_barrio_form_system_theme_settings_alter(&$form, FormStateInte
),
'#description' => t('Replace standard color scheme for the system mantainance alerts with Google Material Design color scheme'),
);
$form['colors']['tables'] = array(
'#type' => 'details',
'#title' => t('Tables'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['colors']['tables']['bootstrap_barrio_table_style'] = array(
'#type' => 'select',
'#title' => t('Table cell style'),
'#default_value' => theme_get_setting('bootstrap_barrio_table_style'),
'#empty_option' => t('Default'),
'#options' => array(
'messages_light' => t('Light'),
'messages_dark' => t('Dark'),
),
);
$form['colors']['tables']['bootstrap_barrio_table_hover'] = array(
'#type' => 'checkbox',
'#title' => t('Hover efect over table cells'),
'#description' => t('Apply Bootstrap table hover effect.'),
'#default_value' => theme_get_setting('bootstrap_barrio_table_hover'),
);
$form['colors']['tables']['bootstrap_barrio_table_head'] = array(
'#type' => 'select',
'#title' => t('Table Header Color Scheme'),
'#default_value' => theme_get_setting('bootstrap_barrio_table_head'),
'#empty_option' => t('Default'),
'#options' => array(
'table-striped' => t('Striped'),
'table-bordered' => t('Bordered'),
),
'#description' => t('Select the table head color scheme'),
);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment