Skip to content

Commit c50739c

Browse files
committed
feat: add empty search message component
1 parent eebf8f9 commit c50739c

File tree

3 files changed

+62
-10
lines changed

3 files changed

+62
-10
lines changed

src/app/components/message.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,39 @@ export class NoEventsMessage {
8181
title = input.required<string>();
8282
description = input.required<string>();
8383
}
84+
85+
@Component({
86+
selector: 'app-empty-search-communities-message',
87+
template: `
88+
<div
89+
class="flex flex-col items-center justify-center py-12 px-6 text-center max-w-md mx-auto"
90+
>
91+
<div class="w-16 h-16 mb-4 text-gray-400">
92+
<svg
93+
viewBox="0 0 24 24"
94+
fill="none"
95+
stroke="currentColor"
96+
stroke-width="2"
97+
stroke-linecap="round"
98+
stroke-linejoin="round"
99+
>
100+
<circle cx="11" cy="11" r="8"></circle>
101+
<path d="m21 21-4.35-4.35"></path>
102+
<path d="M16 11a5 5 0 1 1-10 0 5 5 0 0 1 10 0z"></path>
103+
</svg>
104+
</div>
105+
<h3 class="text-lg font-semibold text-gray-800 mb-2">{{ title() }}</h3>
106+
<p class="text-gray-600 mb-4">{{ description() }}</p>
107+
<div class="flex flex-col sm:flex-row gap-2 text-sm text-gray-500">
108+
<span>Try adjusting your search terms</span>
109+
<span class="hidden sm:inline">•</span>
110+
<span>or browse all communities above</span>
111+
</div>
112+
</div>
113+
`,
114+
standalone: true,
115+
})
116+
export class EmptySearchCommunitiesMessage {
117+
title = input.required<string>();
118+
description = input.required<string>();
119+
}

src/app/pages/communities-page.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { FormsModule } from '@angular/forms';
66
import { Community } from '../../models/community.model';
77
import { toSignal } from '@angular/core/rxjs-interop';
88
import { HttpClient } from '@angular/common/http';
9+
import { EmptySearchCommunitiesMessage } from '../components/message';
910

1011
export const routeMeta = {
1112
meta: [
@@ -17,7 +18,7 @@ export const routeMeta = {
1718
};
1819

1920
@Component({
20-
imports: [CommunityCard, FormsModule],
21+
imports: [CommunityCard, FormsModule, EmptySearchCommunitiesMessage],
2122
template: `
2223
<section class="max-w-screen-xl mx-auto px-6">
2324
<input
@@ -26,13 +27,29 @@ export const routeMeta = {
2627
placeholder="Search communities"
2728
[(ngModel)]="search"
2829
/>
29-
<ul class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6 mt-6">
30-
@for (community of filteredCommunities(); track community) {
31-
<li>
32-
<app-community-card class="h-full" [community]="community" />
33-
</li>
34-
}
35-
</ul>
30+
@if (filteredCommunities().length) {
31+
<ul class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6 mt-6">
32+
@for (community of filteredCommunities(); track community) {
33+
<li>
34+
<app-community-card class="h-full" [community]="community" />
35+
</li>
36+
}
37+
</ul>
38+
}
39+
40+
<!-- Show message when search has no results -->
41+
@if (
42+
search().length &&
43+
!filteredCommunities().length &&
44+
communities().length > 0
45+
) {
46+
<app-empty-search-communities-message
47+
[title]="'No communities found'"
48+
[description]="
49+
'We could not find any communities matching your search criteria. Try different keywords or browse all available communities.'
50+
"
51+
/>
52+
}
3653
</section>
3754
`,
3855
})

src/server-elysia.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ export function app() {
6767
try {
6868
// parse(CommunityListSchema, communities);
6969
return (organizers as Community[]).filter(
70-
(community) =>
71-
community.type !== 'workshop' && community.type !== 'other',
70+
(community) => community.type === 'angular-community',
7271
);
7372
} catch (error) {
7473
throw new Error('Invalid community data format');

0 commit comments

Comments
 (0)