summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2014-10-15 11:05:01 +0100
committerNathaniel Catchpole2014-10-15 11:05:01 +0100
commit9d5d3b3b5cac64654a8ec6249cf831f281c9d48f (patch)
tree16b8d336c8573dc7c90af98cb071eb2177c858c2
parent90863aeeb1cafe310033e7ec6fc95c0fcf1631a0 (diff)
Issue #2234331 by mortendk, lauriii, LewisNyman, sqndr, rteijeiro, G-raph, amitgoyal: Fixed Change the body classes to follow Drupal 8 CSS standards.
-rw-r--r--core/includes/theme.inc60
-rw-r--r--core/modules/block/block.module2
-rw-r--r--core/themes/bartik/css/style.css19
-rw-r--r--core/themes/seven/css/layout/node-add.css5
-rw-r--r--core/themes/seven/css/theme/install-page.css2
-rw-r--r--core/themes/seven/css/theme/maintenance-page.css8
-rw-r--r--core/themes/seven/seven.theme12
7 files changed, 55 insertions, 53 deletions
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 8c947e2..0a76479 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -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';
}
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 073da6a..2d2c679 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -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,
diff --git a/core/themes/bartik/css/style.css b/core/themes/bartik/css/style.css
index 3027fbb..c55134d 100644
--- a/core/themes/bartik/css/style.css
+++ b/core/themes/bartik/css/style.css
@@ -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,
diff --git a/core/themes/seven/css/layout/node-add.css b/core/themes/seven/css/layout/node-add.css
index 6bbe892..7f5274a 100644
--- a/core/themes/seven/css/layout/node-add.css
+++ b/core/themes/seven/css/layout/node-add.css
@@ -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;
diff --git a/core/themes/seven/css/theme/install-page.css b/core/themes/seven/css/theme/install-page.css
index d114dac..c9d124d 100644
--- a/core/themes/seven/css/theme/install-page.css
+++ b/core/themes/seven/css/theme/install-page.css
@@ -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;
diff --git a/core/themes/seven/css/theme/maintenance-page.css b/core/themes/seven/css/theme/maintenance-page.css
index 80b18f9..edf9018 100644
--- a/core/themes/seven/css/theme/maintenance-page.css
+++ b/core/themes/seven/css/theme/maintenance-page.css
@@ -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%;
diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme
index 88c2570..4863525 100644
--- a/core/themes/seven/seven.theme
+++ b/core/themes/seven/seven.theme
@@ -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');
+ }
+ }
+ }
+}