Render country flags as images
This commit is contained in:
+24
-7
@@ -207,7 +207,7 @@ label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
.visitor-facts span {
|
||||
.visitor-facts > span {
|
||||
max-width: 96px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -326,12 +326,29 @@ label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
|
||||
border-color: #d9e6df;
|
||||
background: #fbfdfb;
|
||||
}
|
||||
.flag-emoji {
|
||||
font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
.country-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
}
|
||||
.country-code {
|
||||
.flag-image {
|
||||
width: 18px;
|
||||
height: 13px;
|
||||
flex: 0 0 auto;
|
||||
border-radius: 2px;
|
||||
background-color: #e4ebe6;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
box-shadow: 0 0 0 1px rgb(0 0 0 / 8%);
|
||||
}
|
||||
.country-badge.unknown .flag-image {
|
||||
width: auto;
|
||||
height: auto;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
.country-badge strong {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
line-height: 1;
|
||||
@@ -518,7 +535,7 @@ label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.visitor-compact-meta span {
|
||||
.visitor-compact-meta > span {
|
||||
flex: 0 0 auto;
|
||||
max-width: 72px;
|
||||
overflow: hidden;
|
||||
|
||||
+9
-4
@@ -380,7 +380,7 @@ function renderVisitors() {
|
||||
${presenceDot(visitor.presence)}
|
||||
</div>
|
||||
<div class="visitor-compact-meta">
|
||||
<span>${visitor.countryFlag || escapeHtml(visitor.countryCode || "?")}</span>
|
||||
<span>${visitorCountry(visitor)}</span>
|
||||
<span>${formatDuration(visitor.sessionSeconds)}</span>
|
||||
<span>${Number(visitor.visitCount || visitor.pageCount || 1)} navst.</span>
|
||||
<span>${Number(visitor.conversationCount || 0)} chaty</span>
|
||||
@@ -507,9 +507,14 @@ function statusButtons(item) {
|
||||
|
||||
function visitorCountry(item) {
|
||||
const countryCode = item.countryCode || countryFromLanguage(item.language) || countryFromTimezone(item.timezone);
|
||||
const countryFlag = item.countryFlag || flag(countryCode);
|
||||
if (!countryCode) return `<span class="flag-emoji" aria-hidden="true">?</span><strong class="country-code">?</strong>`;
|
||||
return `<span class="flag-emoji" aria-hidden="true">${countryFlag}</span><strong class="country-code">${escapeHtml(countryCode)}</strong>`;
|
||||
const code = String(countryCode || "").toUpperCase();
|
||||
if (!/^[A-Z]{2}$/.test(code)) return `<span class="country-badge unknown"><span class="flag-image">?</span><strong>?</strong></span>`;
|
||||
return `
|
||||
<span class="country-badge">
|
||||
<span class="flag-image" style="background-image:url('https://flagcdn.com/24x18/${code.toLowerCase()}.png')" aria-hidden="true"></span>
|
||||
<strong>${escapeHtml(code)}</strong>
|
||||
</span>
|
||||
`;
|
||||
}
|
||||
|
||||
function visitorDetails(conversation) {
|
||||
|
||||
Reference in New Issue
Block a user