change(miniflux) filters colors should align with content
This commit is contained in:
parent
a89696f8b6
commit
a1945a98e6
@ -30,7 +30,7 @@
|
||||
|
||||
document.querySelectorAll('article.item.entry-item').forEach(entry => {
|
||||
const mins = parseMinutes(entry.querySelector('.item-meta-info-reading-time span'));
|
||||
if (mins !== null) {
|
||||
if (mins === null) return;
|
||||
if (mins <= SHORT_MAX) {
|
||||
stylize(entry, {
|
||||
bg: 'rgb(37, 44, 39)',
|
||||
@ -48,25 +48,39 @@
|
||||
});
|
||||
entry.dataset.readCategory = 'long';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function addFilter(label, category) {
|
||||
const nav = document.querySelector('.page-header nav ul');
|
||||
if (!nav) return;
|
||||
const entries = document.querySelectorAll('article.item.entry-item');
|
||||
if (!nav || entries.length === 0) return; // no content -> no button
|
||||
|
||||
const mapping = {
|
||||
short: { border: 'rgb(79, 194, 20)', bg: 'rgb(37, 44, 39)' },
|
||||
long: { border: 'rgb(194, 79, 20)', bg: 'rgb(44, 39, 37)' },
|
||||
all: { border: '#ccc', bg: '#ccc' },
|
||||
};
|
||||
const m = mapping[category];
|
||||
|
||||
const btn = document.createElement('button');
|
||||
btn.textContent = `Filter: ${label}`;
|
||||
Object.assign(btn.style, {
|
||||
marginLeft: '10px',
|
||||
padding: '5px 10px',
|
||||
border: '1px solid rgb(79, 194, 20)',
|
||||
border: `1px solid ${m.border}`,
|
||||
borderRadius: '5px',
|
||||
backgroundColor: 'rgb(37, 44, 39)',
|
||||
color: '#fff',
|
||||
backgroundColor: m.bg,
|
||||
color: category === 'all' ? '#000' : '#fff',
|
||||
cursor: 'pointer',
|
||||
});
|
||||
btn.addEventListener('mouseover', () => {
|
||||
btn.style.borderColor = category === 'all' ? '#999' : m.border;
|
||||
});
|
||||
btn.addEventListener('mouseout', () => {
|
||||
btn.style.borderColor = m.border;
|
||||
});
|
||||
btn.onclick = () => {
|
||||
document.querySelectorAll('article.item.entry-item').forEach(e => {
|
||||
entries.forEach(e => {
|
||||
e.style.display = (category === 'all' || e.dataset.readCategory === category) ? '' : 'none';
|
||||
});
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user