UX: Render invitees count (#663)

This commit is contained in:
Jordan Vidrine 2024-12-05 16:22:09 -06:00 committed by GitHub
parent 9dd361fbaa
commit d967cb18f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 53 deletions

View File

@ -1,78 +1,38 @@
import Component from "@glimmer/component";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DButton from "discourse/components/d-button";
import icon from "discourse-common/helpers/d-icon";
import i18n from "discourse-common/helpers/i18n";
import PostEventInvitees from "../modal/post-event-invitees";
import Invitee from "./invitee";
export default class DiscoursePostEventInvitees extends Component {
@service modal;
@service siteSettings;
@action
showAllInvitees() {
this.modal.show(PostEventInvitees, {
model: {
event: this.args.event,
title: this.args.event.title,
extraClass: this.args.event.extraClass,
},
});
get hasAttendees() {
return this.args.event.stats.going > 0;
}
get statsInfo() {
const stats = [];
const visibleStats = this.siteSettings.event_participation_buttons
.split("|")
.filter(Boolean);
return this.args.event.stats.going;
}
if (this.args.event.isPrivate) {
visibleStats.push("invited");
}
visibleStats.forEach((button) => {
const localeKey = button.replace(" ", "_");
if (button === "not_going") {
button = "notGoing";
}
const count = this.args.event.stats[button] || 0;
const label = i18n(
`discourse_post_event.models.invitee.status.${localeKey}_count`,
{ count }
);
stats.push({
class: `event-status-${localeKey}`,
label,
});
get inviteesTitle() {
return i18n("discourse_post_event.models.invitee.status.going_count", {
count: this.args.event.stats.going,
});
return stats;
}
<template>
{{#unless @event.minimal}}
{{#if @event.shouldDisplayInvitees}}
<section class="event__section event-invitees">
<div class="header">
<div class="event-invitees-status">
{{#each this.statsInfo as |info|}}
<span class={{info.class}}>{{info.label}}</span>
{{/each}}
</div>
<DButton
class="show-all btn-small"
@label="discourse_post_event.show_all"
@action={{this.showAllInvitees}}
/>
</div>
<div class="event-invitees-avatars-container">
{{icon "users"}}
<div class="event-invitees-icon" title={{this.inviteesTitle}}>
{{icon "users"}}
{{#if this.hasAttendees}}
<span class="going">{{this.statsInfo}}</span>
{{/if}}
</div>
<ul class="event-invitees-avatars">
{{#each @event.sampleInvitees as |invitee|}}
<Invitee @invitee={{invitee}} />

View File

@ -401,4 +401,20 @@ $show-interested: inherit;
font-weight: 400;
grid-column-start: 2;
}
.event-invitees-icon {
position: relative;
display: flex;
}
.event-invitees-icon .going {
font-size: var(--font-down-3);
position: absolute;
right: 4px;
bottom: -8px;
background: var(--secondary);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: var(--primary-medium);
}
}