Significant changes to splitter handle and button approach

- WIP!;
- WIP on drag to collapse;
This commit is contained in:
charlesh88 2018-08-23 16:02:02 -07:00
parent a1d9c11e82
commit f9b764bb64
3 changed files with 68 additions and 270 deletions

View File

@ -240,9 +240,10 @@ $splitterCollapseBtnD: (10px, 35px);
$splitterHandleD: 2px; $splitterHandleD: 2px;
$splitterGrippyD: ($splitterHandleD - 4, 75px, 50px); // thickness, length, min-length $splitterGrippyD: ($splitterHandleD - 4, 75px, 50px); // thickness, length, min-length
$colorSplitterBaseBg: $colorBodyBg; $colorSplitterBaseBg: $colorBodyBg;
$colorSplitterBg: pullForward($colorSplitterBaseBg, 10%); $colorSplitterBg: pullForward($colorSplitterBaseBg, 20%);
$colorSplitterFg: $colorBodyBg; $colorSplitterFg: $colorBodyBg;
$colorSplitterButtonBg: pullForward($colorSplitterBaseBg, 20%); $colorSplitterButtonBg: rgba($colorBodyFg, 0.1); //pullForward($colorSplitterBaseBg, 20%);
$colorSplitterButtonFg: $colorBodyFg;
$colorSplitterGrippy: pullForward($colorSplitterBaseBg, 30%); $colorSplitterGrippy: pullForward($colorSplitterBaseBg, 30%);
$splitterShdw: none; $splitterShdw: none;
$splitterEndCr: none; $splitterEndCr: none;

View File

@ -26,7 +26,7 @@
// TODO: integrate approach at https://codepen.io/charlesh88/pen/KxpvOP // TODO: integrate approach at https://codepen.io/charlesh88/pen/KxpvOP
$hitMargin: 4px; $hitMargin: 2px;
/**************************** BASE - MOBILE AND DESKTOP */ /**************************** BASE - MOBILE AND DESKTOP */
.l-pane { .l-pane {
opacity: 1; opacity: 1;
@ -43,15 +43,13 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
top: 0; right: 0; // Default top: 0; right: 0; // Default
z-index: 3; z-index: 1;
} }
&[class*="--horizontal"] { &[class*="--horizontal"] {
&.l-pane--collapsed { &.l-pane--collapsed {
padding-left: 0 !important; padding-left: 0 !important;
padding-right: 0 !important; padding-right: 0 !important;
width: 0px;
min-width: 0px;
} }
} }
@ -59,8 +57,6 @@
&.l-pane--collapsed { &.l-pane--collapsed {
padding-top: 0 !important; padding-top: 0 !important;
padding-top: 0 !important; padding-top: 0 !important;
height: 0px;
min-height: 0px;
} }
} }
@ -76,6 +72,9 @@
/************************ COLLAPSED STATE */ /************************ COLLAPSED STATE */
&--collapsed { &--collapsed {
flex-basis: 0px;
min-width: 0px !important;
min-height: 0px !important;
transition: all 350ms ease; transition: all 350ms ease;
.l-pane__contents { .l-pane__contents {
@ -93,9 +92,10 @@
//@include test(blue, 0.1); //@include test(blue, 0.1);
&__handle { &__handle {
z-index: 1; background: $colorSplitterBg;
display: block; display: block;
position: absolute; position: absolute;
z-index: 20;
&:before { &:before {
content: ''; content: '';
@ -107,20 +107,46 @@
&__collapse-button { &__collapse-button {
background: $colorSplitterButtonBg; background: $colorSplitterButtonBg;
color: $colorSplitterFg; color: $colorSplitterButtonFg;
&:before { &:before {
content: $glyph-icon-arrow-right;
font-family: symbolsfont;
font-size: .5rem; font-size: .5rem;
} }
} }
&[class*="--collapsed"] { &[class*="--collapsed"] {
$d: nth($splitterCollapseBtnD, 1);
flex-basis: $d;
min-width: $d !important;
min-height: $d !important;
> .l-pane__handle { > .l-pane__handle {
display: none; display: none;
} }
} }
&[class*="--horizontal"] { &[class*="--horizontal"] {
$splitterHorzPad: nth($splitterCollapseBtnD, 1) + $interiorMargin;
&[class*="--collapsed"] {
> .l-pane__handle {
//background: $colorSplitterButtonBg;
//width: nth($splitterCollapseBtnD, 1) + 1;
}
> .l-pane__collapse-button {
bottom: 0; height: auto;
border-radius: unset;
&:before {
transform: scaleX(-1);
}
}
}
> .l-pane__handle { > .l-pane__handle {
cursor: col-resize; cursor: col-resize;
top: 0; top: 0;
@ -137,18 +163,15 @@
} }
> .l-pane__collapse-button { > .l-pane__collapse-button {
border-bottom-right-radius: $controlCr; //border-bottom-right-radius: $controlCr;
height: nth($splitterCollapseBtnD, 2); bottom: 0;
height: auto; //nth($splitterCollapseBtnD, 2);
width: nth($splitterCollapseBtnD, 1); width: nth($splitterCollapseBtnD, 1);
&:before {
content: $glyph-icon-arrow-right;
}
} }
/************************** Splitter Before */ /************************** Splitter Before */
&[class*="-before"] { &[class*="-before"] {
padding-left: nth($splitterCollapseBtnD, 1) + $interiorMargin; padding-left: $splitterHorzPad;
> .l-pane__handle, > .l-pane__handle,
> .l-pane__collapse-button { > .l-pane__collapse-button {
@ -156,19 +179,16 @@
transform: translateX(floor($splitterHandleD / -2)); // Center over the pane edge transform: translateX(floor($splitterHandleD / -2)); // Center over the pane edge
} }
> .l-pane__collapse-button {
}
&[class*="--collapsed"] { &[class*="--collapsed"] {
> .l-pane__collapse-button { > .l-pane__collapse-button {
transform: translateX(-100%) scaleX(-1); // transform: scaleX(-1);
} }
} }
} }
/************************** Splitter After */ /************************** Splitter After */
&[class*="-after"] { &[class*="-after"] {
padding-right: nth($splitterCollapseBtnD, 1) + $interiorMargin; padding-right: $splitterHorzPad;
> .l-pane__handle, > .l-pane__handle,
> .l-pane__collapse-button { > .l-pane__collapse-button {
@ -182,7 +202,7 @@
&[class*="--collapsed"] { &[class*="--collapsed"] {
> .l-pane__collapse-button { > .l-pane__collapse-button {
transform: translateX(100%) scaleX(1); // transform: scaleX(1);
} }
} }
} }
@ -210,254 +230,10 @@
} }
} }
} // Ends .body.desktop } // Ends .body.desktop
} // Ends .l-pane } // Ends .l-pane
.l-pane {
/************************ PANES */
&--horizontal {
// Pane adjusts size horizontally, handles run vertically
// Selectors here
> .l-pane__handle {
/* top: 0;
bottom: 0;
&--before {
left: 0;
[class*="collapse-button"] {
left: 0;
}
}
&--after {
right: 0;
[class*="collapse-button"] {
right: 0;
}
}
*/
body.desktop & {
cursor: col-resize;
width: $splitterHandleD;
&:before {
// Extended hit area
top: 0;
right: $hitMargin * -1;
bottom: 0;
left: $hitMargin * -1;
}
&:after {
// Grippy
min-height: nth($splitterGrippyD, 3);
height: nth($splitterGrippyD, 2);
width: nth($splitterGrippyD, 1);
top: 50%; left: ($splitterHandleD - nth($splitterGrippyD, 1)) / 2;
transform: translateY(-50%);
}
&--before {
// Handle at left edge of containing pane
// left: 0;
[class*="collapse-button"] {
// left: 0;
transform: scaleX(-1);
}
}
&--after {
// Handle at right edge of containing pane
// right: 0;
/*[class*="collapse-button"] {
right: 0;
}*/
}
[class*="collapse-button"] {
background: $colorSplitterGrippy;
color: $colorSplitterFg;
font-size: 0.6em;
height: nth($splitterCollapseBtnD, 2);
width: nth($splitterCollapseBtnD, 1);
&:before {
content: $glyph-icon-arrow-left;
}
}
&.l-pane--collapsed {
> .l-pane__handle {
&--before {
transform: translateX($splitterHandleD * -1) scaleX(-1);
}
&--after {
transform: translateX($splitterHandleD) scaleX(-1);
}
}
}
}
}
/* &.l-pane--collapsed {
padding-left: 0 !important;
padding-right: 0 !important;
width: 0px;
min-width: 0px;
}*/
}
&--vertical {
// Pane adjusts size vertically, handles run horizontally
// Selectors here
> .l-pane__handle {
//background: green;
cursor: row-resize;
height: $splitterHandleD;
left: 0;
right: 0;
&:before {
top: $hitMargin * -1;
right: 0;
bottom: $hitMargin * -1;
left: 0;
}
&:after {
// Grippy
min-width: nth($splitterGrippyD, 3);
width: nth($splitterGrippyD, 2);
height: nth($splitterGrippyD, 1);
left: 50%; top: ($splitterHandleD - nth($splitterGrippyD, 1)) / 2;
transform: translateX(-50%);
}
&--before {
// Handle at top edge of containing pane
top: 0;
}
&--after {
// Handle at bottom edge of containing pane
bottom: 0;
}
}
[class*="collapse-button"] {
height: nth($splitterCollapseBtnD, 1);
width: nth($splitterCollapseBtnD, 2);
}
&.l-pane--collapsed {
padding-top: 0 !important;
padding-bottom: 0 !important;
height: 0px;
min-height: 0px;
}
}
/************************ HANDLES */
&__handle {
// Selectors for handle in any context
/* z-index: 1;
display: block;
position: absolute;*/
body.desktop & {
background: $colorSplitterBg;
transition: $transOut;
&:before {
// Extended hit area
content: '';
display: block;
position: absolute;
z-index: -1;
}
&:after {
// Grippy affordance
content: '';
background: $colorSplitterGrippy;
border-radius: 5px;
display: block;
position: absolute;
z-index: 1;
}
&:active, &:hover {
transition: $transIn;
}
&:active {
background: $colorSplitterActive; // Not really working with drag
}
&:hover {
background: $colorSplitterHover;
}
}
}
/************************ COLLAPSE BUTTONS */
&__collapse-button {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
z-index: 3;
body.desktop & {
transition: $transOut;
&:active, &:hover {
transition: $transIn;
}
&:hover {
background: $colorSplitterHover;
}
&:active {
background: $colorSplitterActive;
}
}
&:before {
// Glyph holder
display: block;
font-family: symbolsfont;
}
}
}
</style> </style>
<script> <script>
export default { export default {
props: { props: {
@ -484,12 +260,16 @@ export default {
}*/ }*/
}, },
methods: { methods: {
toggleCollapse: function () { toggleCollapse: function (restoreSize) {
this.collapsed = !this.collapsed; this.collapsed = !this.collapsed;
// console.log("rs " + restoreSize);
if (!restoreSize) { restoreSize = this.$el.style[this.styleProp]; }
if (this.collapsed) { if (this.collapsed) {
// Pane is expanded and is being collapsed
this.currentSize = this.$el.style[this.styleProp]; this.currentSize = this.$el.style[this.styleProp];
this.$el.style[this.styleProp] = ''; this.$el.style[this.styleProp] = '';
} else { } else {
// Pane is collapsed and is being expanded
this.$el.style[this.styleProp] = this.currentSize; this.$el.style[this.styleProp] = this.currentSize;
delete this.currentSize; delete this.currentSize;
} }
@ -518,6 +298,18 @@ export default {
updatePosition: function (event) { updatePosition: function (event) {
let size = this.getNewSize(event); let size = this.getNewSize(event);
this.$el.style[this.styleProp] = size; this.$el.style[this.styleProp] = size;
/*
let intSize = parseInt(size.substr(0, size.length - 2));
// console.log(this.initial);
if (intSize < 50) {
// this.currentSize = this.initial;
console.log("initial: " + this.initial);
// this.toggleCollapse("initial: " + this.initial);
document.body.removeEventListener('mousemove', this.updatePosition);
document.body.removeEventListener('mouseup', this.end);
} else {
this.$el.style[this.styleProp] = size;
}*/
}, },
start: function (event) { start: function (event) {
this.startPosition = this.getPosition(event); this.startPosition = this.getPosition(event);

View File

@ -19,7 +19,7 @@
<pane class="l-shell__pane-main"> <pane class="l-shell__pane-main">
<div class="l-shell__main-container" ref="mainContainer"></div> <div class="l-shell__main-container" ref="mainContainer"></div>
</pane> </pane>
<pane class="l-shell__pane-inspector" <pane class="l-shell__pane-inspector l-pane--holds-multipane"
handle="before" handle="before"
collapsable> collapsable>
<MctInspector ref="inspector"></MctInspector> <MctInspector ref="inspector"></MctInspector>
@ -97,6 +97,7 @@
&__pane-inspector { &__pane-inspector {
display: flex; display: flex;
padding: $m;
body.mobile & { body.mobile & {
display: none; display: none;
@ -169,12 +170,16 @@
&__pane-tree, &__pane-tree,
&__pane-inspector { &__pane-inspector {
max-width: 30%; max-width: 30%;
min-width: 5%; min-width: 0;
} }
&__pane-tree { &__pane-tree {
width: 300px; width: 300px;
} }
&__pane-inspector {
width: 200px;
}
} }
} }
</style> </style>