-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b9cfff
commit 8a204db
Showing
19 changed files
with
1,015 additions
and
503 deletions.
There are no files selected for viewing
301 changes: 264 additions & 37 deletions
301
angular-hub/src/app/components/cards/community-card.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,287 @@ | ||
import { ChangeDetectionStrategy, Component, input } from '@angular/core'; | ||
import { NgOptimizedImage, TitleCasePipe } from '@angular/common'; | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
computed, | ||
input, | ||
} from '@angular/core'; | ||
import { DatePipe, NgOptimizedImage, TitleCasePipe } from '@angular/common'; | ||
import { Community } from '../../../models/community.model'; | ||
import community from '../../../server/routes/v1/community'; | ||
|
||
@Component({ | ||
selector: 'app-community-card', | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
imports: [NgOptimizedImage, TitleCasePipe], | ||
imports: [NgOptimizedImage, TitleCasePipe, DatePipe], | ||
template: ` | ||
<article> | ||
<a | ||
[href]="community().url ?? '#'" | ||
target="_blank" | ||
class="flex flex-col max-w-36 items-start gap-1" | ||
> | ||
<img | ||
class="rounded-xl" | ||
[src]="community().logo" | ||
height="200" | ||
width="200" | ||
alt="" | ||
/> | ||
<div class="text-start"> | ||
<span class="font-bold text-primary" itemprop="type">{{ | ||
community().type | titlecase | ||
}}</span> | ||
<h3 | ||
[attr.aria-labelledby]="community().name" | ||
class="text-xl font-bold" | ||
itemprop="title" | ||
> | ||
{{ community().name }} | ||
</h3> | ||
<span class="text-gray-500 dark:text-gray-400" itemprop="location">{{ | ||
community().location | ||
}}</span> | ||
<article | ||
class="flex items-start md:items-center gap-6 bg-[#20212C] px-6 pt-8 pb-4 rounded-xl relative" | ||
> | ||
<div class="absolute type"> | ||
<span | ||
class="font-medium text-sm text-black bg-slate-400 rounded p-1 mr-4" | ||
itemprop="type" | ||
>{{ community().type | titlecase }}</span | ||
> | ||
@if (upcomingEventLength() > 0) { | ||
<span | ||
class="font-medium text-sm text-black bg-green-100 rounded p-1" | ||
itemprop="type" | ||
> | ||
{{ upcomingEventLength() }} upcoming event(s) | ||
</span> | ||
} | ||
@if (inactive()) { | ||
<span | ||
class="font-medium text-sm text-black bg-orange-200 rounded p-1" | ||
itemprop="type" | ||
> | ||
inactive since {{ inactiveSince() | date: 'MMMM y' }} | ||
</span> | ||
} | ||
</div> | ||
<img | ||
class="rounded-xl" | ||
[src]="community().logo" | ||
height="60" | ||
width="60" | ||
alt="" | ||
/> | ||
<div class="flex-1"> | ||
<h3 class="text-xl font-bold" itemprop="title"> | ||
{{ community().name }} | ||
</h3> | ||
<span class="text-gray-500 dark:text-gray-400" itemprop="location">{{ | ||
community().location | ||
}}</span> | ||
<div class="flex md:hidden gap-4 mt-2"> | ||
@if (community().eventsUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().eventsUrl" | ||
target="_blank" | ||
title="events URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/event-icon.svg" | ||
alt="" | ||
height="24" | ||
width="24" | ||
/> | ||
</a> | ||
} | ||
@if (community().websiteUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().websiteUrl" | ||
target="_blank" | ||
title="website URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/website_link-icon.svg" | ||
alt="" | ||
height="24" | ||
width="24" | ||
/> | ||
</a> | ||
} | ||
@if (community().organizersUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().organizersUrl" | ||
target="_blank" | ||
title="organizers URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/group-icon.svg" | ||
alt="" | ||
height="24" | ||
width="24" | ||
/> | ||
</a> | ||
} | ||
@if (community().youtubeUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().youtubeUrl" | ||
target="_blank" | ||
title="YouTube URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/youtube-icon.svg" | ||
alt="" | ||
height="24" | ||
width="24" | ||
/> | ||
</a> | ||
} | ||
@if (community().twitterUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().twitterUrl" | ||
target="_blank" | ||
title="events URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/twitter-icon.svg" | ||
alt="" | ||
height="24" | ||
width="24" | ||
/> | ||
</a> | ||
} | ||
@if (community().linkedinUrl) { | ||
<a | ||
class="rounded-xl bg-[#6b6e92] p-2" | ||
[attr.href]="community().linkedinUrl" | ||
target="_blank" | ||
> | ||
<img | ||
ngSrc="/assets/icons/linkedin-icon.svg" | ||
alt="" | ||
height="24" | ||
width="24" | ||
/> | ||
</a> | ||
} | ||
</div> | ||
</a> | ||
</div> | ||
<div class="hidden md:flex gap-4 ml-6"> | ||
@if (community().eventsUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().eventsUrl" | ||
target="_blank" | ||
title="events URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/event-icon.svg" | ||
alt="" | ||
height="30" | ||
width="30" | ||
/> | ||
</a> | ||
} | ||
@if (community().websiteUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().websiteUrl" | ||
target="_blank" | ||
title="website URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/website_link-icon.svg" | ||
alt="" | ||
height="30" | ||
width="30" | ||
/> | ||
</a> | ||
} | ||
@if (community().organizersUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().organizersUrl" | ||
target="_blank" | ||
title="organizers URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/group-icon.svg" | ||
alt="" | ||
height="30" | ||
width="30" | ||
/> | ||
</a> | ||
} | ||
@if (community().youtubeUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().youtubeUrl" | ||
target="_blank" | ||
title="YouTube URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/youtube-icon.svg" | ||
alt="" | ||
height="30" | ||
width="30" | ||
/> | ||
</a> | ||
} | ||
@if (community().twitterUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().twitterUrl" | ||
target="_blank" | ||
title="Twitter URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/twitter-icon.svg" | ||
alt="" | ||
height="30" | ||
width="30" | ||
/> | ||
</a> | ||
} | ||
@if (community().linkedinUrl) { | ||
<a | ||
class="rounded-xl bg-[#344255] p-2" | ||
[attr.href]="community().linkedinUrl" | ||
target="_blank" | ||
title="LinkedIn URL" | ||
> | ||
<img | ||
ngSrc="/assets/icons/linkedin-icon.svg" | ||
alt="" | ||
height="30" | ||
width="30" | ||
/> | ||
</a> | ||
} | ||
</div> | ||
</article> | ||
`, | ||
styles: [ | ||
` | ||
:host { | ||
display: block; | ||
padding-block: 0.5rem; | ||
cursor: pointer; | ||
} | ||
&:hover { | ||
h3 { | ||
@apply text-secondary underline; | ||
} | ||
} | ||
.type { | ||
top: -0.7rem; | ||
left: 1.2rem; | ||
} | ||
`, | ||
], | ||
}) | ||
export class CommunityCardComponent { | ||
community = input.required<Community>(); | ||
|
||
upcomingEventLength = computed(() => { | ||
return this.community().events?.filter( | ||
(event) => new Date(event.date).getTime() > new Date().getTime(), | ||
).length; | ||
}); | ||
|
||
inactive = computed(() => { | ||
const inactivityLimit = new Date(); | ||
inactivityLimit.setMonth(inactivityLimit.getMonth() - 6); | ||
|
||
const newestEvent = this.community().events?.sort( | ||
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(), | ||
)[0]; | ||
|
||
return newestEvent | ||
? new Date(newestEvent.date).getTime() < inactivityLimit.getTime() && | ||
this.community().type === 'meetup' | ||
: false; | ||
}); | ||
|
||
inactiveSince = computed(() => { | ||
const event = this.community().events?.sort( | ||
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(), | ||
)[0]; | ||
|
||
return event ? new Date(event.date) : null; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
angular-hub/src/app/components/navigation/navigation.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.