Skip to content

Commit 7c7c441

Browse files
committed
feat: add empty search and no events messages components to enhance user feedback on events page
1 parent 21bff5c commit 7c7c441

File tree

2 files changed

+101
-26
lines changed

2 files changed

+101
-26
lines changed

src/app/components/message.ts

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,81 @@ import { MessageModule } from 'primeng/message';
33

44
@Component({
55
selector: 'app-message',
6-
template: `
7-
<p-message
8-
[severity]="severity()"
9-
[text]="title()"
10-
/>
11-
`,
6+
template: ` <p-message [severity]="severity()" [text]="title()" /> `,
127
imports: [MessageModule],
138
})
149
export class Message {
1510
title = input.required<string>();
1611
severity = input.required<string>();
1712
}
13+
14+
@Component({
15+
selector: 'app-empty-search-message',
16+
template: `
17+
<div
18+
class="flex flex-col items-center justify-center py-12 px-6 text-center max-w-md mx-auto"
19+
>
20+
<div class="w-16 h-16 mb-4 text-gray-400">
21+
<svg
22+
viewBox="0 0 24 24"
23+
fill="none"
24+
stroke="currentColor"
25+
stroke-width="2"
26+
stroke-linecap="round"
27+
stroke-linejoin="round"
28+
>
29+
<circle cx="11" cy="11" r="8"></circle>
30+
<path d="m21 21-4.35-4.35"></path>
31+
<path d="M16 11a5 5 0 1 1-10 0 5 5 0 0 1 10 0z"></path>
32+
</svg>
33+
</div>
34+
<h3 class="text-lg font-semibold text-gray-800 mb-2">{{ title() }}</h3>
35+
<p class="text-gray-600 mb-4">{{ description() }}</p>
36+
<div class="flex flex-col sm:flex-row gap-2 text-sm text-gray-500">
37+
<span>Try adjusting your search terms</span>
38+
<span class="hidden sm:inline">•</span>
39+
<span>or browse all events above</span>
40+
</div>
41+
</div>
42+
`,
43+
standalone: true,
44+
})
45+
export class EmptySearchMessage {
46+
title = input.required<string>();
47+
description = input.required<string>();
48+
}
49+
50+
@Component({
51+
selector: 'app-no-events-message',
52+
template: `
53+
<div
54+
class="flex flex-col items-center justify-center py-16 px-6 text-center max-w-md mx-auto"
55+
>
56+
<div class="w-20 h-20 mb-4 text-gray-400">
57+
<svg
58+
viewBox="0 0 24 24"
59+
fill="none"
60+
stroke="currentColor"
61+
stroke-width="2"
62+
stroke-linecap="round"
63+
stroke-linejoin="round"
64+
>
65+
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
66+
<line x1="16" y1="2" x2="16" y2="6"></line>
67+
<line x1="8" y1="2" x2="8" y2="6"></line>
68+
<line x1="3" y1="10" x2="21" y2="10"></line>
69+
</svg>
70+
</div>
71+
<h3 class="text-lg font-semibold text-gray-800 mb-2">{{ title() }}</h3>
72+
<p class="text-gray-600 mb-4">{{ description() }}</p>
73+
<div class="text-sm text-gray-500">
74+
<span>Check back soon for upcoming Angular events!</span>
75+
</div>
76+
</div>
77+
`,
78+
standalone: true,
79+
})
80+
export class NoEventsMessage {
81+
title = input.required<string>();
82+
description = input.required<string>();
83+
}

src/app/pages/events-page.ts

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import {
88
import { Title } from '@angular/platform-browser';
99
import { ButtonModule } from 'primeng/button';
1010
import { MessageModule } from 'primeng/message';
11-
import { Message } from '../components/message';
11+
import {
12+
Message,
13+
EmptySearchMessage,
14+
NoEventsMessage,
15+
} from '../components/message';
1216
import { JsonLdService } from '../services/json-ld.service';
1317
import { HttpClient, httpResource } from '@angular/common/http';
1418
import { EventCard } from '../components/cards/event-card';
@@ -54,30 +58,27 @@ export const routeMeta = {
5458
}
5559
</ul>
5660
57-
<!-- TODO create custom message UI -->
58-
@if (search().length && !filteredEvents()?.length) {
59-
<app-message
60-
[title]="
61-
'No event found with these criteria, update or reset the filters'
61+
<!-- Show message when search has no results -->
62+
@if (
63+
search().length && !filteredEvents().length && events().length > 0
64+
) {
65+
<app-empty-search-message
66+
[title]="'No events found'"
67+
[description]="
68+
'We could not find any events matching your search criteria. Try different keywords or browse all available events.'
6269
"
63-
severity="warn"
6470
/>
6571
}
6672
67-
<!-- TODO create custom message UI -->
68-
@if (!filteredEvents()?.length) {
69-
<app-message
70-
[title]="'No upcoming event tracked, see you later!'"
71-
severity="warn"
73+
<!-- Show message when there are no events at all -->
74+
@if (!events().length) {
75+
<app-no-events-message
76+
[title]="'No upcoming events'"
77+
[description]="
78+
'There are currently no upcoming Angular events scheduled. New events are added regularly, so please check back soon!'
79+
"
7280
/>
7381
}
74-
75-
@if (filteredEvents()?.length) {
76-
<p class="text-sm text-gray-500 mt-4 ml-4">
77-
* Prices are updated manually, check the event website for the most
78-
accurate information.
79-
</p>
80-
}
8182
</section>
8283
`,
8384
styles: [
@@ -89,7 +90,15 @@ export const routeMeta = {
8990
}
9091
`,
9192
],
92-
imports: [ButtonModule, MessageModule, EventCard, Message, FormsModule],
93+
imports: [
94+
ButtonModule,
95+
MessageModule,
96+
EventCard,
97+
Message,
98+
EmptySearchMessage,
99+
NoEventsMessage,
100+
FormsModule,
101+
],
93102
changeDetection: ChangeDetectionStrategy.OnPush,
94103
})
95104
export default class EventsPage {

0 commit comments

Comments
 (0)