feat: card UI polish — voting pill, rank badge, selection, density
Rework card layout from flex to block flow for sidebar compatibility. Add voting pill capsule with voted-state tinting (orange/purple), rank badge watermark, custom rt-selected selection system replacing Reddit/RES classes, density-responsive border radius, bold titles, and comprehensive dark mode variants for all interactive states. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,12 @@
|
||||
function processPost(post) {
|
||||
if (post.classList.contains("rt-card")) return;
|
||||
post.classList.add("rt-card");
|
||||
|
||||
var rank = post.querySelector(":scope > .rank");
|
||||
if (rank) {
|
||||
rank.classList.add("rt-rank-badge");
|
||||
post.appendChild(rank);
|
||||
}
|
||||
}
|
||||
|
||||
function processPosts() {
|
||||
@@ -36,17 +42,44 @@
|
||||
}
|
||||
}
|
||||
|
||||
var DENSITY_CLASSES = ["rt-density-cozy", "rt-density-modern", "rt-density-extra"];
|
||||
|
||||
function applyDensity(settings) {
|
||||
var html = document.documentElement;
|
||||
for (var i = 0; i < DENSITY_CLASSES.length; i++) {
|
||||
html.classList.remove(DENSITY_CLASSES[i]);
|
||||
}
|
||||
var cls = "rt-density-" + (settings.cardDensity || "modern");
|
||||
html.classList.add(cls);
|
||||
}
|
||||
|
||||
function initSelection() {
|
||||
document.addEventListener("mousedown", function (e) {
|
||||
var clickedCard = e.target.closest(".rt-card");
|
||||
var prev = document.querySelectorAll(".rt-card.rt-selected");
|
||||
for (var i = 0; i < prev.length; i++) {
|
||||
prev[i].classList.remove("rt-selected");
|
||||
}
|
||||
if (clickedCard) {
|
||||
clickedCard.classList.add("rt-selected");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function apply(settings) {
|
||||
document.documentElement.classList.add("rt-card-enabled");
|
||||
applyDarkMode(settings);
|
||||
applyBackground(settings);
|
||||
applyDensity(settings);
|
||||
applyGap(settings);
|
||||
processPosts();
|
||||
initSelection();
|
||||
}
|
||||
|
||||
function updateSettings(settings) {
|
||||
applyDarkMode(settings);
|
||||
applyBackground(settings);
|
||||
applyDensity(settings);
|
||||
applyGap(settings);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user