Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masterbar: Add menu structure #17629

Merged
merged 38 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c7649d0
First pass at admin menu restructuring.
obenland Oct 27, 2020
703e425
Micro optimizations
obenland Oct 27, 2020
dd5e3a2
Add private badge on atomic
obenland Oct 27, 2020
23b7be4
Move Jetpack menu on Atomic sites
obenland Oct 28, 2020
41ed931
Update menu and link structure
obenland Oct 28, 2020
12c5b1f
Improved API request detection
obenland Oct 29, 2020
5d0e825
Always use calypso plugin screen for simple sites
obenland Oct 29, 2020
e96b61d
Add unit test scaffolding
obenland Oct 29, 2020
3a798ac
Remove wpcom-only code
obenland Oct 29, 2020
d7fca1c
Make unit tests work
obenland Nov 4, 2020
ed46e8d
Add some more tests
obenland Nov 5, 2020
0579af9
Add more unit tests
obenland Nov 6, 2020
a78b8b0
Improve test set up and tear down.
obenland Nov 6, 2020
0124077
Sync styles with latest revision
obenland Nov 6, 2020
d9cfb57
Fix site card icon
obenland Nov 6, 2020
32f959c
Update My Home URL
obenland Nov 6, 2020
3b611f2
[not verified] # This is a combination of 2 commits.
obenland Nov 6, 2020
c17ff5e
Remove Scan & Backup link for atomic sites
obenland Nov 7, 2020
813c0ea
Moar unit tests, including multisite
obenland Nov 9, 2020
1347dca
Make usre Atomic fallback site icon doesn't throw off CSS class
obenland Nov 9, 2020
cb20771
Add last batch of unit tests
obenland Nov 10, 2020
d349880
Add instance test
obenland Nov 10, 2020
ac637bd
Disable entirely, even on simple and atomic
obenland Nov 10, 2020
814a42c
Styles lint only
Nov 11, 2020
d13a6ad
Adds nav unification styles
Nov 11, 2020
2a4fe69
Update file structure
obenland Nov 11, 2020
ea06c75
Rewrite admin-menu.js in IE11-safe vanilla ES5
sgomes Nov 12, 2020
e710393
Update modules/masterbar.php
obenland Nov 16, 2020
dc60a6d
Introduce jetpack_get_site_suffix() to get calypso domains
obenland Nov 17, 2020
6c0d64e
Adds use of Automattic\Jetpack\Redirect to prevent errors when using …
Nov 20, 2020
da78f21
Adds Browse sites to eligible atomic sites
Nov 20, 2020
f81e36f
Fix phpcs notices
obenland Nov 23, 2020
b5d78d0
Upgrade side suffix to new Status method.
obenland Nov 23, 2020
5c4100c
Update modules/masterbar/admin-menu/class-admin-menu.php
obenland Nov 23, 2020
b162de4
Removes unused commented out code
Nov 24, 2020
324384c
Simplify logic for Browse sites link
obenland Nov 24, 2020
71ae80d
Update modules/masterbar/admin-menu/class-admin-menu.php
obenland Nov 30, 2020
9f6cc03
Leave CPTs in wp-admin
obenland Dec 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions modules/masterbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@

new Masterbar();
new Admin_Color_Schemes();

/**
* Whether to load the admin menu functionality.
*
* @use add_filter( 'jetpack_load_admin_menu_class', '__return_true' );
* @module masterbar
*
* @since 9.2.0
obenland marked this conversation as resolved.
Show resolved Hide resolved
*
* @param bool $load_admin_menu_class Load Jetpack's custom admin menu functionality. Default to false.
*/
if ( apply_filters( 'jetpack_load_admin_menu_class', false ) ) {
require_once __DIR__ . '/masterbar/admin-menu/class-admin-menu.php';
Admin_Menu::get_instance();
}
325 changes: 325 additions & 0 deletions modules/masterbar/admin-menu/admin-menu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
#adminmenu {
margin: 0;
}

/**
* Menu width
*/
#wpcontent,
#wpfooter {
margin-left: 272px;
}

#adminmenuback,
#adminmenuwrap,
#adminmenu,
#adminmenu .wp-submenu {
width: 272px;
}

#adminmenu .wp-submenu {
left: 272px;
}

#adminmenu .wp-not-current-submenu .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
min-width: 272px;
}

/**
* Jetpack logo
*/
#adminmenu [class*='activity-log'] .wp-menu-image img {
padding-top: 7px;
}

/**
* Site Switcher
*/
#adminmenu a.site-switcher {
color: #a2aab2;
}

#adminmenu a.site-switcher:hover {
color: #00b9eb;
}

/**
* Site Card
*/
#adminmenu .toplevel_page_site-card .wp-menu-name {
margin-left: 40px; /* icon width (32) + padding (8). */
padding: 0;
}

#adminmenu li.toplevel_page_site-card {
border-bottom: 1px solid #333333;
border-top: 1px solid #333333;
}

#adminmenu li.toplevel_page_site-card a {
padding: 10px 0 10px 8px;
}

#adminmenu .toplevel_page_site-card .wp-menu-image {
background-image: none;
background-position: center;
background-repeat: no-repeat;
background-size: 18px 18px;
height: 32px;
transform: translateZ( 0 );
transition-property: background-image, background-color;
transition-duration: 0.2s;
width: 32px;
}
#adminmenu .toplevel_page_site-card:not( .has-site-icon ) .wp-menu-image {
background-color: #c3c4c7;
}

#adminmenu .toplevel_page_site-card.has-site-icon img {
opacity: initial;
padding: 0;
}

#adminmenu .toplevel_page_site-card:hover div.wp-menu-image,
#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image {
background-color: #006fad;
background-image: url( "data:image/svg+xml,%3Csvg class='gridicon gridicons-house' height='24' width='24' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg%3E%3Cpath fill='%230a4b78' d='M22 9L12 1 2 9v2h2v10h5v-4c0-1.657 1.343-3 3-3s3 1.343 3 3v4h5V11h2V9z'/%3E%3C/g%3E%3C/svg%3E%0A" );
width: 34px;
}

#adminmenu
.toplevel_page_site-card:not( .has-site-icon )
.wp-menu-image
img[src^='data:image/svg'] {
height: auto;
padding-top: 7px;
width: 18px;
}

#adminmenu .toplevel_page_site-card:hover div.wp-menu-image img,
#adminmenu .toplevel_page_site-card a:focus div.wp-menu-image img {
display: none;
}

.site__info .site__title {
color: white;
display: block;
font-size: 14px;
font-weight: 400;
line-height: 1.3;
}

.site__info .site__domain {
color: #a2aab2;
display: block;
max-width: 95%;
font-size: 12px;
line-height: 1.4;
margin-top: 2px;
}

.site__info .site__title,
.site__info .site__domain {
overflow: hidden;
white-space: nowrap;
}
.site__info .site__title::after,
.site__info .site__domain::after {
content: '';
display: block;
position: absolute;
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;
pointer-events: none;
background: linear-gradient( 90deg, rgba( 35, 40, 45, 0 ), rgba( 35, 40, 45, 1 ) 90% );
top: 0;
bottom: 0;
right: 0;
left: auto;
width: 20%;
height: auto;
}

.site__info > .site__badge {
background: #dcdcde;
color: #1d2327;
font-size: 12px;
border-radius: 12px;
clear: both;
display: inline-block;
margin-top: 6px;
margin-right: 3px;
padding: 1px 10px;
}

/**
* Stats
*/
[class*="toplevel_page_https://wordpress.com/stats/day"] .sidebar-unified__sparkline
{
float: right;
margin-right: 8px;
}

/**
* Folded State
*/
.folded #adminmenu a.menu-top {
height: 31px;
}

.folded #adminmenu li.toplevel_page_site-card a {
padding-left: 0;
}

#wpadminbar {
background: #101517 !important;
}

#wpadminbar #wp-admin-bar-notes #wpnt-notes-unread-count.wpn-unread {
top: 50%;
left: 50%;
transform: translate( -10px, -13px );
background-color: #f283aa !important;
border-color: #101517;
}

#wpadminbar .ab-top-menu > li.my-sites > .ab-item {
background: #23282d;
}

#wpadminbar:not( .mobile ) .ab-top-menu > li:hover > .ab-item {
background: #333333;
}

#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar {
transform: translateX( 1px );
}

#wpadminbar .ab-top-menu > li.wpnt-show > .ab-item,
#wpadminbar .ab-top-menu > li.ab-hover.wpnt-show > .ab-item {
background: #23282d !important;
color: #ffffff !important;
}

#wpadminbar > #wp-toolbar .wpnt-show span.noticon,
#wpadminbar #wp-admin-bar-notes.wpnt-show .noticon {
color: #ffffff;
}

#wpadminbar #wp-admin-bar-notes.active .noticon-bell:before {
background-image: url( 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cmVjdCB4PSIwIiBmaWxsPSJub25lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiLz48Zz48cGF0aCBmaWxsPSIjZmZmZmZmIiBkPSJNNi4xNCAxNC45N2wyLjgyOCAyLjgyN2MtLjM2Mi4zNjItLjg2Mi41ODYtMS40MTQuNTg2LTEuMTA1IDAtMi0uODk1LTItMiAwLS41NTIuMjI0LTEuMDUyLjU4Ni0xLjQxNHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRjMi4zNC0yLjM0IDYuMTM1LTIuMzQgOC40NzUgMHMyLjM0IDYuMTM1IDAgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L2c+PC9zdmc+' ) !important;
}

#wpadminbar .quicklinks ul#wp-admin-bar-root-default {
padding-left: 0 !important;
}

#wpadminbar #wp-admin-bar-menu-toggle {
display: none;
}

/* Auto-folding of the admin menu */
@media only screen and ( max-width: 960px ) {
#adminmenu,
#adminmenuwrap,
#adminmenuback {
width: 272px;
}

.auto-fold #adminmenu a[class*='toplevel_page_http'].wp-first-item {
height: auto;
}

.wp-responsive-open #adminmenu a.menu-top {
height: auto;
}

.auto-fold #adminmenu div.wp-menu-image {
width: 36px;
}
}

@media screen and ( min-width: 782px ) and ( max-width: 960px ) {
.auto-fold #adminmenu a.menu-top {
height: 34px;
}

.auto-fold #adminmenu li.toplevel_page_site-card a {
height: 36px;
padding-left: 1px;
}
}

@media screen and ( max-width: 782px ) {
#adminmenu li.menu-top .wp-submenu > li > a,
.auto-fold #adminmenu li.menu-top .wp-submenu > li > a {
padding-left: 42px;
}

.auto-fold #adminmenu,
.auto-fold #adminmenuback,
.auto-fold #adminmenuwrap {
width: 272px;
}

.auto-fold #adminmenu a.site-switcher,
#adminmenu a.site-switcher {
font-size: 14px;
}

#wp-toolbar > ul > li {
display: block;
}

#wpadminbar li#wp-admin-bar-menu-toggle {
display: none;
}

#wpadminbar .quicklinks > ul > li > a,
#wpadminbar .quicklinks .ab-empty-item {
height: 32px;
line-height: 32px;
}

#wpadminbar #wp-admin-bar-my-account > .ab-item {
width: auto;
}

#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
position: static;
}

#wpadminbar #wp-admin-bar-my-sites > .ab-item,
#wpadminbar #wp-admin-bar-site-name > .ab-item,
#wpadminbar #wp-admin-bar-customize > .ab-item,
#wpadminbar #wp-admin-bar-edit > .ab-item,
#wpadminbar #wp-admin-bar-my-account > .ab-item {
text-indent: 0;
}
}

@media only screen and ( max-width: 660px ) {
#adminmenuback,
#adminmenuwrap,
#adminmenu,
#adminmenu .wp-submenu,
.auto-fold #adminmenu,
.auto-fold #adminmenuback,
.auto-fold #adminmenuwrap {
width: 100%;
}

ul#adminmenu a.wp-has-current-submenu:after,
ul#adminmenu > li.current > a.current:after,
ul#adminmenu li:hover a.wp-has-current-submenu:after,
.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after {
display: none;
}

.auto-fold #adminmenu li.toplevel_page_site-card a {
padding: 18px 0 18px 12px;
}
}
46 changes: 46 additions & 0 deletions modules/masterbar/admin-menu/admin-menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
( function () {
function init() {
var adminbar = document.querySelector( '#wpadminbar' );
var wpwrap = document.querySelector( '#wpwrap' );

function setAriaExpanded( value ) {
var anchors = adminbar.querySelectorAll( '#wp-admin-bar-blog a' );
for ( var i = 0; i < anchors.length; i++ ) {
anchors[ i ].setAttribute( 'aria-expanded', value );
}
}

setAriaExpanded( 'false' );

var adminbarBlog = adminbar.querySelector( '#wp-admin-bar-blog' );
// Toggle sidebar when toggle is clicked.
if ( adminbarBlog ) {
adminbarBlog.addEventListener( 'click', function ( event ) {
event.preventDefault();

// Close any open toolbar submenus.
var hovers = adminbar.querySelectorAll( '.hover' );
for ( var i = 0; i < hovers.length; i++ ) {
hovers[ i ].classList.remove( 'hover' );
}

wpwrap.classList.toggle( 'wp-responsive-open' );
if ( wpwrap.classList.contains( 'wp-responsive-open' ) ) {
setAriaExpanded( 'true' );
var first = document.querySelector( '#adminmenu a:first' );
if ( first ) {
first.focus();
}
} else {
setAriaExpanded( 'false' );
}
} );
}
}

if ( document.readyState === 'loading' ) {
document.addEventListener( 'DOMContentLoaded', init );
} else {
init();
}
} )();
Loading