Spaces:
Running
Running
axeronis commited on
Commit ·
5c59261
1
Parent(s): 0931191
feat: Neon scrollbar, drag-to-scroll nav, and translation fixes
Browse files
frontend/components/SecondaryNav.tsx
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
| 19 |
import { cn } from '@/lib/utils'
|
| 20 |
import { useTranslation } from '@/lib/i18n'
|
| 21 |
import { useAuth } from '@/contexts/AuthContext'
|
| 22 |
-
import { useRef, useEffect } from 'react'
|
| 23 |
|
| 24 |
const navItems = [
|
| 25 |
{ href: '/dashboard', icon: LayoutDashboard, labelKey: 'nav.analytics', label: 'Аналитика', ownerOnly: true },
|
|
@@ -42,6 +42,11 @@ export function SecondaryNav() {
|
|
| 42 |
const { t } = useTranslation()
|
| 43 |
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
const isOwner = user?.role === 'OWNER' || user?.role === 'admin' || user?.is_superuser
|
| 46 |
const visibleItems = navItems.filter(item => isOwner || !item.ownerOnly)
|
| 47 |
|
|
@@ -62,42 +67,81 @@ export function SecondaryNav() {
|
|
| 62 |
const handleWheel = (e: React.WheelEvent) => {
|
| 63 |
if (scrollContainerRef.current) {
|
| 64 |
if (e.deltaY !== 0) {
|
| 65 |
-
// Manually scrolling: set 'auto' to prevent conflict with CSS 'smooth' if any
|
| 66 |
scrollContainerRef.current.style.scrollBehavior = 'auto'
|
| 67 |
-
scrollContainerRef.current.scrollLeft += e.deltaY * 0.5
|
| 68 |
}
|
| 69 |
}
|
| 70 |
}
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
return (
|
| 73 |
<div className="hidden md:flex lg:hidden w-full h-14 bg-black/60 backdrop-blur-xl border-b border-white/5 sticky top-16 z-20">
|
| 74 |
-
{/* Custom Styles for Scrollbar */}
|
| 75 |
<style jsx>{`
|
| 76 |
.aurora-scroll::-webkit-scrollbar {
|
| 77 |
-
height:
|
| 78 |
background: transparent;
|
| 79 |
}
|
| 80 |
.aurora-scroll::-webkit-scrollbar-track {
|
| 81 |
-
background:
|
| 82 |
}
|
| 83 |
.aurora-scroll::-webkit-scrollbar-thumb {
|
| 84 |
-
background:
|
| 85 |
border-radius: 99px;
|
| 86 |
-
|
| 87 |
-
box-shadow:
|
|
|
|
|
|
|
|
|
|
| 88 |
}
|
| 89 |
.aurora-scroll::-webkit-scrollbar-thumb:hover {
|
| 90 |
-
background:
|
|
|
|
|
|
|
|
|
|
| 91 |
}
|
|
|
|
|
|
|
| 92 |
`}</style>
|
| 93 |
|
| 94 |
<div
|
| 95 |
ref={scrollContainerRef}
|
| 96 |
onWheel={handleWheel}
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
style={{
|
| 99 |
-
scrollbarWidth: 'thin',
|
| 100 |
-
scrollbarColor: '
|
| 101 |
}}
|
| 102 |
>
|
| 103 |
{visibleItems.map((item) => {
|
|
@@ -109,6 +153,7 @@ export function SecondaryNav() {
|
|
| 109 |
key={item.href}
|
| 110 |
href={item.href}
|
| 111 |
data-active={active}
|
|
|
|
| 112 |
className={cn(
|
| 113 |
"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap transition-all duration-200 shrink-0 select-none",
|
| 114 |
active
|
|
|
|
| 19 |
import { cn } from '@/lib/utils'
|
| 20 |
import { useTranslation } from '@/lib/i18n'
|
| 21 |
import { useAuth } from '@/contexts/AuthContext'
|
| 22 |
+
import { useRef, useEffect, useState } from 'react'
|
| 23 |
|
| 24 |
const navItems = [
|
| 25 |
{ href: '/dashboard', icon: LayoutDashboard, labelKey: 'nav.analytics', label: 'Аналитика', ownerOnly: true },
|
|
|
|
| 42 |
const { t } = useTranslation()
|
| 43 |
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
| 44 |
|
| 45 |
+
// Drag to scroll state
|
| 46 |
+
const [isDragging, setIsDragging] = useState(false)
|
| 47 |
+
const [startX, setStartX] = useState(0)
|
| 48 |
+
const [scrollLeft, setScrollLeft] = useState(0)
|
| 49 |
+
|
| 50 |
const isOwner = user?.role === 'OWNER' || user?.role === 'admin' || user?.is_superuser
|
| 51 |
const visibleItems = navItems.filter(item => isOwner || !item.ownerOnly)
|
| 52 |
|
|
|
|
| 67 |
const handleWheel = (e: React.WheelEvent) => {
|
| 68 |
if (scrollContainerRef.current) {
|
| 69 |
if (e.deltaY !== 0) {
|
|
|
|
| 70 |
scrollContainerRef.current.style.scrollBehavior = 'auto'
|
| 71 |
+
scrollContainerRef.current.scrollLeft += e.deltaY * 0.5
|
| 72 |
}
|
| 73 |
}
|
| 74 |
}
|
| 75 |
|
| 76 |
+
// Drag handlers
|
| 77 |
+
const handleMouseDown = (e: React.MouseEvent) => {
|
| 78 |
+
if (!scrollContainerRef.current) return
|
| 79 |
+
setIsDragging(true)
|
| 80 |
+
setStartX(e.pageX - scrollContainerRef.current.offsetLeft)
|
| 81 |
+
setScrollLeft(scrollContainerRef.current.scrollLeft)
|
| 82 |
+
scrollContainerRef.current.style.cursor = 'grabbing'
|
| 83 |
+
scrollContainerRef.current.style.scrollBehavior = 'auto' // Disable smooth for direct 1:1 drag
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
const handleMouseLeave = () => {
|
| 87 |
+
setIsDragging(false)
|
| 88 |
+
if (scrollContainerRef.current) scrollContainerRef.current.style.cursor = 'grab'
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
const handleMouseUp = () => {
|
| 92 |
+
setIsDragging(false)
|
| 93 |
+
if (scrollContainerRef.current) scrollContainerRef.current.style.cursor = 'grab'
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
const handleMouseMove = (e: React.MouseEvent) => {
|
| 97 |
+
if (!isDragging || !scrollContainerRef.current) return
|
| 98 |
+
e.preventDefault()
|
| 99 |
+
const x = e.pageX - scrollContainerRef.current.offsetLeft
|
| 100 |
+
const walk = (x - startX) * 1.5 // Scroll-fast multiplier
|
| 101 |
+
scrollContainerRef.current.scrollLeft = scrollLeft - walk
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
return (
|
| 105 |
<div className="hidden md:flex lg:hidden w-full h-14 bg-black/60 backdrop-blur-xl border-b border-white/5 sticky top-16 z-20">
|
| 106 |
+
{/* Custom Styles for Neon Scrollbar */}
|
| 107 |
<style jsx>{`
|
| 108 |
.aurora-scroll::-webkit-scrollbar {
|
| 109 |
+
height: 4px; /* Visible height */
|
| 110 |
background: transparent;
|
| 111 |
}
|
| 112 |
.aurora-scroll::-webkit-scrollbar-track {
|
| 113 |
+
background: rgba(255, 255, 255, 0.02);
|
| 114 |
}
|
| 115 |
.aurora-scroll::-webkit-scrollbar-thumb {
|
| 116 |
+
background: #818cf8; /* Indigo 400 - bright core */
|
| 117 |
border-radius: 99px;
|
| 118 |
+
/* Neon Glow Effect */
|
| 119 |
+
box-shadow:
|
| 120 |
+
0 0 8px rgba(99, 102, 241, 0.8), /* Inner glow */
|
| 121 |
+
0 0 15px rgba(129, 140, 248, 0.5); /* Outer glow */
|
| 122 |
+
border: 1px solid rgba(255,255,255,0.1);
|
| 123 |
}
|
| 124 |
.aurora-scroll::-webkit-scrollbar-thumb:hover {
|
| 125 |
+
background: #a5b4fc; /* Indigo 300 */
|
| 126 |
+
box-shadow:
|
| 127 |
+
0 0 12px rgba(99, 102, 241, 1),
|
| 128 |
+
0 0 20px rgba(129, 140, 248, 0.8);
|
| 129 |
}
|
| 130 |
+
/* Hide scrollbar by default, show on hover or active?
|
| 131 |
+
User asked for "stylish neon", implies visibility. */
|
| 132 |
`}</style>
|
| 133 |
|
| 134 |
<div
|
| 135 |
ref={scrollContainerRef}
|
| 136 |
onWheel={handleWheel}
|
| 137 |
+
onMouseDown={handleMouseDown}
|
| 138 |
+
onMouseLeave={handleMouseLeave}
|
| 139 |
+
onMouseUp={handleMouseUp}
|
| 140 |
+
onMouseMove={handleMouseMove}
|
| 141 |
+
className="flex items-center gap-1 px-4 overflow-x-auto w-full aurora-scroll cursor-grab active:cursor-grabbing"
|
| 142 |
style={{
|
| 143 |
+
scrollbarWidth: 'thin',
|
| 144 |
+
scrollbarColor: '#818cf8 transparent'
|
| 145 |
}}
|
| 146 |
>
|
| 147 |
{visibleItems.map((item) => {
|
|
|
|
| 153 |
key={item.href}
|
| 154 |
href={item.href}
|
| 155 |
data-active={active}
|
| 156 |
+
draggable={false} // Prevent native drag
|
| 157 |
className={cn(
|
| 158 |
"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap transition-all duration-200 shrink-0 select-none",
|
| 159 |
active
|
frontend/lib/i18n/translations/ru.ts
CHANGED
|
@@ -77,6 +77,7 @@ export const ru = {
|
|
| 77 |
partner: 'Партнёрская программа',
|
| 78 |
admin: 'Админ',
|
| 79 |
products: 'Каталог',
|
|
|
|
| 80 |
},
|
| 81 |
|
| 82 |
// Auth
|
|
|
|
| 77 |
partner: 'Партнёрская программа',
|
| 78 |
admin: 'Админ',
|
| 79 |
products: 'Каталог',
|
| 80 |
+
demo: 'Корректировка',
|
| 81 |
},
|
| 82 |
|
| 83 |
// Auth
|