Redesign Premades member list as avatar chips with a crown for the lead
Replaces the plain bordered-row list with pill-shaped chips (avatar +
name), matching the site's avatar system - shows a member's real
uploaded picture when they're a linked website account, otherwise the
usual letter placeholder. The lead now appears as a chip too (previously
only shown via a header badge) with a gold-tinted border and a crown
icon; pending invites get a dashed border. Dropped the now-redundant
"👑 owner" header badge since the lead's chip covers that.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
357ff7eb1e
commit
fc0ba31ea2
3 changed files with 79 additions and 24 deletions
|
|
@ -782,24 +782,48 @@ input:focus, select:focus, textarea:focus {
|
|||
|
||||
.raid-premade-row select { width: auto; }
|
||||
|
||||
.premade-member-list {
|
||||
list-style: none;
|
||||
.premade-members {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin: 0.75rem 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.premade-member-list li {
|
||||
.premade-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
padding: 0.4rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 0.3rem 0.65rem 0.3rem 0.3rem;
|
||||
background: var(--bg-panel-alt);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.premade-member-list li:last-child { border-bottom: none; }
|
||||
.premade-chip-lead {
|
||||
border-color: var(--gold);
|
||||
background: rgba(201, 162, 39, 0.12);
|
||||
}
|
||||
|
||||
.premade-member-pending { color: var(--text-muted); }
|
||||
.premade-chip-pending {
|
||||
border-style: dashed;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.premade-crown {
|
||||
display: inline-flex;
|
||||
color: var(--gold);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.premade-crown .icon { width: 15px; height: 15px; }
|
||||
|
||||
.premade-chip .icon-button {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin-left: 0.1rem;
|
||||
}
|
||||
|
||||
.premade-chip .icon-button .icon { width: 13px; height: 13px; }
|
||||
|
||||
.premade-invite-row {
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ function icon(string $name): string
|
|||
'archive' => '<polyline points="21 8 21 21 3 21 3 8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/>',
|
||||
'restore' => '<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>',
|
||||
'trash' => '<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/>',
|
||||
'crown' => '<path d="M4 8l4 3 4-6 4 6 4-3-2 9H6z"/><path d="M6 20h12"/>',
|
||||
];
|
||||
|
||||
$path = $paths[$name] ?? '';
|
||||
|
|
|
|||
60
premades.php
60
premades.php
|
|
@ -27,13 +27,15 @@ foreach ($premades as $p) {
|
|||
$allDiscordIds = array_values(array_unique(array_filter($allDiscordIds)));
|
||||
|
||||
$namesByDiscordId = [];
|
||||
$linkedUsersByDiscordId = [];
|
||||
if (!empty($allDiscordIds)) {
|
||||
$placeholders = implode(',', array_fill(0, count($allDiscordIds), '?'));
|
||||
$stmt = db()->prepare("SELECT discord_id, discord_username, display_name FROM users WHERE discord_id IN ($placeholders)");
|
||||
$stmt = db()->prepare("SELECT id, discord_id, discord_username, display_name, avatar_filename FROM users WHERE discord_id IN ($placeholders)");
|
||||
$stmt->execute($allDiscordIds);
|
||||
foreach ($stmt->fetchAll() as $row) {
|
||||
$name = $row['display_name'] !== '' ? $row['display_name'] : $row['discord_username'];
|
||||
$namesByDiscordId[(int) $row['discord_id']] = $name;
|
||||
$linkedUsersByDiscordId[(int) $row['discord_id']] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +50,17 @@ function premade_name_for(int $discordId, array $namesByDiscordId, ?string $apiN
|
|||
return $namesByDiscordId[$discordId] ?? ('Discord-Nutzer ' . $discordId);
|
||||
}
|
||||
|
||||
// Baut ein fuer avatar_html() nutzbares Nutzer-Array: das echte, hochgeladene Profilbild,
|
||||
// falls die Discord-ID zu einem verknuepften Website-Account gehoert, sonst ein Platzhalter
|
||||
// mit dem Anfangsbuchstaben des (von der API aufgeloesten) Namens.
|
||||
function premade_avatar_user(int $discordId, array $linkedUsersByDiscordId, string $displayName): array
|
||||
{
|
||||
if (isset($linkedUsersByDiscordId[$discordId])) {
|
||||
return $linkedUsersByDiscordId[$discordId];
|
||||
}
|
||||
return ['id' => $discordId, 'display_name' => $displayName, 'username' => $displayName, 'avatar_filename' => null];
|
||||
}
|
||||
|
||||
$myRelation = $discordId ? find_my_premade($premades, $discordId) : null;
|
||||
$myPendingInvites = $discordId ? find_my_pending_invites($premades, $discordId) : [];
|
||||
|
||||
|
|
@ -147,44 +160,61 @@ include __DIR__ . '/includes/header.php';
|
|||
<div class="raid-header">
|
||||
<h2>⚔️ <?= e($premadeName) ?></h2>
|
||||
<div class="badge-group">
|
||||
<span class="badge">👑 <?= e(premade_name_for($ownerId, $namesByDiscordId, $premade['owner_name'] ?? null)) ?></span>
|
||||
<span class="badge"><?= count($accepted) + 1 ?> Mitglieder</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="premade-member-list">
|
||||
<div class="premade-members">
|
||||
<?php
|
||||
$ownerName = premade_name_for($ownerId, $namesByDiscordId, $premade['owner_name'] ?? null);
|
||||
$ownerAvatarUser = premade_avatar_user($ownerId, $linkedUsersByDiscordId, $ownerName);
|
||||
?>
|
||||
<div class="premade-chip premade-chip-lead">
|
||||
<?= avatar_html($ownerAvatarUser, 28) ?>
|
||||
<span><?= e($ownerName) ?></span>
|
||||
<span class="premade-crown" title="Lead der Premade"><?= icon('crown') ?></span>
|
||||
</div>
|
||||
<?php foreach ($accepted as $member): ?>
|
||||
<li>
|
||||
<span><?= e(premade_name_for((int) ($member['user_id'] ?? 0), $namesByDiscordId, $member['name'] ?? null)) ?></span>
|
||||
<?php
|
||||
$memberId = (int) ($member['user_id'] ?? 0);
|
||||
$memberName = premade_name_for($memberId, $namesByDiscordId, $member['name'] ?? null);
|
||||
$memberAvatarUser = premade_avatar_user($memberId, $linkedUsersByDiscordId, $memberName);
|
||||
?>
|
||||
<div class="premade-chip">
|
||||
<?= avatar_html($memberAvatarUser, 28) ?>
|
||||
<span><?= e($memberName) ?></span>
|
||||
<?php if ($canManageThis): ?>
|
||||
<form method="post" action="/premade_action.php" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="remove_member">
|
||||
<input type="hidden" name="premade_id" value="<?= $premadeId ?>">
|
||||
<input type="hidden" name="user_id" value="<?= (int) ($member['user_id'] ?? 0) ?>">
|
||||
<input type="hidden" name="user_id" value="<?= $memberId ?>">
|
||||
<button type="submit" class="icon-button icon-button-danger" title="Aus der Premade entfernen"><?= icon('x') ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($pending as $member): ?>
|
||||
<li class="premade-member-pending">
|
||||
<span>⏳ <?= e(premade_name_for((int) ($member['user_id'] ?? 0), $namesByDiscordId, $member['name'] ?? null)) ?> <span class="text-muted">(Einladung offen)</span></span>
|
||||
<?php
|
||||
$memberId = (int) ($member['user_id'] ?? 0);
|
||||
$memberName = premade_name_for($memberId, $namesByDiscordId, $member['name'] ?? null);
|
||||
$memberAvatarUser = premade_avatar_user($memberId, $linkedUsersByDiscordId, $memberName);
|
||||
?>
|
||||
<div class="premade-chip premade-chip-pending" title="Einladung offen">
|
||||
<?= avatar_html($memberAvatarUser, 28) ?>
|
||||
<span>⏳ <?= e($memberName) ?></span>
|
||||
<?php if ($canManageThis): ?>
|
||||
<form method="post" action="/premade_action.php" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="remove_member">
|
||||
<input type="hidden" name="premade_id" value="<?= $premadeId ?>">
|
||||
<input type="hidden" name="user_id" value="<?= (int) ($member['user_id'] ?? 0) ?>">
|
||||
<input type="hidden" name="user_id" value="<?= $memberId ?>">
|
||||
<button type="submit" class="icon-button icon-button-danger" title="Einladung zurückziehen"><?= icon('x') ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($accepted) && empty($pending)): ?>
|
||||
<li class="text-muted">Noch keine weiteren Mitglieder.</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?php if ($canManageThis): ?>
|
||||
<div class="premade-manage">
|
||||
|
|
|
|||
Loading…
Reference in a new issue