Skip to content

Commit 3ccae10

Browse files
authored
Implement responsive design for question page (#94)
* Replace panel with PrimeNG sidebar to make it responsive * Make questions table responsive * Add min width to ensure the contents don't collapse on each other * Reduce margins on smaller screen
1 parent d4439c9 commit 3ccae10

File tree

3 files changed

+19
-40
lines changed

3 files changed

+19
-40
lines changed

frontend/src/app/questions/questions.component.css

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,7 @@
66
background-color: #181818 !important;
77
}
88

9-
.sliding-panel {
10-
position: fixed;
11-
top: 0;
12-
right: -600px; /* Adjust the width as needed */
13-
width: 600px;
14-
height: 100%;
15-
background-color: #181818 !important;
16-
color: var(--text-color); /* Use theme variable */
17-
box-shadow: -2px 0 5px rgba(0,0,0,0.5);
18-
transition: right 0.3s ease;
19-
z-index: 1000;
20-
}
21-
22-
.sliding-panel.open {
23-
right: 0;
24-
}
25-
26-
.panel-header {
27-
display: flex;
28-
justify-content: space-between;
29-
align-items: center;
30-
padding: 1rem;
31-
background-color: #181818 !important;
32-
border-bottom: 1px solid #000000; /* Use theme variable */
33-
}
34-
359
.panel-content {
36-
padding: 1rem;
3710
line-height: 1.6; /* Adjust line height for better readability */
3811
color: #ffffff; /* Ensure text color is readable */
3912
}

frontend/src/app/questions/questions.component.html

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="card mx-8">
1+
<div class="card mx-3 md:mx-8">
22
@if (loading) {
33
<p-progressSpinner
44
class="flex align-items-center justify-content-center h-screen"
@@ -41,7 +41,12 @@
4141
[value]="questions"
4242
[(selection)]="selectedQuestions"
4343
datakey="id"
44-
[tableStyle]="{ 'table-layout': 'fixed', width: '100%', 'text-align': 'center' }"
44+
[tableStyle]="{
45+
'table-layout': 'fixed',
46+
width: '100%',
47+
'min-width': '50rem',
48+
'text-align': 'center',
49+
}"
4550
[paginator]="true"
4651
[rows]="10"
4752
[rowsPerPageOptions]="[10, 25, 50]"
@@ -108,18 +113,17 @@ <h3 class="m-0">Questions</h3>
108113
(successfulRequest)="onSuccessfulRequest($event)">
109114
</app-question-dialog>
110115
<p-confirmDialog [style]="{ width: '450px' }" />
111-
<div class="sliding-panel" [class.open]="isPanelVisible">
112-
<div class="panel-header">
113-
<h4>{{ clickedOnQuestion?.title }}</h4>
114-
<p-button
115-
icon="pi pi-times"
116-
severity="secondary"
117-
label="Close"
118-
(onClick)="closePanel()"
119-
class="p-button-text" />
120-
</div>
116+
<p-sidebar
117+
[(visible)]="isPanelVisible"
118+
position="right"
119+
[blockScroll]="true"
120+
styleClass="w-10 md:w-4"
121+
transitionOptions="300ms cubic-bezier(0, 0, 0.2, 1)">
122+
<ng-template pTemplate="header">
123+
<h3>{{ clickedOnQuestion?.title }}</h3>
124+
</ng-template>
121125
<div class="panel-content">
122126
<p style="white-space: pre-wrap">{{ clickedOnQuestion?.description }}</p>
123127
</div>
124-
</div>
128+
</p-sidebar>
125129
</div>

frontend/src/app/questions/questions.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { MultiSelectModule } from 'primeng/multiselect';
1212
import { ReactiveFormsModule } from '@angular/forms';
1313
import { DropdownModule } from 'primeng/dropdown';
1414
import { ProgressSpinnerModule } from 'primeng/progressspinner';
15+
import { SidebarModule } from 'primeng/sidebar';
1516
import { Question } from './question.model';
1617
import { QuestionService } from '../../_services/question.service';
1718
import { HttpErrorResponse } from '@angular/common/http';
@@ -26,6 +27,7 @@ import { User } from '../../_models/user.model';
2627
imports: [
2728
TableModule,
2829
NgFor,
30+
SidebarModule,
2931
CommonModule,
3032
FormsModule,
3133
ToastModule,

0 commit comments

Comments
 (0)