fix(single): match reference article action bar 1:1
The action bar used a locally invented pill-chip style that overrode the reference theme's 80px icon-over-text columns, and the JS toggled a class no stylesheet targeted — so likes/favorites showed no selected state at all. - restore reference markup: <svg class="icon"> + <text>/<count> and the actived class, with data-stat-count/data-base-count preserved - toggle actived plus a transient action-animation so the lovestar keyframes finally reach the DOM - drop the CSS overrides and now-dead action-btn/.action-btn--reward and .post-actions-card rules; main.css already carried the reference rules the overrides were shadowing
This commit is contained in:
1 parent
1ce8e263c3
commit
8d16ce6e02
13 files changed
+43
-255
No files matched your search
+14
-14
@@ -247,22 +247,22 @@
|
||||
var likeBtns = collectActionButtons(scope, ".action-like[data-post-id]");
|
||||
var favBtns = collectActionButtons(scope, ".action-favorite[data-post-id]");
|
||||
|
||||
function paintLike(btn, isActive) {
|
||||
function paintLike(btn, isActive, animate) {
|
||||
btn.dataset.initialActive = isActive ? "1" : "0";
|
||||
btn.classList.toggle("is-active", isActive);
|
||||
var icon = btn.querySelector("i");
|
||||
if (icon) icon.className = isActive ? "fa fas fa-heart" : "fa fas fa-heart";
|
||||
// actived 为参考主题的选中态类名;action-animation 只在点亮瞬间附加,
|
||||
// 触发 main.css 中的 lovestar 关键帧。
|
||||
btn.classList.toggle("actived", isActive);
|
||||
btn.classList.toggle("action-animation", !!(isActive && animate));
|
||||
}
|
||||
|
||||
function paintFavorite(btn, isActive) {
|
||||
function paintFavorite(btn, isActive, animate) {
|
||||
btn.dataset.initialActive = isActive ? "1" : "0";
|
||||
btn.classList.toggle("is-active", isActive);
|
||||
var icon = btn.querySelector("i");
|
||||
if (icon) icon.className = isActive ? "fa fas fa-star" : "fa fas fa-star";
|
||||
btn.classList.toggle("actived", isActive);
|
||||
btn.classList.toggle("action-animation", !!(isActive && animate));
|
||||
}
|
||||
|
||||
function applyLikeState(isActive, count) {
|
||||
for (var i = 0; i < likeBtns.length; i++) paintLike(likeBtns[i], isActive);
|
||||
function applyLikeState(isActive, count, animate) {
|
||||
for (var i = 0; i < likeBtns.length; i++) paintLike(likeBtns[i], isActive, animate);
|
||||
if ("number" === typeof count && !isNaN(count)) {
|
||||
setBaseStatCount("likes", count);
|
||||
} else {
|
||||
@@ -270,8 +270,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
function applyFavoriteState(isActive, count) {
|
||||
for (var i = 0; i < favBtns.length; i++) paintFavorite(favBtns[i], isActive);
|
||||
function applyFavoriteState(isActive, count, animate) {
|
||||
for (var i = 0; i < favBtns.length; i++) paintFavorite(favBtns[i], isActive, animate);
|
||||
if ("number" === typeof count && !isNaN(count)) {
|
||||
setBaseStatCount("favorites", count);
|
||||
} else {
|
||||
@@ -292,7 +292,7 @@
|
||||
var nextState = likeBtn.dataset.initialActive !== "1";
|
||||
setButtonBusy(likeBtn, true);
|
||||
requestInteraction("aksrt_toggle_like", postId, nextState).then(function (data) {
|
||||
applyLikeState(!!data.active, parseInt(data.count, 10) || 0);
|
||||
applyLikeState(!!data.active, parseInt(data.count, 10) || 0, true);
|
||||
notyf(data.active ? "感谢你的点赞" : "已取消点赞", "success");
|
||||
}).catch(function (error) {
|
||||
notyf(error && error.message ? error.message : "点赞失败", "danger");
|
||||
@@ -317,7 +317,7 @@
|
||||
var nextState = favBtn.dataset.initialActive !== "1";
|
||||
setButtonBusy(favBtn, true);
|
||||
requestInteraction("aksrt_toggle_favorite", postId, nextState).then(function (data) {
|
||||
applyFavoriteState(!!data.active, parseInt(data.count, 10) || 0);
|
||||
applyFavoriteState(!!data.active, parseInt(data.count, 10) || 0, true);
|
||||
notyf(data.active ? "收藏成功" : "已取消收藏", "success");
|
||||
}).catch(function (error) {
|
||||
notyf(error && error.message ? error.message : "收藏失败", "danger");
|
||||
|
||||
Reference in new issue
Block a user