Commit 9d5d3b3b authored by catch's avatar catch

Issue #2234331 by mortendk, lauriii, LewisNyman, sqndr, rteijeiro, G-raph,...

Issue #2234331 by mortendk, lauriii, LewisNyman, sqndr, rteijeiro, G-raph, amitgoyal: Fixed Change the body classes to follow Drupal 8 CSS standards.
parent 90863aee
......@@ -1676,27 +1676,29 @@ function template_preprocess_html(&$variables) {
$variables['page'] = $page;
// Compile a list of classes that are going to be applied to the body element.
// This allows advanced theming based on context (home page, node of certain type, etc.).
// This allows advanced theming based on context (home page, node of certain
// type, etc.).
$body_classes = $variables['attributes']['class'];
$body_classes[] = 'html';
// Add a class that tells us whether we're on the front page or not.
$body_classes[] = $variables['is_front'] ? 'front' : 'not-front';
// Add a class that tells us whether the page is viewed by an authenticated user or not.
$body_classes[] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in';
$variables['attributes']['class'] = $body_classes;
$path_args = explode('/', current_path());
// Populate the body classes.
if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) {
foreach ($suggestions as $suggestion) {
if ($suggestion != 'page-front') {
// Add current suggestion to page classes to make it possible to theme
// the page depending on the current page type (e.g. node, admin, user,
// etc.) as well as more specific data like node-12 or node-edit.
$variables['attributes']['class'][] = drupal_html_class($suggestion);
}
}
// Add a class that tells us whether the page is viewed by an authenticated
// user.
if ($variables['logged_in']) {
$body_classes[] = 'user-logged-in';
}
// Add a class that tells us what path the page is located make it possible
// to theme the page depending on the current path (e.g. node, admin, user,
// etc.) as well as more specific data like path-frontpage.
$path = \Drupal::request()->getPathInfo();
if (drupal_is_front_page()) {
$body_classes[] = 'path-frontpage';
}
else {
$segment = explode('/', $path);
$body_classes[] = 'path-' . drupal_html_class($segment[1]);
}
$variables['attributes']['class'] = $body_classes;
$site_config = \Drupal::config('system.site');
// Construct page title.
......@@ -1786,15 +1788,6 @@ function template_preprocess_page(&$variables) {
}
}
// Set up layout variable.
$variables['layout'] = 'none';
if (!empty($variables['page']['sidebar_first'])) {
$variables['layout'] = 'first';
}
if (!empty($variables['page']['sidebar_second'])) {
$variables['layout'] = ($variables['layout'] == 'first') ? 'both' : 'second';
}
$variables['base_path'] = base_path();
$variables['front_page'] = \Drupal::url('<front>');
$variables['language'] = $language_interface;
......@@ -1873,16 +1866,16 @@ function template_preprocess_page(&$variables) {
*/
function theme_get_suggestions($args, $base, $delimiter = '__') {
// Build a list of suggested theme hooks or body classes in order of
// Build a list of suggested theme hooks in order of
// specificity. One suggestion is made for every element of the current path,
// though numeric elements are not carried to subsequent suggestions. For
// example, for $base='page', http://www.example.com/node/1/edit would result
// in the following suggestions and body classes:
// in the following suggestions:
//
// page__node page-node
// page__node__% page-node-%
// page__node__1 page-node-1
// page__node__edit page-node-edit
// page__node
// page__node__%
// page__node__1
// page__node__edit
$suggestions = array();
$prefix = $base;
......@@ -1937,7 +1930,6 @@ function template_preprocess_maintenance_page(&$variables) {
$attributes = $page_object->getBodyAttributes();
$classes = $attributes['class'];
$classes[] = 'maintenance-page';
$classes[] = 'in-maintenance';
if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
$classes[] = 'db-offline';
}
......
......@@ -82,7 +82,7 @@ function block_page_build(&$page) {
// Append region description if we are rendering the regions demo page.
$visible_regions = array_keys(system_region_list($theme, REGIONS_VISIBLE));
foreach ($visible_regions as $region) {
$description = '<div class="block-region">' . $all_regions[$region] . '</div>';
$description = '<div class="block-region demo-block">' . $all_regions[$region] . '</div>';
$page[$region]['block_description'] = array(
'#markup' => $description,
'#weight' => 15,
......
......@@ -1820,14 +1820,18 @@ div.add-or-remove-shortcuts {
}
/* ---------- Admin-specific Theming ---------- */
.page-admin #content img {
.path-admin #content img {
margin-right: 15px; /* LTR */
}
.page-admin #content .simpletest-image img {
.path-admin #content .simpletest-image img {
margin: 0;
}
.page-admin-structure-block-demo .block-region {
.path-admin #admin-dblog img {
margin: 0 5px;
}
/* Block demo mode */
.demo-block {
background: #ffff66;
border: 1px dotted #9f9e00;
color: #000;
......@@ -1837,15 +1841,12 @@ div.add-or-remove-shortcuts {
text-align: center;
text-shadow: none;
}
.page-admin-structure-block-demo #featured .block-region {
#featured .demo-block {
font-size: 0.55em;
}
.page-admin-structure-block-demo #header .block-region {
#header .demo-block {
width: 500px;
}
.page-admin #admin-dblog img {
margin: 0 5px;
}
/* Configuration. */
div.admin .right,
......
......@@ -10,9 +10,7 @@
@media
screen and (min-width: 780px),
(orientation: landscape) and (min-device-height: 780px) {
[class*="page-node-add-"] .messages,
.page-node-edit .messages {
.node-form-layout .messages {
margin-top: 1em;
margin-bottom: 1em;
}
......@@ -20,7 +18,6 @@
@media
screen and (max-width: 1020px),
(orientation: landscape) and (max-device-height: 1020px) {
.toolbar-vertical .block-list-secondary,
.toolbar-vertical .layout-region-node-secondary {
margin-bottom: 0;
......
......@@ -3,7 +3,7 @@
* Installation styling.
*
* Unfortunately we have to make our styling quite strong, to override the
* .in-maintenance styling.
* .maintenance-page styling.
*/
.install-background {
background-color: #1275b2;
......
......@@ -13,7 +13,7 @@
/* Maintenance theming */
.install-page,
.in-maintenance {
.maintenance-page {
background: none;
}
.page-title {
......@@ -131,13 +131,13 @@
html {
display: table;
}
.in-maintenance,
.install-page {
.install-page,
.maintenance-page {
display: table-cell;
padding: 1em 0;
vertical-align: middle;
}
html, .install-page, .in-maintenance {
html, .install-page, .maintenance-page {
margin: 0;
width: 100%;
height: 100%;
......
......@@ -208,3 +208,15 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) {
$form['revision_information']['#type'] = 'container';
$form['revision_information']['#group'] = 'meta';
}
function seven_preprocess_html(&$variables) {
// If on a node add or edit page, add a node-layout class.
$path_args = explode('/', \Drupal::request()->getPathInfo());
if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) {
foreach ($suggestions as $suggestion) {
if ($suggestion === 'page-node-edit' || strpos($suggestion, 'page-node-add') !== FALSE) {
$variables['attributes']['class'][] = drupal_html_class('node-form-layout');
}
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment