initial commit (frontend)

This commit is contained in:
2026-09-20 15:08:32 +03:00
commit 04cc53e66d
84 changed files with 36264 additions and 0 deletions
+378
View File
@@ -0,0 +1,378 @@
import { useEffect, useRef, useState } from 'react';
import { useLanguage } from '../../i18n/LanguageContext';
import { radius } from '../../styles/theme';
interface NewsModalProps {
isOpen: boolean;
onClose: () => void;
/** Флаг админа — приходит из MenuPage (уже есть в MenuPage) */
isAdmin?: boolean;
}
const NewsModal: React.FC<NewsModalProps> = ({ isOpen, onClose, isAdmin = false }) => {
const { t } = useLanguage();
const scrollRef = useRef<HTMLDivElement>(null);
const [showAdminStub, setShowAdminStub] = useState(false);
const accentColor = '#E8B93F';
const accentDark = '#CE9A1E';
const textColor = '#1A1A2E';
const subColor = '#6B7280';
const cardBg = 'rgba(255,255,255,0.55)';
const glass = (extra: React.CSSProperties = {}): React.CSSProperties => ({
background: cardBg,
backdropFilter: 'blur(24px) saturate(180%)',
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
border: '1px solid rgba(255,255,255,0.7)',
boxShadow: '0 8px 32px rgba(31,38,73,0.10), inset 0 1px 0 rgba(255,255,255,0.85)',
...extra,
});
// Сброс скролла и админ-заглушки при каждом открытии
useEffect(() => {
if (isOpen) {
if (scrollRef.current) scrollRef.current.scrollTop = 0;
setShowAdminStub(false);
}
}, [isOpen]);
// Escape
useEffect(() => {
if (!isOpen) return;
const handleKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
window.addEventListener('keydown', handleKey);
return () => window.removeEventListener('keydown', handleKey);
}, [isOpen, onClose]);
if (!isOpen) return null;
return (
<div
style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
background: 'rgba(20,22,35,0.35)',
zIndex: 1000,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
padding: '20px',
backdropFilter: 'blur(6px)',
WebkitBackdropFilter: 'blur(6px)',
animation: 'newsFadeIn 0.2s ease',
}}
onClick={(e) => {
if (e.target === e.currentTarget) onClose();
}}
>
<style>{`
@keyframes newsFadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes newsSlideUp {
0% { transform: translateY(20px); opacity: 0; }
100% { transform: translateY(0); opacity: 1; }
}
@keyframes newsPopIn {
0% { transform: scale(0.4); opacity: 0; }
60% { transform: scale(1.1); opacity: 1; }
100% { transform: scale(1); opacity: 1; }
}
@keyframes newsFloat {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-6px); }
}
`}</style>
<div
ref={scrollRef}
onClick={(e) => e.stopPropagation()}
style={{
...glass({
borderRadius: radius.lg,
padding: '24px',
width: '100%',
maxWidth: '400px',
maxHeight: '80vh',
overflowY: 'auto',
boxShadow: '0 24px 60px rgba(31,38,73,0.25), inset 0 1px 0 rgba(255,255,255,0.85)',
}),
animation: 'newsSlideUp 0.3s ease',
}}
>
{/* ============ Заголовок ============ */}
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: '20px',
paddingBottom: '14px',
borderBottom: '1px solid rgba(0,0,0,0.06)',
gap: '8px',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '10px', minWidth: 0 }}>
{/* 🔧 ФИКС iOS 27: lineHeight 1.2 для эмодзи в заголовке */}
<span style={{ fontSize: '24px', flexShrink: 0, lineHeight: '1.2', display: 'inline-block' }}>📰</span>
<h3
style={{
margin: 0,
fontSize: '18px',
fontWeight: 800,
color: textColor,
letterSpacing: '-0.2px',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{t('newsModalTitle')}
</h3>
</div>
<div style={{ display: 'flex', gap: '6px', flexShrink: 0 }}>
{/* ➕ Кнопка добавления — только админу */}
{isAdmin && !showAdminStub && (
<button
onClick={() => setShowAdminStub(true)}
aria-label="Add news"
title="Add news"
style={{
...glass({
padding: '8px 12px',
borderRadius: radius.sm,
}),
color: accentDark,
fontSize: '16px',
fontWeight: 800,
cursor: 'pointer',
WebkitTapHighlightColor: 'transparent',
lineHeight: '1.2', // 🔧 ФИКС iOS 27
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
minHeight: '36px',
}}
onTouchStart={(e) => {
e.currentTarget.style.transform = 'scale(0.9)';
}}
onTouchEnd={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
➕
</button>
)}
{/* Кнопка закрытия */}
<button
onClick={onClose}
aria-label="Close"
style={{
...glass({
padding: '8px 14px',
borderRadius: radius.sm,
}),
color: textColor,
fontSize: '14px',
fontWeight: 600,
cursor: 'pointer',
WebkitTapHighlightColor: 'transparent',
}}
onTouchStart={(e) => {
e.currentTarget.style.transform = 'scale(0.9)';
}}
onTouchEnd={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
✕
</button>
</div>
</div>
{/* ============ Админ-заглушка (по кнопке ➕) ============ */}
{showAdminStub ? (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
padding: '32px 16px',
textAlign: 'center',
animation: 'newsPopIn 0.3s ease',
}}
>
{/* 🔧 ФИКС iOS 27: lineHeight 1.2 + padding для эмодзи 56px */}
<div
style={{
fontSize: '56px',
lineHeight: '1.2',
padding: '8px 0',
marginBottom: '16px',
filter: `drop-shadow(0 8px 20px ${accentColor}40)`,
userSelect: 'none',
display: 'inline-block',
}}
>
🛠️
</div>
<div
style={{
fontSize: '14px',
fontWeight: 700,
color: accentDark,
marginBottom: '8px',
textTransform: 'uppercase',
letterSpacing: '0.5px',
}}
>
Admin mode
</div>
<p
style={{
margin: 0,
fontSize: '14px',
fontWeight: 500,
color: subColor,
lineHeight: '1.5',
maxWidth: '280px',
}}
>
News management is coming soon.
</p>
<button
onClick={() => setShowAdminStub(false)}
style={{
marginTop: '20px',
padding: '10px 20px',
borderRadius: radius.md,
border: `1px solid ${accentColor}40`,
background: `${accentColor}15`,
color: accentDark,
fontSize: '13px',
fontWeight: 700,
cursor: 'pointer',
WebkitTapHighlightColor: 'transparent',
}}
onTouchStart={(e) => {
e.currentTarget.style.transform = 'scale(0.96)';
}}
onTouchEnd={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
← {t('back')}
</button>
</div>
) : (
/* ============ Пустое состояние для всех ============ */
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
padding: '32px 16px',
textAlign: 'center',
}}
>
{/* 🔧 ФИКС iOS 27: lineHeight 1.2 + padding для большого эмодзи */}
<div
style={{
fontSize: '64px',
lineHeight: '1.2',
padding: '8px 0',
marginBottom: '20px',
animation: 'newsPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), newsFloat 3s ease-in-out 0.5s infinite',
filter: `drop-shadow(0 8px 20px ${accentColor}40)`,
userSelect: 'none',
display: 'inline-block',
}}
>
📰
</div>
<p
style={{
margin: 0,
fontSize: '15px',
fontWeight: 500,
color: subColor,
lineHeight: '1.5',
maxWidth: '280px',
}}
>
{t('newsModalEmpty')}
</p>
<div
style={{
display: 'flex',
gap: '6px',
marginTop: '24px',
}}
>
{[0, 1, 2].map((i) => (
<div
key={i}
style={{
width: '6px',
height: '6px',
borderRadius: '50%',
background: accentColor,
opacity: 0.3 + i * 0.2,
}}
/>
))}
</div>
</div>
)}
{/* ============ Кнопка "Понятно" — только когда не админ-заглушка ============ */}
{!showAdminStub && (
<button
onClick={onClose}
style={{
width: '100%',
marginTop: '16px',
padding: '14px 20px',
borderRadius: radius.md,
border: 'none',
background: `linear-gradient(135deg, ${accentColor}, ${accentDark})`,
color: '#FFFFFF',
fontSize: '15px',
fontWeight: 700,
cursor: 'pointer',
boxShadow: `0 6px 20px ${accentColor}40`,
WebkitTapHighlightColor: 'transparent',
letterSpacing: '0.2px',
}}
onTouchStart={(e) => {
e.currentTarget.style.transform = 'scale(0.97)';
}}
onTouchEnd={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
{t('modalGotIt')}
</button>
)}
</div>
</div>
);
};
export default NewsModal;