Issue #2485375 by marieke_h, Manjit.Singh, MathieuSpil, LewisNyman, geertvd: Clean up shortcut CSS inline with our CSS standards

8.0.x
Alex Pott 2015-06-02 17:09:42 +01:00
parent 537da55a56
commit eed1c99c51
6 changed files with 29 additions and 25 deletions

View File

@ -17,24 +17,24 @@
/** /**
* Add/remove links. * Add/remove links.
*/ */
.add-or-remove-shortcuts .icon { .shortcut-action__icon {
background: transparent url(../images/favstar.svg) no-repeat left top; background: transparent url(../images/favstar.svg) no-repeat left top;
width: 20px; width: 20px;
height: 20px; height: 20px;
display: inline-block; display: inline-block;
vertical-align: -2px; vertical-align: -2px;
} }
[dir="rtl"] .add-or-remove-shortcuts .icon { [dir="rtl"] .shortcut-action__icon {
background-image: url(../images/favstar-rtl.svg); background-image: url(../images/favstar-rtl.svg);
} }
.add-shortcut a:hover .icon, .shortcut-action--add:hover .shortcut-action__icon,
.add-shortcut a:focus .icon { .shortcut-action--add:focus .shortcut-action__icon {
background-position: -20px top; background-position: -20px top;
} }
.remove-shortcut .icon { .shortcut-action--remove .shortcut-action__icon {
background-position: -40px top; background-position: -40px top;
} }
.remove-shortcut a:focus .icon, .shortcut-action--remove:focus .shortcut-action__icon,
.remove-shortcut a:hover .icon { .shortcut-action--remove:hover .shortcut-action__icon {
background-position: -60px top; background-position: -60px top;
} }

View File

@ -23,15 +23,15 @@
/** /**
* Add/remove links. * Add/remove links.
*/ */
.add-or-remove-shortcuts { .shortcut-action {
display: inline-block; display: inline-block;
margin-left: 0.3em; /* LTR */ margin-left: 0.3em; /* LTR */
} }
[dir="rtl"] .add-or-remove-shortcuts { [dir="rtl"] .shortcut-action {
margin-left: 0; margin-left: 0;
margin-right: 0.3em; margin-right: 0.3em;
} }
.add-or-remove-shortcuts .text { .shortcut-action__message {
background: #000000; background: #000000;
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
border-radius: 5px; border-radius: 5px;
@ -49,12 +49,12 @@
-webkit-backface-visibility: hidden; -webkit-backface-visibility: hidden;
backface-visibility: hidden; backface-visibility: hidden;
} }
[dir="rtl"] .add-or-remove-shortcuts .text { [dir="rtl"] .shortcut-action__message {
margin-left: 0; margin-left: 0;
margin-right: 0.3em; margin-right: 0.3em;
} }
.add-or-remove-shortcuts a:hover .text, .shortcut-action:hover .shortcut-action__message,
.add-or-remove-shortcuts a:focus .text { .shortcut-action:focus .shortcut-action__message {
opacity: 1; opacity: 1;
-ms-transform: translateY(-2px); -ms-transform: translateY(-2px);
-webkit-transform: translateY(-2px); -webkit-transform: translateY(-2px);

View File

@ -347,12 +347,16 @@ function shortcut_preprocess_page(&$variables) {
'shortcut/drupal.shortcut', 'shortcut/drupal.shortcut',
), ),
), ),
'#prefix' => '<div class="add-or-remove-shortcuts ' . $link_mode . '-shortcut">',
'#type' => 'link', '#type' => 'link',
'#title' => SafeMarkup::format('<span class="icon"></span><span class="text">@text</span>', array('@text' => $link_text)), '#title' => SafeMarkup::format('<span class="shortcut-action__icon"></span><span class="shortcut-action__message">@text</span>', array('@text' => $link_text)),
'#url' => Url::fromRoute($route_name, $route_parameters), '#url' => Url::fromRoute($route_name, $route_parameters),
'#options' => array('query' => $query), '#options' => array('query' => $query),
'#suffix' => '</div>', '#attributes' => array(
'class' => array(
'shortcut-action',
'shortcut-action--' . $link_mode,
),
),
); );
} }
} }

View File

@ -243,23 +243,23 @@ class ShortcutLinksTest extends ShortcutTestBase {
->save(); ->save();
$this->drupalGet('page-that-does-not-exist'); $this->drupalGet('page-that-does-not-exist');
$result = $this->xpath('//div[contains(@class, "add-shortcut")]'); $result = $this->xpath('//a[contains(@class, "shortcut-action--add")]');
$this->assertTrue(empty($result), 'Add to shortcuts link was not shown on a page not found.'); $this->assertTrue(empty($result), 'Add to shortcuts link was not shown on a page not found.');
// The user does not have access to this path. // The user does not have access to this path.
$this->drupalGet('admin/modules'); $this->drupalGet('admin/modules');
$result = $this->xpath('//div[contains(@class, "add-shortcut")]'); $result = $this->xpath('//a[contains(@class, "shortcut-action--add")]');
$this->assertTrue(empty($result), 'Add to shortcuts link was not shown on a page the user does not have access to.'); $this->assertTrue(empty($result), 'Add to shortcuts link was not shown on a page the user does not have access to.');
// Verify that the testing mechanism works by verifying the shortcut // Verify that the testing mechanism works by verifying the shortcut link
// link appears on admin/people. // appears on admin/content.
$this->drupalGet('admin/people'); $this->drupalGet('admin/content');
$result = $this->xpath('//div[contains(@class, "remove-shortcut")]'); $result = $this->xpath('//a[contains(@class, "shortcut-action--remove")]');
$this->assertTrue(!empty($result), 'Remove from shortcuts link was shown on a page the user does have access to.'); $this->assertTrue(!empty($result), 'Remove from shortcuts link was shown on a page the user does have access to.');
// Verify that the shortcut link appears on routing only pages. // Verify that the shortcut link appears on routing only pages.
$this->drupalGet('router_test/test2'); $this->drupalGet('router_test/test2');
$result = $this->xpath('//div[contains(@class, "add-shortcut")]'); $result = $this->xpath('//a[contains(@class, "shortcut-action--add")]');
$this->assertTrue(!empty($result), 'Add to shortcuts link was shown on a page the user does have access to.'); $this->assertTrue(!empty($result), 'Add to shortcuts link was shown on a page the user does have access to.');
} }

View File

@ -10,6 +10,6 @@
[dir="rtl"] .shortcut-wrapper h1#page-title { [dir="rtl"] .shortcut-wrapper h1#page-title {
float: right; float: right;
} }
div.add-or-remove-shortcuts { .shortcut-action {
padding-top: 0.9em; padding-top: 0.9em;
} }

View File

@ -20,7 +20,7 @@ body {
#toolbar, #toolbar,
.site-footer, .site-footer,
.tabs, .tabs,
.add-or-remove-shortcuts { .shortcut-action {
display: none; display: none;
} }
.one-sidebar #content, .one-sidebar #content,