Commit 91d867f5 authored by alexpott's avatar alexpott

Issue #1982256 by mortendk, rteijeiro, tim.plunkett, LewisNyman, tlattimore,...

Issue #1982256 by mortendk, rteijeiro, tim.plunkett, LewisNyman, tlattimore, yannickoo, ry5n: Clean up html.html.twig markup.
parent f5a948f8
......@@ -2511,22 +2511,6 @@ function template_preprocess_html(&$variables) {
// Add a class that tells us whether the page is viewed by an authenticated user or not.
$variables['attributes']['class'][] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in';
// Add information about the number of sidebars.
if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
$variables['attributes']['class'][] = 'two-sidebars';
}
elseif (!empty($variables['page']['sidebar_first'])) {
$variables['attributes']['class'][] = 'one-sidebar';
$variables['attributes']['class'][] = 'sidebar-first';
}
elseif (!empty($variables['page']['sidebar_second'])) {
$variables['attributes']['class'][] = 'one-sidebar';
$variables['attributes']['class'][] = 'sidebar-second';
}
else {
$variables['attributes']['class'][] = 'no-sidebars';
}
// Populate the body classes.
if ($suggestions = theme_get_suggestions(arg(), 'page', '-')) {
foreach ($suggestions as $suggestion) {
......@@ -2539,11 +2523,6 @@ function template_preprocess_html(&$variables) {
}
}
// If on an individual node page, add the node type to body classes.
if ($node = menu_get_object()) {
$variables['attributes']['class'][] = drupal_html_class('node-type-' . $node->getType());
}
// Initializes attributes which are specific to the html and body elements.
$variables['html_attributes'] = new Attribute;
......
......@@ -577,6 +577,16 @@ function node_is_page(EntityInterface $node) {
return (!empty($page_node) ? $page_node->id() == $node->id() : FALSE);
}
/**
* Implements hook_preprocess_HOOK() for HTML document templates.
*/
function node_preprocess_html(&$variables) {
// If on an individual node page, add the node type to body classes.
if ($node = menu_get_object()) {
$variables['attributes']['class'][] = drupal_html_class('node-type-' . $node->getType());
}
}
/**
* Implements hook_preprocess_HOOK() for block templates.
*/
......
......@@ -63,7 +63,7 @@ html[dir="rtl"] {
#overlay-title:focus {
outline: 0;
}
.overlay #skip-link a {
.overlay .skip-link {
color: #fff; /* This is white to contrast with the dark background behind it. */
}
......
......@@ -35,11 +35,9 @@
{{ scripts }}
</head>
<body{{ attributes }}>
<div id="skip-link">
<a href="#main-content" class="visually-hidden focusable">
{{ 'Skip to main content'|t }}
</a>
</div>
<a href="#main-content" class="visually-hidden focusable skip-link">
{{ 'Skip to main content'|t }}
</a>
{{ page_top }}
{{ page }}
{{ page_bottom }}
......
......@@ -13,6 +13,22 @@
* Adds body classes if certain regions have content.
*/
function bartik_preprocess_html(&$variables) {
// Add information about the number of sidebars.
if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
$variables['attributes']['class'][] = 'two-sidebars';
}
elseif (!empty($variables['page']['sidebar_first'])) {
$variables['attributes']['class'][] = 'one-sidebar';
$variables['attributes']['class'][] = 'sidebar-first';
}
elseif (!empty($variables['page']['sidebar_second'])) {
$variables['attributes']['class'][] = 'one-sidebar';
$variables['attributes']['class'][] = 'sidebar-second';
}
else {
$variables['attributes']['class'][] = 'no-sidebars';
}
if (!empty($variables['page']['featured'])) {
$variables['attributes']['class'][] = 'featured';
}
......
......@@ -114,7 +114,7 @@ body,
}
#header,
#footer-wrapper,
#skip-link,
.skip-link,
ul.contextual-links,
ul.links,
ul.primary,
......@@ -315,17 +315,18 @@ ul.tips {
}
/* ------------------ Header ------------------ */
#skip-link {
.skip-link,
.skip-link.visually-hidden.focusable {
left: 50%;
margin-left: -5.25em;
margin-top: 0;
position: absolute;
position: absolute !important;
width: auto;
z-index: 50;
}
#skip-link a,
#skip-link a:link,
#skip-link a:visited {
.skip-link,
.skip-link:link,
.skip-link:visited {
background: #444;
background: rgba(0, 0, 0, 0.6);
color: #fff;
......@@ -336,9 +337,9 @@ ul.tips {
text-decoration: none;
border-radius: 0 0 10px 10px;
}
#skip-link a:hover,
#skip-link a:active,
#skip-link a:focus {
.skip-link:hover,
.skip-link:active,
.skip-link:focus {
outline: 0;
}
#logo {
......
......@@ -20,9 +20,9 @@
</head>
<body class="{{ attributes.class }}"{{ attributes }}>
<div id="skip-link">
<a href="#main-content" class="visually-hidden focusable">{{ 'Skip to main content'|t }}</a>
</div>
<a href="#main-content" class="visually-hidden focusable skip-link">
{{ 'Skip to main content'|t }}
</a>
<div id="page-wrapper"><div id="page">
......
......@@ -30,6 +30,20 @@ function seven_library_info() {
return $libraries;
}
/**
* Implements hook_preprocess_HOOK() for HTML document templates.
*/
function seven_preprocess_html(&$variables) {
// Add information about the number of sidebars.
if (!empty($variables['page']['sidebar_first'])) {
$variables['attributes']['class'][] = 'one-sidebar';
$variables['attributes']['class'][] = 'sidebar-first';
}
else {
$variables['attributes']['class'][] = 'no-sidebars';
}
}
/**
* Implements hook_preprocess_HOOK() for page templates.
*/
......
......@@ -158,7 +158,7 @@ pre {
/**
* Skip link.
*/
#skip-link {
.skip-link {
margin-top: 0;
position: absolute;
left: 50%; /* LTR */
......@@ -166,13 +166,13 @@ pre {
width: auto;
z-index: 50;
}
[dir="rtl"] #skip-link {
[dir="rtl"] .skip-link {
right: 50%;
margin-right: -5.25em;
}
#skip-link a,
#skip-link a:link,
#skip-link a:visited {
.skip-link,
.skip-link:link,
.skip-link:visited {
display: inline-block;
background: #444;
color: #fff;
......@@ -181,14 +181,14 @@ pre {
text-decoration: none;
border-radius: 0 0 10px 10px;
}
[dir="rtl"] #skip-link a,
[dir="rtl"] #skip-link a:link,
[dir="rtl"] #skip-link a:visited {
[dir="rtl"] .skip-link,
[dir="rtl"] .skip-link:link,
[dir="rtl"] .skip-link:visited {
padding: 1px 10px 2px 10px;
}
#skip-link a:hover,
#skip-link a:focus,
#skip-link a:active {
.skip-link:hover,
.skip-link:focus,
.skip-link:active {
outline: 0;
}
......
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