From 2808c5c595b7fde1f7a2346200e1efd1f2926326 Mon Sep 17 00:00:00 2001 From: Isarra Date: Wed, 24 Jul 2019 20:50:53 +0000 Subject: [PATCH] CSS-based pokeys No more need to add in an html pokey element every potential dropdown menu. Aaaaaagh that made it bigger, didn't it. Change-Id: I5d3817aa026849a5304710a32a3585f3e698321d --- includes/TimelessTemplate.php | 9 ++--- resources/mixins.less | 53 +++++++++++++++++++++++++++++ resources/screen-common.less | 27 --------------- resources/screen-desktop-small.less | 5 +++ resources/screen-desktop.less | 3 +- 5 files changed, 63 insertions(+), 34 deletions(-) diff --git a/includes/TimelessTemplate.php b/includes/TimelessTemplate.php index 95e8fb8..ad43975 100644 --- a/includes/TimelessTemplate.php +++ b/includes/TimelessTemplate.php @@ -309,8 +309,7 @@ class TimelessTemplate extends BaseTemplate { Html::rawElement( 'h2', [], Html::element( 'span', [], $this->getMsg( $headerMessage )->text() - ) . - Html::element( 'div', [ 'class' => 'pokey' ] ) + ) ) . Html::rawElement( 'div', [ 'class' => 'sidebar-inner' ], $content ) ); @@ -548,8 +547,7 @@ class TimelessTemplate extends BaseTemplate { $html .= Html::rawElement( 'div', [ 'id' => 'personal' ], Html::rawElement( 'h2', [], - Html::element( 'span', [], $dropdownHeader ) . - Html::element( 'div', [ 'class' => 'pokey' ] ) + Html::element( 'span', [], $dropdownHeader ) ) . Html::rawElement( 'div', [ 'id' => 'personal-inner', 'class' => 'dropdown' ], $this->getPortlet( 'personal', $personalTools, $headerMsg ) @@ -870,8 +868,7 @@ class TimelessTemplate extends BaseTemplate { if ( $this->data['language_urls'] || $this->pileOfTools['variants'] ) { $html .= Html::rawElement( 'div', [ 'id' => 'ca-languages' ], Html::rawElement( 'h2', [], - Html::element( 'span', [], $this->getMsg( 'timeless-languages' )->text() ) . - Html::element( 'div', [ 'class' => 'pokey' ] ) + Html::element( 'span', [], $this->getMsg( 'timeless-languages' )->text() ) ) . Html::rawElement( 'div', [ 'id' => 'languages-inner', 'class' => 'dropdown' ], $variants . diff --git a/resources/mixins.less b/resources/mixins.less index bb57dc0..a54b404 100644 --- a/resources/mixins.less +++ b/resources/mixins.less @@ -126,6 +126,59 @@ z-index: 3; } +.dropdown-pokey() { + &:before, + &:after { + transform: rotate( 360deg ); // to force some smoothing in annoying browsers + border-bottom: 10px solid @base80; + border-left: 10px solid transparent; + border-right: 10px solid transparent; + content: ''; + height: 0; + width: 0; + position: absolute; + right: 1em; + z-index: 4; + } + + &:before { + top: -10px; + } + + &:after { + border-bottom-color: @base100; + top: -8px; + } +} + +// stupid pokey alignment for menus on the left... (desktop-small dropdowns) +.dropdown-pokey-left() { + &:hover h2 span { + &:before, + &:after { + display: block; + } + } + + h2 span { + .dropdown-pokey(); + + &:before, + &:after { + right: 0; + display: none; + } + + &:before { + top: 34px; + } + + &:after { + top: 36px; + } + } +} + // Categories on bottom of page .categories-bottom() { diff --git a/resources/screen-common.less b/resources/screen-common.less index 57b1ffd..8b5d9c0 100644 --- a/resources/screen-common.less +++ b/resources/screen-common.less @@ -152,33 +152,6 @@ body { } } -/* Dropdown stuff */ - -.pokey, -.pokey:after { - border-bottom: 10px solid @base80; - border-left: 10px solid transparent; - border-right: 10px solid transparent; - content: ''; - height: 0; - position: absolute; - transform: rotate( 360deg ); // to force some smoothing in annoying browsers - width: 0; - z-index: 4; -} - -.pokey { - top: 1.85em; - right: 1px; - display: none; -} - -.pokey:after { - border-bottom-color: #fff; - right: -10px; - top: 2px; -} - .dropdown-toggle { .dropdown-header(); } diff --git a/resources/screen-desktop-small.less b/resources/screen-desktop-small.less index 71751c0..6097c80 100644 --- a/resources/screen-desktop-small.less +++ b/resources/screen-desktop-small.less @@ -87,6 +87,10 @@ .sidebar-inner { .dropdown-menu( left ); } + + .sidebar-chunk { + .dropdown-pokey-left(); + } } #mw-related-navigation { @@ -100,6 +104,7 @@ .sidebar-inner { .dropdown-menu(); + .dropdown-pokey(); top: 2.95em !important; // to override mobile positioning } } diff --git a/resources/screen-desktop.less b/resources/screen-desktop.less index a97b4d0..c1d4079 100644 --- a/resources/screen-desktop.less +++ b/resources/screen-desktop.less @@ -71,6 +71,7 @@ top: 3.15em; display: none !important; .dropdown-menu(); + .dropdown-pokey(); } .pokey { @@ -118,7 +119,7 @@ .dropdown { display: none !important; .dropdown-menu(); - right: 0; + .dropdown-pokey(); // Override the mobile thing top: 2.25em !important; }