Files
tnsu-ui-kit/src/Sidebar/Sidebar.module.scss
T
Тимур Городецкий 048fec0696 feat: Sidebar — разделители и перенос длинных названий (0.14.0)
Проп dividers рисует тонкие линии между пунктами (подпункты раскрытой
группы — без линий). Длинное название пункта переносится на вторую
строку вместо обрезки многоточием (не больше 2 строк).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 17:54:45 +05:00

272 lines
6.1 KiB
SCSS

@import '../tokens/tokens';
// Тёмный боковой рейл на всю высоту (фирменный navy-градиент, золотой
// маркер активного пункта). Не «плавает»: примыкает к контенту, тянется по высоте.
.nav {
display: flex;
flex-direction: column;
width: 248px;
padding: $sp-4 0 $sp-3;
background: $grad-header;
box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06);
transition: width .2s;
}
.navCollapsed {
width: 64px;
}
// ---- Шапка рейла: бренд + сворачивание ----
.head {
display: flex;
align-items: center;
justify-content: space-between;
gap: $sp-2;
padding: 0 $sp-4 $sp-4;
border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.navCollapsed .head {
flex-direction: column;
gap: $sp-3;
padding: 0 0 $sp-3;
}
.brand {
display: flex;
align-items: center;
gap: $sp-2;
min-width: 0;
}
.brandText {
font-family: $font-serif;
font-size: 15px;
font-weight: 600;
color: $white;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.toggle {
flex-shrink: 0;
display: inline-flex;
align-items: center;
justify-content: center;
width: 26px;
height: 26px;
padding: 0;
border: 1px solid rgba(255, 255, 255, .18);
border-radius: $r-sm;
background: transparent;
color: rgba(255, 255, 255, .6);
cursor: pointer;
transition: .16s;
&:hover {
border-color: $gold-400;
color: $gold-300;
}
}
// ---- Пункты разделов ----
.items {
display: flex;
flex-direction: column;
gap: 2px;
margin-top: $sp-4;
}
.navCollapsed .items {
margin-top: $sp-3;
}
.item {
position: relative;
display: flex;
align-items: center;
gap: $sp-3;
width: 100%;
padding: 12px 18px;
border: 0;
border-left: 3px solid transparent;
background: transparent;
color: rgba(255, 255, 255, .62);
font-family: $font-sans;
font-size: 13.5px;
font-weight: 500;
text-align: left;
// Пункт-ссылка (<a>) выглядит так же, как пункт-кнопка.
text-decoration: none;
// Длинное название переносится (не больше 2 строк — см. .itemTitle), а не обрезается многоточием.
white-space: normal;
cursor: pointer;
transition: color .18s, background .18s, border-color .18s;
&:hover {
color: rgba(255, 255, 255, .92);
background: rgba(255, 255, 255, .04);
}
}
.navCollapsed .item {
justify-content: center;
padding: 12px 0;
}
.itemActive {
color: $white;
background: rgba(255, 255, 255, .07);
border-left-color: $gold-500;
.itemIcon {
color: $gold-400;
}
}
.itemIcon {
flex-shrink: 0;
display: inline-flex;
color: inherit;
}
// Не больше 2 строк: совсем длинное название обрезается многоточием на второй строке.
.itemTitle {
flex: 1;
min-width: 0;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
line-height: 1.3;
overflow-wrap: anywhere;
}
// ---- Линии между пунктами (проп dividers) ----
// Линия — над каждым пунктом, кроме первого; подпункты раскрытой группы лежат внутри .group — их не трогаем.
.navDividers .items {
gap: 0;
> * + * {
border-top: 1px solid rgba(255, 255, 255, .06);
}
}
.badge {
flex-shrink: 0;
min-width: 18px;
padding: 1px 6px;
border-radius: $r-full;
background: $gold-500;
color: $navy-950;
font-size: $fs-overline;
font-weight: 700;
text-align: center;
}
.navCollapsed .badge {
position: absolute;
top: 6px;
right: 8px;
}
// ---- Раскрывающаяся группа: подпункты без иконок, с отступом под иконку шапки ----
$sub-item-indent: 48px; // 18px отступ пункта + 3px маркер + иконка 16px + зазор
.group {
display: flex;
flex-direction: column;
}
.groupChevron {
flex-shrink: 0;
display: inline-flex;
color: rgba(255, 255, 255, .45);
}
.subItems {
display: flex;
flex-direction: column;
padding-bottom: $sp-1;
}
.subItem {
display: flex;
align-items: center;
gap: $sp-2;
width: 100%;
padding: 8px 18px 8px $sub-item-indent;
border: 0;
border-left: 3px solid transparent;
background: transparent;
color: rgba(255, 255, 255, .55);
font-family: $font-sans;
font-size: 13px;
text-align: left;
text-decoration: none;
white-space: normal;
cursor: pointer;
transition: color .18s, background .18s;
&:hover {
color: rgba(255, 255, 255, .92);
background: rgba(255, 255, 255, .04);
}
}
.subItemActive {
color: $white;
border-left-color: $gold-500;
}
// ---- Затемнение фона под мобильным drawer ----
.backdrop {
display: none;
}
// ---- Адаптив: < 768px рейл превращается в выезжающий drawer ----
// На мобилке сайдбар спрятан за левым краем и выезжает поверх контента, когда
// родитель ставит mobileOpen (бургер в шапке). Свёрнутый режим (иконки) на
// мобилке не применяем — drawer всегда полный; переключатель ширины прячем.
@include below($bp-md) {
.nav,
.navCollapsed {
position: fixed;
top: 0;
left: 0;
bottom: 0;
z-index: 1000;
width: 248px;
transform: translateX(-100%);
transition: transform .25s ease;
}
.navMobileOpen {
transform: translateX(0);
box-shadow: $sh-modal;
}
.toggle {
display: none;
}
.backdrop {
display: block;
position: fixed;
inset: 0;
z-index: 999;
background: rgba(10, 27, 48, .45);
}
}
// На совсем узких экранах drawer занимает почти всю ширину, оставляя щель
// для затемнения справа — так видно, что за ним есть контент.
@include below($bp-xs) {
.nav,
.navCollapsed {
width: 86vw;
max-width: 300px;
}
}