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

ui: Update ResizablePanelGroup internals #1355

Merged
merged 72 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
befc593
Add test for horizontal resizable group
backspace Jun 14, 2024
394767e
Add example of bug in usage
backspace Jun 14, 2024
73904e6
Add test demonstrating bug
backspace Jun 14, 2024
7f0514d
Add partial refactor
backspace Jun 15, 2024
2edff64
Extract PanelContext class
backspace Jun 17, 2024
c8104f4
Fix collapsing
backspace Jun 17, 2024
029d09b
Rename properties for orientation-agnosticism
backspace Jun 17, 2024
4adbc1f
Move properties together
backspace Jun 17, 2024
0839bda
Remove intermediate context class
backspace Jun 17, 2024
3e3d0d9
Move toggle beneath panel group
backspace Jun 18, 2024
3df4912
Rename handle file and class
backspace Jun 18, 2024
3279eed
Add note for future examination
backspace Jun 18, 2024
60526a9
Rename handle property
backspace Jun 18, 2024
69fba88
Remove non-existent class
backspace Jun 18, 2024
acc8717
Fix renamed imports
backspace Jun 18, 2024
45ad3ca
Fix calculation of width without handles
backspace Jun 18, 2024
aa49370
Add more logging
backspace Jun 18, 2024
a50c1ef
Move ratio into panel
backspace Jun 18, 2024
fef1eab
Fix mapping of new panel lengths to panels
backspace Jun 18, 2024
a1c47dc
Update names of inline functions
backspace Jun 18, 2024
6e311e6
Remove outdated comment
backspace Jun 18, 2024
5a5cc4e
Fix yielded handle types
backspace Jun 18, 2024
ae1de1a
Change more handle property names
backspace Jun 18, 2024
1c6edbc
Remove unused element
backspace Jun 18, 2024
43976df
Remove and update more handle interface
backspace Jun 18, 2024
504cae8
Fix handle yielded properties
backspace Jun 18, 2024
569bf57
Fix type
backspace Jun 18, 2024
0ef2116
Remove unused attributes
backspace Jun 18, 2024
925d104
Remove unused constant
backspace Jun 18, 2024
59f1db7
Change CSS class name
backspace Jun 18, 2024
75c812f
Remove unused import
backspace Jun 18, 2024
b937a7d
Restore test selector
backspace Jun 18, 2024
55d833f
Change name of change notification handler
backspace Jun 18, 2024
19470b4
Remove unused properties
backspace Jun 18, 2024
f75cccd
Remove outdated note
backspace Jun 18, 2024
3435902
Fix function name
backspace Jun 18, 2024
d1d0140
Remove incorrect underscore
backspace Jun 18, 2024
423029a
Remove unused bound argument
backspace Jun 18, 2024
aa7a54c
Change property name for clarity
backspace Jun 18, 2024
11da5b1
Extract repeated calculation
backspace Jun 18, 2024
fca4dec
Remove optionality
backspace Jun 19, 2024
7907fe9
Fix name of resize event handler
backspace Jun 19, 2024
e5d1627
Revert "Remove optionality"
backspace Jun 19, 2024
5c6330a
Fix types for lack of optionality
backspace Jun 19, 2024
b98b7cc
Remove some notes
backspace Jun 19, 2024
a38bcdb
Remove skipped test
backspace Jun 19, 2024
ea04ed7
Change for to forEach
backspace Jun 19, 2024
71fbf3e
Remove logging
backspace Jun 19, 2024
83e9f77
Fix variable names
backspace Jun 19, 2024
893d5c6
Remove unused addon
backspace Jun 19, 2024
3e1d47a
Remove usage changes
backspace Jun 19, 2024
453c095
Add documentation of @isHidden
backspace Jun 19, 2024
2924106
Remove unused getters
backspace Jun 19, 2024
0adb2b0
Add clarification to warning
backspace Jun 19, 2024
945bdab
Add empty commit
backspace Jun 19, 2024
1377827
Extract shared tests
backspace Jun 20, 2024
f6d25e4
Change name of delay function for clarity
backspace Jun 20, 2024
16dac59
Fix warnings about dynamic styles
backspace Jun 20, 2024
6fd71c7
Remove redundancy in test template
backspace Jun 20, 2024
c7eaf86
Remove unused import
backspace Jun 20, 2024
a6723eb
Remove unnecessary length variation
backspace Jun 20, 2024
c613212
Change style property orders to be consistent
backspace Jun 20, 2024
da5bf87
Fix indentation
backspace Jun 20, 2024
471363e
Change to use data selector instead of class
backspace Jun 20, 2024
51ef6ed
Extract shared container styles
backspace Jun 20, 2024
f202bab
Remove extraneous container styles
backspace Jun 20, 2024
f9cd49e
Remove unused style property
backspace Jun 20, 2024
f73318b
Remove redundant comments
backspace Jun 20, 2024
cab6ad7
Remove redundant test
backspace Jun 20, 2024
3c5cdac
Extract length of resize handle
backspace Jun 21, 2024
3f48baf
Extract minimim length variable
backspace Jun 21, 2024
6dc6c9f
Merge branch 'main' into ui/resizable-collapse-cs-6940
backspace Jun 21, 2024
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
1 change: 0 additions & 1 deletion packages/boxel-ui/addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"ember-load-initializers": "^2.1.2",
"ember-modifier": "^4.1.0",
"ember-power-select": "^8.0.0",
"ember-ref-bucket": "5.0.5",
"ember-resize-modifier": "^0.6.0",
"ember-set-body-class": "^1.0.2",
"ember-sortable": "^5.0.2",
Expand Down
2 changes: 0 additions & 2 deletions packages/boxel-ui/addon/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import ResizablePanelGroup, {
ResizablePanel,
ResizeHandle,
} from './components/resizable-panel-group/index.gts';
import type { PanelContext } from './components/resizable-panel-group/panel.gts';
import BoxelSelect from './components/select/index.gts';
import Tooltip from './components/tooltip/index.gts';

Expand Down Expand Up @@ -58,7 +57,6 @@ export {
Menu,
Message,
Modal,
PanelContext,
RadioInput,
ResizablePanel,
ResizablePanelGroup,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
import { registerDestructor } from '@ember/destroyable';
import { on } from '@ember/modifier';
import { action } from '@ember/object';
import { scheduleOnce } from '@ember/runloop';
import Component from '@glimmer/component';
import { modifier } from 'ember-modifier';

import type ResizablePanelGroup from './index.gts';

interface Signature {
Args: {
hide: boolean;
onDoubleClick: (event: MouseEvent) => void;
onMouseDown: (event: MouseEvent) => void;
orientation: 'horizontal' | 'vertical';
panelGroupComponent: ResizablePanelGroup;
registerHandle: (handle: Handle) => void;
reverseArrow: boolean;
unregisterHandle: (handle: Handle) => void;
};
Blocks: {
default: [];
};
Element: HTMLDivElement;
}

let registerHandle = modifier((element, [handle]: [Handle]) => {
handle.element = element as HTMLDivElement;
scheduleOnce('afterRender', handle, handle.registerHandle);
});

export default class Handle extends Component<Signature> {
<template>
<div
class='separator-{{@orientation}}'
{{registerHandle this}}
...attributes
>
<button
class='resize-handle {{@orientation}} {{if @hide "hidden"}}'
aria-label='Resize handle'
{{on 'mousedown' @onMouseDown}}
{{on 'dblclick' @onDoubleClick}}
data-test-resize-handle
><div class={{this.arrowResizeHandleClass}} /></button>
</div>
<style>
.separator-horizontal {
display: flex;
align-items: center;
--boxel-panel-resize-handle-height: 100px;
--boxel-panel-resize-handle-width: 5px;
--boxel-panel-resize-handle-background-color: var(--boxel-450);
--boxel-panel-resize-handle-hover-background-color: var(
--boxel-highlight
);

padding: var(--boxel-sp-xxxs);
}

.separator-vertical {
display: flex;
justify-content: center;
--boxel-panel-resize-handle-width: 100px;
--boxel-panel-resize-handle-height: 5px;
--boxel-panel-resize-handle-background-color: var(--boxel-450);
--boxel-panel-resize-handle-hover-background-color: var(
--boxel-highlight
);

padding: var(--boxel-sp-xxxs);
}

.resize-handle {
width: var(--boxel-panel-resize-handle-width);
height: var(--boxel-panel-resize-handle-height);

border: none;
border-radius: var(--boxel-border-radius-xl);
padding: 0;
background-color: var(--boxel-panel-resize-handle-background-color);

position: relative;
}

.resize-handle:hover {
background-color: var(
--boxel-panel-resize-handle-hover-background-color
);
}

.resize-handle.horizontal {
cursor: col-resize;
}

.resize-handle.vertical {
cursor: row-resize;
}

.resize-handle.hidden {
visibility: hidden;
}

.arrow {
content: '';
position: absolute;
width: 0;
height: 0;
pointer-events: none;
}

.arrow.right {
top: 50%;
right: calc(var(--boxel-panel-resize-handle-width) * -1);
transform: translateY(-50%);
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 10px solid
var(--boxel-panel-resize-handle-background-color);
}

.resize-handle:hover .arrow.right {
border-left-color: var(
--boxel-panel-resize-handle-hover-background-color
);
}

.arrow.left {
top: 50%;
left: calc(var(--boxel-panel-resize-handle-width) * -1);
transform: translateY(-50%);
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-right: 10px solid
var(--boxel-panel-resize-handle-background-color);
}

.resize-handle:hover .arrow.left {
border-right-color: var(
--boxel-panel-resize-handle-hover-background-color
);
}

.arrow.top {
left: 50%;
top: calc(var(--boxel-panel-resize-handle-height) * -1);
transform: translateX(-50%);
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 10px solid
var(--boxel-panel-resize-handle-background-color);
}

.resize-handle:hover .arrow.top {
border-bottom-color: var(
--boxel-panel-resize-handle-hover-background-color
);
}

.arrow.bottom {
left: 50%;
bottom: calc(var(--boxel-panel-resize-handle-height) * -1);
transform: translateX(-50%);
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 10px solid var(--boxel-panel-resize-handle-background-color);
}

.resize-handle:hover .arrow.bottom {
border-top-color: var(
--boxel-panel-resize-handle-hover-background-color
);
}
</style>
</template>

element!: HTMLDivElement;

constructor(owner: any, args: any) {
super(owner, args);

registerDestructor(this, this.args.unregisterHandle);
}

@action registerHandle() {
this.args.registerHandle(this);
}

get arrowResizeHandleClass() {
let horizontal = this.args.orientation === 'horizontal';
let reverse = this.args.reverseArrow;

let myIndex = this.args.panelGroupComponent.resizeHandles.indexOf(this);

if (myIndex == undefined) {
return '';
}

let toward: string | null = null;

let groupComponent = this.args.panelGroupComponent;

let isFirstPanel = myIndex === 0;
let isCollapsed = groupComponent.panels[myIndex]?.lengthPx === 0;

let nextPanelIsLast = groupComponent.resizeHandles.length - 1 === myIndex;
let nextPanelIsCollapsed =
groupComponent.panels[myIndex + 1]?.lengthPx === 0;

if (isFirstPanel && !isCollapsed) {
if (nextPanelIsLast && nextPanelIsCollapsed) {
toward = reverse ? 'beginning' : 'end';
} else {
toward = reverse ? 'end' : 'beginning';
}
} else if (nextPanelIsLast || (isFirstPanel && isCollapsed)) {
if (nextPanelIsCollapsed) {
toward = 'beginning';
} else {
toward = reverse ? 'beginning' : 'end';
}
}

if (toward) {
if (toward === 'beginning') {
return horizontal ? 'arrow left' : 'arrow top';
} else {
return horizontal ? 'arrow right' : 'arrow bottom';
}
} else {
return '';
}
}
}
Loading