Align admin, community, search, library, learning and course management with the mockup. Add saved courses, download history, public community feed, instructor directory, backend search, course views, admin content tools and community moderation. Harden API and Nginx for production.
48 lines
3.1 KiB
TypeScript
48 lines
3.1 KiB
TypeScript
import React from 'react';
|
|
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
|
import { CaretLeftIcon } from '@phosphor-icons/react';
|
|
import {
|
|
CommunityTabFilledMockIcon, CommunityTabMockIcon, ExploreTabFilledMockIcon, ExploreTabMockIcon,
|
|
SearchTabFilledMockIcon, SearchTabMockIcon, TrailsTabFilledMockIcon, TrailsTabMockIcon, UserMockIcon,
|
|
} from '../ui/MockupIcons';
|
|
import { useAuth } from '../../context/AuthContext';
|
|
import { Avatar } from '../ui/Avatar';
|
|
import { paths } from '../../lib/routes';
|
|
import { navKeyFor } from '../../lib/navigation';
|
|
|
|
const root = new Set([paths.explore, paths.trails, paths.search, paths.community, paths.you]);
|
|
const parentFor = (path: string) => path.startsWith('/cursos/') && path.includes('/aulas/') ? path.split('/aulas/')[0]
|
|
: path.startsWith('/trilhas/') ? paths.trails
|
|
: path.startsWith('/cursos/') ? paths.explore
|
|
: path.startsWith('/instrutores/') || path.startsWith('/perfis/') ? paths.community
|
|
: paths.you;
|
|
|
|
export const MobileBack: React.FC = () => {
|
|
const location = useLocation();
|
|
const navigate = useNavigate();
|
|
if (root.has(location.pathname)) return null;
|
|
const parent = parentFor(location.pathname);
|
|
const label = parent === paths.trails ? 'Trilhas' : parent === paths.explore ? 'Explorar' : parent === paths.community ? 'Comunidade' : parent === paths.you ? 'Você' : 'Curso';
|
|
const back = () => { if ((window.history.state?.idx ?? 0) > 0) navigate(-1); else navigate(parent); };
|
|
return <nav className="m-nav" aria-label="Voltar"><button type="button" className="m-back" onClick={back}><CaretLeftIcon className="ph" /><span>Voltar</span></button><span className="m-nt">{label}</span><span /></nav>;
|
|
};
|
|
|
|
export const MobileTabBar: React.FC = () => {
|
|
const location = useLocation();
|
|
const { user } = useAuth();
|
|
if (location.pathname.includes('/aulas/')) return null;
|
|
const key = navKeyFor(location.pathname);
|
|
const active = key === 'trails' ? 'trails' : key === 'search' ? 'search' : key === 'community' || key === 'professors' ? 'community' : key === 'explore' ? 'explore' : 'you';
|
|
const items = [
|
|
{ key: 'explore', label: 'Explorar', to: paths.explore, icon: ExploreTabMockIcon, activeIcon: ExploreTabFilledMockIcon },
|
|
{ key: 'trails', label: 'Trilhas', to: paths.trails, icon: TrailsTabMockIcon, activeIcon: TrailsTabFilledMockIcon },
|
|
{ key: 'search', label: 'Buscar', to: paths.search, icon: SearchTabMockIcon, activeIcon: SearchTabFilledMockIcon },
|
|
{ key: 'community', label: 'Comunidade', to: paths.community, icon: CommunityTabMockIcon, activeIcon: CommunityTabFilledMockIcon },
|
|
{ key: 'you', label: 'Você', to: paths.you, icon: UserMockIcon, activeIcon: UserMockIcon },
|
|
] as const;
|
|
return <nav className="tabbar" aria-label="Navegação mobile">{items.map(({ key: itemKey, label, to, icon: InactiveIcon, activeIcon: ActiveIcon }) => {
|
|
const Icon = active === itemKey ? ActiveIcon : InactiveIcon;
|
|
return <Link key={itemKey} to={to} aria-current={active === itemKey ? 'page' : undefined}>{itemKey === 'you' && user ? <Avatar name={user.name} src={user.avatar} size="sm" /> : <Icon className="ph" />}<span>{label}</span></Link>;
|
|
})}</nav>;
|
|
};
|