change main page
This commit is contained in:
+32
-22
@@ -87,29 +87,27 @@ function renderWordGroups(grouped: GroupedWords[]) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const entry of grouped) {
|
// Табы групп
|
||||||
const groupEl = document.createElement('div');
|
const tabsContainer = document.createElement('div');
|
||||||
groupEl.className = 'word-group';
|
tabsContainer.className = 'group-tabs';
|
||||||
|
|
||||||
const header = document.createElement('div');
|
const panelsContainer = document.createElement('div');
|
||||||
header.className = 'word-group-header';
|
panelsContainer.className = 'group-panels';
|
||||||
header.innerHTML = `
|
|
||||||
<span class="word-group-name">${escapeHtml(entry.group.name)}</span>
|
|
||||||
<span class="word-group-count">${entry.tags.reduce((s, t) => s + t.words.length, 0)} слов</span>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// Коллапс по клику на заголовке
|
let activeIndex = 0;
|
||||||
let collapsed = false;
|
|
||||||
header.addEventListener('click', () => {
|
|
||||||
collapsed = !collapsed;
|
|
||||||
tagsContainer.style.display = collapsed ? 'none' : '';
|
|
||||||
header.classList.toggle('collapsed', collapsed);
|
|
||||||
});
|
|
||||||
|
|
||||||
groupEl.appendChild(header);
|
for (let i = 0; i < grouped.length; i++) {
|
||||||
|
const entry = grouped[i];
|
||||||
|
|
||||||
const tagsContainer = document.createElement('div');
|
// Кнопка таба
|
||||||
tagsContainer.className = 'word-group-tags';
|
const tabBtn = document.createElement('button');
|
||||||
|
tabBtn.className = 'group-tab' + (i === activeIndex ? ' active' : '');
|
||||||
|
const totalWords = entry.tags.reduce((s, t) => s + t.words.length, 0);
|
||||||
|
tabBtn.innerHTML = `${escapeHtml(entry.group.name)} <span class="group-tab-count">${totalWords}</span>`;
|
||||||
|
|
||||||
|
// Панель с тегами
|
||||||
|
const panel = document.createElement('div');
|
||||||
|
panel.className = 'group-panel' + (i === activeIndex ? ' active' : '');
|
||||||
|
|
||||||
for (const tagEntry of entry.tags) {
|
for (const tagEntry of entry.tags) {
|
||||||
const tagBlock = document.createElement('div');
|
const tagBlock = document.createElement('div');
|
||||||
@@ -156,12 +154,24 @@ function renderWordGroups(grouped: GroupedWords[]) {
|
|||||||
|
|
||||||
tagBlock.appendChild(tagHeader);
|
tagBlock.appendChild(tagHeader);
|
||||||
tagBlock.appendChild(wordsContainer);
|
tagBlock.appendChild(wordsContainer);
|
||||||
tagsContainer.appendChild(tagBlock);
|
panel.appendChild(tagBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
groupEl.appendChild(tagsContainer);
|
tabBtn.addEventListener('click', () => {
|
||||||
containerEl.appendChild(groupEl);
|
// Деактивируем все
|
||||||
|
tabsContainer.querySelectorAll('.group-tab').forEach((b) => b.classList.remove('active'));
|
||||||
|
panelsContainer.querySelectorAll('.group-panel').forEach((p) => p.classList.remove('active'));
|
||||||
|
// Активируем текущие
|
||||||
|
tabBtn.classList.add('active');
|
||||||
|
panel.classList.add('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
tabsContainer.appendChild(tabBtn);
|
||||||
|
panelsContainer.appendChild(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
containerEl.appendChild(tabsContainer);
|
||||||
|
containerEl.appendChild(panelsContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderSetsPage() {
|
function renderSetsPage() {
|
||||||
|
|||||||
+44
-35
@@ -300,55 +300,64 @@ body {
|
|||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ──── Группировка слов ──── */
|
/* ──── Группировка слов (табы) ──── */
|
||||||
|
|
||||||
.word-group {
|
.group-tabs {
|
||||||
margin-bottom: 1rem;
|
display: flex;
|
||||||
|
gap: 0;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
overflow-x: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
scrollbar-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.word-group-header {
|
.group-tabs::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-tab {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
font-family: var(--sans);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 0.65rem 0.5rem;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
white-space: nowrap;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
gap: 0.5rem;
|
||||||
padding: 10px 12px;
|
|
||||||
background: var(--card-bg);
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
border-radius: 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
-webkit-tap-highlight-color: transparent;
|
|
||||||
transition: background 0.15s;
|
|
||||||
min-height: 48px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.word-group-header:hover {
|
.group-tab.active {
|
||||||
|
color: var(--accent);
|
||||||
|
border-bottom-color: var(--accent);
|
||||||
background: var(--accent-light);
|
background: var(--accent-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.word-group-header::after {
|
.group-tab-count {
|
||||||
content: '▾';
|
font-size: 0.7rem;
|
||||||
font-size: 0.8rem;
|
background: var(--accent-light);
|
||||||
color: var(--text);
|
color: var(--accent);
|
||||||
transition: transform 0.2s;
|
padding: 1px 6px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.word-group-header.collapsed::after {
|
.group-panel {
|
||||||
transform: rotate(-90deg);
|
display: none;
|
||||||
|
padding-top: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.word-group-name {
|
.group-panel.active {
|
||||||
font-weight: 600;
|
display: block;
|
||||||
color: var(--text-h);
|
|
||||||
font-size: 0.95rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.word-group-count {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
color: var(--text);
|
|
||||||
margin-right: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.word-group-tags {
|
|
||||||
padding-top: 0.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.word-tag-block {
|
.word-tag-block {
|
||||||
|
|||||||
Reference in New Issue
Block a user