Skip to content

Commit 9bcef87

Browse files
committed
refactor(test-results-bar): improve resize handling and styling
Update resizing logic to enforce min and max height constraints for the test results bar to enhance usability and prevent it from collapsing too small or expanding beyond the viewport. Replace usage of htmlSafe on height strings with safer style handling and introduce a computed containerStyle property to centralize inline style logic. Adjust component classes to add rounded corners when expanded for a better visual appearance and simplify container width classes for clarity.
1 parent 6ea5cca commit 9bcef87

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

app/components/course-page/test-results-bar/index.hbs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div
2-
class="bg-gray-900 border-t border-gray-800 dark flex flex-col items-center"
3-
style={{if this.isExpanded this.customHeight}}
2+
class="bg-gray-900 border-t border-gray-800 dark flex flex-col items-center {{if this.isExpanded 'rounded-t-lg'}}"
3+
style={{this.containerStyle}}
44
data-test-test-results-bar
55
...attributes
66
>
@@ -17,10 +17,7 @@
1717
</div>
1818
{{/if}}
1919

20-
<div
21-
class="relative w-full max-w-(--breakpoint-lg) xl:max-w-(--breakpoint-xl) flex flex-col grow overflow-auto {{unless this.isExpanded 'h-0'}}"
22-
data-test-contents
23-
>
20+
<div class="relative w-full flex flex-col grow overflow-auto {{unless this.isExpanded 'h-0'}}" data-test-contents>
2421
{{#if this.isExpanded}}
2522
<CoursePage::TestResultsBar::TopSection
2623
@onCollapseButtonClick={{this.handleCollapseButtonClick}}

app/components/course-page/test-results-bar/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class TestResultsBar extends Component<Signature> {
2424
@service declare coursePageState: CoursePageStateService;
2525
@service declare authenticator: AuthenticatorService;
2626
@tracked activeTabSlug = 'logs'; // 'logs' | 'autofix'
27-
@tracked customHeight = htmlSafe('height: 75vh');
27+
@tracked customHeight = '75vh';
2828

2929
get availableTabSlugs() {
3030
if (this.args.activeStep.type === 'CourseStageStep') {
@@ -44,6 +44,14 @@ export default class TestResultsBar extends Component<Signature> {
4444
}
4545
}
4646

47+
get containerStyle() {
48+
if (this.isExpanded) {
49+
return htmlSafe(`height: ${this.customHeight}`);
50+
} else {
51+
return htmlSafe('height: auto');
52+
}
53+
}
54+
4755
get isCollapsed() {
4856
return !this.isExpanded;
4957
}
@@ -65,14 +73,14 @@ export default class TestResultsBar extends Component<Signature> {
6573
@action
6674
handleMouseResize(event: MouseEvent) {
6775
const newHeight = window.innerHeight - event.clientY;
68-
this.customHeight = htmlSafe(`height: min(100vh, ${newHeight}px)`);
76+
this.customHeight = `max(250px, min(calc(100vh - 20px), ${newHeight}px))`;
6977
}
7078

7179
@action
7280
handleTouchResize(event: TouchEvent) {
7381
const touch = event.touches[0] as Touch;
7482
const newHeight = window.innerHeight - touch.clientY;
75-
this.customHeight = htmlSafe(`height: ${newHeight}px`);
83+
this.customHeight = `max(250px, min(calc(100vh - 20px), ${newHeight}px))`;
7684
}
7785

7886
@action

0 commit comments

Comments
 (0)