feat(matrix): 格子里主打赞/评,作品条数挪到左下角
原来的格子里只有条数 + 标签,想看「这条发得怎么样」得一个个悬停。现在 每格直接显示点赞/评论(一万以上缩成 1.2万),作品条数压暗贴左下角; 标签保留在下方。悬停提示不变(仍然有完整指标和逐条标题)。
This commit is contained in:
+73
-12
@@ -102,21 +102,48 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
tbody td {
|
tbody td {
|
||||||
|
position: relative;
|
||||||
border-right: 1px solid var(--line);
|
border-right: 1px solid var(--line);
|
||||||
border-bottom: 1px solid var(--line);
|
border-bottom: 1px solid var(--line);
|
||||||
padding: 5px 8px;
|
/* 底部留一条给左下角的作品条数,别让它压到标签上。 */
|
||||||
|
padding: 4px 8px 15px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
min-width: 92px;
|
min-width: 112px;
|
||||||
}
|
}
|
||||||
tbody tr:hover th, tbody tr:hover td { background: #131c28; }
|
tbody tr:hover th, tbody tr:hover td { background: #131c28; }
|
||||||
|
|
||||||
.count {
|
/* 一格的主角:点赞 / 评论。标签是分类,数字才是「这条发得怎么样」。 */
|
||||||
display: inline-block;
|
.cell-metrics {
|
||||||
min-width: 16px;
|
display: flex;
|
||||||
margin-right: 5px;
|
gap: 8px;
|
||||||
color: var(--cyan);
|
margin-bottom: 2px;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
.cell-metrics span { font-size: 12px; }
|
||||||
|
.cell-metrics b {
|
||||||
|
margin-right: 2px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
.cell-metrics .like { color: var(--pink); }
|
||||||
|
.cell-metrics .comment { color: var(--cyan); }
|
||||||
|
|
||||||
|
/* 左下角的作品条数:是参照信息,压暗、贴角,不参与主视觉。 */
|
||||||
|
.cell-count {
|
||||||
|
position: absolute;
|
||||||
|
left: 5px;
|
||||||
|
bottom: 1px;
|
||||||
|
min-width: 14px;
|
||||||
|
padding: 0 3px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: rgba(123, 139, 163, 0.14);
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 10px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
.tag {
|
.tag {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@@ -260,7 +287,8 @@
|
|||||||
<div id="tip"></div>
|
<div id="tip"></div>
|
||||||
<div class="legend">
|
<div class="legend">
|
||||||
<span><b>名字左边</b> = 粉丝数</span>
|
<span><b>名字左边</b> = 粉丝数</span>
|
||||||
<span><b>N</b> = 当天发出的作品条数</span>
|
<span><b>赞 / 评</b> = 当天这些作品的点赞 / 评论</span>
|
||||||
|
<span><b>左下角数字</b> = 当天作品条数</span>
|
||||||
<span><b>无标签</b> = 发了但没打标签</span>
|
<span><b>无标签</b> = 发了但没打标签</span>
|
||||||
<span><b>空白</b> = 当天没发作品</span>
|
<span><b>空白</b> = 当天没发作品</span>
|
||||||
<span>鼠标停到格子上可以看当天的点赞 / 评论 / 收藏 / 分享</span>
|
<span>鼠标停到格子上可以看当天的点赞 / 评论 / 收藏 / 分享</span>
|
||||||
@@ -290,6 +318,30 @@
|
|||||||
return Number(value).toLocaleString('zh-CN');
|
return Number(value).toLocaleString('zh-CN');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 格子里的数字要短:一万以上用「万」,否则一行放不下赞和评两个数。 */
|
||||||
|
function compact(value) {
|
||||||
|
if (value === null || value === undefined) return '—';
|
||||||
|
const number = Number(value);
|
||||||
|
if (!Number.isFinite(number)) return '—';
|
||||||
|
if (Math.abs(number) >= 100000000) {
|
||||||
|
return (number / 100000000).toFixed(1).replace(/\.0$/, '') + '亿';
|
||||||
|
}
|
||||||
|
if (Math.abs(number) >= 10000) {
|
||||||
|
return (number / 10000).toFixed(1).replace(/\.0$/, '') + '万';
|
||||||
|
}
|
||||||
|
return number.toLocaleString('zh-CN');
|
||||||
|
}
|
||||||
|
|
||||||
|
function metricNode(label, kind, value) {
|
||||||
|
const span = document.createElement('span');
|
||||||
|
span.className = kind;
|
||||||
|
const name = document.createElement('b');
|
||||||
|
name.textContent = label;
|
||||||
|
span.appendChild(name);
|
||||||
|
span.appendChild(document.createTextNode(compact(value)));
|
||||||
|
return span;
|
||||||
|
}
|
||||||
|
|
||||||
function hideTip() {
|
function hideTip() {
|
||||||
tip.style.display = 'none';
|
tip.style.display = 'none';
|
||||||
}
|
}
|
||||||
@@ -414,10 +466,12 @@
|
|||||||
td.appendChild(dot);
|
td.appendChild(dot);
|
||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
const count = document.createElement('span');
|
// 主角:点赞 / 评论。数字未知时显示「—」,不是 0。
|
||||||
count.className = 'count';
|
const metrics = document.createElement('div');
|
||||||
count.textContent = cell.count;
|
metrics.className = 'cell-metrics';
|
||||||
td.appendChild(count);
|
metrics.appendChild(metricNode('赞', 'like', cell.likes));
|
||||||
|
metrics.appendChild(metricNode('评', 'comment', cell.comments));
|
||||||
|
td.appendChild(metrics);
|
||||||
|
|
||||||
if (!cell.tags || cell.tags.length === 0) {
|
if (!cell.tags || cell.tags.length === 0) {
|
||||||
const none = document.createElement('span');
|
const none = document.createElement('span');
|
||||||
@@ -433,6 +487,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 作品条数放左下角。
|
||||||
|
const count = document.createElement('span');
|
||||||
|
count.className = 'cell-count';
|
||||||
|
count.textContent = cell.count;
|
||||||
|
count.title = '当天共 ' + cell.count + ' 条作品';
|
||||||
|
td.appendChild(count);
|
||||||
|
|
||||||
td._cell = cell;
|
td._cell = cell;
|
||||||
td.dataset.day = day;
|
td.dataset.day = day;
|
||||||
td.dataset.creator = creatorName;
|
td.dataset.creator = creatorName;
|
||||||
|
|||||||
Reference in New Issue
Block a user