Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

[expand button]: initial PR #129

Merged
merged 2 commits into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 15 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var timingView = require('./views/timing');
var ajaxView = require('./views/ajax');
var dataView = require('./views/data');
var logsView = require('./views/logs');
var expandButtonView = require('./views/expand-button-view');
var util = require('./lib/util');

const state = {
Expand All @@ -23,11 +24,13 @@ function render(state) {
<div class="glimpse-hud">
<div class="glimpse-hud-data" data-glimpse-expanded="${state.expanded}">
${versionView.render()}
${expandButtonView.render()}
${timingView.render()}
${logsView.render()}
${dataView.render()}
${ajaxView.render()}
<div class="glimpse-hud-popup">
${expandButtonView.renderPopup()}
${timingView.renderPopup()}
${logsView.renderPopup()}
${dataView.renderPopup()}
Expand All @@ -40,16 +43,21 @@ function render(state) {
}

function postRender(initPromise) {
var hudData = document.querySelector('.glimpse-hud-data');
var expandButton = document.querySelector('#js-glimpse-expand-button');
var collapseButton = document.querySelector('#js-glimpse-collapse-button');

ajaxView.postRender(initPromise);
logsView.postRender(initPromise)
logsView.postRender(initPromise);

var hudData = document.querySelector('.glimpse-hud-data');
var setOpenState = function(panelState) {
util.localSet(state, 'expanded', panelState, function() {
hudData.setAttribute('data-glimpse-expanded', panelState);
});
};

hudData.addEventListener('click', function() {
util.localSet(state, 'expanded', !state.expanded, function() {
hudData.setAttribute('data-glimpse-expanded', state.expanded);
});
});
expandButton.addEventListener('click', function() { setOpenState(true); });
collapseButton.addEventListener('click', function() { setOpenState(false); });
}

function preInit(initPromise) {
Expand Down
47 changes: 44 additions & 3 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ $popup-delay: 0s;

&[data-glimpse-expanded="true"] {
border-color: transparent !important;
transition-delay: 0s !important;
transition-delay: 0s !important;

> :not(.glimpse-hud-popup) {
background-color: transparent !important;
Expand Down Expand Up @@ -297,7 +297,7 @@ $popup-delay: 0s;
white-space: nowrap !important;
text-overflow: ellipsis !important;
overflow: hidden !important;

&:last-child {
text-align: right !important;
}
Expand Down Expand Up @@ -331,15 +331,19 @@ $popup-delay: 0s;

.glimpse-hud-popup-section {
padding: 10px !important;
padding-right: 15px !important;

~ * {
border-left: 1px solid #999 !important;
margin-left: 5px !important;
}

&.-ajax {
flex-grow: 1 !important;
}

&:last-of-type {
padding-right: 10px !important;
}
}

.glimpse-hud-field {
Expand Down Expand Up @@ -450,3 +454,40 @@ $popup-delay: 0s;
max-height: 150px !important;
overflow-y: auto !important;
}

$expandHoverColor: #3c3c3c;
$collapseHoverColor: #353535;
.glimpse-expand-button,
.glimpse-hud-popup-section--arrow {
position: relative !important;

$arrowSize: 5px;
&::after {
content: "" !important;
position: absolute !important;
left: 50% !important;
top: 50% !important;
border: $arrowSize solid transparent !important;
margin-top: -$arrowSize !important;
margin-left: -$arrowSize/5 !important;
border-left-color: white !important;
}

&:hover {
background-color: $expandHoverColor !important;
cursor: pointer !important;
}
}

.glimpse-hud-popup-section--arrow {
background-color: $expandHoverColor !important;

&::after {
transform: rotate(45deg) translateX(-1px) !important;
}

&:hover {
background-color: $collapseHoverColor !important;
cursor: pointer !important;
}
}
14 changes: 14 additions & 0 deletions src/views/expand-button-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
render: function() {
return `
<div class="glimpse-section glimpse-expand-button" id="js-glimpse-expand-button" title="expand">
</div>
`;
},
renderPopup: function() {
return `
<div class="glimpse-hud-popup-section glimpse-hud-popup-section--arrow" id="js-glimpse-collapse-button" title="collapse">
</div>
`;
}
};