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
+863
View File
@@ -0,0 +1,863 @@
import { useState, useEffect, useRef, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { useLanguage } from '../i18n/LanguageContext';
import { fonts, radius } from '../styles/theme';
import { fetchProgress, getLeaderboard, setUserLevel, getUnreadCount, getUserUnreadCount, getIsAdmin, registerUser } from '../api';
import { getUserId } from '../telegram';
import SupportChatModal from '../components/SupportChatModal';
import OnboardingModal from '../components/OnboardingModal';
import HighlightsCarousel from '../components/HighlightsCarousel';
import FeedModal, { type FeedSection } from '../components/FeedModal';
// 🔧 ОБНОВЛЕНО (18.09.2026): единый FeedModal заменил 4 отдельные модалки.
// Тип SlideId теперь — алиас на FeedSection, чтобы не было конфликта типов.
type SlideId = FeedSection;
const MenuPage: React.FC = () => {
const navigate = useNavigate();
const { t, language, setLang } = useLanguage();
const [nextLevel, setNextLevel] = useState(1);
const [totalScore, setTotalScore] = useState(0);
const [rank, setRank] = useState<number | null>(null);
const [pressing, setPressing] = useState<string | null>(null);
const [showLangModal, setShowLangModal] = useState(false);
const [showLevelModal, setShowLevelModal] = useState(false);
const [showGamesModal, setShowGamesModal] = useState(false);
const [showSupportModal, setShowSupportModal] = useState(false);
const [showOnboarding, setShowOnboarding] = useState(false);
const [currentLevel, setCurrentLevel] = useState('A1');
const [isAdmin, setIsAdmin] = useState(() => {
// Начальное значение из localStorage, чтобы не мигало при загрузке
return localStorage.getItem('filwords_is_admin') === '1';
});
const [unreadCount, setUnreadCount] = useState(0);
// 🔧 Активная модалка карусели (единый FeedModal)
const [activeSlideModal, setActiveSlideModal] = useState<SlideId | null>(null);
const touchStartY = useRef(0);
const touchStartX = useRef(0);
const touchMoved = useRef(false);
const SCROLL_THRESHOLD = 8;
const brandColor = '#2ECC71';
const helpColor = '#E74C3C';
// 🔧 ОБНОВЛЕНО: убраны неиспользуемые цвета pronunciation / typing,
// потому что кнопки перенесены в меню учителя.
const palette: Record<string, string> = {
play: brandColor,
bubble: '#4FA9E8',
sentence: '#A970D6',
wordquiz: '#E8933F',
leaderboard: '#E8B93F',
teacher: '#8B5CF6',
support: '#FF6B6B',
dashboard: '#E8B93F',
};
const languages = [
{ code: 'pl', name: 'Polski', flag: '🇵🇱', short: 'PL' },
{ code: 'ru', name: 'Русский', flag: '🇷🇺', short: 'RU' },
{ code: 'uk', name: 'Українська', flag: '🇺🇦', short: 'UA' },
{ code: 'en', name: 'English', flag: '🇬🇧', short: 'EN' },
];
const currentLang = languages.find(l => l.code === language) || languages[0];
const getSupportLabel = (): string => {
const labels: Record<string, string> = {
pl: 'Wsparcie',
ru: 'Поддержка',
uk: 'Підтримка',
en: 'Support',
};
return labels[language] || labels.en;
};
const getDashboardLabel = (): string => {
const labels: Record<string, string> = {
pl: 'Panel',
ru: 'Дашборд',
uk: 'Дашборд',
en: 'Dashboard',
};
return labels[language] || labels.en;
};
const makeButtonHandlers = useCallback((buttonName: string, action: () => void) => ({
onTouchStart: (e: React.TouchEvent) => {
touchStartY.current = e.touches[0].clientY;
touchStartX.current = e.touches[0].clientX;
touchMoved.current = false;
setPressing(buttonName);
},
onTouchMove: (e: React.TouchEvent) => {
const deltaY = Math.abs(e.touches[0].clientY - touchStartY.current);
const deltaX = Math.abs(e.touches[0].clientX - touchStartX.current);
if (deltaY > SCROLL_THRESHOLD || deltaX > SCROLL_THRESHOLD) {
touchMoved.current = true;
setPressing(null);
}
},
onTouchEnd: () => {
setPressing(null);
if (!touchMoved.current) {
action();
}
},
onMouseDown: () => setPressing(buttonName),
onMouseUp: () => { setPressing(null); action(); },
}), []);
useEffect(() => {
const myId = getUserId();
registerUser()
.then((data) => {
if (typeof data.is_admin === 'boolean') {
setIsAdmin(data.is_admin);
localStorage.setItem('filwords_is_admin', data.is_admin ? '1' : '0');
} else {
getIsAdmin()
.then((adminData) => {
setIsAdmin(adminData.is_admin);
localStorage.setItem('filwords_is_admin', adminData.is_admin ? '1' : '0');
})
.catch(() => {});
}
})
.catch(() => {});
fetchProgress()
.then((data) => {
setNextLevel(data.last_completed_level + 1);
setTotalScore(data.total_score || 0);
if (data.current_level) {
setCurrentLevel(data.current_level);
localStorage.setItem('filwords_level', data.current_level);
}
})
.catch(() => {
setNextLevel(1);
setTotalScore(0);
});
getLeaderboard(100)
.then((data) => {
const leaderboard = data.leaderboard || [];
const myEntry = leaderboard.find((entry: any) =>
entry.telegram_id === myId
);
if (myEntry) {
setRank(myEntry.rank);
}
})
.catch(() => {});
const savedLevel = localStorage.getItem('filwords_level');
if (savedLevel) {
setCurrentLevel(savedLevel);
}
const langSaved = localStorage.getItem('filwords_lang');
const onboardingDone = localStorage.getItem('filwords_onboarding_done');
if (langSaved && !onboardingDone) {
setTimeout(() => setShowOnboarding(true), 500);
}
}, []);
const refreshUnreadCount = useCallback(() => {
if (isAdmin) {
getUnreadCount()
.then((data) => setUnreadCount(data.unread_count || 0))
.catch(() => {});
} else {
getUserUnreadCount()
.then((data) => setUnreadCount(data.unread_count || 0))
.catch(() => {});
}
}, [isAdmin]);
useEffect(() => {
refreshUnreadCount();
if (isAdmin) return;
const intervalId = setInterval(() => {
if (!showSupportModal) {
refreshUnreadCount();
}
}, 60000);
return () => clearInterval(intervalId);
}, [isAdmin, showSupportModal, refreshUnreadCount]);
useEffect(() => {
if (isAdmin) return;
const handleVisibilityChange = () => {
if (document.visibilityState === 'visible' && !showSupportModal) {
refreshUnreadCount();
}
};
document.addEventListener('visibilitychange', handleVisibilityChange);
return () => {
document.removeEventListener('visibilitychange', handleVisibilityChange);
};
}, [isAdmin, showSupportModal, refreshUnreadCount]);
const handleLevelSelect = (level: string) => {
setCurrentLevel(level);
localStorage.setItem('filwords_level', level);
setUserLevel(level).catch(() => {});
setShowLevelModal(false);
};
const handleOpenDashboard = () => {
window.dispatchEvent(new Event('open-dashboard'));
};
const handleOnboardingComplete = () => {
localStorage.setItem('filwords_onboarding_done', '1');
};
// 🔧 Обработчик клика по слайду карусели — открывает FeedModal с нужной секцией
const handleSlideClick = (slideId: SlideId) => {
if (window.Telegram?.WebApp?.HapticFeedback) {
window.Telegram.WebApp.HapticFeedback.impactOccurred('light');
}
setActiveSlideModal(slideId);
};
// 🔧 Обработчик клика по кнопке "очки + рейтинг"
const handleScoreClick = () => {
if (window.Telegram?.WebApp?.HapticFeedback) {
window.Telegram.WebApp.HapticFeedback.impactOccurred('light');
}
navigate('/leaderboard');
};
// 🔧 ОБНОВЛЕНО: убраны typingHandlers и pronunciationHandlers —
// эти разделы теперь живут в меню учителя (☰ → Произношение / Печать).
const teacherHandlers = makeButtonHandlers('teacher', () => navigate('/teacher'));
const gamesHandlers = makeButtonHandlers('games', () => setShowGamesModal(true));
const leaderboardHandlers = makeButtonHandlers('leaderboard', () => navigate('/leaderboard'));
const supportHandlers = makeButtonHandlers('support', () => setShowSupportModal(true));
const dashboardHandlers = makeButtonHandlers('dashboard', handleOpenDashboard);
const onboardingHandlers = makeButtonHandlers('onboarding', () => setShowOnboarding(true));
const glass = (extra: React.CSSProperties = {}): React.CSSProperties => ({
background: 'rgba(255,255,255,0.55)',
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,
});
const getButtonStyle = (name: string, isLarge = false): React.CSSProperties => {
const accent = palette[name] || brandColor;
const isPressed = pressing === name;
return {
padding: isLarge ? '22px' : '18px',
borderRadius: radius.lg,
border: isPressed ? `1px solid ${accent}80` : '1px solid rgba(255,255,255,0.7)',
background: isPressed
? `linear-gradient(180deg, ${accent}E6, ${accent}CC)`
: 'rgba(255,255,255,0.55)',
backdropFilter: 'blur(24px) saturate(180%)',
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
color: isPressed ? '#12271C' : '#1A1A2E',
fontSize: isLarge ? '18px' : '16px',
fontWeight: 700,
cursor: 'pointer',
boxShadow: isPressed
? `0 8px 24px ${accent}50, inset 0 1px 0 rgba(255,255,255,0.6)`
: '0 6px 20px rgba(31,38,73,0.08), inset 0 1px 0 rgba(255,255,255,0.85)',
transform: isPressed ? 'scale(0.97)' : 'scale(1)',
transition: 'all 0.2s ease',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '10px',
};
};
return (
<div style={{
minHeight: '100vh',
background: '#F4F5F7',
color: '#1A1A2E',
fontFamily: fonts.main,
display: 'flex',
flexDirection: 'column',
padding: '24px',
position: 'relative',
overflow: 'hidden',
}}>
<div style={{ position: 'fixed', top: '-120px', left: '-90px', width: '320px', height: '320px', borderRadius: '50%', background: palette.teacher, opacity: 0.25, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
<div style={{ position: 'fixed', top: '100px', right: '-110px', width: '300px', height: '300px', borderRadius: '50%', background: palette.bubble, opacity: 0.26, filter: 'blur(100px)', pointerEvents: 'none', zIndex: 0 }} />
<div style={{ position: 'fixed', bottom: '140px', left: '-80px', width: '280px', height: '280px', borderRadius: '50%', background: palette.sentence, opacity: 0.22, filter: 'blur(95px)', pointerEvents: 'none', zIndex: 0 }} />
<div style={{ position: 'fixed', bottom: '-90px', right: '-40px', width: '260px', height: '260px', borderRadius: '50%', background: palette.wordquiz, opacity: 0.22, filter: 'blur(90px)', pointerEvents: 'none', zIndex: 0 }} />
<style>{`
@keyframes fadeInUp {
0% { transform: translateY(10px); opacity: 0; }
100% { transform: translateY(0); opacity: 1; }
}
@keyframes modalFadeIn {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes modalSlideUp {
0% { transform: translateY(20px); opacity: 0; }
100% { transform: translateY(0); opacity: 1; }
}
@keyframes badgePulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.2); }
}
`}</style>
<div style={{ position: 'relative', zIndex: 1, display: 'flex', flexDirection: 'column', flex: 1 }}>
{/* ============ МОДАЛКИ ============ */}
{/* Онбординг */}
<OnboardingModal
isOpen={showOnboarding}
onClose={() => setShowOnboarding(false)}
onComplete={handleOnboardingComplete}
/>
{/* 🔧 ЕДИНЫЙ FeedModal — заменяет 4 старые модалки карусели */}
<FeedModal
isOpen={activeSlideModal !== null}
onClose={() => setActiveSlideModal(null)}
section={activeSlideModal || 'news'}
isAdmin={isAdmin}
/>
{/* Модальное окно выбора языка */}
{showLangModal && (
<div
style={{
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
background: 'rgba(20,22,35,0.25)', zIndex: 500,
display: 'flex', alignItems: 'center', justifyContent: 'center',
animation: 'modalFadeIn 0.2s ease', padding: '20px',
backdropFilter: 'blur(4px)', WebkitBackdropFilter: 'blur(4px)',
}}
onClick={(e) => { if (e.target === e.currentTarget) setShowLangModal(false); }}
>
<div style={{
...glass({
borderRadius: radius.lg,
padding: '20px',
width: '100%',
maxWidth: '340px',
boxShadow: '0 24px 60px rgba(31,38,73,0.20), inset 0 1px 0 rgba(255,255,255,0.85)',
}),
animation: 'modalSlideUp 0.3s ease',
}}>
<h3 style={{
margin: '0 0 16px 0',
fontSize: '18px',
fontWeight: 700,
textAlign: 'center',
color: '#1A1A2E',
}}>
{t('selectLanguage')}
</h3>
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}>
{languages.map((lang) => (
<button
key={lang.code}
onClick={() => { setLang(lang.code); setShowLangModal(false); }}
style={{
padding: '14px 18px',
borderRadius: radius.md,
border: `2px solid ${lang.code === language ? brandColor : 'rgba(0,0,0,0.06)'}`,
background: lang.code === language ? `${brandColor}18` : 'rgba(255,255,255,0.6)',
color: '#1A1A2E',
fontSize: '16px',
fontWeight: 600,
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
gap: '12px',
boxShadow: lang.code === language ? `0 0 0 3px ${brandColor}15` : 'none',
transition: 'all 0.2s ease',
}}
>
<span style={{ fontSize: '24px' }}>{lang.flag}</span>
<span>{lang.name}</span>
{lang.code === language && (
<span style={{ marginLeft: 'auto', color: brandColor, fontWeight: 800 }}>✓</span>
)}
</button>
))}
</div>
</div>
</div>
)}
{/* Модальное окно выбора уровня */}
{showLevelModal && (
<div
style={{
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
background: 'rgba(20,22,35,0.25)', zIndex: 500,
display: 'flex', alignItems: 'center', justifyContent: 'center',
animation: 'modalFadeIn 0.2s ease', padding: '20px',
backdropFilter: 'blur(4px)', WebkitBackdropFilter: 'blur(4px)',
}}
onClick={(e) => { if (e.target === e.currentTarget) setShowLevelModal(false); }}
>
<div style={{
...glass({
borderRadius: radius.lg,
padding: '20px',
width: '100%',
maxWidth: '340px',
boxShadow: '0 24px 60px rgba(31,38,73,0.20), inset 0 1px 0 rgba(255,255,255,0.85)',
}),
animation: 'modalSlideUp 0.3s ease',
}}>
<h3 style={{
margin: '0 0 16px 0',
fontSize: '18px',
fontWeight: 700,
textAlign: 'center',
color: '#1A1A2E',
}}>
{t('selectLevel')}
</h3>
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}>
{[
{ code: 'A1', descKey: 'levelA1Name', available: true },
{ code: 'A2', descKey: 'levelA2Name', available: true },
{ code: 'B1', descKey: 'levelB1Name', available: true },
{ code: 'B2', descKey: 'levelB2Name', available: false },
{ code: 'C1', descKey: 'levelC1Name', available: false },
{ code: 'C2', descKey: 'levelC2Name', available: false },
].map((level) => (
<button
key={level.code}
onClick={() => level.available && handleLevelSelect(level.code)}
disabled={!level.available}
style={{
padding: '14px 18px',
borderRadius: radius.md,
border: `2px solid ${level.code === currentLevel ? brandColor : level.available ? 'rgba(0,0,0,0.06)' : 'rgba(0,0,0,0.03)'}`,
background: level.code === currentLevel ? `${brandColor}18` : level.available ? 'rgba(255,255,255,0.6)' : 'rgba(0,0,0,0.03)',
color: level.available ? '#1A1A2E' : 'rgba(26,26,46,0.35)',
fontSize: '16px',
fontWeight: 600,
cursor: level.available ? 'pointer' : 'default',
display: 'flex',
alignItems: 'center',
gap: '12px',
boxShadow: level.code === currentLevel ? `0 0 0 3px ${brandColor}15` : 'none',
transition: 'all 0.2s ease',
opacity: level.available ? 1 : 0.7,
}}
>
<span style={{ fontSize: '20px', fontWeight: 800, width: '36px' }}>{level.code}</span>
<span style={{ fontSize: '13px', opacity: 0.7 }}>
{level.available ? t(level.descKey) : `${t(level.descKey)} (${t('comingSoon')})`}
</span>
{level.available ? (
level.code === currentLevel && (
<span style={{ marginLeft: 'auto', color: brandColor, fontWeight: 800 }}>✓</span>
)
) : (
<span style={{ marginLeft: 'auto', fontSize: '16px' }}>🔒</span>
)}
</button>
))}
</div>
</div>
</div>
)}
{/* Модальное окно выбора игры */}
{showGamesModal && (
<div
style={{
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
background: 'rgba(20,22,35,0.25)', zIndex: 500,
display: 'flex', alignItems: 'center', justifyContent: 'center',
animation: 'modalFadeIn 0.2s ease', padding: '20px',
backdropFilter: 'blur(4px)', WebkitBackdropFilter: 'blur(4px)',
}}
onClick={(e) => { if (e.target === e.currentTarget) setShowGamesModal(false); }}
>
<div style={{
...glass({
borderRadius: radius.lg,
padding: '20px',
width: '100%',
maxWidth: '340px',
boxShadow: '0 24px 60px rgba(31,38,73,0.20), inset 0 1px 0 rgba(255,255,255,0.85)',
}),
animation: 'modalSlideUp 0.3s ease',
}}>
<h3 style={{
margin: '0 0 16px 0',
fontSize: '18px',
fontWeight: 700,
textAlign: 'center',
color: '#1A1A2E',
}}>
{t('games') || 'Games'}
</h3>
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}>
<button
onClick={() => { setShowGamesModal(false); navigate(`/play/${nextLevel}`); }}
style={{
padding: '16px 18px',
borderRadius: radius.md,
border: '2px solid rgba(0,0,0,0.06)',
background: 'rgba(255,255,255,0.6)',
color: '#1A1A2E',
fontSize: '16px',
fontWeight: 600,
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
gap: '12px',
transition: 'all 0.2s ease',
}}
>
<span style={{ fontSize: '24px' }}>🎮</span>
<span>{t('play')}</span>
</button>
<button
onClick={() => { setShowGamesModal(false); navigate('/bubble'); }}
style={{
padding: '16px 18px',
borderRadius: radius.md,
border: '2px solid rgba(0,0,0,0.06)',
background: 'rgba(255,255,255,0.6)',
color: '#1A1A2E',
fontSize: '16px',
fontWeight: 600,
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
gap: '12px',
transition: 'all 0.2s ease',
}}
>
<span style={{ fontSize: '24px' }}>🫧</span>
<span>{t('bubbleWords') || 'Bubbles'}</span>
</button>
<button
onClick={() => { setShowGamesModal(false); navigate('/sentence'); }}
style={{
padding: '16px 18px',
borderRadius: radius.md,
border: '2px solid rgba(0,0,0,0.06)',
background: 'rgba(255,255,255,0.6)',
color: '#1A1A2E',
fontSize: '16px',
fontWeight: 600,
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
gap: '12px',
transition: 'all 0.2s ease',
}}
>
<span style={{ fontSize: '24px' }}>📝</span>
<span>{t('sentenceBuilder')}</span>
</button>
<button
onClick={() => { setShowGamesModal(false); navigate('/wordquiz'); }}
style={{
padding: '16px 18px',
borderRadius: radius.md,
border: '2px solid rgba(0,0,0,0.06)',
background: 'rgba(255,255,255,0.6)',
color: '#1A1A2E',
fontSize: '16px',
fontWeight: 600,
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
gap: '12px',
transition: 'all 0.2s ease',
}}
>
<span style={{ fontSize: '24px' }}>🎯</span>
<span>{t('wordQuiz') || 'Выбери слово'}</span>
</button>
</div>
</div>
</div>
)}
{/* Модальное окно поддержки */}
{showSupportModal && (
<div
style={{
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
background: 'rgba(20,22,35,0.25)', zIndex: 500,
display: 'flex', alignItems: 'center', justifyContent: 'center',
animation: 'modalFadeIn 0.2s ease', padding: '20px',
backdropFilter: 'blur(4px)', WebkitBackdropFilter: 'blur(4px)',
}}
onClick={(e) => { if (e.target === e.currentTarget) setShowSupportModal(false); }}
>
<SupportChatModal
isOpen={showSupportModal}
onClose={() => {
setShowSupportModal(false);
refreshUnreadCount();
}}
isAdmin={isAdmin}
onUnreadChange={refreshUnreadCount}
/>
</div>
)}
{/* ============ ВЕРХНИЙ УГОЛ ============ */}
<div style={{
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'center',
gap: '8px',
marginBottom: '32px',
animation: 'fadeInUp 0.3s ease',
}}>
{/* ? — Онбординг */}
<button
{...onboardingHandlers}
style={{
...glass({
padding: '10px 14px',
borderRadius: radius.md,
}),
color: helpColor,
fontSize: '16px',
fontWeight: 800,
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
transition: 'all 0.2s ease',
flexShrink: 0,
}}
title={
language === 'ru' ? 'Как пользоваться приложением' :
language === 'uk' ? 'Як користуватися додатком' :
language === 'pl' ? 'Jak korzystać z aplikacji' :
'How to use the app'
}
>
?
</button>
{/* 💯 Очки + Рейтинг */}
<button
onClick={handleScoreClick}
style={{
...glass({
padding: '10px 14px',
borderRadius: radius.md,
display: 'flex',
alignItems: 'center',
gap: '6px',
}),
color: '#1A1A2E',
fontSize: '14px',
fontWeight: 800,
cursor: 'pointer',
transition: 'all 0.2s ease',
flexShrink: 0,
}}
onTouchStart={(e) => {
e.currentTarget.style.transform = 'scale(0.95)';
}}
onTouchEnd={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
<span style={{ fontSize: '14px' }}>💯</span>
<span style={{ color: '#1A1A2E' }}>
{totalScore.toLocaleString()}
</span>
{rank !== null && rank <= 50 && (
<span style={{
fontSize: '11px',
fontWeight: 700,
color: '#B8860B',
background: '#E8B93F15',
padding: '2px 6px',
borderRadius: '6px',
marginLeft: '2px',
}}>
#{rank}
</span>
)}
</button>
{/* A1 ▼ — Уровень */}
<button
onClick={() => setShowLevelModal(true)}
style={{
...glass({
padding: '10px 14px',
borderRadius: radius.md,
display: 'flex',
alignItems: 'center',
gap: '6px',
}),
color: '#4B5563',
fontSize: '14px',
fontWeight: 700,
cursor: 'pointer',
transition: 'all 0.2s ease',
flexShrink: 0,
}}
onTouchStart={(e) => {
e.currentTarget.style.transform = 'scale(0.95)';
}}
onTouchEnd={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
<span style={{ fontSize: '14px', color: brandColor, fontWeight: 800 }}>
{currentLevel}
</span>
<span style={{ fontSize: '10px', opacity: 0.5 }}>▼</span>
</button>
{/* 🇵🇱 PL ▼ — Язык */}
<button
onClick={() => setShowLangModal(true)}
style={{
...glass({
padding: '10px 14px',
borderRadius: radius.md,
display: 'flex',
alignItems: 'center',
gap: '6px',
}),
color: '#4B5563',
fontSize: '14px',
fontWeight: 700,
cursor: 'pointer',
transition: 'all 0.2s ease',
flexShrink: 0,
}}
onTouchStart={(e) => {
e.currentTarget.style.transform = 'scale(0.95)';
}}
onTouchEnd={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
<span style={{ fontSize: '16px' }}>{currentLang.flag}</span>
<span>{currentLang.short}</span>
<span style={{ fontSize: '10px', opacity: 0.5 }}>▼</span>
</button>
</div>
{/* ============ ЛОГОТИП ============ */}
<div style={{
textAlign: 'center',
marginBottom: '24px',
animation: 'fadeInUp 0.3s ease 0.05s both',
}}>
<h1 style={{
fontSize: '46px',
fontWeight: 900,
margin: 0,
letterSpacing: '-1px',
color: '#1A1A2E',
}}>
Filwords{' '}
<span style={{
color: brandColor,
textShadow: `0 0 20px ${brandColor}40`,
}}>PL</span>
</h1>
<p style={{ color: '#6B7280', fontSize: '16px', marginTop: '8px' }}>
Ucz się polskiego przez grę.
</p>
</div>
{/* ============ КАРУСЕЛЬ ============ */}
<HighlightsCarousel onSlideClick={handleSlideClick} />
{/* ============ КНОПКИ ============ */}
<div style={{
display: 'flex',
flexDirection: 'column',
gap: '12px',
flex: 1,
overflow: 'auto',
WebkitOverflowScrolling: 'touch',
}}>
<button {...teacherHandlers} style={getButtonStyle('teacher', true)}>
<span>🎓</span> {t('teacher')}
</button>
<button {...gamesHandlers} style={getButtonStyle('play')}>
<span>🎮</span> {t('games') || 'Games'}
</button>
<button {...leaderboardHandlers} style={getButtonStyle('leaderboard')}>
🏆 {t('leaderboard')}
</button>
{/* Кнопка Поддержка */}
<button {...supportHandlers} style={{
...getButtonStyle('support'),
position: 'relative',
}}>
<span>📮</span> {getSupportLabel()}
{unreadCount > 0 && (
<span style={{
position: 'absolute',
top: '8px',
right: '10px',
minWidth: '22px',
height: '22px',
borderRadius: '11px',
background: '#E74C3C',
color: '#FFFFFF',
fontSize: '12px',
fontWeight: 800,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
padding: '0 6px',
animation: 'badgePulse 2s ease infinite',
boxShadow: '0 2px 8px rgba(231,76,60,0.4)',
}}>
{unreadCount > 99 ? '99+' : unreadCount}
</span>
)}
</button>
{/* Кнопка Дашборд — только для админов */}
{isAdmin && (
<button {...dashboardHandlers} style={getButtonStyle('dashboard')}>
<span>📊</span> {getDashboardLabel()}
</button>
)}
</div>
<div style={{ textAlign: 'center', marginTop: '24px', color: '#9CA3AF', fontSize: '12px' }}>
Filwords PL © 2026
</div>
</div>
</div>
);
};
export default MenuPage;