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

[NFR] Persistent toggle Toolbar #44

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion src/Fabfuel/Prophiler/View/css/screen.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 29 additions & 4 deletions src/Fabfuel/Prophiler/View/sass/screen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@import "compass/css3";
@import "compass/utilities/general/clearfix";

$c-background: #fff;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your demo, the background colors are not aligned. The button's background color is #fff, but the toolbar's is #f8f8f8

$c-lines: #eee;
$c-headline: #777;

Expand All @@ -12,26 +13,50 @@ $c-event-blue: rgba(57, 126, 185, .75);
$c-event-sky: rgba(96, 194, 223, .75);
$c-event-grey: rgba(216, 216, 216, 0.75);

$z-index: 10000;

body {
margin-top: 33px !important;
position: relative;
}

#prophiler-placeholder {
margin-top:33px;
}

#skel-layers-wrapper {
-webkit-perspective: none !important;
}

#prophiler-toggle {
position: fixed;
top: 0;
left: 0;
z-index: $z-index;
background-color: $c-background;
border-radius: 0 0 6px 0;

a {
display: block;
border: none;
padding: 0 12px;
line-height: 33px;
height: 36px;
}
}

#prophiler {
visibility: hidden;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
font-size: 12px;
line-height: 1.42857143;
position: fixed;
display: block;
padding-left: 24px;
top: 0;
left: 0;
right: 0;
z-index: 10000;
background-color: #fff;
z-index: $z-index;
background-color: $c-background;
opacity: 0.97;
@include box-shadow(0 3px 10px rgba(0, 0, 0, .125));

Expand Down Expand Up @@ -161,7 +186,7 @@ body {
float: left;
padding: 5px 15px;
font-size: 18px;
line-height: 20px;
line-height: 22px;
margin: 0;
}

Expand Down
30 changes: 30 additions & 0 deletions src/Fabfuel/Prophiler/View/toolbar.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use Fabfuel\Prophiler\Toolbar\Formatter\BenchmarkFormatter;
<div id="prophiler">

<div class="toolbar">

<h1 class="logo">Prophiler</h1>

<nav>
Expand Down Expand Up @@ -79,6 +80,13 @@ use Fabfuel\Prophiler\Toolbar\Formatter\BenchmarkFormatter;
<?php foreach ($aggregators as $aggregator): ?>
<?php $this->partial('partials/aggregator', ['profiler' => $profiler, 'aggregator' => $aggregator]); ?>
<?php endforeach; ?>

</div>

<div id="prophiler-toggle">
<a href="javascript:void(0);">
<i class="fa fa-angle-up"></i>
</a>
</div>

<script>
Expand All @@ -89,5 +97,27 @@ use Fabfuel\Prophiler\Toolbar\Formatter\BenchmarkFormatter;
$('json').each(function (index, el) {
el.innerHTML = JSON.stringify(JSON.parse(el.innerHTML), null, ' ');
});

// Move toggle event to delegate handler
$('body')
.on('click', '#prophiler-toggle', function() {
$(this).find('.fa').toggleClass('fa-angle-up fa-angle-down');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can not assume, the user's project is using Font Awesome.
The toggle button needs to work/be visible without it as well.

var visible = !!$('#prophiler, #prophiler-placeholder').slideToggle('fast').eq(0).height();
if(visible) {
document.cookie = 'prophiler_toolbar_hidden=; max-age=0; path=/';
} else {
document.cookie = 'prophiler_toolbar_hidden=1; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/';
}
})
.prepend('<div id="prophiler-placeholder"></div>');

// Persistent toolbar state
if(document.cookie.match(/(^|;)\s*prophiler_toolbar_hidden\s*=/)) {
$('#prophiler, #prophiler-placeholder').hide();
$('#prophiler-toggle').find('.fa').toggleClass('fa-angle-up fa-angle-down');
}

// Prevent jumpy loading
$('#prophiler').css({visibility:'visible'});
});
</script>