feat: finalize academy redesign and production readiness
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.
162
App.tsx
@@ -1,13 +1,12 @@
|
|||||||
import React, { useState } from 'react';
|
import React from 'react';
|
||||||
import { HashRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
|
import { BrowserRouter as Router, Routes, Route, Navigate, useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { Navbar } from './components/Navbar';
|
|
||||||
import { Hero } from './components/Hero';
|
|
||||||
import { CourseGrid } from './components/CourseGrid';
|
|
||||||
import { ManageCourses } from './pages/ManageCourses';
|
import { ManageCourses } from './pages/ManageCourses';
|
||||||
import { MaterialsPage } from './pages/MaterialsPage';
|
import { MaterialsPage } from './pages/MaterialsPage';
|
||||||
import { CoursePlayerModal } from './components/CoursePlayerModal';
|
|
||||||
import { AuthProvider, useAuth } from './context/AuthContext';
|
import { AuthProvider, useAuth } from './context/AuthContext';
|
||||||
import { ToastProvider } from './context/ToastContext';
|
import { ToastProvider } from './context/ToastContext';
|
||||||
|
import { ThemeProvider } from './context/ThemeContext';
|
||||||
|
import { CatalogProvider } from './context/CatalogContext';
|
||||||
|
import { AppShell } from './components/shell/AppShell';
|
||||||
import { Course, UserRole } from './types';
|
import { Course, UserRole } from './types';
|
||||||
import { SuperAdmin } from './pages/SuperAdmin';
|
import { SuperAdmin } from './pages/SuperAdmin';
|
||||||
import { AccessTokenPage } from './pages/AccessTokenPage';
|
import { AccessTokenPage } from './pages/AccessTokenPage';
|
||||||
@@ -16,87 +15,63 @@ import { ProfilePage } from './pages/ProfilePage';
|
|||||||
import { InstructorProfile } from './pages/InstructorProfile';
|
import { InstructorProfile } from './pages/InstructorProfile';
|
||||||
import { TrailDetail } from './pages/TrailDetail';
|
import { TrailDetail } from './pages/TrailDetail';
|
||||||
import { TrailPage } from './pages/TrailPage';
|
import { TrailPage } from './pages/TrailPage';
|
||||||
|
import { AuthPage, homeFor } from './pages/AuthPage';
|
||||||
|
import { paths } from './lib/routes';
|
||||||
|
import { ExplorePage } from './pages/ExplorePage';
|
||||||
|
import { SearchPage } from './pages/SearchPage';
|
||||||
|
import { TrailsPage } from './pages/TrailsPage';
|
||||||
|
import { ProfessorsPage } from './pages/ProfessorsPage';
|
||||||
|
import { CommunityPage } from './pages/CommunityPage';
|
||||||
|
import { DownloadsPage } from './pages/DownloadsPage';
|
||||||
|
import { YouPage } from './pages/YouPage';
|
||||||
|
import { ContinueCourse, CoursePage } from './pages/CoursePage';
|
||||||
|
import { LessonPage } from './pages/LessonPage';
|
||||||
|
|
||||||
|
/** Keeps old /#/... links (invites, password resets, bookmarks) working after moving off HashRouter. */
|
||||||
|
const LegacyHashRedirect: React.FC = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (location.hash.startsWith('#/')) navigate(location.hash.slice(1), { replace: true });
|
||||||
|
}, [location.hash, navigate]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
// Protected Route Component
|
|
||||||
const ProtectedRoute: React.FC<{ children: React.ReactNode; allowedRoles?: UserRole[] }> = ({ children, allowedRoles }) => {
|
const ProtectedRoute: React.FC<{ children: React.ReactNode; allowedRoles?: UserRole[] }> = ({ children, allowedRoles }) => {
|
||||||
const { user, isLoading } = useAuth();
|
const { user, isLoading } = useAuth();
|
||||||
|
|
||||||
if (isLoading) return null;
|
if (isLoading) return null;
|
||||||
|
if (!user) return <Navigate to={paths.signIn} replace />;
|
||||||
if (!user) {
|
if (allowedRoles && !allowedRoles.includes(user.role)) return <Navigate to={homeFor(user.role)} replace />;
|
||||||
return <Navigate to="/" replace />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allowedRoles && !allowedRoles.includes(user.role)) {
|
|
||||||
return <Navigate to={user.role === 'superadmin' ? '/admin' : user.role === 'professor' ? '/gerenciar' : '/'} replace />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Home component
|
|
||||||
interface HomeProps {
|
|
||||||
onPlay: (course: Course) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Home: React.FC<HomeProps> = ({ onPlay }) => {
|
|
||||||
return (
|
|
||||||
<main>
|
|
||||||
<Hero onPlay={onPlay} />
|
|
||||||
<CourseGrid onCourseSelect={onPlay} />
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
function AppContent() {
|
function AppContent() {
|
||||||
const [selectedCourse, setSelectedCourse] = useState<Course | null>(null);
|
const navigate = useNavigate();
|
||||||
|
const setSelectedCourse = (course: Course) => navigate(paths.course(course.id));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-black text-white font-sans selection:bg-orange-500/30 selection:text-white">
|
<AppShell>
|
||||||
{/* Navbar with Direct Materials Hub Trigger */}
|
|
||||||
<Navbar
|
|
||||||
onPlay={setSelectedCourse}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route
|
<Route path="/" element={<ExplorePage />} />
|
||||||
path="/"
|
<Route path="/buscar" element={<SearchPage />} />
|
||||||
element={
|
<Route path="/trilhas" element={<TrailsPage />} />
|
||||||
<Home
|
<Route path="/comunidade" element={<CommunityPage />} />
|
||||||
onPlay={setSelectedCourse}
|
<Route path="/professores" element={<ProfessorsPage />} />
|
||||||
/>
|
<Route path="/cursos/:courseId" element={<CoursePage />} />
|
||||||
}
|
<Route path="/cursos/:courseId/continuar" element={<ContinueCourse />} />
|
||||||
/>
|
<Route path="/cursos/:courseId/aulas/:lessonId" element={<LessonPage />} />
|
||||||
|
<Route path="/entrar" element={<AuthPage mode="signin" />} />
|
||||||
{/* Full Dedicated Materials & Downloads Page */}
|
<Route path="/criar-conta" element={<AuthPage mode="signup" />} />
|
||||||
<Route
|
<Route path="/materiais" element={<MaterialsPage onPlayCourse={setSelectedCourse} />} />
|
||||||
path="/materiais"
|
<Route path="/downloads" element={<ProtectedRoute><DownloadsPage /></ProtectedRoute>} />
|
||||||
element={
|
<Route path="/voce" element={<YouPage />} />
|
||||||
<ProtectedRoute>
|
<Route path="/gerenciar" element={<ProtectedRoute allowedRoles={['professor', 'superadmin']}><ManageCourses /></ProtectedRoute>} />
|
||||||
<MaterialsPage onPlayCourse={setSelectedCourse} />
|
<Route path="/admin" element={<ProtectedRoute allowedRoles={['superadmin']}><SuperAdmin /></ProtectedRoute>} />
|
||||||
</ProtectedRoute>
|
<Route path="/admin/trilhas/:trailId" element={<ProtectedRoute allowedRoles={['superadmin']}><div className="legacy-skin"><TrailDetail /></div></ProtectedRoute>} />
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Professor Route - Protected */}
|
|
||||||
<Route
|
|
||||||
path="/gerenciar"
|
|
||||||
element={
|
|
||||||
<ProtectedRoute allowedRoles={['professor', 'superadmin']}>
|
|
||||||
<ManageCourses />
|
|
||||||
</ProtectedRoute>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Route
|
|
||||||
path="/admin"
|
|
||||||
element={
|
|
||||||
<ProtectedRoute allowedRoles={['superadmin']}>
|
|
||||||
<SuperAdmin />
|
|
||||||
</ProtectedRoute>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Route path="/admin/trilhas/:trailId" element={<ProtectedRoute allowedRoles={['superadmin']}><TrailDetail /></ProtectedRoute>} />
|
|
||||||
<Route path="/trilhas/:trailId" element={<TrailPage onPlay={setSelectedCourse} />} />
|
<Route path="/trilhas/:trailId" element={<TrailPage onPlay={setSelectedCourse} />} />
|
||||||
<Route path="/meu-aprendizado" element={<ProtectedRoute><MyLearning onPlay={setSelectedCourse} /></ProtectedRoute>} />
|
<Route path="/meu-aprendizado" element={<ProtectedRoute><MyLearning onPlay={setSelectedCourse} /></ProtectedRoute>} />
|
||||||
<Route path="/perfil" element={<ProtectedRoute><ProfilePage /></ProtectedRoute>} />
|
<Route path="/perfil" element={<ProtectedRoute><ProfilePage /></ProtectedRoute>} />
|
||||||
@@ -104,42 +79,25 @@ function AppContent() {
|
|||||||
<Route path="/perfis/:profileId" element={<InstructorProfile onPlay={setSelectedCourse} />} />
|
<Route path="/perfis/:profileId" element={<InstructorProfile onPlay={setSelectedCourse} />} />
|
||||||
<Route path="/invite" element={<AccessTokenPage mode="invite" />} />
|
<Route path="/invite" element={<AccessTokenPage mode="invite" />} />
|
||||||
<Route path="/reset-password" element={<AccessTokenPage mode="reset" />} />
|
<Route path="/reset-password" element={<AccessTokenPage mode="reset" />} />
|
||||||
|
|
||||||
{/* Catch all redirect */}
|
|
||||||
<Route path="*" element={<Navigate to="/" replace />} />
|
<Route path="*" element={<Navigate to="/" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
</AppShell>
|
||||||
{/* Global Player Modal */}
|
|
||||||
<CoursePlayerModal
|
|
||||||
course={selectedCourse}
|
|
||||||
onClose={() => setSelectedCourse(null)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Footer */}
|
|
||||||
<footer className="py-12 px-6 border-t border-white/10 bg-[#070709]">
|
|
||||||
<div className="max-w-[1920px] mx-auto flex flex-col md:flex-row items-center justify-between gap-6 text-gray-400 text-sm">
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<span className="font-semibold text-white">Compor HUB</span>
|
|
||||||
<span className="text-gray-600">|</span>
|
|
||||||
<span>Portal de Cursos & Central de Downloads</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-wrap justify-center md:justify-start gap-6 text-xs text-gray-500">
|
|
||||||
<span>© {new Date().getFullYear()} Compor HUB. Todos os direitos reservados.</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
<AuthProvider>
|
<LegacyHashRedirect />
|
||||||
<ToastProvider>
|
<ThemeProvider>
|
||||||
<AppContent />
|
<AuthProvider>
|
||||||
</ToastProvider>
|
<ToastProvider>
|
||||||
</AuthProvider>
|
<CatalogProvider>
|
||||||
|
<AppContent />
|
||||||
|
</CatalogProvider>
|
||||||
|
</ToastProvider>
|
||||||
|
</AuthProvider>
|
||||||
|
</ThemeProvider>
|
||||||
</Router>
|
</Router>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
10
BACKEND.md
@@ -14,10 +14,16 @@ The API health endpoint is available at `http://localhost:3001/api/v1/health` an
|
|||||||
|
|
||||||
## Current API
|
## Current API
|
||||||
|
|
||||||
- `GET /api/v1/courses` returns published courses.
|
- `GET /api/v1/courses` returns published courses and, for authenticated learners, their completion percentage and last activity.
|
||||||
- `GET /api/v1/courses/:courseId` returns one published course.
|
- `GET /api/v1/courses/:courseId` returns one published course.
|
||||||
|
- `POST /api/v1/courses/:courseId/view` records a course view for the “most watched” shelves.
|
||||||
- `GET /api/v1/courses/me/learning` returns the authenticated learner's started courses, ordered by their last activity, with completion percentage.
|
- `GET /api/v1/courses/me/learning` returns the authenticated learner's started courses, ordered by their last activity, with completion percentage.
|
||||||
- `GET /api/v1/courses/:courseId/progress` and `PUT /api/v1/lessons/:lessonId/progress` persist completion and watch position.
|
- `GET /api/v1/courses/:courseId/progress` and `PUT /api/v1/lessons/:lessonId/progress` persist completion and watch position.
|
||||||
|
- `GET /api/v1/community/comments` returns the public, paginated community feed.
|
||||||
|
- `GET/PUT/DELETE /api/v1/saved-courses` keeps the authenticated learner's saved-course list.
|
||||||
|
- `GET /api/v1/downloads` and `POST /api/v1/downloads/:assetId` keep the authenticated learner's download history.
|
||||||
|
- `GET /api/v1/profiles/instructors` lists public instructor profiles.
|
||||||
|
- `GET /api/v1/search?q=&area=` searches courses, paths and public instructors.
|
||||||
- `GET /api/v1/admin/audit-log` exposes the last 50 administrative actions to superadmins.
|
- `GET /api/v1/admin/audit-log` exposes the last 50 administrative actions to superadmins.
|
||||||
|
|
||||||
## Accounts and instructor access
|
## Accounts and instructor access
|
||||||
@@ -34,7 +40,7 @@ To create the first local administrator, set `SUPERADMIN_EMAIL`, `SUPERADMIN_PAS
|
|||||||
|
|
||||||
For local demos, `npm run db:seed-demo-content` imports the original frontend catalogue into PostgreSQL. It requires the bootstrap administrator to exist and skips courses already present.
|
For local demos, `npm run db:seed-demo-content` imports the original frontend catalogue into PostgreSQL. It requires the bootstrap administrator to exist and skips courses already present.
|
||||||
|
|
||||||
Anonymous visitors can browse course and lesson information, but media and download links are removed from their response. A signed-in account is required to play lessons, download materials, track progress, or participate in discussion.
|
Anonymous visitors can browse course, path, instructor and community information, but media and download links are removed from their response. A signed-in account is required to play lessons, download materials, track progress, or participate in discussion.
|
||||||
|
|
||||||
## Provider boundaries
|
## Provider boundaries
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { PlayCircle, Download, FileText, CheckCircle2 } from 'lucide-react';
|
import {
|
||||||
|
PlayCircleIcon as PlayCircle,
|
||||||
|
DownloadSimpleIcon as Download,
|
||||||
|
FileTextIcon as FileText,
|
||||||
|
CheckCircleIcon as CheckCircle2
|
||||||
|
} from '@phosphor-icons/react';
|
||||||
import { Course, SectionVariant } from '../types';
|
import { Course, SectionVariant } from '../types';
|
||||||
import { CourseCoverImage } from './CourseCoverImage';
|
import { CourseCoverImage } from './CourseCoverImage';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|||||||
@@ -1,243 +0,0 @@
|
|||||||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
||||||
import { CourseRow } from './CourseRow';
|
|
||||||
import { Section, Course } from '../types';
|
|
||||||
import { getCourses, getLearningPaths, PublicLearningPath } from '../services/db';
|
|
||||||
import { useAuth } from '../context/AuthContext';
|
|
||||||
import { Loader2, ChevronLeft, ChevronRight } from 'lucide-react';
|
|
||||||
import { LearningPathRow } from './LearningPathRow';
|
|
||||||
|
|
||||||
interface CourseGridProps {
|
|
||||||
onCourseSelect?: (course: Course) => void;
|
|
||||||
selectedCategoryFilter?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CourseGrid: React.FC<CourseGridProps> = ({
|
|
||||||
onCourseSelect,
|
|
||||||
selectedCategoryFilter
|
|
||||||
}) => {
|
|
||||||
const [courses, setCourses] = useState<Course[]>([]);
|
|
||||||
const [paths, setPaths] = useState<PublicLearningPath[]>([]);
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
const [activeCategory, setActiveCategory] = useState<string>('all');
|
|
||||||
const { user } = useAuth();
|
|
||||||
|
|
||||||
// Slider State & Refs for Categories
|
|
||||||
const categoryScrollRef = useRef<HTMLDivElement>(null);
|
|
||||||
const isMouseDownRef = useRef(false);
|
|
||||||
const startXRef = useRef(0);
|
|
||||||
const scrollLeftRef = useRef(0);
|
|
||||||
const draggedDistanceRef = useRef(0);
|
|
||||||
const [isDraggingCategory, setIsDraggingCategory] = useState(false);
|
|
||||||
const [canScrollCatLeft, setCanScrollCatLeft] = useState(false);
|
|
||||||
const [canScrollCatRight, setCanScrollCatRight] = useState(false);
|
|
||||||
|
|
||||||
const checkCategoryBoundaries = useCallback(() => {
|
|
||||||
if (!categoryScrollRef.current) return;
|
|
||||||
const { scrollLeft, scrollWidth, clientWidth } = categoryScrollRef.current;
|
|
||||||
setCanScrollCatLeft(scrollLeft > 10);
|
|
||||||
setCanScrollCatRight(scrollLeft + clientWidth < scrollWidth - 10);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const loadData = async () => {
|
|
||||||
try {
|
|
||||||
const [loadedCourses, loadedPaths] = await Promise.all([getCourses(), getLearningPaths()]);
|
|
||||||
setCourses(loadedCourses);
|
|
||||||
setPaths(loadedPaths);
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
loadData();
|
|
||||||
}, [user]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
checkCategoryBoundaries();
|
|
||||||
window.addEventListener('resize', checkCategoryBoundaries);
|
|
||||||
return () => window.removeEventListener('resize', checkCategoryBoundaries);
|
|
||||||
}, [checkCategoryBoundaries, courses]);
|
|
||||||
|
|
||||||
const handleCategoryScroll = (direction: 'left' | 'right') => {
|
|
||||||
if (!categoryScrollRef.current) return;
|
|
||||||
const scrollAmount = 300;
|
|
||||||
categoryScrollRef.current.scrollBy({
|
|
||||||
left: direction === 'left' ? -scrollAmount : scrollAmount,
|
|
||||||
behavior: 'smooth'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCatMouseDown = (e: React.MouseEvent) => {
|
|
||||||
if (!categoryScrollRef.current) return;
|
|
||||||
isMouseDownRef.current = true;
|
|
||||||
startXRef.current = e.pageX - categoryScrollRef.current.offsetLeft;
|
|
||||||
scrollLeftRef.current = categoryScrollRef.current.scrollLeft;
|
|
||||||
draggedDistanceRef.current = 0;
|
|
||||||
setIsDraggingCategory(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCatMouseMove = (e: React.MouseEvent) => {
|
|
||||||
if (!isMouseDownRef.current || !categoryScrollRef.current) return;
|
|
||||||
e.preventDefault();
|
|
||||||
const x = e.pageX - categoryScrollRef.current.offsetLeft;
|
|
||||||
const walk = (x - startXRef.current) * 1.4;
|
|
||||||
draggedDistanceRef.current = Math.abs(walk);
|
|
||||||
|
|
||||||
if (draggedDistanceRef.current > 5) {
|
|
||||||
setIsDraggingCategory(true);
|
|
||||||
categoryScrollRef.current.scrollLeft = scrollLeftRef.current - walk;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCatMouseUp = () => {
|
|
||||||
isMouseDownRef.current = false;
|
|
||||||
setTimeout(() => {
|
|
||||||
setIsDraggingCategory(false);
|
|
||||||
draggedDistanceRef.current = 0;
|
|
||||||
}, 50);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCategoryClick = (cat: string) => {
|
|
||||||
if (draggedDistanceRef.current < 8) {
|
|
||||||
setActiveCategory(cat);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const categories = Array.from(new Set<string>(courses.map((course) => course.category)))
|
|
||||||
.sort((left, right) => left.localeCompare(right, 'pt-BR'));
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return (
|
|
||||||
<div className="flex justify-center items-center h-64 w-full">
|
|
||||||
<Loader2 className="w-10 h-10 text-orange-500 animate-spin" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (courses.length === 0) {
|
|
||||||
return (
|
|
||||||
<section className="min-h-[60vh] flex items-center justify-center px-6 pt-28 pb-20">
|
|
||||||
<div className="max-w-md text-center rounded-2xl border border-white/10 bg-zinc-950/80 p-8">
|
|
||||||
<h2 className="text-xl font-bold text-white">Cursos em breve</h2>
|
|
||||||
<p className="mt-3 text-sm leading-relaxed text-gray-400">Ainda não há cursos publicados. Cadastre o primeiro curso no Painel do Instrutor.</p>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter courses if a specific category is active
|
|
||||||
const filteredCourses = activeCategory === 'all'
|
|
||||||
? courses
|
|
||||||
: courses.filter(c => c.category === activeCategory);
|
|
||||||
|
|
||||||
// Group into curated sections for Netflix/Apple TV style layout
|
|
||||||
const sections: Section[] = [
|
|
||||||
{
|
|
||||||
title: activeCategory === 'all' ? 'Cursos em Destaque' : activeCategory,
|
|
||||||
variant: 'landscape',
|
|
||||||
courses: filteredCourses
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Com Materiais & Planilhas para Download',
|
|
||||||
variant: 'landscape',
|
|
||||||
courses: courses.filter(c => (c.attachments && c.attachments.length > 0) || c.lessons.some(l => l.attachments && l.attachments.length > 0))
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="relative z-20 pb-32 space-y-8">
|
|
||||||
|
|
||||||
{/* Category Pills Slider Container */}
|
|
||||||
<div className="px-6 md:px-12 max-w-[1440px] mx-auto select-none">
|
|
||||||
<div className="relative group/catslider flex items-center">
|
|
||||||
|
|
||||||
{/* Scroll Button Left */}
|
|
||||||
{canScrollCatLeft && (
|
|
||||||
<button
|
|
||||||
onClick={() => handleCategoryScroll('left')}
|
|
||||||
className="absolute -left-3 sm:-left-4 z-20 w-8 h-8 sm:w-9 sm:h-9 rounded-full bg-zinc-900/90 hover:bg-orange-500 text-white border border-white/20 backdrop-blur-md flex items-center justify-center shadow-xl transition-all hover:scale-110 active:scale-95 shrink-0"
|
|
||||||
title="Categorias anteriores"
|
|
||||||
>
|
|
||||||
<ChevronLeft className="w-4 h-4 sm:w-5 sm:h-5" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Left Gradient Fade */}
|
|
||||||
{canScrollCatLeft && (
|
|
||||||
<div className="absolute left-0 top-0 bottom-0 w-12 bg-gradient-to-r from-black via-black/80 to-transparent pointer-events-none z-10" />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Scrollable Category Track */}
|
|
||||||
<div
|
|
||||||
ref={categoryScrollRef}
|
|
||||||
onMouseDown={handleCatMouseDown}
|
|
||||||
onMouseMove={handleCatMouseMove}
|
|
||||||
onMouseUp={handleCatMouseUp}
|
|
||||||
onMouseLeave={handleCatMouseUp}
|
|
||||||
onScroll={checkCategoryBoundaries}
|
|
||||||
className={`flex items-center gap-2.5 overflow-x-auto py-2 hide-scrollbar flex-1 min-w-0 overscroll-x-contain scroll-smooth ${
|
|
||||||
isDraggingCategory ? 'cursor-grabbing' : 'cursor-grab'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
onClick={() => handleCategoryClick('all')}
|
|
||||||
className={`px-5 py-2.5 rounded-[980px] text-xs font-bold uppercase tracking-wider transition-all whitespace-nowrap shrink-0 shadow-sm ${
|
|
||||||
activeCategory === 'all'
|
|
||||||
? 'bg-orange-500 text-white shadow-lg shadow-orange-500/25 scale-[1.02]'
|
|
||||||
: 'bg-zinc-900/90 text-gray-300 hover:bg-zinc-800 hover:text-white border border-white/10'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
Todos os Cursos ({courses.length})
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{categories.map(cat => {
|
|
||||||
const count = courses.filter(c => c.category === cat).length;
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={cat}
|
|
||||||
onClick={() => handleCategoryClick(cat)}
|
|
||||||
className={`px-5 py-2.5 rounded-[980px] text-xs font-bold uppercase tracking-wider transition-all whitespace-nowrap shrink-0 shadow-sm ${
|
|
||||||
activeCategory === cat
|
|
||||||
? 'bg-orange-500 text-white shadow-lg shadow-orange-500/25 scale-[1.02]'
|
|
||||||
: 'bg-zinc-900/90 text-gray-300 hover:bg-zinc-800 hover:text-white border border-white/10'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{cat} {count > 0 && `(${count})`}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right Gradient Fade */}
|
|
||||||
{canScrollCatRight && (
|
|
||||||
<div className="absolute right-0 top-0 bottom-0 w-12 bg-gradient-to-l from-black via-black/80 to-transparent pointer-events-none z-10" />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Scroll Button Right */}
|
|
||||||
{canScrollCatRight && (
|
|
||||||
<button
|
|
||||||
onClick={() => handleCategoryScroll('right')}
|
|
||||||
className="absolute -right-3 sm:-right-4 z-20 w-8 h-8 sm:w-9 sm:h-9 rounded-full bg-zinc-900/90 hover:bg-orange-500 text-white border border-white/20 backdrop-blur-md flex items-center justify-center shadow-xl transition-all hover:scale-110 active:scale-95 shrink-0"
|
|
||||||
title="Mais categorias"
|
|
||||||
>
|
|
||||||
<ChevronRight className="w-4 h-4 sm:w-5 sm:h-5" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Sections Rows */}
|
|
||||||
{sections.map((section, index) => (
|
|
||||||
section.courses.length > 0 && (
|
|
||||||
<CourseRow
|
|
||||||
key={`${section.title}-${index}`}
|
|
||||||
section={section}
|
|
||||||
onCourseClick={onCourseSelect}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
))}
|
|
||||||
{activeCategory === 'all' && paths.length > 0 && <LearningPathRow paths={paths} courses={courses} onCourseSelect={onCourseSelect} />}
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,682 +0,0 @@
|
|||||||
import React, { useState, useEffect, useRef } from 'react';
|
|
||||||
import {
|
|
||||||
X,
|
|
||||||
Send,
|
|
||||||
User as UserIcon,
|
|
||||||
Lightbulb,
|
|
||||||
Paperclip,
|
|
||||||
Lock,
|
|
||||||
Unlock,
|
|
||||||
ListVideo,
|
|
||||||
Play,
|
|
||||||
Download,
|
|
||||||
Sparkles,
|
|
||||||
MessageSquare,
|
|
||||||
CheckCircle2,
|
|
||||||
Check,
|
|
||||||
Share2,
|
|
||||||
FileText
|
|
||||||
} from 'lucide-react';
|
|
||||||
import { Course, Comment, Lesson, Attachment } from '../types';
|
|
||||||
import { useAuth } from '../context/AuthContext';
|
|
||||||
import { getComments, getLessonProgress, saveComment, saveLessonCompletion, saveLessonProgress, incrementViews } from '../services/db';
|
|
||||||
import { LoginModal } from './LoginModal';
|
|
||||||
import { MaterialCard } from './MaterialCard';
|
|
||||||
import { courseApi, LessonPlayback } from '../services/api';
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
interface Window {
|
|
||||||
playerjs?: {
|
|
||||||
Player: new (element: HTMLIFrameElement) => {
|
|
||||||
on: (event: string, listener: (data?: { seconds?: number; duration?: number }) => void) => void;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let bunnyPlayerJsPromise: Promise<void> | null = null;
|
|
||||||
|
|
||||||
const loadBunnyPlayerJs = () => {
|
|
||||||
if (window.playerjs) return Promise.resolve();
|
|
||||||
if (bunnyPlayerJsPromise) return bunnyPlayerJsPromise;
|
|
||||||
bunnyPlayerJsPromise = new Promise((resolve, reject) => {
|
|
||||||
const script = document.createElement('script');
|
|
||||||
script.src = 'https://assets.mediadelivery.net/playerjs/player-0.1.0.min.js';
|
|
||||||
script.async = true;
|
|
||||||
script.onload = () => resolve();
|
|
||||||
script.onerror = () => reject(new Error('Bunny player events could not be loaded'));
|
|
||||||
document.head.appendChild(script);
|
|
||||||
});
|
|
||||||
return bunnyPlayerJsPromise;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface CoursePlayerModalProps {
|
|
||||||
course: Course | null;
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CoursePlayerModal: React.FC<CoursePlayerModalProps> = ({ course, onClose }) => {
|
|
||||||
const { user } = useAuth();
|
|
||||||
const [comments, setComments] = useState<Comment[]>([]);
|
|
||||||
const [newComment, setNewComment] = useState('');
|
|
||||||
const [currentLesson, setCurrentLesson] = useState<Lesson | null>(null);
|
|
||||||
const [completedLessonIds, setCompletedLessonIds] = useState<string[]>([]);
|
|
||||||
const [watchedSecondsByLesson, setWatchedSecondsByLesson] = useState<Record<string, number>>({});
|
|
||||||
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
|
|
||||||
const [activeTab, setActiveTab] = useState<'playlist' | 'materials' | 'discussion'>('playlist');
|
|
||||||
const [copiedLink, setCopiedLink] = useState(false);
|
|
||||||
const [playback, setPlayback] = useState<LessonPlayback | null>(null);
|
|
||||||
const [playbackError, setPlaybackError] = useState('');
|
|
||||||
|
|
||||||
const videoRef = useRef<HTMLVideoElement>(null);
|
|
||||||
const bunnyFrameRef = useRef<HTMLIFrameElement>(null);
|
|
||||||
const lastProgressSave = useRef<Record<string, number>>({});
|
|
||||||
|
|
||||||
// Load course data and this learner's saved state from PostgreSQL.
|
|
||||||
useEffect(() => {
|
|
||||||
if (course) {
|
|
||||||
incrementViews(course.id);
|
|
||||||
setCompletedLessonIds([]);
|
|
||||||
setWatchedSecondsByLesson({});
|
|
||||||
lastProgressSave.current = {};
|
|
||||||
if (user) {
|
|
||||||
getComments(course.id).then(setComments).catch(() => setComments([]));
|
|
||||||
getLessonProgress(course.id).then((progress) => {
|
|
||||||
const completed = progress.filter((item) => item.completedAt).map((item) => item.lessonId);
|
|
||||||
setCompletedLessonIds(completed);
|
|
||||||
setWatchedSecondsByLesson(Object.fromEntries(progress.map((item) => [item.lessonId, item.watchedSeconds])));
|
|
||||||
lastProgressSave.current = Object.fromEntries(progress.map((item) => [item.lessonId, item.watchedSeconds]));
|
|
||||||
const nextIncomplete = course.lessons.find((lesson) => !completed.includes(lesson.id));
|
|
||||||
if (nextIncomplete) setCurrentLesson(nextIncomplete);
|
|
||||||
}).catch(() => setCompletedLessonIds([]));
|
|
||||||
} else {
|
|
||||||
setComments([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Select first lesson by default
|
|
||||||
if (course.lessons && course.lessons.length > 0) {
|
|
||||||
setCurrentLesson(course.lessons[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [course, user]);
|
|
||||||
|
|
||||||
// The API verifies the session before returning a time-limited Bunny embed
|
|
||||||
// URL. A video provider key is never sent to the browser.
|
|
||||||
useEffect(() => {
|
|
||||||
if (!course || !user || !currentLesson) {
|
|
||||||
setPlayback(null);
|
|
||||||
setPlaybackError('');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let cancelled = false;
|
|
||||||
setPlayback(null);
|
|
||||||
setPlaybackError('');
|
|
||||||
courseApi.playback(course.id, currentLesson.id)
|
|
||||||
.then((response) => {
|
|
||||||
if (!cancelled) setPlayback(response.data);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
if (!cancelled) setPlaybackError(error instanceof Error ? error.message : 'Não foi possível carregar este vídeo.');
|
|
||||||
});
|
|
||||||
return () => { cancelled = true; };
|
|
||||||
}, [course, user, currentLesson]);
|
|
||||||
|
|
||||||
// Persist completed lessons and recalculate progress
|
|
||||||
const updateCompletedLessons = (newCompleted: string[]) => {
|
|
||||||
setCompletedLessonIds(newCompleted);
|
|
||||||
if (course) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleLessonCompleted = (lessonId: string) => {
|
|
||||||
if (!user) {
|
|
||||||
setShowLoginPrompt(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (completedLessonIds.includes(lessonId)) {
|
|
||||||
const updated = completedLessonIds.filter(id => id !== lessonId);
|
|
||||||
updateCompletedLessons(updated);
|
|
||||||
saveLessonCompletion(lessonId, false).catch(() => updateCompletedLessons(completedLessonIds));
|
|
||||||
} else {
|
|
||||||
markLessonCompleted(lessonId);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const markLessonCompleted = (lessonId: string, watchedSeconds?: number) => {
|
|
||||||
if (!user || completedLessonIds.includes(lessonId)) return;
|
|
||||||
const previous = completedLessonIds;
|
|
||||||
updateCompletedLessons([...previous, lessonId]);
|
|
||||||
saveLessonCompletion(lessonId, true, watchedSeconds).catch(() => updateCompletedLessons(previous));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Video finished automatically -> mark lesson as completed
|
|
||||||
const handleVideoEnded = () => {
|
|
||||||
if (currentLesson && !completedLessonIds.includes(currentLesson.id)) {
|
|
||||||
markLessonCompleted(currentLesson.id, Math.round(videoRef.current?.duration || 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Auto-advance to next lesson if available
|
|
||||||
if (course?.lessons && currentLesson) {
|
|
||||||
const currentIndex = course.lessons.findIndex(l => l.id === currentLesson.id);
|
|
||||||
if (currentIndex >= 0 && currentIndex < course.lessons.length - 1) {
|
|
||||||
const nextLesson = course.lessons[currentIndex + 1];
|
|
||||||
if (user) {
|
|
||||||
setTimeout(() => {
|
|
||||||
setCurrentLesson(nextLesson);
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Track video progress
|
|
||||||
const handleTimeUpdate = () => {
|
|
||||||
if (videoRef.current) {
|
|
||||||
const { currentTime, duration } = videoRef.current;
|
|
||||||
if (duration > 0) {
|
|
||||||
if (user && currentLesson && currentTime - (lastProgressSave.current[currentLesson.id] || 0) >= 30) {
|
|
||||||
const watchedSeconds = Math.floor(currentTime);
|
|
||||||
lastProgressSave.current[currentLesson.id] = watchedSeconds;
|
|
||||||
setWatchedSecondsByLesson((current) => ({ ...current, [currentLesson.id]: watchedSeconds }));
|
|
||||||
saveLessonProgress(currentLesson.id, watchedSeconds).catch(() => undefined);
|
|
||||||
}
|
|
||||||
const percent = Math.round((currentTime / duration) * 100);
|
|
||||||
// Automatically mark as complete when reaching 95%+
|
|
||||||
if (percent >= 95 && currentLesson && !completedLessonIds.includes(currentLesson.id)) {
|
|
||||||
markLessonCompleted(currentLesson.id, Math.round(currentTime));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Bunny's iframe does not expose an HTMLVideoElement. Player.js receives
|
|
||||||
// Bunny's trusted playback events and sends the same progress updates used
|
|
||||||
// for external video providers.
|
|
||||||
useEffect(() => {
|
|
||||||
if (!playback || playback.kind !== 'embed' || !currentLesson || !user) return;
|
|
||||||
let disposed = false;
|
|
||||||
const lessonId = currentLesson.id;
|
|
||||||
void loadBunnyPlayerJs().then(() => {
|
|
||||||
if (disposed || !bunnyFrameRef.current || !window.playerjs) return;
|
|
||||||
const player = new window.playerjs.Player(bunnyFrameRef.current);
|
|
||||||
player.on('timeupdate', (data) => {
|
|
||||||
const watchedSeconds = Math.floor(data?.seconds || 0);
|
|
||||||
if (disposed || watchedSeconds <= 0 || watchedSeconds - (lastProgressSave.current[lessonId] || 0) < 30) return;
|
|
||||||
lastProgressSave.current[lessonId] = watchedSeconds;
|
|
||||||
setWatchedSecondsByLesson((current) => ({ ...current, [lessonId]: watchedSeconds }));
|
|
||||||
saveLessonProgress(lessonId, watchedSeconds).catch(() => undefined);
|
|
||||||
});
|
|
||||||
player.on('ended', (data) => {
|
|
||||||
if (disposed) return;
|
|
||||||
markLessonCompleted(lessonId, Math.floor(data?.duration || data?.seconds || 0));
|
|
||||||
});
|
|
||||||
}).catch(() => undefined);
|
|
||||||
return () => { disposed = true; };
|
|
||||||
}, [playback, currentLesson, user, completedLessonIds]);
|
|
||||||
|
|
||||||
const restoreWatchPosition = () => {
|
|
||||||
if (!currentLesson || !videoRef.current) return;
|
|
||||||
const watchedSeconds = watchedSecondsByLesson[currentLesson.id] || 0;
|
|
||||||
if (watchedSeconds > 0 && watchedSeconds < videoRef.current.duration - 5) videoRef.current.currentTime = watchedSeconds;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAddComment = async (e: React.FormEvent) => {
|
|
||||||
e.preventDefault();
|
|
||||||
if (!newComment.trim() || !course) return;
|
|
||||||
|
|
||||||
const comment = {
|
|
||||||
courseId: course.id,
|
|
||||||
lessonId: currentLesson?.id,
|
|
||||||
text: newComment,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const savedComment = await saveComment(comment);
|
|
||||||
setComments([savedComment, ...comments]);
|
|
||||||
setNewComment('');
|
|
||||||
} catch {
|
|
||||||
// The server remains the source of truth; leave the text intact for a retry.
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const changeLesson = (lesson: Lesson) => {
|
|
||||||
setCurrentLesson(lesson);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleShare = () => {
|
|
||||||
navigator.clipboard.writeText(window.location.href);
|
|
||||||
setCopiedLink(true);
|
|
||||||
setTimeout(() => setCopiedLink(false), 2500);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Collect all downloadable materials for this course (Global + All Lessons)
|
|
||||||
const allCourseAttachments: Array<{ attachment: Attachment; source: string }> = [];
|
|
||||||
|
|
||||||
if (course?.attachments) {
|
|
||||||
course.attachments.forEach(att => {
|
|
||||||
allCourseAttachments.push({ attachment: att, source: 'Material Geral do Curso' });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (course?.lessons) {
|
|
||||||
course.lessons.forEach(l => {
|
|
||||||
if (l.attachments) {
|
|
||||||
l.attachments.forEach(att => {
|
|
||||||
allCourseAttachments.push({ attachment: att, source: l.title });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentLessonAttachments = currentLesson?.attachments || [];
|
|
||||||
|
|
||||||
// Access Control Logic
|
|
||||||
const canWatch = currentLesson && Boolean(user);
|
|
||||||
|
|
||||||
if (!course) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="fixed inset-0 z-[100] bg-[#09090b] text-white overflow-y-auto animate-fade-in-up">
|
|
||||||
{/* Top Bar Floating Controls */}
|
|
||||||
<div className="fixed top-0 left-0 right-0 p-4 md:p-6 z-30 flex items-center justify-between bg-gradient-to-b from-black/90 via-black/40 to-transparent pointer-events-none">
|
|
||||||
<div className="flex items-center gap-3 pointer-events-auto bg-black/60 backdrop-blur-md px-4 py-2 rounded-[980px] border border-white/10">
|
|
||||||
<span className="w-2 h-2 rounded-[980px] bg-orange-500 animate-pulse"></span>
|
|
||||||
<span className="text-caption font-semibold tracking-caption text-gray-200 truncate max-w-[200px] md:max-w-md">
|
|
||||||
{course.title}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-3 pointer-events-auto">
|
|
||||||
<button
|
|
||||||
onClick={handleShare}
|
|
||||||
className="flex items-center gap-2 bg-white/10 hover:bg-white/20 backdrop-blur-md text-white text-body-sm font-semibold tracking-body-sm px-4 py-2.5 rounded-[980px] transition-all active:scale-95 shadow-xl"
|
|
||||||
title="Copiar Link"
|
|
||||||
>
|
|
||||||
<Share2 className="w-4 h-4 text-orange-400" />
|
|
||||||
<span className="hidden sm:inline">{copiedLink ? 'Link Copiado!' : 'Compartilhar'}</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={onClose}
|
|
||||||
className="bg-white/10 hover:bg-white/20 backdrop-blur-md p-2.5 rounded-[980px] transition-all active:scale-95 text-white shadow-xl"
|
|
||||||
title="Fechar"
|
|
||||||
>
|
|
||||||
<X className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="max-w-[1440px] mx-auto min-h-screen pt-16 md:pt-20 pb-20">
|
|
||||||
<div className="flex flex-col lg:flex-row gap-8 px-4 md:px-8">
|
|
||||||
|
|
||||||
{/* Main Left Column: Video & Lesson Details */}
|
|
||||||
<div className="flex-1 lg:max-w-[65%] xl:max-w-[68%]">
|
|
||||||
|
|
||||||
{/* Video Player Section */}
|
|
||||||
<div className="w-full aspect-video bg-black rounded-[8px] overflow-hidden relative shadow-xl border border-white/10 group">
|
|
||||||
{canWatch ? (
|
|
||||||
playback ? (
|
|
||||||
playback.kind === 'embed' && playback.embedUrl ? (
|
|
||||||
<iframe
|
|
||||||
key={currentLesson?.id}
|
|
||||||
ref={bunnyFrameRef}
|
|
||||||
src={playback.embedUrl}
|
|
||||||
title={currentLesson?.title || 'Vídeo da aula'}
|
|
||||||
className="w-full h-full border-0 rounded-[8px]"
|
|
||||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; picture-in-picture; fullscreen"
|
|
||||||
allowFullScreen
|
|
||||||
/>
|
|
||||||
) : playback.source ? (
|
|
||||||
<video
|
|
||||||
key={currentLesson?.id}
|
|
||||||
ref={videoRef}
|
|
||||||
src={playback.source}
|
|
||||||
className="w-full h-full object-contain rounded-[8px]"
|
|
||||||
controls
|
|
||||||
autoPlay
|
|
||||||
onTimeUpdate={handleTimeUpdate}
|
|
||||||
onEnded={handleVideoEnded}
|
|
||||||
onLoadedMetadata={restoreWatchPosition}
|
|
||||||
>
|
|
||||||
Seu navegador não suporta a tag de vídeo.
|
|
||||||
</video>
|
|
||||||
) : (
|
|
||||||
<div className="absolute inset-0 flex items-center justify-center text-sm text-gray-400">Vídeo indisponível.</div>
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<div className="absolute inset-0 flex flex-col items-center justify-center text-center p-6 text-sm text-gray-400">
|
|
||||||
{playbackError ? <span className="text-amber-300">{playbackError}</span> : <span>Carregando vídeo seguro...</span>}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
// Locked State
|
|
||||||
<div className="absolute inset-0 flex flex-col items-center justify-center bg-zinc-950/90 backdrop-blur-md z-10 text-center p-6 rounded-[8px]">
|
|
||||||
<div className="bg-orange-500/10 border border-orange-500/20 p-4 rounded-[8px] mb-4 text-orange-400">
|
|
||||||
<Lock className="w-8 h-8" />
|
|
||||||
</div>
|
|
||||||
<h2 className="font-display text-subheading md:text-heading-sm font-bold tracking-heading-sm leading-heading-sm mb-2">Aula Exclusiva (Pro)</h2>
|
|
||||||
<p className="text-body-sm font-normal text-gray-400 mb-6 max-w-md leading-body-sm tracking-body-sm">
|
|
||||||
Esta aula e seus materiais de download complementares estão disponíveis para membros. Faça login para continuar assistindo.
|
|
||||||
</p>
|
|
||||||
<button
|
|
||||||
onClick={() => setShowLoginPrompt(true)}
|
|
||||||
className="bg-orange-500 hover:bg-orange-600 text-white text-body-sm font-semibold tracking-body-sm px-8 py-3 rounded-[980px] transition-all shadow-xl shadow-orange-500/25 active:scale-95"
|
|
||||||
>
|
|
||||||
Fazer Login para Acessar
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Current Lesson Header Info */}
|
|
||||||
<div className="mt-6 mb-8">
|
|
||||||
<div className="flex flex-wrap items-center justify-between gap-3 mb-3">
|
|
||||||
<div className="flex items-center gap-2.5 text-caption font-semibold uppercase tracking-caption text-orange-400">
|
|
||||||
<span>{course.category}</span>
|
|
||||||
<span className="w-1 h-1 rounded-[980px] bg-zinc-700"></span>
|
|
||||||
<span className="text-gray-400">{currentLesson?.duration || '15m'}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{/* Mark as completed toggle button */}
|
|
||||||
{currentLesson && (
|
|
||||||
<button
|
|
||||||
onClick={() => toggleLessonCompleted(currentLesson.id)}
|
|
||||||
className={`inline-flex items-center gap-1.5 text-xs font-semibold px-3.5 py-1.5 rounded-[980px] transition-all active:scale-95 ${
|
|
||||||
completedLessonIds.includes(currentLesson.id)
|
|
||||||
? 'bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/30 border border-emerald-500/30 font-bold'
|
|
||||||
: 'bg-white/10 hover:bg-emerald-500/20 hover:text-emerald-300 text-gray-300'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<CheckCircle2 className="w-3.5 h-3.5" />
|
|
||||||
<span>{completedLessonIds.includes(currentLesson.id) ? 'Aula Concluída' : 'Concluir Aula'}</span>
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Direct Button to Materials Tab if Available */}
|
|
||||||
{allCourseAttachments.length > 0 && (
|
|
||||||
<button
|
|
||||||
onClick={() => setActiveTab('materials')}
|
|
||||||
className="inline-flex items-center gap-2 text-caption font-semibold tracking-caption bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 px-3.5 py-1.5 rounded-[980px] transition-all"
|
|
||||||
>
|
|
||||||
<Download className="w-3.5 h-3.5" />
|
|
||||||
<span>{allCourseAttachments.length} {allCourseAttachments.length === 1 ? 'Material' : 'Materiais'}</span>
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h1 className="font-display text-subheading sm:text-heading-sm md:text-heading font-bold tracking-heading leading-heading text-white mb-3">
|
|
||||||
{currentLesson?.title || course.title}
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<p className="text-body-sm sm:text-body text-gray-300 leading-body tracking-body font-normal mb-6">
|
|
||||||
{currentLesson?.description || course.description}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{/* Lesson Specific Quick Downloads (if present) */}
|
|
||||||
{currentLessonAttachments.length > 0 && (
|
|
||||||
<div className="p-6 rounded-[8px] bg-zinc-900/80 border border-orange-500/20 mb-8 space-y-4 shadow-xl">
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<h4 className="text-caption font-semibold uppercase tracking-caption text-orange-400 flex items-center gap-2">
|
|
||||||
<Download className="w-4 h-4" />
|
|
||||||
Downloads Desta Aula
|
|
||||||
</h4>
|
|
||||||
<span className="text-caption font-mono text-gray-400">
|
|
||||||
{currentLessonAttachments.length} {currentLessonAttachments.length === 1 ? 'arquivo' : 'arquivos'}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
|
||||||
{currentLessonAttachments.map(att => (
|
|
||||||
<MaterialCard key={att.id} attachment={att} compact />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Instructor Key Takeaways / Tips */}
|
|
||||||
{course.tips && course.tips.length > 0 && (
|
|
||||||
<div className="bg-gradient-to-br from-zinc-900 to-black border border-white/10 rounded-[8px] p-6 mb-8 shadow-xl">
|
|
||||||
<h3 className="font-display text-subheading font-bold text-white mb-4 flex items-center gap-2.5 tracking-subheading leading-subheading">
|
|
||||||
<Lightbulb className="w-5 h-5 text-amber-400" />
|
|
||||||
Recomendações Práticas do Instrutor
|
|
||||||
</h3>
|
|
||||||
<ul className="space-y-3">
|
|
||||||
{course.tips.map((tip, i) => (
|
|
||||||
<li key={i} className="flex gap-3 text-gray-300 text-body-sm font-normal leading-body-sm tracking-body-sm">
|
|
||||||
<span className="block w-2 h-2 rounded-[980px] bg-orange-500 mt-2 shrink-0"></span>
|
|
||||||
<span>{tip}</span>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right Sidebar: Tabs for Playlist, Materials, and Discussion */}
|
|
||||||
<div className="lg:w-[35%] xl:w-[32%] shrink-0 flex flex-col space-y-6">
|
|
||||||
|
|
||||||
{/* Tab Navigation */}
|
|
||||||
<div className="flex items-center justify-between bg-zinc-950/90 p-1.5 rounded-[980px] border border-white/10 shadow-xl gap-1">
|
|
||||||
<button
|
|
||||||
onClick={() => setActiveTab('playlist')}
|
|
||||||
className={`flex-1 flex items-center justify-center gap-1.5 py-2 px-3 sm:px-3.5 rounded-[980px] text-xs font-semibold whitespace-nowrap transition-all ${
|
|
||||||
activeTab === 'playlist'
|
|
||||||
? 'bg-orange-500 text-white shadow-md shadow-orange-500/25'
|
|
||||||
: 'text-gray-400 hover:text-white hover:bg-white/5'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<ListVideo className="w-3.5 h-3.5 shrink-0" />
|
|
||||||
<span>Aulas ({course.lessons.length})</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={() => setActiveTab('materials')}
|
|
||||||
className={`flex-1 flex items-center justify-center gap-1.5 py-2 px-3 sm:px-3.5 rounded-[980px] text-xs font-semibold whitespace-nowrap transition-all ${
|
|
||||||
activeTab === 'materials'
|
|
||||||
? 'bg-orange-500 text-white shadow-md shadow-orange-500/25'
|
|
||||||
: 'text-gray-400 hover:text-white hover:bg-white/5'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<Download className="w-3.5 h-3.5 shrink-0" />
|
|
||||||
<span>Downloads ({allCourseAttachments.length})</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={() => setActiveTab('discussion')}
|
|
||||||
className={`flex-1 flex items-center justify-center gap-1.5 py-2 px-3 sm:px-3.5 rounded-[980px] text-xs font-semibold whitespace-nowrap transition-all ${
|
|
||||||
activeTab === 'discussion'
|
|
||||||
? 'bg-orange-500 text-white shadow-md shadow-orange-500/25'
|
|
||||||
: 'text-gray-400 hover:text-white hover:bg-white/5'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<MessageSquare className="w-3.5 h-3.5 shrink-0" />
|
|
||||||
<span>Dúvidas ({comments.length})</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* TAB CONTENT: Playlist */}
|
|
||||||
{activeTab === 'playlist' && (
|
|
||||||
<div className="bg-zinc-950/80 rounded-2xl p-5 space-y-3 shadow-xl">
|
|
||||||
<div className="flex items-center justify-between pb-3 border-b border-white/5">
|
|
||||||
<span className="text-xs font-bold uppercase tracking-wider text-gray-400">Trilha de Aulas</span>
|
|
||||||
<span className="text-xs text-orange-400 font-mono font-bold">{course.duration}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-2 max-h-[600px] overflow-y-auto pr-1">
|
|
||||||
{course.lessons.map((lesson, index) => {
|
|
||||||
const isActive = currentLesson?.id === lesson.id;
|
|
||||||
const isCompleted = completedLessonIds.includes(lesson.id);
|
|
||||||
const isLocked = !user;
|
|
||||||
const hasAttachments = lesson.attachments && lesson.attachments.length > 0;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={lesson.id}
|
|
||||||
onClick={() => changeLesson(lesson)}
|
|
||||||
className={`
|
|
||||||
group flex items-start gap-3.5 p-3.5 rounded-xl cursor-pointer transition-all border
|
|
||||||
${isActive
|
|
||||||
? 'bg-orange-500/15 border-orange-500/40 text-orange-400 shadow-md shadow-orange-500/10'
|
|
||||||
: isCompleted
|
|
||||||
? 'bg-emerald-950/40 hover:bg-emerald-900/50 border-emerald-500/30 text-emerald-300 shadow-sm'
|
|
||||||
: 'bg-zinc-900/80 hover:bg-zinc-800/90 border-transparent text-gray-200'
|
|
||||||
}
|
|
||||||
${isLocked ? 'opacity-70' : 'opacity-100'}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
{/* Status Icon */}
|
|
||||||
<div className="mt-0.5 shrink-0">
|
|
||||||
{isActive ? (
|
|
||||||
<div className="p-2 rounded-lg bg-orange-500 text-white shadow-md">
|
|
||||||
<Play className="w-3.5 h-3.5 fill-white" />
|
|
||||||
</div>
|
|
||||||
) : isCompleted ? (
|
|
||||||
<div className="p-2 rounded-lg bg-emerald-500 text-white shadow-md">
|
|
||||||
<Check className="w-3.5 h-3.5 stroke-[3]" />
|
|
||||||
</div>
|
|
||||||
) : isLocked ? (
|
|
||||||
<div className="p-2 rounded-lg bg-white/5 text-gray-400">
|
|
||||||
<Lock className="w-3.5 h-3.5" />
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="p-2 rounded-lg bg-white/5 text-gray-400 font-mono text-xs font-bold w-8 h-8 flex items-center justify-center">
|
|
||||||
{index + 1}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex-1 min-w-0">
|
|
||||||
<h4 className={`text-xs sm:text-sm font-semibold truncate ${
|
|
||||||
isActive
|
|
||||||
? 'text-orange-400 font-bold'
|
|
||||||
: isCompleted
|
|
||||||
? 'text-emerald-300 group-hover:text-emerald-200 font-semibold'
|
|
||||||
: 'text-gray-200 group-hover:text-white'
|
|
||||||
}`}>
|
|
||||||
{lesson.title}
|
|
||||||
</h4>
|
|
||||||
<div className="flex items-center gap-2 text-xs text-gray-400 mt-1 font-normal">
|
|
||||||
<span>{lesson.duration}</span>
|
|
||||||
|
|
||||||
{isCompleted && (
|
|
||||||
<span className="bg-emerald-500/20 text-emerald-400 px-2 py-0.5 rounded-md text-[10px] font-bold uppercase flex items-center gap-1">
|
|
||||||
<CheckCircle2 className="w-2.5 h-2.5" /> Concluída
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{lesson.isFree ? (
|
|
||||||
<span className="bg-emerald-500/15 text-emerald-400 px-2 py-0.5 rounded-md text-[10px] font-bold uppercase">Grátis</span>
|
|
||||||
) : (
|
|
||||||
<span className="bg-purple-500/15 text-purple-400 px-2 py-0.5 rounded-md text-[10px] font-bold uppercase">Exclusiva</span>
|
|
||||||
)}
|
|
||||||
{hasAttachments && (
|
|
||||||
<span className="flex items-center gap-1 text-[10px] text-orange-400 bg-orange-500/15 px-2 py-0.5 rounded-md font-bold">
|
|
||||||
<Paperclip className="w-2.5 h-2.5" />
|
|
||||||
{lesson.attachments!.length} anexo(s)
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* TAB CONTENT: Materials & Downloads */}
|
|
||||||
{activeTab === 'materials' && (
|
|
||||||
<div className="bg-zinc-950/80 rounded-2xl p-5 space-y-4 shadow-xl">
|
|
||||||
<div className="flex items-center justify-between pb-3 border-b border-white/5">
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-bold text-white">Materiais para Download</h3>
|
|
||||||
<p className="text-xs text-gray-400 mt-0.5">Arquivos anexados a este curso</p>
|
|
||||||
</div>
|
|
||||||
<span className="text-xs bg-orange-500/15 text-orange-400 font-bold px-2.5 py-1 rounded-full">
|
|
||||||
{allCourseAttachments.length} Total
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{allCourseAttachments.length === 0 ? (
|
|
||||||
<div className="py-12 text-center text-gray-500">
|
|
||||||
<Download className="w-8 h-8 mx-auto mb-2 opacity-30 text-orange-400" />
|
|
||||||
<p className="text-xs text-gray-400">Nenhum material cadastrado para este curso ainda.</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="space-y-3 max-h-[600px] overflow-y-auto pr-1">
|
|
||||||
{allCourseAttachments.map((item, idx) => (
|
|
||||||
<div key={`${item.attachment.id}-${idx}`} className="space-y-1.5">
|
|
||||||
<span className="text-xs text-gray-400 font-semibold px-1 flex items-center gap-1.5">
|
|
||||||
<span className="w-1.5 h-1.5 rounded-full bg-orange-500"></span>
|
|
||||||
{item.source}
|
|
||||||
</span>
|
|
||||||
<MaterialCard attachment={item.attachment} compact />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* TAB CONTENT: Discussion */}
|
|
||||||
{activeTab === 'discussion' && (
|
|
||||||
<div className="bg-zinc-950/80 rounded-2xl p-5 flex flex-col space-y-4 shadow-xl">
|
|
||||||
<h3 className="text-sm font-bold text-white pb-2 border-b border-white/5">Dúvidas & Comentários</h3>
|
|
||||||
|
|
||||||
{/* Comment Form */}
|
|
||||||
<form onSubmit={handleAddComment} className="flex gap-2">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={newComment}
|
|
||||||
onChange={(e) => setNewComment(e.target.value)}
|
|
||||||
placeholder={user ? "Faça uma pergunta sobre a aula..." : "Faça login para comentar"}
|
|
||||||
disabled={!user}
|
|
||||||
className="flex-1 bg-zinc-900/90 rounded-xl px-3.5 py-2.5 text-xs text-white placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-orange-500"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
disabled={!newComment.trim() || !user}
|
|
||||||
className="p-2.5 rounded-xl bg-orange-500 hover:bg-orange-600 disabled:opacity-30 text-white transition-colors"
|
|
||||||
>
|
|
||||||
<Send className="w-4 h-4" />
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{/* Comments List */}
|
|
||||||
<div className="space-y-3 max-h-[450px] overflow-y-auto pr-1">
|
|
||||||
{comments.length === 0 ? (
|
|
||||||
<p className="text-xs text-gray-500 text-center py-8">Nenhum comentário ainda. Seja o primeiro a perguntar!</p>
|
|
||||||
) : (
|
|
||||||
comments.map(c => (
|
|
||||||
<div key={c.id} className="p-3 rounded-xl bg-zinc-900/90 space-y-1">
|
|
||||||
<div className="flex items-center justify-between text-xs font-semibold">
|
|
||||||
<span className="text-gray-200">{c.user}</span>
|
|
||||||
<span className="text-gray-500 font-mono text-[11px]">{c.date}</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-gray-300 font-normal leading-relaxed">{c.text}</p>
|
|
||||||
|
|
||||||
{c.reply && (
|
|
||||||
<div className="mt-2 pl-3 border-l-2 border-orange-500 text-xs bg-white/[0.02] p-2 rounded-r-lg">
|
|
||||||
<span className="font-bold text-orange-400 uppercase text-[10px]">Instrutor:</span>
|
|
||||||
<p className="text-gray-300 text-xs mt-0.5">{c.reply}</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<LoginModal isOpen={showLoginPrompt} onClose={() => setShowLoginPrompt(false)} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
import React, { useRef, useState, useEffect, useCallback } from 'react';
|
|
||||||
import { CourseCard } from './CourseCard';
|
|
||||||
import { Section, Course } from '../types';
|
|
||||||
import { ChevronRight, ChevronLeft } from 'lucide-react';
|
|
||||||
|
|
||||||
interface CourseRowProps {
|
|
||||||
section: Section;
|
|
||||||
onCourseClick?: (course: Course) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CourseRow: React.FC<CourseRowProps> = ({ section, onCourseClick }) => {
|
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
|
||||||
const isMouseDownRef = useRef(false);
|
|
||||||
const startXRef = useRef(0);
|
|
||||||
const scrollLeftRef = useRef(0);
|
|
||||||
const draggedDistanceRef = useRef(0);
|
|
||||||
|
|
||||||
const [canScrollLeft, setCanScrollLeft] = useState(false);
|
|
||||||
const [canScrollRight, setCanScrollRight] = useState(true);
|
|
||||||
const [isDragging, setIsDragging] = useState(false);
|
|
||||||
|
|
||||||
const checkScrollBoundaries = useCallback(() => {
|
|
||||||
if (!containerRef.current) return;
|
|
||||||
const { scrollLeft, scrollWidth, clientWidth } = containerRef.current;
|
|
||||||
setCanScrollLeft(scrollLeft > 20);
|
|
||||||
setCanScrollRight(scrollLeft + clientWidth < scrollWidth - 20);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
checkScrollBoundaries();
|
|
||||||
window.addEventListener('resize', checkScrollBoundaries);
|
|
||||||
return () => window.removeEventListener('resize', checkScrollBoundaries);
|
|
||||||
}, [checkScrollBoundaries, section.courses]);
|
|
||||||
|
|
||||||
// Arrow button handlers
|
|
||||||
const handleScroll = (direction: 'left' | 'right') => {
|
|
||||||
if (!containerRef.current) return;
|
|
||||||
const scrollAmount = containerRef.current.clientWidth * 0.75;
|
|
||||||
containerRef.current.scrollBy({
|
|
||||||
left: direction === 'left' ? -scrollAmount : scrollAmount,
|
|
||||||
behavior: 'smooth'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mouse Drag-to-Scroll Handlers
|
|
||||||
const handleMouseDown = (e: React.MouseEvent) => {
|
|
||||||
if (!containerRef.current) return;
|
|
||||||
// Don't drag if clicking buttons or specific interactive items
|
|
||||||
isMouseDownRef.current = true;
|
|
||||||
startXRef.current = e.pageX - containerRef.current.offsetLeft;
|
|
||||||
scrollLeftRef.current = containerRef.current.scrollLeft;
|
|
||||||
draggedDistanceRef.current = 0;
|
|
||||||
setIsDragging(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleMouseMove = (e: React.MouseEvent) => {
|
|
||||||
if (!isMouseDownRef.current || !containerRef.current) return;
|
|
||||||
e.preventDefault();
|
|
||||||
const x = e.pageX - containerRef.current.offsetLeft;
|
|
||||||
const walk = (x - startXRef.current) * 1.5; // Drag sensitivity multiplier
|
|
||||||
draggedDistanceRef.current = Math.abs(walk);
|
|
||||||
|
|
||||||
if (draggedDistanceRef.current > 6) {
|
|
||||||
setIsDragging(true);
|
|
||||||
containerRef.current.scrollLeft = scrollLeftRef.current - walk;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleMouseUp = () => {
|
|
||||||
isMouseDownRef.current = false;
|
|
||||||
setTimeout(() => {
|
|
||||||
setIsDragging(false);
|
|
||||||
draggedDistanceRef.current = 0;
|
|
||||||
}, 50);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCardClick = (course: Course) => {
|
|
||||||
// Only trigger play/open if user wasn't dragging
|
|
||||||
if (draggedDistanceRef.current < 10) {
|
|
||||||
onCourseClick?.(course);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col py-6 group/row animate-fade-in-up relative select-none">
|
|
||||||
{/* Title Header */}
|
|
||||||
<div className="px-6 md:px-12 max-w-[1440px] w-full mx-auto mb-4 flex items-center justify-between">
|
|
||||||
<div className="flex items-baseline gap-4 group-hover/row:text-white transition-colors duration-300">
|
|
||||||
<h2 className="font-display text-xl sm:text-2xl md:text-2xl font-bold text-gray-100 tracking-tight">
|
|
||||||
{section.title}
|
|
||||||
</h2>
|
|
||||||
<span className="text-xs font-semibold text-gray-500 uppercase tracking-wider hidden sm:inline">
|
|
||||||
{section.courses.length} {section.courses.length === 1 ? 'curso' : 'cursos'}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Inline Navigation Arrows for Desktop */}
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<button
|
|
||||||
onClick={() => handleScroll('left')}
|
|
||||||
disabled={!canScrollLeft}
|
|
||||||
className="w-9 h-9 rounded-full bg-zinc-900/80 hover:bg-orange-500 disabled:opacity-20 disabled:hover:bg-zinc-900/80 text-white border border-white/10 flex items-center justify-center transition-all active:scale-95 shadow-lg"
|
|
||||||
title="Rolar para a esquerda"
|
|
||||||
>
|
|
||||||
<ChevronLeft className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => handleScroll('right')}
|
|
||||||
disabled={!canScrollRight}
|
|
||||||
className="w-9 h-9 rounded-full bg-zinc-900/80 hover:bg-orange-500 disabled:opacity-20 disabled:hover:bg-zinc-900/80 text-white border border-white/10 flex items-center justify-center transition-all active:scale-95 shadow-lg"
|
|
||||||
title="Rolar para a direita"
|
|
||||||
>
|
|
||||||
<ChevronRight className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Horizontal Carousel Container */}
|
|
||||||
<div className="relative w-full max-w-[1440px] mx-auto group/carousel">
|
|
||||||
|
|
||||||
{/* Floating Side Arrow Left (Hover Overlay) */}
|
|
||||||
{canScrollLeft && (
|
|
||||||
<button
|
|
||||||
onClick={() => handleScroll('left')}
|
|
||||||
className="absolute left-2 top-1/2 -translate-y-1/2 z-20 w-11 h-11 rounded-full bg-black/80 hover:bg-orange-500 text-white border border-white/20 backdrop-blur-md hidden md:flex items-center justify-center opacity-0 group-hover/carousel:opacity-100 transition-all duration-200 shadow-2xl hover:scale-110 active:scale-95"
|
|
||||||
title="Anterior"
|
|
||||||
>
|
|
||||||
<ChevronLeft className="w-6 h-6" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Scroll Container with drag-to-scroll */}
|
|
||||||
<div
|
|
||||||
ref={containerRef}
|
|
||||||
onMouseDown={handleMouseDown}
|
|
||||||
onMouseMove={handleMouseMove}
|
|
||||||
onMouseUp={handleMouseUp}
|
|
||||||
onMouseLeave={handleMouseUp}
|
|
||||||
onScroll={checkScrollBoundaries}
|
|
||||||
className={`flex overflow-x-auto gap-6 px-6 md:px-12 pb-8 pt-1 hide-scrollbar overscroll-x-contain scroll-smooth ${
|
|
||||||
isDragging ? 'cursor-grabbing select-none' : 'cursor-grab'
|
|
||||||
}`}
|
|
||||||
style={{ scrollSnapType: isDragging ? 'none' : 'x mandatory' }}
|
|
||||||
>
|
|
||||||
{section.courses.map((course) => (
|
|
||||||
<div key={course.id} className="snap-start shrink-0">
|
|
||||||
<CourseCard
|
|
||||||
course={course}
|
|
||||||
variant={section.variant}
|
|
||||||
onClick={handleCardClick}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
{/* Padding at the end */}
|
|
||||||
<div className="w-8 md:w-12 flex-none" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Floating Side Arrow Right (Hover Overlay) */}
|
|
||||||
{canScrollRight && (
|
|
||||||
<button
|
|
||||||
onClick={() => handleScroll('right')}
|
|
||||||
className="absolute right-2 top-1/2 -translate-y-1/2 z-20 w-11 h-11 rounded-full bg-black/80 hover:bg-orange-500 text-white border border-white/20 backdrop-blur-md hidden md:flex items-center justify-center opacity-0 group-hover/carousel:opacity-100 transition-all duration-200 shadow-2xl hover:scale-110 active:scale-95"
|
|
||||||
title="Próximo"
|
|
||||||
>
|
|
||||||
<ChevronRight className="w-6 h-6" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Subtle Vignette on the right */}
|
|
||||||
<div className="absolute top-0 bottom-0 right-0 w-16 bg-gradient-to-l from-black to-transparent pointer-events-none z-10 hidden md:block" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
|
||||||
import { ChevronLeft, ChevronRight, Play, Sparkles } from 'lucide-react';
|
|
||||||
import { Course } from '../types';
|
|
||||||
import { getCourses, getHomeBanners, PublicHomeBanner } from '../services/db';
|
|
||||||
import { CourseCoverImage } from './CourseCoverImage';
|
|
||||||
|
|
||||||
interface HeroProps { onPlay?: (course: Course) => void; }
|
|
||||||
|
|
||||||
export const Hero: React.FC<HeroProps> = ({ onPlay }) => {
|
|
||||||
const [banners, setBanners] = useState<PublicHomeBanner[]>([]);
|
|
||||||
const [courses, setCourses] = useState<Course[]>([]);
|
|
||||||
const [index, setIndex] = useState(0);
|
|
||||||
useEffect(() => { Promise.all([getHomeBanners(), getCourses()]).then(([loadedBanners, loadedCourses]) => { setBanners(loadedBanners); setCourses(loadedCourses); }).catch(() => setBanners([])); }, []);
|
|
||||||
useEffect(() => { if (banners.length < 2) return; const timer = window.setInterval(() => setIndex((current) => (current + 1) % banners.length), 7000); return () => window.clearInterval(timer); }, [banners.length]);
|
|
||||||
const fallback = courses[0];
|
|
||||||
const banner = banners[index];
|
|
||||||
const course = banner?.courseId ? courses.find((item) => item.id === banner.courseId) : fallback;
|
|
||||||
if (!banner && !fallback) return null;
|
|
||||||
const title = banner ? (banner.kind === 'course' ? banner.courseTitle || banner.title : banner.title) : fallback.title;
|
|
||||||
const description = banner ? (banner.kind === 'course' ? banner.courseDescription || banner.description : banner.description) : fallback.description;
|
|
||||||
const image = banner ? (banner.kind === 'course' ? banner.courseImageUrl : banner.imageUrl) : fallback.thumbnail;
|
|
||||||
const canPlay = Boolean(course && (banner?.kind !== 'custom' || banner.courseId));
|
|
||||||
return <div className="relative flex h-[75vh] max-h-[800px] min-h-[560px] w-full flex-col justify-end overflow-hidden px-6 pb-12 pt-28 md:px-12"><div className="absolute inset-0">{image && <CourseCoverImage source={image} alt={title} className="h-full w-full object-cover" style={{ transform: `scale(${banner?.coverImageZoom || course?.coverImageZoom || 1})`, objectPosition: `${banner?.coverImagePositionX ?? course?.coverImagePositionX ?? 50}% ${banner?.coverImagePositionY ?? course?.coverImagePositionY ?? 50}%` }} />}<div className="absolute inset-0 bg-gradient-to-t from-black via-black/60 to-black/75" /><div className="absolute inset-0 bg-gradient-to-r from-black/95 via-black/60 to-transparent" /></div><div className="relative z-10 mx-auto w-full max-w-[1440px]"><div className="max-w-3xl"><div className="mb-3 flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-white/90"><span className="flex items-center gap-1 rounded-full bg-orange-500 px-3 py-1"><Sparkles className="h-3 w-3" /> Destaque</span>{banner?.kind === 'course' && <span>{course?.category}</span>}</div><h1 className="font-display text-4xl font-extrabold leading-tight tracking-tight text-white md:text-6xl">{title}</h1>{description && <p className="mt-4 max-w-2xl text-base leading-relaxed text-gray-200 md:text-lg">{description}</p>}{canPlay && <button onClick={() => onPlay?.(course!)} className="mt-7 inline-flex items-center gap-3 rounded-full bg-white px-8 py-3.5 text-sm font-bold text-black"><Play className="h-5 w-5 fill-current" /> Assistir curso</button>}</div></div>{banners.length > 1 && <div className="absolute bottom-7 right-6 z-20 flex items-center gap-3 md:right-12"><button onClick={() => setIndex((index - 1 + banners.length) % banners.length)} className="rounded-full bg-black/50 p-2 text-white"><ChevronLeft className="h-5 w-5" /></button><div className="flex gap-1.5">{banners.map((item, itemIndex) => <button key={item.id} onClick={() => setIndex(itemIndex)} className={`h-2 rounded-full transition-all ${itemIndex === index ? 'w-6 bg-orange-500' : 'w-2 bg-white/50'}`} aria-label={`Banner ${itemIndex + 1}`} />)}</div><button onClick={() => setIndex((index + 1) % banners.length)} className="rounded-full bg-black/50 p-2 text-white"><ChevronRight className="h-5 w-5" /></button></div>}</div>;
|
|
||||||
};
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { ArrowRight, Check, Layers3, X } from 'lucide-react';
|
|
||||||
import { Course } from '../types';
|
|
||||||
import { PublicLearningPath } from '../services/db';
|
|
||||||
import { CourseCoverImage } from './CourseCoverImage';
|
|
||||||
|
|
||||||
interface LearningPathRowProps {
|
|
||||||
paths: PublicLearningPath[];
|
|
||||||
courses: Course[];
|
|
||||||
onCourseSelect?: (course: Course) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const LearningPathRow: React.FC<LearningPathRowProps> = ({ paths, courses, onCourseSelect }) => {
|
|
||||||
const [selectedPath, setSelectedPath] = useState<PublicLearningPath | null>(null);
|
|
||||||
const courseById = new Map(courses.map((course) => [course.id, course]));
|
|
||||||
|
|
||||||
return <>
|
|
||||||
<section className="mx-auto w-full max-w-[1440px] px-6 py-6 md:px-12">
|
|
||||||
<div className="mb-4 flex items-baseline gap-3">
|
|
||||||
<h2 className="font-display text-xl font-bold text-gray-100 md:text-2xl">Trilhas</h2>
|
|
||||||
<span className="text-xs font-semibold uppercase tracking-wider text-gray-500">{paths.length} {paths.length === 1 ? 'trilha' : 'trilhas'}</span>
|
|
||||||
</div>
|
|
||||||
<div className="flex gap-5 overflow-x-auto pb-4 hide-scrollbar snap-x snap-mandatory">
|
|
||||||
{paths.map((path) => <button key={path.id} onClick={() => setSelectedPath(path)} className="group relative w-[300px] shrink-0 snap-start overflow-hidden rounded-xl border border-white/10 bg-zinc-950 text-left shadow-xl transition hover:-translate-y-1 hover:border-orange-500/60">
|
|
||||||
<div className="relative aspect-[16/8] overflow-hidden bg-zinc-900">
|
|
||||||
{path.coverImageUrl ? <CourseCoverImage source={path.coverImageUrl} alt={path.title} className="h-full w-full object-cover transition duration-500 group-hover:scale-105" style={{ transform: `scale(${path.coverImageZoom || 1})`, objectPosition: `${path.coverImagePositionX ?? 50}% ${path.coverImagePositionY ?? 50}%` }} /> : <div className="flex h-full items-center justify-center bg-gradient-to-br from-orange-500/30 to-zinc-900"><Layers3 className="h-9 w-9 text-orange-300" /></div>}
|
|
||||||
<div className="absolute inset-0 bg-gradient-to-t from-black/70 to-transparent" />
|
|
||||||
<span className="absolute bottom-3 left-3 rounded-full bg-black/60 px-2.5 py-1 text-[10px] font-bold uppercase tracking-wider text-white backdrop-blur">{path.courses.length} {path.courses.length === 1 ? 'curso' : 'cursos'}</span>
|
|
||||||
</div>
|
|
||||||
<div className="p-4"><h3 className="truncate font-semibold text-white group-hover:text-orange-300">{path.title}</h3><p className="mt-1 line-clamp-2 min-h-10 text-sm leading-relaxed text-gray-500">{path.description || 'Uma trilha organizada para avançar passo a passo.'}</p><span className="mt-3 inline-flex items-center gap-1 text-sm font-semibold text-orange-400">Ver trilha <ArrowRight className="h-4 w-4" /></span></div>
|
|
||||||
</button>)}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
{selectedPath && <div className="fixed inset-0 z-[90] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm" role="dialog" aria-modal="true" aria-label={selectedPath.title}>
|
|
||||||
<div className="max-h-[90vh] w-full max-w-2xl overflow-y-auto rounded-2xl border border-white/10 bg-zinc-950 shadow-2xl"><div className="flex items-start justify-between border-b border-white/10 p-6"><div><div className="flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-orange-400"><Layers3 className="h-4 w-4" /> Formação</div><h2 className="mt-2 text-2xl font-bold text-white">{selectedPath.title}</h2><p className="mt-2 text-sm leading-relaxed text-gray-400">{selectedPath.description}</p></div><button onClick={() => setSelectedPath(null)} className="rounded-full p-2 text-gray-400 hover:bg-white/10 hover:text-white" aria-label="Fechar"><X className="h-5 w-5" /></button></div><ol className="space-y-2 p-5">{selectedPath.courses.map((pathCourse, index) => { const course = courseById.get(pathCourse.id); return <li key={pathCourse.id}><button onClick={() => { if (course) { setSelectedPath(null); onCourseSelect?.(course); } }} disabled={!course} className="flex w-full items-center gap-4 rounded-xl bg-white/[0.03] px-4 py-3 text-left transition hover:bg-white/[0.07] disabled:cursor-default"><span className="flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-orange-500/15 text-xs font-bold text-orange-400">{index + 1}</span><span className="min-w-0 flex-1"><span className="block truncate font-semibold text-white">{pathCourse.title}</span><span className="mt-0.5 block text-xs text-gray-500">{pathCourse.category}</span></span>{course && <span className="text-xs font-semibold text-orange-400">Abrir curso</span>}</button></li>; })}</ol><div className="border-t border-white/10 p-4 text-center text-xs text-gray-500"><Check className="mr-1 inline h-3.5 w-3.5 text-emerald-400" /> Siga os cursos nesta ordem.</div></div>
|
|
||||||
</div>}
|
|
||||||
</>;
|
|
||||||
};
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { X, Loader2, GraduationCap, School, UserPlus } from 'lucide-react';
|
|
||||||
import { useAuth } from '../context/AuthContext';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { UserRole } from '../types';
|
|
||||||
|
|
||||||
interface LoginModalProps {
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const LoginModal: React.FC<LoginModalProps> = ({ isOpen, onClose }) => {
|
|
||||||
const [email, setEmail] = useState('');
|
|
||||||
const [password, setPassword] = useState('');
|
|
||||||
const [name, setName] = useState('');
|
|
||||||
const [role, setRole] = useState<UserRole>('student');
|
|
||||||
const [isRegistering, setIsRegistering] = useState(false);
|
|
||||||
const [error, setError] = useState('');
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
||||||
const { login, register, logout } = useAuth();
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
if (!isOpen) return null;
|
|
||||||
|
|
||||||
const handleSubmit = async (event: React.FormEvent) => {
|
|
||||||
event.preventDefault();
|
|
||||||
setError('');
|
|
||||||
if (!email.trim() || !/^\S+@\S+\.\S+$/.test(email)) {
|
|
||||||
setError('Informe um e-mail válido.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isRegistering && name.trim().length < 2) {
|
|
||||||
setError('Informe seu nome.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (password.length < 8) {
|
|
||||||
setError('A senha deve ter pelo menos 8 caracteres.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setIsSubmitting(true);
|
|
||||||
|
|
||||||
if (isRegistering && role === 'professor') {
|
|
||||||
setIsSubmitting(false);
|
|
||||||
setError('Contas de instrutor são liberadas pelo administrador da plataforma.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const signedInUser = isRegistering
|
|
||||||
? await register(name, email, password)
|
|
||||||
: await login(email, password);
|
|
||||||
setIsSubmitting(false);
|
|
||||||
|
|
||||||
if (!signedInUser) {
|
|
||||||
setError(isRegistering
|
|
||||||
? 'Não foi possível criar sua conta. Use um e-mail válido e uma senha com pelo menos 8 caracteres.'
|
|
||||||
: 'Credenciais inválidas. Verifique seu e-mail e senha.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (signedInUser.role !== 'superadmin' && signedInUser.role !== role) {
|
|
||||||
logout();
|
|
||||||
setError(role === 'professor'
|
|
||||||
? 'Esta conta não possui acesso de instrutor.'
|
|
||||||
: 'Esta conta possui acesso de instrutor. Selecione a opção Instrutor.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
onClose();
|
|
||||||
navigate(signedInUser.role === 'superadmin' ? '/admin' : signedInUser.role === 'professor' ? '/gerenciar' : '/');
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4">
|
|
||||||
<div className="absolute inset-0 bg-black/60 backdrop-blur-xl transition-opacity" onClick={onClose} />
|
|
||||||
|
|
||||||
<div className="relative w-full max-w-md bg-[#1c1c1e] rounded-[8px] shadow-xl border border-white/10 p-6 md:p-8 animate-fade-in-up">
|
|
||||||
<button onClick={onClose} className="absolute top-5 right-5 text-white/40 hover:text-white transition-colors" aria-label="Fechar">
|
|
||||||
<X className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div className="text-center mb-6">
|
|
||||||
<h2 className="font-display text-heading-sm font-bold text-white mb-1.5 tracking-heading-sm leading-heading-sm">Compor HUB ID</h2>
|
|
||||||
<p className="text-body-sm font-normal text-white/60 tracking-body-sm leading-body-sm">Acesse seu espaço de aprendizado e materiais</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex bg-black/40 p-1 rounded-[8px] mb-6 border border-white/5 relative">
|
|
||||||
<div className={`absolute top-1 bottom-1 w-[calc(50%-4px)] bg-orange-500/20 rounded-[8px] transition-all duration-300 ease-out border border-orange-500/30 shadow-md ${role === 'student' ? 'left-1' : 'left-[calc(50%+4px)]'}`} />
|
|
||||||
<button type="button" onClick={() => setRole('student')} className={`flex-1 flex items-center justify-center gap-2 py-2.5 rounded-[8px] relative z-10 transition-colors duration-300 ${role === 'student' ? 'text-white font-semibold' : 'text-gray-400 hover:text-gray-300'}`}>
|
|
||||||
<GraduationCap className="w-4 h-4" />
|
|
||||||
<span className="text-body-sm font-semibold tracking-body-sm">Aluno</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" onClick={() => setRole('professor')} className={`flex-1 flex items-center justify-center gap-2 py-2.5 rounded-[8px] relative z-10 transition-colors duration-300 ${role === 'professor' ? 'text-white font-semibold' : 'text-gray-400 hover:text-gray-300'}`}>
|
|
||||||
<School className="w-4 h-4" />
|
|
||||||
<span className="text-body-sm font-semibold tracking-body-sm">Instrutor</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form noValidate onSubmit={handleSubmit} className="space-y-5">
|
|
||||||
<div className="space-y-3">
|
|
||||||
{isRegistering && <input type="text" placeholder="Seu nome" value={name} onChange={(event) => setName(event.target.value)} className="w-full bg-white/10 text-white placeholder:text-white/30 px-4 py-3 rounded-[8px] focus:outline-none focus:ring-2 focus:ring-orange-500/50 focus:bg-white/15 transition-all text-body tracking-body" autoFocus />}
|
|
||||||
<input type="email" placeholder="Seu e-mail" value={email} onChange={(event) => setEmail(event.target.value)} className="w-full bg-white/10 text-white placeholder:text-white/30 px-4 py-3 rounded-[8px] focus:outline-none focus:ring-2 focus:ring-orange-500/50 focus:bg-white/15 transition-all text-body tracking-body" autoFocus={!isRegistering} />
|
|
||||||
<input type="password" placeholder="Sua senha" value={password} onChange={(event) => setPassword(event.target.value)} className="w-full bg-white/10 text-white placeholder:text-white/30 px-4 py-3 rounded-[8px] focus:outline-none focus:ring-2 focus:ring-orange-500/50 focus:bg-white/15 transition-all text-body tracking-body" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{error && <div className="bg-red-500/10 border border-red-500/20 rounded-[8px] p-3"><p className="text-red-400 text-caption font-semibold tracking-caption text-center">{error}</p></div>}
|
|
||||||
|
|
||||||
<button type="submit" disabled={isSubmitting} className="w-full bg-white text-black text-body-sm font-semibold tracking-body-sm py-3.5 rounded-[980px] hover:bg-gray-200 active:scale-95 transition-all duration-200 flex items-center justify-center gap-2 shadow-xl">
|
|
||||||
{isSubmitting ? <Loader2 className="w-5 h-5 animate-spin" /> : isRegistering ? <UserPlus className="w-5 h-5" /> : null}
|
|
||||||
{isRegistering ? 'Criar conta' : 'Entrar'}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<button type="button" onClick={() => { setIsRegistering((value) => !value); setError(''); }} className="w-full mt-5 text-xs text-orange-400 hover:text-orange-300 transition-colors">
|
|
||||||
{isRegistering ? 'Já possui conta? Entrar' : 'Não possui conta? Criar acesso de aluno'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
FileText,
|
FileTextIcon as FileText,
|
||||||
FileSpreadsheet,
|
FileXlsIcon as FileSpreadsheet,
|
||||||
FileArchive,
|
FileArchiveIcon as FileArchive,
|
||||||
FileCode,
|
FileCodeIcon as FileCode,
|
||||||
Image as ImageIcon,
|
ImageIcon as ImageIcon,
|
||||||
Link as LinkIcon,
|
LinkIcon as LinkIcon,
|
||||||
Download,
|
DownloadSimpleIcon as Download,
|
||||||
ExternalLink,
|
ArrowSquareOutIcon as ExternalLink,
|
||||||
CheckCircle2,
|
CheckCircleIcon as CheckCircle2,
|
||||||
Paperclip
|
PaperclipIcon as Paperclip
|
||||||
} from 'lucide-react';
|
} from '@phosphor-icons/react';
|
||||||
import { Attachment, AttachmentType } from '../types';
|
import { Attachment, AttachmentType } from '../types';
|
||||||
import { useToast } from '../context/ToastContext';
|
import { useToast } from '../context/ToastContext';
|
||||||
import { downloadCourseAsset } from '../services/api';
|
import { downloadCourseAsset } from '../services/api';
|
||||||
|
|||||||
@@ -1,218 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import {
|
|
||||||
Download,
|
|
||||||
Search,
|
|
||||||
Filter,
|
|
||||||
FileText,
|
|
||||||
FileSpreadsheet,
|
|
||||||
FileArchive,
|
|
||||||
FileCode,
|
|
||||||
Sparkles,
|
|
||||||
ExternalLink,
|
|
||||||
BookOpen,
|
|
||||||
Layers
|
|
||||||
} from 'lucide-react';
|
|
||||||
import { Course, Attachment, AttachmentType } from '../types';
|
|
||||||
import { MaterialCard } from './MaterialCard';
|
|
||||||
|
|
||||||
interface MaterialsHubModalProps {
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
courses: Course[];
|
|
||||||
onSelectCourse?: (course: Course) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MaterialsHubModal: React.FC<MaterialsHubModalProps> = ({
|
|
||||||
isOpen,
|
|
||||||
onClose,
|
|
||||||
courses,
|
|
||||||
onSelectCourse,
|
|
||||||
}) => {
|
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
|
||||||
const [selectedType, setSelectedType] = useState<string>('all');
|
|
||||||
const [selectedCategory, setSelectedCategory] = useState<string>('all');
|
|
||||||
|
|
||||||
if (!isOpen) return null;
|
|
||||||
|
|
||||||
// Aggregate all materials across all courses and lessons
|
|
||||||
const allMaterials: Array<{ attachment: Attachment; course: Course; lessonTitle?: string }> = [];
|
|
||||||
|
|
||||||
courses.forEach(course => {
|
|
||||||
// Global course attachments
|
|
||||||
if (course.attachments && course.attachments.length > 0) {
|
|
||||||
course.attachments.forEach(att => {
|
|
||||||
allMaterials.push({ attachment: att, course });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lesson specific attachments
|
|
||||||
if (course.lessons) {
|
|
||||||
course.lessons.forEach(lesson => {
|
|
||||||
if (lesson.attachments && lesson.attachments.length > 0) {
|
|
||||||
lesson.attachments.forEach(att => {
|
|
||||||
allMaterials.push({ attachment: att, course, lessonTitle: lesson.title });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Filtered materials
|
|
||||||
const filtered = allMaterials.filter(item => {
|
|
||||||
const matchesSearch =
|
|
||||||
item.attachment.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
||||||
item.course.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
||||||
(item.attachment.description && item.attachment.description.toLowerCase().includes(searchTerm.toLowerCase()));
|
|
||||||
|
|
||||||
const matchesType = selectedType === 'all' || item.attachment.type === selectedType;
|
|
||||||
const matchesCategory = selectedCategory === 'all' || item.course.category === selectedCategory;
|
|
||||||
|
|
||||||
return matchesSearch && matchesType && matchesCategory;
|
|
||||||
});
|
|
||||||
|
|
||||||
const categories = Array.from(new Set(courses.map(c => c.category)));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="fixed inset-0 z-[120] bg-black/80 backdrop-blur-xl flex items-center justify-center p-4 md:p-8 animate-fade-in-up">
|
|
||||||
<div className="bg-[#101012] border border-white/10 rounded-[8px] w-full max-w-6xl max-h-[90vh] flex flex-col shadow-xl overflow-hidden">
|
|
||||||
|
|
||||||
{/* Header */}
|
|
||||||
<div className="p-6 md:p-8 border-b border-white/10 flex flex-col md:flex-row md:items-center justify-between gap-6 bg-gradient-to-r from-orange-950/20 via-black to-black">
|
|
||||||
<div>
|
|
||||||
<div className="flex items-center gap-2 text-caption font-semibold uppercase tracking-caption text-orange-400 mb-2">
|
|
||||||
<Sparkles className="w-4 h-4" />
|
|
||||||
<span>Central de Recursos & Downloads</span>
|
|
||||||
</div>
|
|
||||||
<h2 className="font-display text-subheading md:text-heading-sm font-bold text-white tracking-heading-sm leading-heading-sm">
|
|
||||||
Biblioteca de Materiais Complementares
|
|
||||||
</h2>
|
|
||||||
<p className="text-body-sm font-normal text-gray-400 mt-1 leading-body-sm tracking-body-sm">
|
|
||||||
Baixe planilhas, modelos, e-books, checklists e PDFs de todos os cursos do Compor HUB.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={onClose}
|
|
||||||
className="self-end md:self-center px-5 py-2.5 rounded-[980px] bg-white/10 hover:bg-white/20 text-white text-body-sm font-semibold tracking-body-sm transition-all shadow-xl"
|
|
||||||
>
|
|
||||||
Fechar
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Filters and Search Bar */}
|
|
||||||
<div className="p-6 border-b border-white/5 bg-[#141417] space-y-4">
|
|
||||||
<div className="flex flex-col md:flex-row gap-4 items-stretch md:items-center justify-between">
|
|
||||||
{/* Search Input */}
|
|
||||||
<div className="relative flex-1">
|
|
||||||
<Search className="w-5 h-5 text-gray-400 absolute left-4 top-1/2 -translate-y-1/2" />
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={searchTerm}
|
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
|
||||||
placeholder="Pesquisar material por nome, curso ou palavra-chave..."
|
|
||||||
className="w-full bg-black/60 border border-white/10 rounded-[8px] pl-12 pr-4 py-3 text-body-sm text-white placeholder:text-gray-500 focus:outline-none focus:border-orange-500/50 focus:ring-1 focus:ring-orange-500/50 transition-all"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Type Filters Pills */}
|
|
||||||
<div className="flex items-center gap-2 overflow-x-auto pb-1 md:pb-0 hide-scrollbar">
|
|
||||||
{[
|
|
||||||
{ id: 'all', label: 'Todos' },
|
|
||||||
{ id: 'pdf', label: 'PDFs' },
|
|
||||||
{ id: 'spreadsheet', label: 'Planilhas' },
|
|
||||||
{ id: 'zip', label: 'Pacotes ZIP' },
|
|
||||||
{ id: 'doc', label: 'Documentos' },
|
|
||||||
{ id: 'link', label: 'Links' },
|
|
||||||
].map(t => (
|
|
||||||
<button
|
|
||||||
key={t.id}
|
|
||||||
onClick={() => setSelectedType(t.id)}
|
|
||||||
className={`px-4 py-2 rounded-[980px] text-body-sm font-semibold tracking-body-sm whitespace-nowrap transition-all ${
|
|
||||||
selectedType === t.id
|
|
||||||
? 'bg-orange-500 text-white shadow-xl shadow-orange-500/20'
|
|
||||||
: 'bg-white/5 text-gray-400 hover:bg-white/10 hover:text-white'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{t.label}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Category Filter */}
|
|
||||||
<div className="flex items-center gap-2 flex-wrap text-caption font-semibold tracking-caption text-gray-400 pt-1">
|
|
||||||
<span className="text-gray-300 flex items-center gap-1.5 mr-1">
|
|
||||||
<Filter className="w-3.5 h-3.5 text-orange-400" /> Categoria:
|
|
||||||
</span>
|
|
||||||
<button
|
|
||||||
onClick={() => setSelectedCategory('all')}
|
|
||||||
className={`px-3 py-1 rounded-[980px] transition-colors ${
|
|
||||||
selectedCategory === 'all' ? 'bg-white/20 text-white' : 'hover:text-white'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
Todas ({allMaterials.length})
|
|
||||||
</button>
|
|
||||||
{categories.map(cat => {
|
|
||||||
const count = allMaterials.filter(m => m.course.category === cat).length;
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={cat}
|
|
||||||
onClick={() => setSelectedCategory(cat)}
|
|
||||||
className={`px-3 py-1 rounded-[980px] transition-colors ${
|
|
||||||
selectedCategory === cat ? 'bg-white/20 text-white' : 'hover:text-white'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{cat} ({count})
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Material Cards Grid */}
|
|
||||||
<div className="flex-1 overflow-y-auto p-6 md:p-8 space-y-6">
|
|
||||||
{filtered.length === 0 ? (
|
|
||||||
<div className="py-20 text-center text-gray-500">
|
|
||||||
<Download className="w-12 h-12 mx-auto mb-3 opacity-30 text-orange-400" />
|
|
||||||
<p className="text-body font-semibold text-gray-400">Nenhum material encontrado</p>
|
|
||||||
<p className="text-caption text-gray-600 mt-1">Tente ajustar seus termos de pesquisa ou filtros.</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5">
|
|
||||||
{filtered.map((item, index) => (
|
|
||||||
<div key={`${item.attachment.id}-${index}`} className="flex flex-col">
|
|
||||||
{/* Context Badge: Which Course / Lesson */}
|
|
||||||
<div className="flex items-center justify-between text-caption font-semibold tracking-caption text-gray-400 mb-2 px-1">
|
|
||||||
<span
|
|
||||||
onClick={() => {
|
|
||||||
onClose();
|
|
||||||
onSelectCourse?.(item.course);
|
|
||||||
}}
|
|
||||||
className="hover:text-orange-400 cursor-pointer truncate flex items-center gap-1.5"
|
|
||||||
>
|
|
||||||
<BookOpen className="w-3.5 h-3.5 text-orange-500/80" />
|
|
||||||
{item.course.title}
|
|
||||||
</span>
|
|
||||||
{item.lessonTitle && (
|
|
||||||
<span className="text-gray-500 truncate max-w-[120px] font-normal" title={item.lessonTitle}>
|
|
||||||
{item.lessonTitle}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<MaterialCard attachment={item.attachment} />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Footer info */}
|
|
||||||
<div className="p-4 px-8 border-t border-white/5 bg-[#0a0a0c] flex items-center justify-between text-caption font-semibold tracking-caption text-gray-500">
|
|
||||||
<span>{filtered.length} materiais disponíveis para download</span>
|
|
||||||
<span>Compor HUB • Materiais Exclusivos</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
|
||||||
import { User as UserIcon, LogOut, Search, Folder, BookOpenCheck, ChevronDown, ShieldCheck, Settings, UserRound } from 'lucide-react';
|
|
||||||
import { useAuth } from '../context/AuthContext';
|
|
||||||
import { LoginModal } from './LoginModal';
|
|
||||||
import { SearchModal } from './SearchModal';
|
|
||||||
import { useNavigate, useLocation } from 'react-router-dom';
|
|
||||||
import { Course } from '../types';
|
|
||||||
import { Logo } from './Logo';
|
|
||||||
|
|
||||||
interface NavbarProps {
|
|
||||||
onPlay: (course: Course) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Navbar: React.FC<NavbarProps> = ({ onPlay }) => {
|
|
||||||
const [scrolled, setScrolled] = useState(false);
|
|
||||||
const [showLoginModal, setShowLoginModal] = useState(false);
|
|
||||||
const [showSearchModal, setShowSearchModal] = useState(false);
|
|
||||||
const [showAccountMenu, setShowAccountMenu] = useState(false);
|
|
||||||
const { user, logout } = useAuth();
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const location = useLocation();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleScroll = () => {
|
|
||||||
setScrolled(window.scrollY > 20);
|
|
||||||
};
|
|
||||||
window.addEventListener('scroll', handleScroll);
|
|
||||||
return () => window.removeEventListener('scroll', handleScroll);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleLogout = () => {
|
|
||||||
logout();
|
|
||||||
navigate('/');
|
|
||||||
};
|
|
||||||
|
|
||||||
const isMaterialsPage = location.pathname === '/materiais';
|
|
||||||
const isHomePage = location.pathname === '/';
|
|
||||||
const goTo = (path: string) => {
|
|
||||||
setShowAccountMenu(false);
|
|
||||||
navigate(path);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<nav
|
|
||||||
className={`fixed top-0 left-0 right-0 z-50 transition-all duration-500 ease-in-out px-6 md:px-12 py-4 ${
|
|
||||||
scrolled || location.pathname !== '/'
|
|
||||||
? 'bg-[#09090b]/95 backdrop-blur-xl shadow-2xl shadow-black/80'
|
|
||||||
: 'bg-transparent bg-gradient-to-b from-black/90 via-black/40 to-transparent'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<div className="max-w-[1440px] mx-auto flex items-center justify-between gap-4">
|
|
||||||
<div className="flex items-center gap-6 md:gap-8">
|
|
||||||
<div
|
|
||||||
className="flex items-center gap-2 group cursor-pointer"
|
|
||||||
onClick={() => navigate('/')}
|
|
||||||
>
|
|
||||||
<Logo variant="dark" size="lg" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Quick Navigation Links */}
|
|
||||||
<div className="hidden md:flex items-center gap-2 text-sm font-medium">
|
|
||||||
<button
|
|
||||||
onClick={() => navigate('/')}
|
|
||||||
className={`px-4 py-2 rounded-[980px] transition-colors ${
|
|
||||||
isHomePage
|
|
||||||
? 'text-white bg-white/10 font-semibold'
|
|
||||||
: 'text-gray-400 hover:text-white hover:bg-white/5'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
Cursos
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => navigate('/materiais')}
|
|
||||||
className={`px-4 py-2 rounded-[980px] transition-colors flex items-center gap-2 ${
|
|
||||||
isMaterialsPage
|
|
||||||
? 'text-orange-400 bg-orange-500/15 font-semibold border border-orange-500/30'
|
|
||||||
: 'text-gray-400 hover:text-orange-400 hover:bg-white/5'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<Folder className="w-4 h-4 text-orange-400" />
|
|
||||||
<span>Biblioteca de Materiais</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-3 sm:gap-4">
|
|
||||||
|
|
||||||
{/* Search */}
|
|
||||||
<button
|
|
||||||
onClick={() => setShowSearchModal(true)}
|
|
||||||
className="text-gray-300 hover:text-white text-sm font-medium transition-colors flex items-center gap-2 px-3.5 py-2.5 rounded-[980px] hover:bg-white/10 border border-transparent hover:border-white/10"
|
|
||||||
>
|
|
||||||
<Search className="w-4 h-4" />
|
|
||||||
<span className="hidden lg:inline">Buscar</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{!user ? (
|
|
||||||
<button
|
|
||||||
onClick={() => setShowLoginModal(true)}
|
|
||||||
className="flex items-center gap-2.5 bg-orange-500 hover:bg-orange-600 active:scale-95 transition-all duration-300 px-6 py-2.5 rounded-[980px] text-sm font-bold text-white shadow-xl shadow-orange-500/25 shrink-0"
|
|
||||||
>
|
|
||||||
<UserIcon className="w-4 h-4 text-white" />
|
|
||||||
<span>Entrar</span>
|
|
||||||
</button>
|
|
||||||
) : (
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<div className="relative">
|
|
||||||
<button onClick={() => setShowAccountMenu((current) => !current)} className="flex items-center gap-2 rounded-[980px] px-3 py-2 text-sm text-gray-300 hover:bg-white/10 hover:text-white transition-colors" aria-expanded={showAccountMenu} aria-haspopup="menu">
|
|
||||||
<span className="hidden md:block">Olá, <strong className="font-semibold text-white">{user.name.split(' ')[0]}</strong></span>
|
|
||||||
<ChevronDown className={`h-4 w-4 transition-transform ${showAccountMenu ? 'rotate-180' : ''}`} />
|
|
||||||
</button>
|
|
||||||
{showAccountMenu && <div role="menu" className="absolute right-0 top-full mt-2 w-56 overflow-hidden rounded-xl border border-white/10 bg-zinc-950 p-1.5 shadow-2xl shadow-black/60">
|
|
||||||
<button role="menuitem" onClick={() => goTo('/perfil')} className="flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm text-gray-200 hover:bg-white/10"><UserRound className="h-4 w-4 text-orange-400" /> Meu perfil</button>
|
|
||||||
{user.role === 'student' && <button role="menuitem" onClick={() => goTo('/meu-aprendizado')} className="flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm text-gray-200 hover:bg-white/10"><BookOpenCheck className="h-4 w-4 text-orange-400" /> Meu aprendizado</button>}
|
|
||||||
{user.role === 'professor' && <button role="menuitem" onClick={() => goTo('/gerenciar')} className="flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm text-gray-200 hover:bg-white/10"><Settings className="h-4 w-4 text-orange-400" /> Painel do instrutor</button>}
|
|
||||||
{user.role === 'superadmin' && <><button role="menuitem" onClick={() => goTo('/admin')} className="flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm text-gray-200 hover:bg-white/10"><ShieldCheck className="h-4 w-4 text-orange-400" /> Painel administrativo</button><button role="menuitem" onClick={() => goTo('/gerenciar')} className="flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm text-gray-200 hover:bg-white/10"><Settings className="h-4 w-4 text-orange-400" /> Gerenciar cursos</button></>}
|
|
||||||
</div>}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="h-4 w-[1px] bg-white/20 hidden sm:block"></div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-2.5">
|
|
||||||
<button
|
|
||||||
onClick={handleLogout}
|
|
||||||
className="flex items-center gap-2 bg-red-500/10 hover:bg-red-500/20 active:scale-95 transition-all duration-300 px-4 py-2 rounded-[980px] border border-red-500/20 group text-xs font-semibold text-red-400"
|
|
||||||
title="Encerrar Sessão"
|
|
||||||
>
|
|
||||||
<LogOut className="w-3.5 h-3.5" />
|
|
||||||
<span className="hidden sm:inline">Sair</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<LoginModal isOpen={showLoginModal} onClose={() => setShowLoginModal(false)} />
|
|
||||||
<SearchModal isOpen={showSearchModal} onClose={() => setShowSearchModal(false)} onPlay={onPlay} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
import React, { useState, useEffect, useRef } from 'react';
|
|
||||||
import { Search, X, Loader2, PlayCircle, Download } from 'lucide-react';
|
|
||||||
import { Course } from '../types';
|
|
||||||
import { getCourses } from '../services/db';
|
|
||||||
import { CourseCoverImage } from './CourseCoverImage';
|
|
||||||
|
|
||||||
interface SearchModalProps {
|
|
||||||
isOpen: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
onPlay: (course: Course) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const SearchModal: React.FC<SearchModalProps> = ({ isOpen, onClose, onPlay }) => {
|
|
||||||
const [query, setQuery] = useState('');
|
|
||||||
const [allCourses, setAllCourses] = useState<Course[]>([]);
|
|
||||||
const [results, setResults] = useState<Course[]>([]);
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
// Load courses on mount
|
|
||||||
useEffect(() => {
|
|
||||||
const loadData = async () => {
|
|
||||||
const courses = await getCourses();
|
|
||||||
setAllCourses(courses);
|
|
||||||
setLoading(false);
|
|
||||||
};
|
|
||||||
loadData();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Focus input when opened
|
|
||||||
useEffect(() => {
|
|
||||||
if (isOpen) {
|
|
||||||
setTimeout(() => {
|
|
||||||
inputRef.current?.focus();
|
|
||||||
}, 100);
|
|
||||||
document.body.style.overflow = 'hidden';
|
|
||||||
} else {
|
|
||||||
document.body.style.overflow = 'unset';
|
|
||||||
}
|
|
||||||
return () => { document.body.style.overflow = 'unset'; };
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
// Filter logic across Title, Category, Instructor and Materials
|
|
||||||
useEffect(() => {
|
|
||||||
if (!query.trim()) {
|
|
||||||
setResults([]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowerQuery = query.toLowerCase();
|
|
||||||
const filtered = allCourses.filter(c => {
|
|
||||||
const matchesTitle = c.title.toLowerCase().includes(lowerQuery);
|
|
||||||
const matchesCat = c.category.toLowerCase().includes(lowerQuery);
|
|
||||||
const matchesInstructor = c.instructor?.toLowerCase().includes(lowerQuery);
|
|
||||||
const matchesLessons = c.lessons.some(l => l.title.toLowerCase().includes(lowerQuery));
|
|
||||||
const matchesAttachments = c.attachments?.some(a => a.name.toLowerCase().includes(lowerQuery));
|
|
||||||
|
|
||||||
return matchesTitle || matchesCat || matchesInstructor || matchesLessons || matchesAttachments;
|
|
||||||
});
|
|
||||||
setResults(filtered);
|
|
||||||
}, [query, allCourses]);
|
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
||||||
if (e.key === 'Escape') onClose();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!isOpen) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="fixed inset-0 z-[100] bg-[#0a0a0c]/95 backdrop-blur-xl animate-fade-in-up flex flex-col">
|
|
||||||
{/* Header / Search Input */}
|
|
||||||
<div className="pt-20 px-6 md:px-12 pb-6 border-b border-white/10 relative">
|
|
||||||
<button
|
|
||||||
onClick={onClose}
|
|
||||||
className="absolute top-6 right-6 md:right-12 p-2.5 bg-white/10 hover:bg-white/20 rounded-[980px] text-white transition-colors"
|
|
||||||
>
|
|
||||||
<X className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div className="max-w-[1440px] mx-auto w-full">
|
|
||||||
<div className="flex items-center gap-4">
|
|
||||||
<Search className="w-7 h-7 text-orange-400 shrink-0" />
|
|
||||||
<input
|
|
||||||
ref={inputRef}
|
|
||||||
type="text"
|
|
||||||
value={query}
|
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
|
||||||
onKeyDown={handleKeyDown}
|
|
||||||
placeholder="Buscar por cursos, aulas, instrutor ou materiais..."
|
|
||||||
className="w-full bg-transparent font-display text-2xl md:text-heading font-bold text-white placeholder:text-gray-600 focus:outline-none tracking-heading leading-heading"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Results Area */}
|
|
||||||
<div className="flex-1 overflow-y-auto px-6 md:px-12 py-8">
|
|
||||||
<div className="max-w-[1440px] mx-auto">
|
|
||||||
{loading ? (
|
|
||||||
<div className="flex justify-center mt-20">
|
|
||||||
<Loader2 className="w-10 h-10 text-orange-500 animate-spin" />
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{!query && (
|
|
||||||
<div className="text-center mt-20 opacity-40 space-y-2">
|
|
||||||
<p className="font-display text-subheading font-normal text-gray-300 tracking-subheading leading-subheading">Digite um termo para pesquisar cursos ou arquivos</p>
|
|
||||||
<p className="text-caption font-normal text-gray-500 tracking-caption">Ex: Meta Ads, ROAS, Planilha, Criativos, Funil</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{query && results.length === 0 && (
|
|
||||||
<div className="text-center mt-20">
|
|
||||||
<p className="text-body font-normal text-gray-400 tracking-body">Nenhum curso ou material encontrado para "{query}"</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{results.length > 0 && (
|
|
||||||
<div>
|
|
||||||
<h3 className="text-gray-400 font-semibold mb-6 uppercase tracking-caption text-caption flex items-center gap-2">
|
|
||||||
<span className="w-2 h-2 rounded-[980px] bg-orange-500"></span>
|
|
||||||
{results.length} Curso{results.length !== 1 ? 's' : ''} Encontrado{results.length !== 1 ? 's' : ''}
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-6">
|
|
||||||
{results.map(course => {
|
|
||||||
const matCount = (course.attachments?.length || 0) + course.lessons.reduce((acc, l) => acc + (l.attachments?.length || 0), 0);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={course.id}
|
|
||||||
onClick={() => { onPlay(course); onClose(); }}
|
|
||||||
className="cursor-pointer group bg-zinc-900/60 rounded-[8px] p-3 border border-white/5 hover:border-orange-500/40 transition-all duration-300 shadow-xl"
|
|
||||||
>
|
|
||||||
<div className="aspect-video bg-gray-900 rounded-[8px] overflow-hidden mb-3 relative">
|
|
||||||
<CourseCoverImage
|
|
||||||
source={course.thumbnail}
|
|
||||||
alt={course.title}
|
|
||||||
className="w-full h-full object-cover opacity-80 group-hover:opacity-100 group-hover:scale-105 transition-all duration-300 rounded-[8px]"
|
|
||||||
style={{
|
|
||||||
transform: `scale(${course.coverImageZoom || 1})`,
|
|
||||||
objectPosition: `${course.coverImagePositionX ?? 50}% ${course.coverImagePositionY ?? 50}%`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/40">
|
|
||||||
<PlayCircle className="w-10 h-10 text-orange-500" />
|
|
||||||
</div>
|
|
||||||
{matCount > 0 && (
|
|
||||||
<div className="absolute bottom-2 right-2 bg-black/70 backdrop-blur-md px-2 py-0.5 rounded-[980px] text-caption font-semibold text-orange-400 border border-orange-500/30 flex items-center gap-1">
|
|
||||||
<Download className="w-2.5 h-2.5" />
|
|
||||||
{matCount}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4 className="text-white font-semibold text-body-sm truncate group-hover:text-orange-400 transition-colors leading-body-sm tracking-body-sm">
|
|
||||||
{course.title}
|
|
||||||
</h4>
|
|
||||||
<div className="flex items-center justify-between text-caption font-normal tracking-caption text-gray-500 mt-1">
|
|
||||||
<span className="truncate">{course.category}</span>
|
|
||||||
<span>{course.duration}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,8 +1,19 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Copy, Download, KeyRound, Loader2, Pencil, Plus, Trash2, UserCheck, UserX, X } from 'lucide-react';
|
import {
|
||||||
|
CopyIcon as Copy,
|
||||||
|
DownloadSimpleIcon as Download,
|
||||||
|
KeyIcon as KeyRound,
|
||||||
|
CircleNotchIcon as Loader2,
|
||||||
|
PencilIcon as Pencil,
|
||||||
|
PlusIcon as Plus,
|
||||||
|
TrashIcon as Trash2,
|
||||||
|
UserCheckIcon as UserCheck,
|
||||||
|
UserMinusIcon as UserX,
|
||||||
|
XIcon as X
|
||||||
|
} from '@phosphor-icons/react';
|
||||||
import { ManagedUser } from '../services/api';
|
import { ManagedUser } from '../services/api';
|
||||||
|
|
||||||
const roleLabel: Record<ManagedUser['role'], string> = { admin: 'Superadmin', instructor: 'Instrutor', student: 'Aluno' };
|
const roleLabel: Record<ManagedUser['role'], string> = { admin: 'Admin', instructor: 'Instrutor', student: 'Aluno' };
|
||||||
const inputClass = 'w-full rounded-xl border border-white/10 bg-zinc-900 px-3 py-2.5 text-sm text-white outline-none focus:border-orange-500/70 focus:ring-2 focus:ring-orange-500/15';
|
const inputClass = 'w-full rounded-xl border border-white/10 bg-zinc-900 px-3 py-2.5 text-sm text-white outline-none focus:border-orange-500/70 focus:ring-2 focus:ring-orange-500/15';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
115
components/admin/BannerManager.tsx
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
|
import { adminApi, HomeBanner } from '../../services/api';
|
||||||
|
import { instructorApi } from '../../services/api';
|
||||||
|
import { useToast } from '../../context/ToastContext';
|
||||||
|
import { CourseCoverImage } from '../CourseCoverImage';
|
||||||
|
import { Select } from '../ui/Select';
|
||||||
|
import { ArrowDownIcon, ArrowUpIcon, PlusIcon, TrashIcon } from '@phosphor-icons/react';
|
||||||
|
import { PlusMockIcon } from '../ui/MockupIcons';
|
||||||
|
|
||||||
|
type CourseOption = { id: string; title: string; category: string; coverImageUrl: string | null };
|
||||||
|
|
||||||
|
export const BannerManager: React.FC<{ courses: CourseOption[]; onChanged?: () => void }> = ({ courses, onChanged }) => {
|
||||||
|
const { showToast } = useToast();
|
||||||
|
const [banners, setBanners] = useState<HomeBanner[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [kind, setKind] = useState<'course' | 'custom'>('course');
|
||||||
|
const [courseId, setCourseId] = useState('');
|
||||||
|
const [title, setTitle] = useState('');
|
||||||
|
const [description, setDescription] = useState('');
|
||||||
|
const [imageUrl, setImageUrl] = useState('');
|
||||||
|
const [uploading, setUploading] = useState(false);
|
||||||
|
const [coverConfigured, setCoverConfigured] = useState(false);
|
||||||
|
const fileInput = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
adminApi.homeBanners().then((response) => setBanners(response.data)).catch(() => showToast('Não foi possível carregar os banners.', 'error')).finally(() => setLoading(false));
|
||||||
|
instructorApi.coverConfiguration().then((response) => setCoverConfigured(response.data.configured)).catch(() => setCoverConfigured(false));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const persist = async (next: HomeBanner[]) => {
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
const response = await adminApi.updateHomeBanners(next.map(({ kind: bannerKind, courseId: bannerCourseId, imageUrl: bannerImage, title: bannerTitle, description: bannerDescription }) => ({ kind: bannerKind, courseId: bannerCourseId, imageUrl: bannerImage, title: bannerTitle, description: bannerDescription })));
|
||||||
|
setBanners(response.data);
|
||||||
|
showToast('Banners atualizados.', 'success');
|
||||||
|
onChanged?.();
|
||||||
|
} catch {
|
||||||
|
showToast('Não foi possível salvar os banners.', 'error');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const upload = async (file?: File) => {
|
||||||
|
if (!file) return;
|
||||||
|
if (!coverConfigured) { showToast('O envio de imagens ainda não está configurado.', 'error'); return; }
|
||||||
|
setUploading(true);
|
||||||
|
try {
|
||||||
|
const response = await instructorApi.uploadCover(file);
|
||||||
|
setImageUrl(response.data.coverImageUrl);
|
||||||
|
} catch {
|
||||||
|
showToast('Não foi possível enviar a imagem.', 'error');
|
||||||
|
} finally {
|
||||||
|
setUploading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const add = () => {
|
||||||
|
if (kind === 'course' && !courseId) { showToast('Selecione um curso para o banner.', 'error'); return; }
|
||||||
|
if (kind === 'custom' && !imageUrl) { showToast('Envie uma imagem para o banner.', 'error'); return; }
|
||||||
|
const next: HomeBanner[] = [...banners, {
|
||||||
|
id: `banner-${Date.now()}`,
|
||||||
|
kind,
|
||||||
|
courseId: kind === 'course' ? courseId : null,
|
||||||
|
imageUrl: kind === 'custom' ? imageUrl : null,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
position: banners.length + 1,
|
||||||
|
courseTitle: kind === 'course' ? courses.find((course) => course.id === courseId)?.title || null : null,
|
||||||
|
courseDescription: null,
|
||||||
|
courseImageUrl: kind === 'course' ? courses.find((course) => course.id === courseId)?.coverImageUrl || null : null,
|
||||||
|
}];
|
||||||
|
setKind('course');
|
||||||
|
setCourseId('');
|
||||||
|
setTitle('');
|
||||||
|
setDescription('');
|
||||||
|
setImageUrl('');
|
||||||
|
void persist(next);
|
||||||
|
};
|
||||||
|
|
||||||
|
const move = (index: number, direction: -1 | 1) => {
|
||||||
|
const target = index + direction;
|
||||||
|
if (target < 0 || target >= banners.length) return;
|
||||||
|
const next = [...banners];
|
||||||
|
[next[index], next[target]] = [next[target], next[index]];
|
||||||
|
setBanners(next);
|
||||||
|
void persist(next);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading) return <div className="loading">Carregando banners…</div>;
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<div className="box" style={{ marginBottom: 24 }}>
|
||||||
|
<h3>Novo banner</h3>
|
||||||
|
<div className="form" style={{ marginTop: 16 }}>
|
||||||
|
<div className="field"><label>Tipo</label><Select variant="field" value={kind} options={[{ value: 'course', label: 'Curso publicado' }, { value: 'custom', label: 'Imagem personalizada' }]} onChange={(value) => setKind(value as 'course' | 'custom')} ariaLabel="Tipo do banner" /></div>
|
||||||
|
{kind === 'course' ? <div className="field"><label>Curso</label><Select variant="field" value={courseId} options={[{ value: '', label: 'Selecione um curso' }, ...courses.map((course) => ({ value: course.id, label: course.title }))]} onChange={setCourseId} ariaLabel="Curso do banner" /></div> : <>
|
||||||
|
<div className="field"><label>Imagem</label><div style={{ display: 'flex', alignItems: 'center', gap: 12 }}><button className="btn sec" type="button" disabled={!coverConfigured || uploading} onClick={() => fileInput.current?.click()}><PlusMockIcon className="ph" /> {uploading ? 'Enviando…' : 'Enviar imagem'}</button>{imageUrl && <CourseCoverImage source={imageUrl} alt="" style={{ width: 96, height: 54, borderRadius: 8, objectFit: 'cover' }} />}</div><input ref={fileInput} type="file" accept="image/jpeg,image/png,image/webp" hidden onChange={(event) => { const file = event.target.files?.[0]; event.currentTarget.value = ''; void upload(file); }} /></div>
|
||||||
|
{!coverConfigured && <p className="muted" style={{ fontSize: 12 }}>O armazenamento de imagens ainda não está configurado.</p>}
|
||||||
|
</>}
|
||||||
|
<div className="field"><label>Título (opcional)</label><input value={title} onChange={(event) => setTitle(event.target.value)} placeholder="Título do banner" /></div>
|
||||||
|
<div className="field"><label>Descrição (opcional)</label><input value={description} onChange={(event) => setDescription(event.target.value)} placeholder="Descrição do banner" /></div>
|
||||||
|
<button className="btn" type="button" onClick={add} disabled={saving}><PlusIcon className="ph" /> Adicionar banner</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{banners.length ? <div className="list">{banners.map((banner, index) => <div className="row" key={banner.id} style={{ gridTemplateColumns: '96px minmax(0, 1fr) auto' }}>
|
||||||
|
<span style={{ width: 96, height: 54, borderRadius: 8, overflow: 'hidden', background: 'var(--bg-2)', display: 'block' }}>
|
||||||
|
{(banner.imageUrl || banner.courseImageUrl) ? <CourseCoverImage source={banner.imageUrl || banner.courseImageUrl || ''} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover' }} /> : null}
|
||||||
|
</span>
|
||||||
|
<span className="t">{banner.kind === 'course' ? banner.courseTitle || 'Curso' : banner.title || 'Banner personalizado'}<small>{banner.kind === 'course' ? 'Capa do curso' : 'Imagem enviada'}</small></span>
|
||||||
|
<span style={{ display: 'flex', gap: 4 }}><button className="iconbtn" type="button" disabled={index === 0} onClick={() => move(index, -1)} aria-label="Mover banner para cima"><ArrowUpIcon className="ph" /></button><button className="iconbtn" type="button" disabled={index === banners.length - 1} onClick={() => move(index, 1)} aria-label="Mover banner para baixo"><ArrowDownIcon className="ph" /></button><button className="iconbtn" type="button" onClick={() => void persist(banners.filter((item) => item.id !== banner.id))} aria-label="Remover banner"><TrashIcon className="ph" /></button></span>
|
||||||
|
</div>)}</div> : <p className="empty">Nenhum banner configurado. A home usa o primeiro curso como destaque.</p>}
|
||||||
|
</>;
|
||||||
|
};
|
||||||
66
components/admin/CategoryManager.tsx
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { adminApi } from '../../services/api';
|
||||||
|
import { useToast } from '../../context/ToastContext';
|
||||||
|
import { Switch } from '../ui/Switch';
|
||||||
|
import { PlusMockIcon } from '../ui/MockupIcons';
|
||||||
|
|
||||||
|
type Category = { id: string; name: string; position: number; isActive: boolean };
|
||||||
|
|
||||||
|
const CategoryRow: React.FC<{ category: Category; onSave: (category: Category, update: { name: string; isActive: boolean }) => Promise<void> }> = ({ category, onSave }) => {
|
||||||
|
const [name, setName] = useState(category.name);
|
||||||
|
useEffect(() => setName(category.name), [category.name]);
|
||||||
|
const dirty = name.trim() !== category.name && name.trim().length > 0;
|
||||||
|
return <div className="row" style={{ gridTemplateColumns: 'minmax(0, 1fr) auto auto' }}>
|
||||||
|
<input className="input" style={{ height: 40, fontSize: 15 }} value={name} onChange={(event) => setName(event.target.value)} aria-label={`Nome da categoria ${category.name}`} />
|
||||||
|
{dirty ? <button className="btn sec" type="button" onClick={() => void onSave(category, { name: name.trim(), isActive: category.isActive })}>Salvar</button> : <span />}
|
||||||
|
<Switch checked={category.isActive} onChange={(checked) => void onSave(category, { name: name.trim() || category.name, isActive: checked })} label={`Categoria ${category.name} ativa`} />
|
||||||
|
</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CategoryManager: React.FC<{ onChanged?: () => void }> = ({ onChanged }) => {
|
||||||
|
const { showToast } = useToast();
|
||||||
|
const [categories, setCategories] = useState<Category[]>([]);
|
||||||
|
const [newName, setNewName] = useState('');
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
adminApi.categories().then((response) => setCategories(response.data)).catch(() => showToast('Não foi possível carregar as categorias.', 'error')).finally(() => setLoading(false));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const create = async (event: React.FormEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
if (!newName.trim()) return;
|
||||||
|
try {
|
||||||
|
const response = await adminApi.createCategory(newName.trim());
|
||||||
|
setCategories((current) => [...current, response.data].sort((a, b) => a.position - b.position || a.name.localeCompare(b.name)));
|
||||||
|
setNewName('');
|
||||||
|
showToast('Categoria criada.', 'success');
|
||||||
|
onChanged?.();
|
||||||
|
} catch {
|
||||||
|
showToast('Não foi possível criar a categoria. Ela pode já existir.', 'error');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const save = async (category: Category, update: { name: string; isActive: boolean }) => {
|
||||||
|
try {
|
||||||
|
const response = await adminApi.updateCategory(category.id, update);
|
||||||
|
setCategories((current) => current.map((item) => item.id === category.id ? response.data : item));
|
||||||
|
showToast('Categoria atualizada.', 'success');
|
||||||
|
onChanged?.();
|
||||||
|
} catch {
|
||||||
|
showToast('Não foi possível atualizar a categoria.', 'error');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading) return <div className="loading">Carregando categorias…</div>;
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<form className="toolbar" onSubmit={create}>
|
||||||
|
<input className="input" style={{ flex: 1, minWidth: 220 }} value={newName} onChange={(event) => setNewName(event.target.value)} placeholder="Nome da categoria" aria-label="Nova categoria" />
|
||||||
|
<button className="btn" type="submit" disabled={!newName.trim()}><PlusMockIcon className="ph" /> Adicionar categoria</button>
|
||||||
|
</form>
|
||||||
|
<p className="muted" style={{ marginBottom: 12 }}>Categorias ativas aparecem na criação de cursos e nas áreas do catálogo.</p>
|
||||||
|
<div className="list">{categories.map((category) => <CategoryRow key={category.id} category={category} onSave={save} />)}</div>
|
||||||
|
{!categories.length && <p className="empty">Nenhuma categoria cadastrada.</p>}
|
||||||
|
</>;
|
||||||
|
};
|
||||||
143
components/admin/TrailManager.tsx
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import { ArrowDownIcon, ArrowUpIcon, PencilIcon, TrashIcon } from '@phosphor-icons/react';
|
||||||
|
import { adminApi, instructorApi, LearningPath, LearningPathInput, TrailCourseOption } from '../../services/api';
|
||||||
|
import { useToast } from '../../context/ToastContext';
|
||||||
|
import { CourseCoverImage } from '../CourseCoverImage';
|
||||||
|
import { Select } from '../ui/Select';
|
||||||
|
import { ConfirmDialog } from '../ui/ConfirmDialog';
|
||||||
|
import { PlusMockIcon } from '../ui/MockupIcons';
|
||||||
|
|
||||||
|
const emptyInput = (): LearningPathInput => ({ title: '', description: '', coverImageUrl: null, coverImageZoom: 1, coverImagePositionX: 50, coverImagePositionY: 50, status: 'draft', courseIds: [] });
|
||||||
|
const toInput = (path: LearningPath): LearningPathInput => ({ title: path.title, description: path.description, coverImageUrl: path.coverImageUrl, coverImageZoom: path.coverImageZoom, coverImagePositionX: path.coverImagePositionX, coverImagePositionY: path.coverImagePositionY, status: path.status === 'published' ? 'published' : 'draft', courseIds: path.courses.map((course) => course.id) });
|
||||||
|
|
||||||
|
export const TrailManager: React.FC<{ onChanged?: () => void }> = ({ onChanged }) => {
|
||||||
|
const { showToast } = useToast();
|
||||||
|
const [paths, setPaths] = useState<LearningPath[]>([]);
|
||||||
|
const [courses, setCourses] = useState<TrailCourseOption[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [editorOpen, setEditorOpen] = useState(false);
|
||||||
|
const [editing, setEditing] = useState<LearningPath | null>(null);
|
||||||
|
const [input, setInput] = useState<LearningPathInput>(emptyInput());
|
||||||
|
const [courseToAdd, setCourseToAdd] = useState('');
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [uploading, setUploading] = useState(false);
|
||||||
|
const [coverConfigured, setCoverConfigured] = useState(false);
|
||||||
|
const [deleteTarget, setDeleteTarget] = useState<LearningPath | null>(null);
|
||||||
|
const coverInput = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
const load = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const [pathsResponse, coursesResponse] = await Promise.all([adminApi.listPaths(), adminApi.listPathCourses()]);
|
||||||
|
setPaths(pathsResponse.data);
|
||||||
|
setCourses(coursesResponse.data);
|
||||||
|
} catch {
|
||||||
|
showToast('Não foi possível carregar as trilhas.', 'error');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void load();
|
||||||
|
instructorApi.coverConfiguration().then((response) => setCoverConfigured(response.data.configured)).catch(() => setCoverConfigured(false));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const selectedCourses = useMemo(() => input.courseIds.map((id) => courses.find((course) => course.id === id)).filter((course): course is TrailCourseOption => Boolean(course)), [courses, input.courseIds]);
|
||||||
|
const availableCourses = courses.filter((course) => !input.courseIds.includes(course.id));
|
||||||
|
|
||||||
|
const openNew = () => { setEditing(null); setInput(emptyInput()); setCourseToAdd(''); setEditorOpen(true); };
|
||||||
|
const openEdit = (path: LearningPath) => { setEditing(path); setInput(toInput(path)); setCourseToAdd(''); setEditorOpen(true); };
|
||||||
|
|
||||||
|
const uploadCover = async (file?: File) => {
|
||||||
|
if (!file) return;
|
||||||
|
if (!coverConfigured) { showToast('O envio de imagens ainda não está configurado.', 'error'); return; }
|
||||||
|
setUploading(true);
|
||||||
|
try {
|
||||||
|
const response = await instructorApi.uploadCover(file);
|
||||||
|
setInput((current) => ({ ...current, coverImageUrl: response.data.coverImageUrl }));
|
||||||
|
} catch {
|
||||||
|
showToast('Não foi possível enviar a capa.', 'error');
|
||||||
|
} finally {
|
||||||
|
setUploading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const save = async (event: React.FormEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
if (!input.title.trim()) { showToast('Informe o nome da trilha.', 'error'); return; }
|
||||||
|
if (!input.courseIds.length) { showToast('Adicione pelo menos um curso.', 'error'); return; }
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
if (editing) await adminApi.updatePath(editing.id, input);
|
||||||
|
else await adminApi.createPath(input);
|
||||||
|
showToast(editing ? 'Trilha atualizada.' : 'Trilha criada.', 'success');
|
||||||
|
setEditorOpen(false);
|
||||||
|
await load();
|
||||||
|
onChanged?.();
|
||||||
|
} catch (error) {
|
||||||
|
showToast(error instanceof Error ? error.message : 'Não foi possível salvar a trilha.', 'error');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const addCourse = () => {
|
||||||
|
if (!courseToAdd) return;
|
||||||
|
setInput((current) => ({ ...current, courseIds: [...current.courseIds, courseToAdd] }));
|
||||||
|
setCourseToAdd('');
|
||||||
|
};
|
||||||
|
|
||||||
|
const moveCourse = (index: number, direction: -1 | 1) => {
|
||||||
|
const target = index + direction;
|
||||||
|
if (target < 0 || target >= input.courseIds.length) return;
|
||||||
|
const next = [...input.courseIds];
|
||||||
|
[next[index], next[target]] = [next[target], next[index]];
|
||||||
|
setInput((current) => ({ ...current, courseIds: next }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeCourse = (courseId: string) => setInput((current) => ({ ...current, courseIds: current.courseIds.filter((id) => id !== courseId) }));
|
||||||
|
|
||||||
|
const performDelete = async () => {
|
||||||
|
if (!deleteTarget) return;
|
||||||
|
try {
|
||||||
|
await adminApi.deletePath(deleteTarget.id);
|
||||||
|
setPaths((current) => current.filter((path) => path.id !== deleteTarget.id));
|
||||||
|
setDeleteTarget(null);
|
||||||
|
showToast('Trilha excluída. Os cursos foram preservados.', 'success');
|
||||||
|
onChanged?.();
|
||||||
|
} catch {
|
||||||
|
showToast('Não foi possível excluir a trilha.', 'error');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading) return <div className="loading">Carregando trilhas…</div>;
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<div className="toolbar"><h2 style={{ fontSize: 20, marginRight: 'auto' }}>Trilhas</h2><button className="btn" type="button" onClick={openNew}><PlusMockIcon className="ph" /> Nova trilha</button></div>
|
||||||
|
{paths.length ? <div className="list">{paths.map((path) => <div className="row" key={path.id} style={{ gridTemplateColumns: '96px minmax(0, 1fr) auto' }}>
|
||||||
|
<span style={{ width: 96, height: 54, borderRadius: 8, overflow: 'hidden', background: 'var(--bg-2)', display: 'block' }}>{path.coverImageUrl ? <CourseCoverImage source={path.coverImageUrl} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover' }} /> : null}</span>
|
||||||
|
<span className="t">{path.title}<small>{path.status === 'published' ? 'Publicada' : 'Rascunho'} · {path.courses.length} {path.courses.length === 1 ? 'curso' : 'cursos'}</small></span>
|
||||||
|
<span style={{ display: 'flex', gap: 4 }}><button className="iconbtn" type="button" onClick={() => openEdit(path)} aria-label={`Editar trilha ${path.title}`}><PencilIcon className="ph" /></button><button className="iconbtn" type="button" onClick={() => setDeleteTarget(path)} aria-label={`Excluir trilha ${path.title}`}><TrashIcon className="ph" /></button></span>
|
||||||
|
</div>)}</div> : <p className="empty">Nenhuma trilha criada ainda.</p>}
|
||||||
|
|
||||||
|
{editorOpen && <div className="scrim" role="dialog" aria-modal="true" aria-label={editing ? 'Editar trilha' : 'Nova trilha'} onMouseDown={(event) => { if (event.target === event.currentTarget) setEditorOpen(false); }}>
|
||||||
|
<div className="dialog" style={{ maxWidth: 760 }}>
|
||||||
|
<header><div><h2>{editing ? 'Editar trilha' : 'Nova trilha'}</h2><p>Organize cursos existentes na ordem em que os alunos devem assisti-los.</p></div><button type="button" className="iconbtn" onClick={() => setEditorOpen(false)} aria-label="Fechar">×</button></header>
|
||||||
|
<form className="form" onSubmit={save}>
|
||||||
|
<div className="field"><label htmlFor="trail-title">Nome</label><input id="trail-title" value={input.title} onChange={(event) => setInput((current) => ({ ...current, title: event.target.value }))} maxLength={160} required /></div>
|
||||||
|
<div className="field"><label htmlFor="trail-description">Descrição</label><textarea id="trail-description" rows={3} value={input.description} onChange={(event) => setInput((current) => ({ ...current, description: event.target.value }))} maxLength={2000} /></div>
|
||||||
|
<div className="field"><label>Status</label><Select variant="field" value={input.status} options={[{ value: 'draft', label: 'Rascunho' }, { value: 'published', label: 'Publicada' }]} onChange={(status) => setInput((current) => ({ ...current, status: status as LearningPathInput['status'] }))} ariaLabel="Status da trilha" /></div>
|
||||||
|
<div className="field"><label>Capa</label><div style={{ display: 'flex', alignItems: 'center', gap: 12 }}><button className="btn sec" type="button" disabled={!coverConfigured || uploading} onClick={() => coverInput.current?.click()}>{uploading ? 'Enviando…' : 'Enviar imagem'}</button>{input.coverImageUrl && <CourseCoverImage source={input.coverImageUrl} alt="" style={{ width: 120, height: 68, borderRadius: 8, objectFit: 'cover' }} />}</div><input ref={coverInput} type="file" accept="image/jpeg,image/png,image/webp" hidden onChange={(event) => { const file = event.target.files?.[0]; event.currentTarget.value = ''; void uploadCover(file); }} />{!coverConfigured && <p className="muted" style={{ fontSize: 12 }}>O armazenamento de imagens ainda não está configurado.</p>}</div>
|
||||||
|
<div className="field"><label>Cursos da trilha</label>
|
||||||
|
<div className="list">{selectedCourses.map((course, index) => <div className="row" key={course.id} style={{ gridTemplateColumns: '28px minmax(0, 1fr) auto' }}><span className="i num">{index + 1}</span><span className="t">{course.title}<small>{course.category}</small></span><span style={{ display: 'flex', gap: 2 }}><button className="iconbtn" type="button" disabled={index === 0} onClick={() => moveCourse(index, -1)} aria-label="Mover para cima"><ArrowUpIcon className="ph" /></button><button className="iconbtn" type="button" disabled={index === selectedCourses.length - 1} onClick={() => moveCourse(index, 1)} aria-label="Mover para baixo"><ArrowDownIcon className="ph" /></button><button className="iconbtn" type="button" onClick={() => removeCourse(course.id)} aria-label="Remover curso"><TrashIcon className="ph" /></button></span></div>)}</div>
|
||||||
|
<div style={{ display: 'flex', gap: 8, marginTop: 10 }}><div style={{ flex: 1 }}><Select variant="field" value={courseToAdd} options={[{ value: '', label: availableCourses.length ? 'Selecione um curso' : 'Nenhum curso disponível' }, ...availableCourses.map((course) => ({ value: course.id, label: course.title }))]} onChange={setCourseToAdd} ariaLabel="Curso para adicionar" disabled={!availableCourses.length} /></div><button className="btn sec" type="button" onClick={addCourse} disabled={!courseToAdd}><PlusMockIcon className="ph" /> Adicionar</button></div>
|
||||||
|
</div>
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 8, marginTop: 24 }}><button className="btn sec" type="button" onClick={() => setEditorOpen(false)}>Cancelar</button><button className="btn" type="submit" disabled={saving}>{saving ? 'Salvando…' : 'Salvar trilha'}</button></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>}
|
||||||
|
|
||||||
|
<ConfirmDialog open={Boolean(deleteTarget)} title="Excluir trilha" message={deleteTarget ? `Excluir a trilha “${deleteTarget.title}”? Os cursos serão preservados.` : ''} confirmLabel="Excluir trilha" onCancel={() => setDeleteTarget(null)} onConfirm={() => void performDelete()} />
|
||||||
|
</>;
|
||||||
|
};
|
||||||
140
components/catalog/Artwork.tsx
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { Course } from '../../types';
|
||||||
|
import { PublicLearningPath } from '../../services/db';
|
||||||
|
import { CourseCoverImage } from '../CourseCoverImage';
|
||||||
|
import { useCatalog } from '../../context/CatalogContext';
|
||||||
|
import { useAuth } from '../../context/AuthContext';
|
||||||
|
import { courseMeta, hasRealCover, plural, totalDuration } from '../../lib/format';
|
||||||
|
import { paths } from '../../lib/routes';
|
||||||
|
|
||||||
|
type Framing = { zoom?: number; x?: number; y?: number };
|
||||||
|
|
||||||
|
/** A real cover (Bunny) replaces the colour block in the same format. */
|
||||||
|
export const ArtImage: React.FC<{ source: string; framing?: Framing; onMissing?: () => void }> = ({ source, framing, onMissing }) => (
|
||||||
|
<CourseCoverImage
|
||||||
|
source={source}
|
||||||
|
alt=""
|
||||||
|
loading="lazy"
|
||||||
|
draggable={false}
|
||||||
|
className="art-img"
|
||||||
|
onFinalError={onMissing}
|
||||||
|
style={{ transform: framing?.zoom && framing.zoom !== 1 ? `scale(${framing.zoom})` : undefined, objectPosition: `${framing?.x ?? 50}% ${framing?.y ?? 50}%` }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const courseFraming = (course: Course): Framing => ({ zoom: course.coverImageZoom, x: course.coverImagePositionX, y: course.coverImagePositionY });
|
||||||
|
|
||||||
|
/** Hook that tells whether a course shows its uploaded image, falling back to colour if it fails to load. */
|
||||||
|
export const useCoverImage = (source?: string | null) => {
|
||||||
|
const [broken, setBroken] = useState(false);
|
||||||
|
const show = hasRealCover(source) && !broken;
|
||||||
|
return { show, onMissing: () => setBroken(true) };
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Progress: React.FC<{ value: number; inside?: boolean }> = ({ value, inside }) => {
|
||||||
|
const pct = Math.max(0, Math.min(100, Math.round(value)));
|
||||||
|
return (
|
||||||
|
<span className={inside ? 'inprog' : 'prog'} role="progressbar" aria-label={`${pct}% concluído`} aria-valuenow={pct} aria-valuemin={0} aria-valuemax={100} style={inside ? undefined : { display: 'block' }}>
|
||||||
|
<i style={{ width: `${pct}%` }} />
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
interface CoverProps {
|
||||||
|
course: Course;
|
||||||
|
variant?: 'big' | 'mini';
|
||||||
|
progress?: number;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Course artwork: 16:10 block in the area colour with the title, or the uploaded image. */
|
||||||
|
export const Cover: React.FC<CoverProps> = ({ course, variant, progress, className = '' }) => {
|
||||||
|
const { toneOf } = useCatalog();
|
||||||
|
const image = useCoverImage(course.thumbnail);
|
||||||
|
const showBar = progress !== undefined && progress > 0;
|
||||||
|
return (
|
||||||
|
<div className={`cover tr-${toneOf(course.category)}${variant ? ` ${variant}` : ''}${showBar ? ' hp' : ''}${image.show ? ' has-img' : ''} ${className}`}>
|
||||||
|
{image.show && <ArtImage source={course.thumbnail} framing={courseFraming(course)} onMissing={image.onMissing} />}
|
||||||
|
{!image.show && <span className="t">{course.title}</span>}
|
||||||
|
{showBar && <Progress value={progress} inside />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Small colour/image chip used next to titles in lists. */
|
||||||
|
export const Thumb: React.FC<{ course: Course; className?: string }> = ({ course, className = 'thumb' }) => {
|
||||||
|
const { toneOf } = useCatalog();
|
||||||
|
const image = useCoverImage(course.thumbnail);
|
||||||
|
return (
|
||||||
|
<span className={`${className} tr-${toneOf(course.category)}`} aria-hidden="true">
|
||||||
|
{image.show && <ArtImage source={course.thumbnail} framing={courseFraming(course)} onMissing={image.onMissing} />}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CourseCard: React.FC<{ course: Course }> = ({ course }) => {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const image = useCoverImage(course.thumbnail);
|
||||||
|
const progress = user ? course.progress || 0 : 0;
|
||||||
|
return (
|
||||||
|
<Link className="card" to={paths.course(course.id)}>
|
||||||
|
<Cover course={course} progress={progress} />
|
||||||
|
<div className="m">
|
||||||
|
{image.show ? (
|
||||||
|
<><b>{course.title}</b><span className="num one">{[course.instructor, courseMeta(course)].filter(Boolean).join(' · ')}</span></>
|
||||||
|
) : (
|
||||||
|
<><b>{course.instructor || course.category}</b><span className="num one">{[course.category, courseMeta(course)].join(' · ')}</span></>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** "Continue assistindo": opens the next unfinished lesson directly. */
|
||||||
|
export const ContinueCard: React.FC<{ course: Course }> = ({ course }) => (
|
||||||
|
<Link className="card" to={paths.continueCourse(course.id)}>
|
||||||
|
<Cover course={course} progress={course.progress || 0} />
|
||||||
|
<div className="m">
|
||||||
|
<b>{course.title}</b>
|
||||||
|
<span className="num one">{`${Math.round(course.progress || 0)}% concluído · ${course.lessons.length} aulas`}</span>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const pathCourses = (path: PublicLearningPath, courseById: (id: string) => Course | undefined) => path.courses
|
||||||
|
.slice()
|
||||||
|
.sort((a, b) => a.position - b.position)
|
||||||
|
.map((item) => courseById(item.id))
|
||||||
|
.filter((course): course is Course => Boolean(course));
|
||||||
|
|
||||||
|
export const pathProgress = (courses: Course[]) => {
|
||||||
|
const lessons = courses.reduce((sum, course) => sum + course.lessons.length, 0);
|
||||||
|
if (!lessons) return 0;
|
||||||
|
const seen = courses.reduce((sum, course) => sum + ((course.progress || 0) / 100) * course.lessons.length, 0);
|
||||||
|
return (seen / lessons) * 100;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Trilha: 2:3 poster with two cards stacked behind it. */
|
||||||
|
export const TrailPoster: React.FC<{ path: PublicLearningPath }> = ({ path }) => {
|
||||||
|
const { pathTone, courseById } = useCatalog();
|
||||||
|
const { user } = useAuth();
|
||||||
|
const image = useCoverImage(path.coverImageUrl);
|
||||||
|
const tone = pathTone(path);
|
||||||
|
const courses = pathCourses(path, courseById);
|
||||||
|
const duration = totalDuration(courses);
|
||||||
|
const progress = user ? pathProgress(courses) : 0;
|
||||||
|
return (
|
||||||
|
<Link className={`poster-card tr-${tone}`} to={paths.trail(path.id)}>
|
||||||
|
<div className={`poster tr-${tone}${image.show ? ' has-img' : ''}`}>
|
||||||
|
{image.show && path.coverImageUrl && <ArtImage source={path.coverImageUrl} framing={{ zoom: path.coverImageZoom, x: path.coverImagePositionX, y: path.coverImagePositionY }} onMissing={image.onMissing} />}
|
||||||
|
<div>
|
||||||
|
{!image.show && <span className="t">{path.title}</span>}
|
||||||
|
<span className="n num">{[plural(path.courses.length, 'curso', 'cursos'), duration].filter(Boolean).join(' · ')}</span>
|
||||||
|
</div>
|
||||||
|
{progress > 0 && <Progress value={progress} inside />}
|
||||||
|
</div>
|
||||||
|
{image.show && <div className="card"><div className="m"><b>{path.title}</b></div></div>}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
};
|
||||||
173
components/catalog/Hero.tsx
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { CaretLeftIcon, CaretRightIcon, PlayIcon } from '@phosphor-icons/react';
|
||||||
|
import { Course } from '../../types';
|
||||||
|
import { getHomeBanners, PublicHomeBanner } from '../../services/db';
|
||||||
|
import { AreaTone, useCatalog } from '../../context/CatalogContext';
|
||||||
|
import { useAuth } from '../../context/AuthContext';
|
||||||
|
import { ArtImage, courseFraming } from './Artwork';
|
||||||
|
import { courseMeta, hasRealCover } from '../../lib/format';
|
||||||
|
import { paths } from '../../lib/routes';
|
||||||
|
import { useIsMobile } from '../../hooks/useMediaQuery';
|
||||||
|
|
||||||
|
const SLIDE_MS = 6000;
|
||||||
|
|
||||||
|
export interface Slide {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
tone: AreaTone;
|
||||||
|
image: string | null;
|
||||||
|
framing?: { zoom?: number; x?: number; y?: number };
|
||||||
|
course?: Course;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Home banners configured by the admin; without any, the first course is featured. */
|
||||||
|
export const useSlides = () => {
|
||||||
|
const { courses, courseById, toneOf, isLoading } = useCatalog();
|
||||||
|
const [banners, setBanners] = useState<PublicHomeBanner[] | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getHomeBanners().then(setBanners).catch(() => setBanners([]));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return useMemo<Slide[]>(() => {
|
||||||
|
if (isLoading) return [];
|
||||||
|
const fromCourse = (course: Course): Slide => ({
|
||||||
|
id: course.id,
|
||||||
|
title: course.title,
|
||||||
|
description: course.description,
|
||||||
|
tone: toneOf(course.category),
|
||||||
|
image: hasRealCover(course.thumbnail) ? course.thumbnail : null,
|
||||||
|
framing: courseFraming(course),
|
||||||
|
course,
|
||||||
|
});
|
||||||
|
if (banners === null) return [];
|
||||||
|
if (!banners.length) return courses[0] ? [fromCourse(courses[0])] : [];
|
||||||
|
return banners.map((banner): Slide => {
|
||||||
|
const course = banner.courseId ? courseById(banner.courseId) : undefined;
|
||||||
|
if (banner.kind === 'course') {
|
||||||
|
const base = course ? fromCourse(course) : null;
|
||||||
|
return {
|
||||||
|
id: banner.id,
|
||||||
|
title: banner.courseTitle || banner.title || base?.title || '',
|
||||||
|
description: banner.courseDescription || banner.description || base?.description || '',
|
||||||
|
tone: base?.tone || 'midia',
|
||||||
|
image: banner.courseImageUrl && hasRealCover(banner.courseImageUrl) ? banner.courseImageUrl : base?.image || null,
|
||||||
|
framing: { zoom: banner.coverImageZoom ?? course?.coverImageZoom, x: banner.coverImagePositionX ?? course?.coverImagePositionX, y: banner.coverImagePositionY ?? course?.coverImagePositionY },
|
||||||
|
course,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: banner.id,
|
||||||
|
title: banner.title,
|
||||||
|
description: banner.description,
|
||||||
|
tone: 'midia',
|
||||||
|
image: banner.imageUrl,
|
||||||
|
framing: { zoom: banner.coverImageZoom ?? 1, x: banner.coverImagePositionX ?? 50, y: banner.coverImagePositionY ?? 50 },
|
||||||
|
course,
|
||||||
|
};
|
||||||
|
}).filter((slide) => slide.title || slide.image);
|
||||||
|
}, [banners, courseById, courses, isLoading, toneOf]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SlideActions: React.FC<{ course: Course; className?: string; size?: string }> = ({ course, className = '', size = 'lg' }) => {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const started = (course.progress || 0) > 0;
|
||||||
|
return (
|
||||||
|
<div className={`acts ${className}`}>
|
||||||
|
{user
|
||||||
|
? <Link className={`btn ${size} b1`} to={paths.continueCourse(course.id)}><PlayIcon className="ph" weight="fill" /> {started ? `Continuar aula ${Math.min(course.lessons.length, Math.floor((course.progress || 0) * course.lessons.length / 100) + 1)}` : 'Assistir'}</Link>
|
||||||
|
: <Link className={`btn ${size} b1`} to={paths.signUp} state={{ message: 'Crie uma conta gratuita para assistir aos cursos.' }}><PlayIcon className="ph" weight="fill" /> Assistir</Link>}
|
||||||
|
<Link className={`btn ${size} b2`} to={paths.course(course.id)}>Ver curso</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Full-width carousel that runs underneath the glass sidebar, with "Explorar" over it. */
|
||||||
|
export const Hero: React.FC = () => {
|
||||||
|
const slides = useSlides();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
const { user } = useAuth();
|
||||||
|
const [index, setIndex] = useState(0);
|
||||||
|
const [cycle, setCycle] = useState(0);
|
||||||
|
const [paused, setPaused] = useState(false);
|
||||||
|
const heroRef = useRef<HTMLElement>(null);
|
||||||
|
const reduceMotion = useMemo(() => window.matchMedia('(prefers-reduced-motion: reduce)').matches, []);
|
||||||
|
|
||||||
|
const show = useCallback((next: number) => {
|
||||||
|
setIndex(() => (next + slides.length) % Math.max(slides.length, 1));
|
||||||
|
setCycle((value) => value + 1);
|
||||||
|
}, [slides.length]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isMobile || slides.length < 2 || paused || reduceMotion) return;
|
||||||
|
const timer = window.setTimeout(() => show(index + 1), SLIDE_MS);
|
||||||
|
return () => window.clearTimeout(timer);
|
||||||
|
}, [cycle, index, isMobile, paused, reduceMotion, show, slides.length]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const onKey = (event: KeyboardEvent) => {
|
||||||
|
if (!heroRef.current?.contains(document.activeElement)) return;
|
||||||
|
if (event.key === 'ArrowRight') show(index + 1);
|
||||||
|
if (event.key === 'ArrowLeft') show(index - 1);
|
||||||
|
};
|
||||||
|
document.addEventListener('keydown', onKey);
|
||||||
|
return () => document.removeEventListener('keydown', onKey);
|
||||||
|
}, [index, show]);
|
||||||
|
|
||||||
|
if (!slides.length) return isMobile ? <div className="m-gut m-large"><h1>Explorar</h1>{user ? <Link className="m-av" to={paths.you} aria-label="Você">{user.name.slice(0, 2).toUpperCase()}</Link> : <Link className="btn m-sm" to={paths.signUp}>Criar conta</Link>}</div> : <div className="wrap page"><h1>Explorar</h1></div>;
|
||||||
|
const current = slides[Math.min(index, slides.length - 1)];
|
||||||
|
|
||||||
|
if (isMobile) return <section className="m-feat-wrap" aria-label="Cursos em destaque">
|
||||||
|
<div className="m-gut m-large"><h1>Explorar</h1>{user ? <Link className="m-av" to={paths.you} aria-label="Você">{user.name.slice(0, 2).toUpperCase()}</Link> : <Link className="btn m-sm" to={paths.signUp}>Criar conta</Link>}</div>
|
||||||
|
<div className="m-feat" onScroll={(event) => { const rail = event.currentTarget; setIndex(Math.round(rail.scrollLeft / (rail.firstElementChild?.clientWidth || 1))); }}>
|
||||||
|
{slides.map((slide) => <article key={slide.id} className={`m-fc tr-${slide.tone}${slide.image ? ' has-img' : ''}`}>
|
||||||
|
{slide.image && <ArtImage source={slide.image} framing={slide.framing} />}
|
||||||
|
{slide.course && <Link className="m-fc-link" to={paths.course(slide.course.id)} aria-label={`Ver curso ${slide.title}`} />}
|
||||||
|
<div className="m-fc-in"><small>{slide.course?.category}</small><h2>{slide.title}</h2>{slide.course && <p>{[slide.course.instructor, courseMeta(slide.course)].filter(Boolean).join(' · ')}</p>}{slide.course && <Link className="btn m-fc-btn" to={user ? paths.continueCourse(slide.course.id) : paths.signUp}><PlayIcon className="ph" weight="fill" />{user && slide.course.progress ? `Continuar aula ${Math.min(slide.course.lessons.length, Math.floor((slide.course.progress || 0) * slide.course.lessons.length / 100) + 1)}` : 'Assistir'}</Link>}</div>
|
||||||
|
</article>)}
|
||||||
|
</div>
|
||||||
|
{slides.length > 1 && <div className="m-dots">{slides.map((slide, slideIndex) => <i key={slide.id} className={slideIndex === index ? 'on' : ''} />)}</div>}
|
||||||
|
</section>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
ref={heroRef}
|
||||||
|
className={`hero tr-${current.tone}${current.image ? ' has-img' : ''}${paused ? ' paused' : ''}`}
|
||||||
|
style={{ '--hc': 'var(--co)', '--dur': `${SLIDE_MS}ms` } as React.CSSProperties}
|
||||||
|
aria-roledescription="carrossel"
|
||||||
|
aria-label="Cursos em destaque"
|
||||||
|
onMouseEnter={() => setPaused(true)}
|
||||||
|
onMouseLeave={() => { setPaused(false); setCycle((value) => value + 1); }}
|
||||||
|
>
|
||||||
|
{slides.map((slide, slideIndex) => (
|
||||||
|
<article key={slide.id} className={`slide tr-${slide.tone}${slide.image ? ' has-img' : ''}${slideIndex === index ? ' on' : ''}`} aria-hidden={slideIndex !== index} aria-label={`${slideIndex + 1} de ${slides.length}`}>
|
||||||
|
{slide.image && <ArtImage source={slide.image} framing={slide.framing} />}
|
||||||
|
<div className="wrap sl">
|
||||||
|
<div className="copy">
|
||||||
|
<h2>{slide.title}</h2>
|
||||||
|
{slide.course && <div className="meta num">{[slide.course.instructor, courseMeta(slide.course)].filter(Boolean).join(' · ')}</div>}
|
||||||
|
{slide.description && <p>{slide.description}</p>}
|
||||||
|
{slide.course && <SlideActions course={slide.course} />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
<div className="wrap htitle"><h1>Explorar</h1></div>
|
||||||
|
{slides.length > 1 && (
|
||||||
|
<>
|
||||||
|
<div className="hdots">
|
||||||
|
{slides.map((slide, slideIndex) => (
|
||||||
|
<button key={slide.id} type="button" className={`dot${slideIndex === index ? ' on' : ''}`} onClick={() => show(slideIndex)} aria-label={`Destaque ${slideIndex + 1}`}>
|
||||||
|
{slideIndex === index && <i key={cycle} />}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<button type="button" className="harrow l" onClick={() => show(index - 1)} aria-label="Destaque anterior"><CaretLeftIcon className="ph" weight="bold" /></button>
|
||||||
|
<button type="button" className="harrow r" onClick={() => show(index + 1)} aria-label="Próximo destaque"><CaretRightIcon className="ph" weight="bold" /></button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
};
|
||||||
55
components/catalog/Shelf.tsx
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { CaretLeftIcon, CaretRightIcon } from '@phosphor-icons/react';
|
||||||
|
|
||||||
|
interface ShelfProps {
|
||||||
|
title: string;
|
||||||
|
to?: string;
|
||||||
|
kind?: 'wide' | 'tall';
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A horizontal row with scroll-snap; the title is a link and the arrows appear on hover. */
|
||||||
|
export const Shelf: React.FC<ShelfProps> = ({ title, to, kind, children }) => {
|
||||||
|
const railRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [edges, setEdges] = useState({ start: true, end: false, fits: true });
|
||||||
|
|
||||||
|
const update = useCallback(() => {
|
||||||
|
const rail = railRef.current;
|
||||||
|
if (!rail) return;
|
||||||
|
setEdges({
|
||||||
|
start: rail.scrollLeft < 4,
|
||||||
|
end: rail.scrollLeft + rail.clientWidth >= rail.scrollWidth - 4,
|
||||||
|
fits: rail.scrollWidth <= rail.clientWidth + 4,
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
update();
|
||||||
|
const rail = railRef.current;
|
||||||
|
if (!rail) return;
|
||||||
|
const observer = new ResizeObserver(update);
|
||||||
|
observer.observe(rail);
|
||||||
|
return () => observer.disconnect();
|
||||||
|
}, [update, children]);
|
||||||
|
|
||||||
|
const scroll = (direction: -1 | 1) => {
|
||||||
|
const rail = railRef.current;
|
||||||
|
if (rail) rail.scrollBy({ left: direction * rail.clientWidth * 0.9 });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="shelf">
|
||||||
|
<div className="rowhead">
|
||||||
|
{to ? <Link className="shead" to={to}><h2>{title}</h2><CaretRightIcon className="ph" weight="bold" /></Link> : <h2>{title}</h2>}
|
||||||
|
{!edges.fits && (
|
||||||
|
<div className="nav2">
|
||||||
|
<button type="button" className="iconbtn" onClick={() => scroll(-1)} disabled={edges.start} aria-label="Anterior"><CaretLeftIcon className="ph" weight="bold" /></button>
|
||||||
|
<button type="button" className="iconbtn" onClick={() => scroll(1)} disabled={edges.end} aria-label="Próximo"><CaretRightIcon className="ph" weight="bold" /></button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div ref={railRef} className={`rail${kind ? ` ${kind}` : ''}`} onScroll={update}>{children}</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
};
|
||||||
129
components/course/LessonVideo.tsx
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
|
import { CircleNotchIcon, WarningCircleIcon } from '@phosphor-icons/react';
|
||||||
|
import { Lesson } from '../../types';
|
||||||
|
import { courseApi, LessonPlayback } from '../../services/api';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
playerjs?: {
|
||||||
|
Player: new (element: HTMLIFrameElement) => {
|
||||||
|
on: (event: string, listener: (data?: { seconds?: number; duration?: number }) => void) => void;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let bunnyPlayerJsPromise: Promise<void> | null = null;
|
||||||
|
|
||||||
|
const loadBunnyPlayerJs = () => {
|
||||||
|
if (window.playerjs) return Promise.resolve();
|
||||||
|
if (bunnyPlayerJsPromise) return bunnyPlayerJsPromise;
|
||||||
|
bunnyPlayerJsPromise = new Promise((resolve, reject) => {
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.src = 'https://assets.mediadelivery.net/playerjs/player-0.1.0.min.js';
|
||||||
|
script.async = true;
|
||||||
|
script.onload = () => resolve();
|
||||||
|
script.onerror = () => reject(new Error('Bunny player events could not be loaded'));
|
||||||
|
document.head.appendChild(script);
|
||||||
|
});
|
||||||
|
return bunnyPlayerJsPromise;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface LessonVideoProps {
|
||||||
|
courseId: string;
|
||||||
|
lesson: Lesson;
|
||||||
|
/** Saved position to resume from (HTML video only; Bunny resumes on its own). */
|
||||||
|
resumeAt: number;
|
||||||
|
/** Called on playback progress with the current second (and duration when known). */
|
||||||
|
onTime: (seconds: number, duration?: number) => void;
|
||||||
|
/** Called when the video finished playing. `autoAdvance` is true for HTML video, as before. */
|
||||||
|
onEnded: (seconds: number, autoAdvance: boolean) => void;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The API verifies the session before returning a time-limited Bunny embed URL;
|
||||||
|
* a video provider key is never sent to the browser.
|
||||||
|
*/
|
||||||
|
export const LessonVideo: React.FC<LessonVideoProps> = ({ courseId, lesson, resumeAt, onTime, onEnded, className = 'player' }) => {
|
||||||
|
const [playback, setPlayback] = useState<LessonPlayback | null>(null);
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
|
const frameRef = useRef<HTMLIFrameElement>(null);
|
||||||
|
const handlers = useRef({ onTime, onEnded });
|
||||||
|
handlers.current = { onTime, onEnded };
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
setPlayback(null);
|
||||||
|
setError('');
|
||||||
|
courseApi.playback(courseId, lesson.id)
|
||||||
|
.then((response) => { if (!cancelled) setPlayback(response.data); })
|
||||||
|
.catch((reason) => { if (!cancelled) setError(reason instanceof Error ? reason.message : 'Não foi possível carregar este vídeo.'); });
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, [courseId, lesson.id]);
|
||||||
|
|
||||||
|
// Bunny's iframe has no HTMLVideoElement; Player.js relays its playback events.
|
||||||
|
useEffect(() => {
|
||||||
|
if (!playback || playback.kind !== 'embed') return;
|
||||||
|
let disposed = false;
|
||||||
|
void loadBunnyPlayerJs().then(() => {
|
||||||
|
if (disposed || !frameRef.current || !window.playerjs) return;
|
||||||
|
const player = new window.playerjs.Player(frameRef.current);
|
||||||
|
player.on('timeupdate', (data) => {
|
||||||
|
// Bunny only saves the watched position; completion comes from its "ended" event.
|
||||||
|
if (!disposed) handlers.current.onTime(Math.floor(data?.seconds || 0));
|
||||||
|
});
|
||||||
|
player.on('ended', (data) => {
|
||||||
|
if (!disposed) handlers.current.onEnded(Math.floor(data?.duration || data?.seconds || 0), false);
|
||||||
|
});
|
||||||
|
}).catch(() => undefined);
|
||||||
|
return () => { disposed = true; };
|
||||||
|
}, [playback]);
|
||||||
|
|
||||||
|
const restorePosition = () => {
|
||||||
|
const video = videoRef.current;
|
||||||
|
if (video && resumeAt > 0 && resumeAt < video.duration - 5) video.currentTime = resumeAt;
|
||||||
|
};
|
||||||
|
|
||||||
|
let content: React.ReactNode;
|
||||||
|
if (error) {
|
||||||
|
content = <div className="pl msg"><WarningCircleIcon className="ph" size={28} /><span>{error}</span></div>;
|
||||||
|
} else if (!playback) {
|
||||||
|
content = <div className="pl msg"><CircleNotchIcon className="ph spin" size={28} /><span>Carregando vídeo</span></div>;
|
||||||
|
} else if (playback.kind === 'embed' && playback.embedUrl) {
|
||||||
|
content = (
|
||||||
|
<iframe
|
||||||
|
key={lesson.id}
|
||||||
|
ref={frameRef}
|
||||||
|
src={playback.embedUrl}
|
||||||
|
title={lesson.title || 'Vídeo da aula'}
|
||||||
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; picture-in-picture; fullscreen"
|
||||||
|
allowFullScreen
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else if (playback.source) {
|
||||||
|
content = (
|
||||||
|
<video
|
||||||
|
key={lesson.id}
|
||||||
|
ref={videoRef}
|
||||||
|
src={playback.source}
|
||||||
|
controls
|
||||||
|
autoPlay
|
||||||
|
playsInline
|
||||||
|
onTimeUpdate={(event) => {
|
||||||
|
const { currentTime, duration } = event.currentTarget;
|
||||||
|
if (duration > 0) handlers.current.onTime(currentTime, duration);
|
||||||
|
}}
|
||||||
|
onEnded={(event) => handlers.current.onEnded(Math.round(event.currentTarget.duration || 0), true)}
|
||||||
|
onLoadedMetadata={restorePosition}
|
||||||
|
>
|
||||||
|
Seu navegador não suporta vídeo.
|
||||||
|
</video>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
content = <div className="pl msg"><span>Vídeo indisponível.</span></div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div className={className}>{content}</div>;
|
||||||
|
};
|
||||||
86
components/course/Materials.tsx
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
ArrowSquareOutIcon, CheckIcon, CircleNotchIcon, FileIcon,
|
||||||
|
ImageIcon, LinkSimpleIcon, VideoCameraIcon,
|
||||||
|
} from '@phosphor-icons/react';
|
||||||
|
import { DocMockIcon, DownloadMockIcon, PdfMockIcon, XlsMockIcon, ZipMockIcon } from '../ui/MockupIcons';
|
||||||
|
import { Attachment, AttachmentType } from '../../types';
|
||||||
|
import { downloadCourseAsset } from '../../services/api';
|
||||||
|
import { recordDownloadHistory } from '../../services/db';
|
||||||
|
import { useToast } from '../../context/ToastContext';
|
||||||
|
import { useAuth } from '../../context/AuthContext';
|
||||||
|
import { paths } from '../../lib/routes';
|
||||||
|
|
||||||
|
export const attachmentIcon = (type: AttachmentType) => {
|
||||||
|
switch (type) {
|
||||||
|
case 'pdf': return <PdfMockIcon className="ph" />;
|
||||||
|
case 'spreadsheet': return <XlsMockIcon className="ph" />;
|
||||||
|
case 'zip': return <ZipMockIcon className="ph" />;
|
||||||
|
case 'doc': return <DocMockIcon className="ph" />;
|
||||||
|
case 'image': return <ImageIcon className="ph" />;
|
||||||
|
case 'link': return <LinkSimpleIcon className="ph" />;
|
||||||
|
case 'video': return <VideoCameraIcon className="ph" />;
|
||||||
|
default: return <FileIcon className="ph" />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const attachmentLabel = (type: AttachmentType) => ({
|
||||||
|
pdf: 'PDF', spreadsheet: 'Planilha', zip: 'ZIP', doc: 'Documento', image: 'Imagem', link: 'Link', video: 'Vídeo',
|
||||||
|
}[type] || 'Arquivo');
|
||||||
|
|
||||||
|
/** Downloads through the Academy (or opens a link) with the same feedback as before. */
|
||||||
|
export const useMaterialAction = () => {
|
||||||
|
const { showDownloadToast, showToast } = useToast();
|
||||||
|
const { user } = useAuth();
|
||||||
|
const [busyId, setBusyId] = useState<string | null>(null);
|
||||||
|
const [doneId, setDoneId] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const open = async (attachment: Attachment) => {
|
||||||
|
if (attachment.type === 'link') {
|
||||||
|
showToast(`Abrindo “${attachment.name}”.`, 'info');
|
||||||
|
window.open(attachment.url, '_blank', 'noopener,noreferrer');
|
||||||
|
if (user) void recordDownloadHistory(attachment.id).catch(() => undefined);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
setBusyId(attachment.id);
|
||||||
|
try {
|
||||||
|
await downloadCourseAsset(attachment.id, attachment.name);
|
||||||
|
showDownloadToast(attachment.name, attachment.size);
|
||||||
|
if (user) void recordDownloadHistory(attachment.id).catch(() => undefined);
|
||||||
|
setDoneId(attachment.id);
|
||||||
|
window.setTimeout(() => setDoneId((current) => (current === attachment.id ? null : current)), 3000);
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
showToast(error instanceof Error ? error.message : 'Não foi possível baixar este material.', 'error');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
setBusyId(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { open, busyId, doneId };
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MaterialButton: React.FC<{ attachment: Attachment; action: ReturnType<typeof useMaterialAction>; label?: boolean; className?: string }> = ({ attachment, action, label = true, className = 'btn sec' }) => {
|
||||||
|
const { user } = useAuth();
|
||||||
|
if (!user) return label ? <Link className={className} to={paths.signIn}>Entrar para baixar</Link> : null;
|
||||||
|
const isLink = attachment.type === 'link';
|
||||||
|
const busy = action.busyId === attachment.id;
|
||||||
|
const done = action.doneId === attachment.id;
|
||||||
|
const icon = busy ? <CircleNotchIcon className="ph spin" /> : done ? <CheckIcon className="ph" /> : isLink ? <ArrowSquareOutIcon className="ph" /> : <DownloadMockIcon className="ph" />;
|
||||||
|
const text = isLink ? 'Abrir' : done ? 'Baixado' : 'Baixar';
|
||||||
|
return (
|
||||||
|
<button type="button" className={className} onClick={() => void action.open(attachment)} disabled={busy} aria-label={`${text} ${attachment.name}`}>
|
||||||
|
{icon}{label && ` ${text}`}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MaterialRow: React.FC<{ attachment: Attachment; detail?: string; action: ReturnType<typeof useMaterialAction>; compact?: boolean }> = ({ attachment, detail, action, compact }) => (
|
||||||
|
<div className="file" style={compact ? { paddingBlock: 8 } : undefined}>
|
||||||
|
<span className="ic">{attachmentIcon(attachment.type)}</span>
|
||||||
|
<span>{attachment.name}<small className="num">{[detail, attachmentLabel(attachment.type), attachment.size].filter(Boolean).join(' · ')}</small></span>
|
||||||
|
{compact ? <MaterialButton attachment={attachment} action={action} label={false} className="iconbtn" /> : <MaterialButton attachment={attachment} action={action} />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
26
components/shell/AppShell.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
|
import { Sidebar } from './Sidebar';
|
||||||
|
import { MobileBack, MobileTabBar } from './MobileNavigation';
|
||||||
|
import { useIsMobile } from '../../hooks/useMediaQuery';
|
||||||
|
|
||||||
|
export const AppShell: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||||
|
const location = useLocation();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
document.body.classList.toggle('immersive', location.pathname.includes('/aulas/'));
|
||||||
|
return () => document.body.classList.remove('immersive');
|
||||||
|
}, [location.pathname]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{!isMobile && <Sidebar />}
|
||||||
|
{isMobile && <MobileBack />}
|
||||||
|
{/* Keyed by path: the arrival animation only plays when navigating to a new page. */}
|
||||||
|
<div className="main" key={location.pathname}>{children}</div>
|
||||||
|
{isMobile && <MobileTabBar />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
47
components/shell/MobileNavigation.tsx
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
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>;
|
||||||
|
};
|
||||||
197
components/shell/Sidebar.tsx
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
|
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
BooksMockIcon, ChatsMockIcon, ChevronDownMockIcon, CompassMockIcon, FolderMockIcon, GearMockIcon,
|
||||||
|
MoonMockIcon, PathMockIcon, SearchMockIcon, SignOutMockIcon, SunMockIcon, TeacherMockIcon,
|
||||||
|
TrayMockIcon, UserMockIcon, VideoMockIcon,
|
||||||
|
} from '../ui/MockupIcons';
|
||||||
|
import { SidebarSimpleIcon } from '@phosphor-icons/react';
|
||||||
|
import { Logo } from '../Logo';
|
||||||
|
import { Avatar } from '../ui/Avatar';
|
||||||
|
import { useAuth } from '../../context/AuthContext';
|
||||||
|
import { useTheme } from '../../context/ThemeContext';
|
||||||
|
import { useCatalog } from '../../context/CatalogContext';
|
||||||
|
import { NavKey, navKeyFor } from '../../lib/navigation';
|
||||||
|
import { paths } from '../../lib/routes';
|
||||||
|
import { readPreference, writePreference } from '../../lib/storage';
|
||||||
|
|
||||||
|
const GROUPS_KEY = 'ca-groups';
|
||||||
|
const COLLAPSED_KEY = 'ca-side';
|
||||||
|
|
||||||
|
type Item = { key: NavKey; to: string; label: string; icon: React.ReactNode; count?: number };
|
||||||
|
|
||||||
|
const readGroups = (): Record<string, boolean> => {
|
||||||
|
try {
|
||||||
|
return JSON.parse(readPreference(GROUPS_KEY) || '{}');
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const SideItem: React.FC<{ item: Item; current: NavKey }> = ({ item, current }) => (
|
||||||
|
<Link className="sitem" to={item.to} title={item.label} aria-current={current === item.key ? 'page' : undefined}>
|
||||||
|
{item.icon}
|
||||||
|
<span className="lbl">{item.label}</span>
|
||||||
|
{item.count ? <span className="cnt">{item.count}</span> : null}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const Sidebar: React.FC = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { user, logout } = useAuth();
|
||||||
|
const { theme, toggleTheme } = useTheme();
|
||||||
|
const { courses } = useCatalog();
|
||||||
|
const current = navKeyFor(location.pathname);
|
||||||
|
const [shut, setShut] = useState<Record<string, boolean>>(readGroups);
|
||||||
|
const [collapsed, setCollapsed] = useState(() => readPreference(COLLAPSED_KEY) === '1');
|
||||||
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
|
const whoRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const menuRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [menuStyle, setMenuStyle] = useState<React.CSSProperties>({});
|
||||||
|
|
||||||
|
const canTeach = user?.role === 'professor' || user?.role === 'superadmin';
|
||||||
|
const inProgress = user ? courses.filter((course) => (course.progress || 0) > 0 && (course.progress || 0) < 100).length : 0;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.documentElement.classList.toggle('collapsed', collapsed);
|
||||||
|
}, [collapsed]);
|
||||||
|
|
||||||
|
useEffect(() => setMenuOpen(false), [location.pathname]);
|
||||||
|
|
||||||
|
// The account menu lives on <body> with position: fixed, so the sidebar never clips it.
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
if (!menuOpen || !whoRef.current) return;
|
||||||
|
const button = whoRef.current.getBoundingClientRect();
|
||||||
|
const sidebar = whoRef.current.closest('.sidebar')?.getBoundingClientRect();
|
||||||
|
setMenuStyle(collapsed && sidebar
|
||||||
|
? { left: sidebar.right + 10, bottom: Math.max(12, window.innerHeight - button.bottom) }
|
||||||
|
: { left: Math.max(12, button.left), bottom: window.innerHeight - button.top + 8 });
|
||||||
|
}, [collapsed, menuOpen]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!menuOpen) return;
|
||||||
|
const close = (event: MouseEvent) => {
|
||||||
|
const target = event.target as Node;
|
||||||
|
if (!menuRef.current?.contains(target) && !whoRef.current?.contains(target)) setMenuOpen(false);
|
||||||
|
};
|
||||||
|
const onKey = (event: KeyboardEvent) => { if (event.key === 'Escape') setMenuOpen(false); };
|
||||||
|
const onResize = () => setMenuOpen(false);
|
||||||
|
document.addEventListener('mousedown', close);
|
||||||
|
document.addEventListener('keydown', onKey);
|
||||||
|
window.addEventListener('resize', onResize);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('mousedown', close);
|
||||||
|
document.removeEventListener('keydown', onKey);
|
||||||
|
window.removeEventListener('resize', onResize);
|
||||||
|
};
|
||||||
|
}, [menuOpen]);
|
||||||
|
|
||||||
|
const toggleGroup = (id: string) => setShut((state) => {
|
||||||
|
const next = { ...state, [id]: !state[id] };
|
||||||
|
writePreference(GROUPS_KEY, JSON.stringify(next));
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
|
||||||
|
const toggleCollapsed = () => setCollapsed((value) => {
|
||||||
|
writePreference(COLLAPSED_KEY, value ? '0' : '1');
|
||||||
|
return !value;
|
||||||
|
});
|
||||||
|
|
||||||
|
const signOut = () => {
|
||||||
|
setMenuOpen(false);
|
||||||
|
logout();
|
||||||
|
navigate(paths.explore);
|
||||||
|
};
|
||||||
|
|
||||||
|
const group = (id: string, title: string, items: Array<Item | false>) => {
|
||||||
|
const visible = items.filter(Boolean) as Item[];
|
||||||
|
if (!visible.length) return null;
|
||||||
|
return (
|
||||||
|
<div className={`sgroup${shut[id] ? ' shut' : ''}`}>
|
||||||
|
<button type="button" className="ghead" onClick={() => toggleGroup(id)} aria-expanded={!shut[id]}>
|
||||||
|
<span className="lbl">{title}</span>
|
||||||
|
<ChevronDownMockIcon className="ph" />
|
||||||
|
</button>
|
||||||
|
<div className="gbody"><div>{visible.map((item) => <SideItem key={item.key} item={item} current={current} />)}</div></div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const themeButton = (
|
||||||
|
<button type="button" className="iconbtn" onClick={toggleTheme} aria-label={theme === 'dark' ? 'Usar modo claro' : 'Usar modo escuro'} title={theme === 'dark' ? 'Modo claro' : 'Modo escuro'}>
|
||||||
|
{theme === 'dark' ? <SunMockIcon className="ph" /> : <MoonMockIcon className="ph" />}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<aside className="sidebar" aria-label="Navegação principal">
|
||||||
|
<div className="side-top">
|
||||||
|
<button type="button" className="iconbtn" onClick={toggleCollapsed} aria-label={collapsed ? 'Expandir barra lateral' : 'Recolher barra lateral'} title={collapsed ? 'Expandir barra lateral' : 'Recolher barra lateral'}>
|
||||||
|
<SidebarSimpleIcon className="ph" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<Link to={paths.explore} className="logo" aria-label="Compor Academy, início">
|
||||||
|
<Logo width={96} />
|
||||||
|
<span className="mark" aria-hidden="true">c</span>
|
||||||
|
</Link>
|
||||||
|
<nav>
|
||||||
|
<div className="sgroup solo">
|
||||||
|
<SideItem current={current} item={{ key: 'search', to: paths.search, label: 'Buscar', icon: <SearchMockIcon className="ph" /> }} />
|
||||||
|
<SideItem current={current} item={{ key: 'explore', to: paths.explore, label: 'Explorar', icon: <CompassMockIcon className="ph" /> }} />
|
||||||
|
</div>
|
||||||
|
{group('apr', 'Aprendizado', [
|
||||||
|
{ key: 'trails', to: paths.trails, label: 'Trilhas', icon: <PathMockIcon className="ph" /> },
|
||||||
|
Boolean(user) && { key: 'learning', to: paths.learning, label: 'Minha aprendizagem', icon: <BooksMockIcon className="ph" />, count: inProgress },
|
||||||
|
])}
|
||||||
|
{group('com', 'Comunidade', [
|
||||||
|
{ key: 'community', to: paths.community, label: 'Discussões', icon: <ChatsMockIcon className="ph" /> },
|
||||||
|
{ key: 'professors', to: paths.professors, label: 'Professores', icon: <TeacherMockIcon className="ph" /> },
|
||||||
|
])}
|
||||||
|
{group('mat', 'Materiais', [
|
||||||
|
{ key: 'library', to: paths.library, label: 'Biblioteca', icon: <FolderMockIcon className="ph" /> },
|
||||||
|
Boolean(user) && { key: 'downloads', to: paths.downloads, label: 'Meus downloads', icon: <TrayMockIcon className="ph" /> },
|
||||||
|
])}
|
||||||
|
{canTeach && group('ges', 'Gestão', [
|
||||||
|
{ key: 'manage', to: paths.manage, label: 'Gerenciar cursos', icon: <VideoMockIcon className="ph" /> },
|
||||||
|
user?.role === 'superadmin' && { key: 'admin', to: paths.admin, label: 'Administração', icon: <GearMockIcon className="ph" /> },
|
||||||
|
])}
|
||||||
|
</nav>
|
||||||
|
<div className="side-foot">
|
||||||
|
{user ? (
|
||||||
|
<div className="frow">
|
||||||
|
<button ref={whoRef} type="button" className="who-row" onClick={() => setMenuOpen((open) => !open)} aria-haspopup="menu" aria-expanded={menuOpen} title={user.name}>
|
||||||
|
<Avatar name={user.name} src={user.avatar} size="sm" />
|
||||||
|
<span className="lbl">{user.name}</span>
|
||||||
|
</button>
|
||||||
|
{themeButton}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Link className="btn guestbtn" to={paths.signUp}>Criar conta</Link>
|
||||||
|
<div className="frow">
|
||||||
|
<Link className="who-row" to={paths.signIn} title="Entrar">
|
||||||
|
<span className="av sm guestav"><UserMockIcon className="ph" /></span>
|
||||||
|
<span className="lbl">Entrar</span>
|
||||||
|
</Link>
|
||||||
|
{themeButton}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{menuOpen && user && createPortal(
|
||||||
|
<div ref={menuRef} className="menu" role="menu" style={menuStyle}>
|
||||||
|
<div className="who"><b>{user.name}</b><small>{user.email}</small></div>
|
||||||
|
<Link role="menuitem" to={paths.account}><UserMockIcon className="ph" /> Conta</Link>
|
||||||
|
<Link role="menuitem" to={paths.learning}><BooksMockIcon className="ph" /> Minha aprendizagem</Link>
|
||||||
|
<Link role="menuitem" to={paths.downloads}><TrayMockIcon className="ph" /> Meus downloads</Link>
|
||||||
|
{canTeach && <Link role="menuitem" to={paths.manage}><VideoMockIcon className="ph" /> Gerenciar cursos</Link>}
|
||||||
|
{user.role === 'superadmin' && <Link role="menuitem" to={paths.admin}><GearMockIcon className="ph" /> Administração</Link>}
|
||||||
|
<button role="menuitem" type="button" onClick={signOut}><SignOutMockIcon className="ph" /> Sair</button>
|
||||||
|
</div>,
|
||||||
|
document.body,
|
||||||
|
)}
|
||||||
|
</aside>
|
||||||
|
);
|
||||||
|
};
|
||||||
15
components/ui/Avatar.tsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { initials } from '../../lib/format';
|
||||||
|
|
||||||
|
interface AvatarProps {
|
||||||
|
name: string;
|
||||||
|
src?: string | null;
|
||||||
|
size?: 'sm' | 'md' | 'xl';
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Avatar: React.FC<AvatarProps> = ({ name, src, size, className = '' }) => (
|
||||||
|
<span className={`av${size ? ` ${size}` : ''} ${className}`} aria-hidden="true">
|
||||||
|
{src ? <img src={src} alt="" /> : initials(name)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
33
components/ui/ConfirmDialog.tsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
|
|
||||||
|
interface ConfirmDialogProps {
|
||||||
|
open: boolean;
|
||||||
|
title: string;
|
||||||
|
message: string;
|
||||||
|
confirmLabel?: string;
|
||||||
|
busy?: boolean;
|
||||||
|
onCancel: () => void;
|
||||||
|
onConfirm: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** In-app confirmation dialog instead of window.confirm. */
|
||||||
|
export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({ open, title, message, confirmLabel = 'Confirmar', busy = false, onCancel, onConfirm }) => {
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return;
|
||||||
|
const onKey = (event: KeyboardEvent) => { if (event.key === 'Escape') onCancel(); };
|
||||||
|
document.addEventListener('keydown', onKey);
|
||||||
|
return () => document.removeEventListener('keydown', onKey);
|
||||||
|
}, [open, onCancel]);
|
||||||
|
|
||||||
|
if (!open) return null;
|
||||||
|
return createPortal(<div className="scrim" role="dialog" aria-modal="true" aria-label={title} onMouseDown={(event) => { if (event.target === event.currentTarget) onCancel(); }}>
|
||||||
|
<div className="dialog" style={{ maxWidth: 420 }}>
|
||||||
|
<header><div><h2>{title}</h2><p>{message}</p></div></header>
|
||||||
|
<footer>
|
||||||
|
<button className="btn sec" type="button" onClick={onCancel} disabled={busy}>Cancelar</button>
|
||||||
|
<button className="btn danger" type="button" onClick={onConfirm} disabled={busy}>{busy ? 'Aguarde…' : confirmLabel}</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>, document.body);
|
||||||
|
};
|
||||||
58
components/ui/MockupIcons.tsx
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
type MockIconProps = { className?: string };
|
||||||
|
|
||||||
|
const MockIcon: React.FC<MockIconProps & { path: string }> = ({ path, className = 'ph' }) => (
|
||||||
|
<svg className={className} aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor" width="1em" height="1em" focusable="false">
|
||||||
|
<path d={path} />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const SearchMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z" {...props} />;
|
||||||
|
export const ArrowRightMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z" {...props} />;
|
||||||
|
export const PlayMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z" {...props} />;
|
||||||
|
export const CheckMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm45.66,85.66-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z" {...props} />;
|
||||||
|
export const ClockMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm64-88a8,8,0,0,1-8,8H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48A8,8,0,0,1,192,128Z" {...props} />;
|
||||||
|
export const DownloadMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z" {...props} />;
|
||||||
|
export const ChatMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z" {...props} />;
|
||||||
|
export const SaveMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M184,32H72A16,16,0,0,0,56,48V224a8,8,0,0,0,12.24,6.78L128,193.43l59.77,37.35A8,8,0,0,0,200,224V48A16,16,0,0,0,184,32Zm0,177.57-51.77-32.35a8,8,0,0,0-8.48,0L72,209.57V48H184Z" {...props} />;
|
||||||
|
export const UserMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M230.92,212c-15.23-26.33-38.7-45.21-66.09-54.16a72,72,0,1,0-73.66,0C63.78,166.78,40.31,185.66,25.08,212a8,8,0,1,0,13.85,8c18.84-32.56,52.14-52,89.07-52s70.23,19.44,89.07,52a8,8,0,1,0,13.85-8ZM72,96a56,56,0,1,1,56,56A56.06,56.06,0,0,1,72,96Z" {...props} />;
|
||||||
|
export const BooksMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M231.65,194.55,198.46,36.75a16,16,0,0,0-19-12.39L132.65,34.42a16.08,16.08,0,0,0-12.3,19l33.19,157.8A16,16,0,0,0,169.16,224a16.25,16.25,0,0,0,3.38-.36l46.81-10.06A16.09,16.09,0,0,0,231.65,194.55ZM136,50.15c0-.06,0-.09,0-.09l46.8-10,3.33,15.87L139.33,66Zm6.62,31.47,46.82-10.05,3.34,15.9L146,97.53Zm6.64,31.57,46.82-10.06,13.3,63.24-46.82,10.06ZM216,197.94l-46.8,10-3.33-15.87L212.67,182,216,197.85C216,197.91,216,197.94,216,197.94ZM104,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V48A16,16,0,0,0,104,32ZM56,48h48V64H56Zm0,32h48v96H56Zm48,128H56V192h48v16Z" {...props} />;
|
||||||
|
export const GearMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z" {...props} />;
|
||||||
|
export const SignOutMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z" {...props} />;
|
||||||
|
export const UploadMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM93.66,77.66,120,51.31V144a8,8,0,0,0,16,0V51.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,77.66Z" {...props} />;
|
||||||
|
export const PlusMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z" {...props} />;
|
||||||
|
export const EditMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM92.69,208H48V163.31l88-88L180.69,120ZM192,108.68,147.31,64l24-24L216,84.68Z" {...props} />;
|
||||||
|
export const DragMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M104,60A12,12,0,1,1,92,48,12,12,0,0,1,104,60Zm60,12a12,12,0,1,0-12-12A12,12,0,0,0,164,72ZM92,116a12,12,0,1,0,12,12A12,12,0,0,0,92,116Zm72,0a12,12,0,1,0,12,12A12,12,0,0,0,164,116ZM92,184a12,12,0,1,0,12,12A12,12,0,0,0,92,184Zm72,0a12,12,0,1,0,12,12A12,12,0,0,0,164,184Z" {...props} />;
|
||||||
|
export const MoreMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z" {...props} />;
|
||||||
|
export const VideoMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M251.77,73a8,8,0,0,0-8.21.39L208,97.05V72a16,16,0,0,0-16-16H32A16,16,0,0,0,16,72V184a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V159l35.56,23.71A8,8,0,0,0,248,184a8,8,0,0,0,8-8V80A8,8,0,0,0,251.77,73ZM192,184H32V72H192V184Zm48-22.95-32-21.33V116.28L240,95Z" {...props} />;
|
||||||
|
export const CheckCircleMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z" {...props} />;
|
||||||
|
export const SpinnerMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm88,88H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z" {...props} />;
|
||||||
|
export const WarningCircleMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z" {...props} />;
|
||||||
|
export const SunMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z" {...props} />;
|
||||||
|
export const CompassMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM172.42,72.84l-64,32a8.05,8.05,0,0,0-3.58,3.58l-32,64A8,8,0,0,0,80,184a8.1,8.1,0,0,0,3.58-.84l64-32a8.05,8.05,0,0,0,3.58-3.58l32-64a8,8,0,0,0-10.74-10.74ZM138,138,97.89,158.11,118,118l40.15-20.07Z" {...props} />;
|
||||||
|
export const ChevronDownMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z" {...props} />;
|
||||||
|
export const PathMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M200,168a32.06,32.06,0,0,0-31,24H72a32,32,0,0,1,0-64h96a40,40,0,0,0,0-80H72a8,8,0,0,0,0,16h96a24,24,0,0,1,0,48H72a48,48,0,0,0,0,96h97a32,32,0,1,0,31-40Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,200,216Z" {...props} />;
|
||||||
|
export const ChatsMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M232.07,186.76a80,80,0,0,0-62.5-114.17A80,80,0,1,0,23.93,138.76l-7.27,24.71a16,16,0,0,0,19.87,19.87l24.71-7.27a80.39,80.39,0,0,0,25.18,7.35,80,80,0,0,0,108.34,40.65l24.71,7.27a16,16,0,0,0,19.87-19.86ZM62,159.5a8.28,8.28,0,0,0-2.26.32L32,168l8.17-27.76a8,8,0,0,0-.63-6,64,64,0,1,1,26.26,26.26A8,8,0,0,0,62,159.5Zm153.79,28.73L224,216l-27.76-8.17a8,8,0,0,0-6,.63,64.05,64.05,0,0,1-85.87-24.88A79.93,79.93,0,0,0,174.7,89.71a64,64,0,0,1,41.75,92.48A8,8,0,0,0,215.82,188.23Z" {...props} />;
|
||||||
|
export const TeacherMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H53.39a8,8,0,0,0,7.23-4.57,48,48,0,0,1,86.76,0,8,8,0,0,0,7.23,4.57H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM80,144a24,24,0,1,1,24,24A24,24,0,0,1,80,144Zm136,56H159.43a64.39,64.39,0,0,0-28.83-26.16,40,40,0,1,0-53.2,0A64.39,64.39,0,0,0,48.57,200H40V56H216ZM56,96V80a8,8,0,0,1,8-8H192a8,8,0,0,1,8,8v96a8,8,0,0,1-8,8H176a8,8,0,0,1,0-16h8V88H72v8a8,8,0,0,1-16,0Z" {...props} />;
|
||||||
|
export const FolderMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M216,72H130.67L102.93,51.2a16.12,16.12,0,0,0-9.6-3.2H40A16,16,0,0,0,24,64V200a16,16,0,0,0,16,16H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72Zm0,128H40V64H93.33L123.2,86.4A8,8,0,0,0,128,88h88Z" {...props} />;
|
||||||
|
export const TrayMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,16V152h-28.7A15.86,15.86,0,0,0,168,156.69L148.69,176H107.31L88,156.69A15.86,15.86,0,0,0,76.69,152H48V48Zm0,160H48V168H76.69L96,187.31A15.86,15.86,0,0,0,107.31,192h41.38A15.86,15.86,0,0,0,160,187.31L179.31,168H208v40ZM90.34,125.66a8,8,0,0,1,11.32-11.32L120,132.69V72a8,8,0,0,1,16,0v60.69l18.34-18.35a8,8,0,0,1,11.32,11.32l-32,32a8,8,0,0,1-11.32,0Z" {...props} />;
|
||||||
|
export const ArrowLeftMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z" {...props} />;
|
||||||
|
export const PauseMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z" {...props} />;
|
||||||
|
export const MoonMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z" {...props} />;
|
||||||
|
export const UsersMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M117.25,157.92a60,60,0,1,0-66.5,0A95.83,95.83,0,0,0,3.53,195.63a8,8,0,1,0,13.4,8.74,80,80,0,0,1,134.14,0,8,8,0,0,0,13.4-8.74A95.83,95.83,0,0,0,117.25,157.92ZM40,108a44,44,0,1,1,44,44A44.05,44.05,0,0,1,40,108Zm210.14,98.7a8,8,0,0,1-11.07-2.33A79.83,79.83,0,0,0,172,168a8,8,0,0,1,0-16,44,44,0,1,0-16.34-84.87,8,8,0,1,1-5.94-14.85,60,60,0,0,1,55.53,105.64,95.83,95.83,0,0,1,47.22,37.71A8,8,0,0,1,250.14,206.7Z" {...props} />;
|
||||||
|
export const EyeMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z" {...props} />;
|
||||||
|
|
||||||
|
export const PdfMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M224,152a8,8,0,0,1-8,8H192v16h16a8,8,0,0,1,0,16H192v16a8,8,0,0,1-16,0V152a8,8,0,0,1,8-8h32A8,8,0,0,1,224,152ZM92,172a28,28,0,0,1-28,28H56v8a8,8,0,0,1-16,0V152a8,8,0,0,1,8-8H64A28,28,0,0,1,92,172Zm-16,0a12,12,0,0,0-12-12H56v24h8A12,12,0,0,0,76,172Zm88,8a36,36,0,0,1-36,36H112a8,8,0,0,1-8-8V152a8,8,0,0,1,8-8h16A36,36,0,0,1,164,180Zm-16,0a20,20,0,0,0-20-20h-8v40h8A20,20,0,0,0,148,180ZM40,112V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0ZM160,80h28.69L160,51.31Z" {...props} />;
|
||||||
|
export const XlsMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M156,208a8,8,0,0,1-8,8H120a8,8,0,0,1-8-8V152a8,8,0,0,1,16,0v48h20A8,8,0,0,1,156,208ZM92.65,145.49a8,8,0,0,0-11.16,1.86L68,166.24,54.51,147.35a8,8,0,1,0-13,9.3L58.17,180,41.49,203.35a8,8,0,0,0,13,9.3L68,193.76l13.49,18.89a8,8,0,0,0,13-9.3L77.83,180l16.68-23.35A8,8,0,0,0,92.65,145.49Zm98.94,25.82c-4-1.16-8.14-2.35-10.45-3.84-1.25-.82-1.23-1-1.12-1.9a4.54,4.54,0,0,1,2-3.67c4.6-3.12,15.34-1.72,19.82-.56a8,8,0,0,0,4.07-15.48c-2.11-.55-21-5.22-32.83,2.76a20.58,20.58,0,0,0-8.95,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.33-2.15,3.93-4.6,3.06-15.16,1.55-19.54.35A8,8,0,0,0,173.93,214a60.63,60.63,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.81,20.81,0,0,0,9.18-15.23C218,179,201.48,174.17,191.59,171.31ZM40,112V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88v24a8,8,0,1,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0ZM160,80h28.68L160,51.31Z" {...props} />;
|
||||||
|
export const ZipMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M184,144H168a8,8,0,0,0-8,8v56a8,8,0,0,0,16,0v-8h8a28,28,0,0,0,0-56Zm0,40h-8V160h8a12,12,0,0,1,0,24Zm-48-32v56a8,8,0,0,1-16,0V152a8,8,0,0,1,16,0ZM96,208a8,8,0,0,1-8,8H56a8,8,0,0,1-7-12l25.16-44H56a8,8,0,0,1,0-16H88a8,8,0,0,1,7,12L69.79,200H88A8,8,0,0,1,96,208ZM213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48v16a8,8,0,0,0,16,0V88A8,8,0,0,0,213.66,82.34ZM160,80V51.31L188.69,80Z" {...props} />;
|
||||||
|
export const DocMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M52,144H36a8,8,0,0,0-8,8v56a8,8,0,0,0,8,8H52a36,36,0,0,0,0-72Zm0,56H44V160h8a20,20,0,0,1,0,40Zm169.53-4.91a8,8,0,0,1,.25,11.31A30.06,30.06,0,0,1,200,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30.06,30.06,0,0,1,21.78,9.6,8,8,0,0,1-11.56,11.06A14.24,14.24,0,0,0,200,160c-8.82,0-16,9-16,20s7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,0,1,221.53,195.09ZM128,144c-17.65,0-32,16.15-32,36s14.35,36,32,36,32-16.15,32-36S145.65,144,128,144Zm0,56c-8.82,0-16-9-16-20s7.18-20,16-20,16,9,16,20S136.82,200,128,200ZM48,120a8,8,0,0,0,8-8V40h88V88a8,8,0,0,0,8,8h48v16a8,8,0,0,0,16,0V88a8,8,0,0,0-2.34-5.66l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72A8,8,0,0,0,48,120ZM160,51.31,188.69,80H160Z" {...props} />;
|
||||||
|
|
||||||
|
export const ExploreTabMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM172.42,72.84l-64,32a8.05,8.05,0,0,0-3.58,3.58l-32,64A8,8,0,0,0,80,184a8.1,8.1,0,0,0,3.58-.84l64-32a8.05,8.05,0,0,0,3.58-3.58l32-64a8,8,0,0,0-10.74-10.74ZM138,138,97.89,158.11,118,118l40.15-20.07Z" {...props} />;
|
||||||
|
export const ExploreTabFilledMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm51.58,57.79-32,64a4.08,4.08,0,0,1-1.79,1.79l-64,32a4,4,0,0,1-5.37-5.37l32-64a4.08,4.08,0,0,1,1.79-1.79l64-32A4,4,0,0,1,179.58,81.79Z" {...props} />;
|
||||||
|
export const TrailsTabMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M200,168a32.06,32.06,0,0,0-31,24H72a32,32,0,0,1,0-64h96a40,40,0,0,0,0-80H72a8,8,0,0,0,0,16h96a24,24,0,0,1,0,48H72a48,48,0,0,0,0,96h97a32,32,0,1,0,31-40Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,200,216Z" {...props} />;
|
||||||
|
export const TrailsTabFilledMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M228,200a28,28,0,0,1-54.83,8H72a48,48,0,0,1,0-96h96a24,24,0,0,0,0-48H72a8,8,0,0,1,0-16h96a40,40,0,0,1,0,80H72a32,32,0,0,0,0,64H173.17A28,28,0,0,1,228,200Z" {...props} />;
|
||||||
|
export const SearchTabMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z" {...props} />;
|
||||||
|
export const SearchTabFilledMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z" {...props} />;
|
||||||
|
export const CommunityTabMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M232.07,186.76a80,80,0,0,0-62.5-114.17A80,80,0,1,0,23.93,138.76l-7.27,24.71a16,16,0,0,0,19.87,19.87l24.71-7.27a80.39,80.39,0,0,0,25.18,7.35,80,80,0,0,0,108.34,40.65l24.71,7.27a16,16,0,0,0,19.87-19.86ZM62,159.5a8.28,8.28,0,0,0-2.26.32L32,168l8.17-27.76a8,8,0,0,0-.63-6,64,64,0,1,1,26.26,26.26A8,8,0,0,0,62,159.5Zm153.79,28.73L224,216l-27.76-8.17a8,8,0,0,0-6,.63,64.05,64.05,0,0,1-85.87-24.88A79.93,79.93,0,0,0,174.7,89.71a64,64,0,0,1,41.75,92.48A8,8,0,0,0,215.82,188.23Z" {...props} />;
|
||||||
|
export const CommunityTabFilledMockIcon: React.FC<MockIconProps> = (props) => <MockIcon path="M232.07,186.76a80,80,0,0,0-62.5-114.17A80,80,0,1,0,23.93,138.76l-7.27,24.71a16,16,0,0,0,19.87,19.87l24.71-7.27a80.39,80.39,0,0,0,25.18,7.35,80,80,0,0,0,108.34,40.65l24.71,7.27a16,16,0,0,0,19.87-19.86Zm-16.25,1.47L224,216l-27.76-8.17a8,8,0,0,0-6,.63,64.05,64.05,0,0,1-85.87-24.88A79.93,79.93,0,0,0,174.7,89.71a64,64,0,0,1,41.75,92.48A8,8,0,0,0,215.82,188.23Z" {...props} />;
|
||||||
77
components/ui/Select.tsx
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
|
import { CheckMockIcon, ChevronDownMockIcon } from './MockupIcons';
|
||||||
|
|
||||||
|
export type SelectOption = { value: string; label: string };
|
||||||
|
|
||||||
|
interface SelectProps {
|
||||||
|
value: string;
|
||||||
|
options: SelectOption[];
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
ariaLabel: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
variant?: 'default' | 'field' | 'mobile';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Custom listbox used instead of the browser's native select. */
|
||||||
|
export const Select: React.FC<SelectProps> = ({ value, options, onChange, ariaLabel, disabled = false, variant = 'default' }) => {
|
||||||
|
const triggerRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [position, setPosition] = useState<{ top: number; left: number; width: number } | null>(null);
|
||||||
|
const selected = options.find((option) => option.value === value);
|
||||||
|
|
||||||
|
const place = () => {
|
||||||
|
const trigger = triggerRef.current;
|
||||||
|
if (!trigger) return;
|
||||||
|
const rect = trigger.getBoundingClientRect();
|
||||||
|
const width = Math.max(rect.width, 160);
|
||||||
|
const height = Math.min(options.length * 40 + 12, 260);
|
||||||
|
setPosition({
|
||||||
|
top: Math.max(12, Math.min(rect.bottom + 6, window.innerHeight - height - 12)),
|
||||||
|
left: Math.max(12, Math.min(rect.left, window.innerWidth - width - 12)),
|
||||||
|
width,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggle = () => {
|
||||||
|
if (disabled) return;
|
||||||
|
if (!open) place();
|
||||||
|
setOpen((current) => !current);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return;
|
||||||
|
const close = () => setOpen(false);
|
||||||
|
const onKey = (event: KeyboardEvent) => { if (event.key === 'Escape') setOpen(false); };
|
||||||
|
window.addEventListener('resize', close);
|
||||||
|
window.addEventListener('scroll', close, true);
|
||||||
|
document.addEventListener('keydown', onKey);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', close);
|
||||||
|
window.removeEventListener('scroll', close, true);
|
||||||
|
document.removeEventListener('keydown', onKey);
|
||||||
|
};
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<button
|
||||||
|
ref={triggerRef}
|
||||||
|
type="button"
|
||||||
|
className={`select-trigger${variant !== 'default' ? ` ${variant}` : ''}`}
|
||||||
|
disabled={disabled}
|
||||||
|
aria-haspopup="listbox"
|
||||||
|
aria-expanded={open}
|
||||||
|
aria-label={ariaLabel}
|
||||||
|
onClick={toggle}
|
||||||
|
>
|
||||||
|
<span className="select-value">{selected?.label ?? ''}</span>
|
||||||
|
<ChevronDownMockIcon className="ph" />
|
||||||
|
</button>
|
||||||
|
{open && position && createPortal(<>
|
||||||
|
<button type="button" className="menu-scrim" aria-label="Fechar lista" onClick={() => setOpen(false)} />
|
||||||
|
<div className="select-menu" role="listbox" aria-label={ariaLabel} style={{ top: position.top, left: position.left, width: position.width }}>
|
||||||
|
{options.map((option) => <button key={option.value} type="button" role="option" aria-selected={option.value === value} onClick={() => { onChange(option.value); setOpen(false); }}><span>{option.label}</span>{option.value === value && <CheckMockIcon className="ph" />}</button>)}
|
||||||
|
</div>
|
||||||
|
</>, document.body)}
|
||||||
|
</>;
|
||||||
|
};
|
||||||
13
components/ui/Switch.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
interface SwitchProps {
|
||||||
|
checked: boolean;
|
||||||
|
onChange: (checked: boolean) => void;
|
||||||
|
label: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Custom switch matching the mockup, instead of a native checkbox. */
|
||||||
|
export const Switch: React.FC<SwitchProps> = ({ checked, onChange, label, disabled = false }) => (
|
||||||
|
<button type="button" role="switch" aria-checked={checked} aria-label={label} className="sw" disabled={disabled} onClick={() => onChange(!checked)} />
|
||||||
|
);
|
||||||
131
context/CatalogContext.tsx
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||||
|
import { Course } from '../types';
|
||||||
|
import { getCourses, getLearningPaths, PublicLearningPath } from '../services/db';
|
||||||
|
import { courseApi, InstructorSummary, profileApi } from '../services/api';
|
||||||
|
import { useAuth } from './AuthContext';
|
||||||
|
|
||||||
|
/** The three area tones from the design; every category is shown in one of them. */
|
||||||
|
export type AreaTone = 'midia' | 'conv' | 'oper';
|
||||||
|
const TONES: AreaTone[] = ['midia', 'conv', 'oper'];
|
||||||
|
|
||||||
|
export interface Professor {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
courses: Course[];
|
||||||
|
headline?: string;
|
||||||
|
avatarImageUrl?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CatalogContextType {
|
||||||
|
courses: Course[];
|
||||||
|
paths: PublicLearningPath[];
|
||||||
|
/** Categories that have published courses, in the admin-defined order. */
|
||||||
|
areas: string[];
|
||||||
|
professors: Professor[];
|
||||||
|
isLoading: boolean;
|
||||||
|
failed: boolean;
|
||||||
|
reload: () => Promise<void>;
|
||||||
|
courseById: (courseId: string) => Course | undefined;
|
||||||
|
toneOf: (category: string) => AreaTone;
|
||||||
|
pathTone: (path: PublicLearningPath) => AreaTone;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CatalogContext = createContext<CatalogContextType | undefined>(undefined);
|
||||||
|
|
||||||
|
export const CatalogProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||||
|
const { user, isLoading: authLoading } = useAuth();
|
||||||
|
const [courses, setCourses] = useState<Course[]>([]);
|
||||||
|
const [paths, setPaths] = useState<PublicLearningPath[]>([]);
|
||||||
|
const [instructorProfiles, setInstructorProfiles] = useState<InstructorSummary[]>([]);
|
||||||
|
const [categoryOrder, setCategoryOrder] = useState<string[]>([]);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [failed, setFailed] = useState(false);
|
||||||
|
|
||||||
|
const reload = useCallback(async () => {
|
||||||
|
setFailed(false);
|
||||||
|
try {
|
||||||
|
const [loadedCourses, loadedPaths, categories, instructors] = await Promise.all([
|
||||||
|
getCourses(),
|
||||||
|
getLearningPaths().catch(() => [] as PublicLearningPath[]),
|
||||||
|
courseApi.categories().then((response) => response.data).catch(() => [] as string[]),
|
||||||
|
profileApi.instructors().then((response) => response.data).catch(() => [] as InstructorSummary[]),
|
||||||
|
]);
|
||||||
|
setCourses(loadedCourses);
|
||||||
|
setPaths(loadedPaths);
|
||||||
|
setCategoryOrder(categories);
|
||||||
|
setInstructorProfiles(instructors);
|
||||||
|
} catch {
|
||||||
|
// Never replace a failed API with fake catalogue data: the screens use the
|
||||||
|
// `failed` flag to show an honest loading error instead.
|
||||||
|
setFailed(true);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Progress on each course belongs to the signed-in learner, so reload when the session changes.
|
||||||
|
useEffect(() => {
|
||||||
|
if (authLoading) return;
|
||||||
|
void reload();
|
||||||
|
}, [authLoading, reload, user?.id]);
|
||||||
|
|
||||||
|
const value = useMemo<CatalogContextType>(() => {
|
||||||
|
const present: string[] = Array.from(new Set(courses.map((course) => course.category).filter(Boolean)));
|
||||||
|
const ordered = [
|
||||||
|
...categoryOrder.filter((category) => present.includes(category)),
|
||||||
|
...present.filter((category) => !categoryOrder.includes(category)).sort((a, b) => a.localeCompare(b, 'pt-BR')),
|
||||||
|
];
|
||||||
|
const toneIndex = new Map(ordered.map((category, index) => [category, index]));
|
||||||
|
const toneOf = (category: string): AreaTone => TONES[(toneIndex.get(category) ?? 0) % TONES.length];
|
||||||
|
const byId = new Map(courses.map((course) => [course.id, course]));
|
||||||
|
|
||||||
|
const professorMap = new Map<string, Professor>();
|
||||||
|
instructorProfiles.forEach((professor) => {
|
||||||
|
professorMap.set(professor.id, {
|
||||||
|
id: professor.id,
|
||||||
|
name: professor.name,
|
||||||
|
headline: professor.headline || undefined,
|
||||||
|
avatarImageUrl: professor.avatarImageUrl,
|
||||||
|
courses: [],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
courses.forEach((course) => {
|
||||||
|
if (!course.instructorId) return;
|
||||||
|
const entry = professorMap.get(course.instructorId) || {
|
||||||
|
id: course.instructorId,
|
||||||
|
name: course.instructor || 'Professor',
|
||||||
|
headline: undefined,
|
||||||
|
avatarImageUrl: null,
|
||||||
|
courses: [],
|
||||||
|
};
|
||||||
|
entry.courses.push(course);
|
||||||
|
professorMap.set(course.instructorId, entry);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
courses,
|
||||||
|
paths,
|
||||||
|
areas: ordered,
|
||||||
|
professors: Array.from(professorMap.values()).sort((a, b) => a.name.localeCompare(b.name, 'pt-BR')),
|
||||||
|
isLoading,
|
||||||
|
failed,
|
||||||
|
reload,
|
||||||
|
courseById: (courseId: string) => byId.get(courseId),
|
||||||
|
toneOf,
|
||||||
|
pathTone: (path: PublicLearningPath) => {
|
||||||
|
const counts = new Map<string, number>();
|
||||||
|
path.courses.forEach((course) => counts.set(course.category, (counts.get(course.category) || 0) + 1));
|
||||||
|
const main = [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
||||||
|
return main ? toneOf(main) : 'midia';
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}, [categoryOrder, courses, failed, isLoading, instructorProfiles, paths, reload]);
|
||||||
|
|
||||||
|
return <CatalogContext.Provider value={value}>{children}</CatalogContext.Provider>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useCatalog = () => {
|
||||||
|
const context = useContext(CatalogContext);
|
||||||
|
if (!context) throw new Error('useCatalog must be used within CatalogProvider');
|
||||||
|
return context;
|
||||||
|
};
|
||||||
39
context/ThemeContext.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';
|
||||||
|
import { readPreference, writePreference } from '../lib/storage';
|
||||||
|
|
||||||
|
type Theme = 'light' | 'dark';
|
||||||
|
|
||||||
|
interface ThemeContextType {
|
||||||
|
theme: Theme;
|
||||||
|
toggleTheme: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const THEME_KEY = 'ca-theme';
|
||||||
|
const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
|
||||||
|
|
||||||
|
// Light by default; the choice is saved and the system preference is not followed.
|
||||||
|
const initialTheme = (): Theme => (readPreference(THEME_KEY) === 'dark' ? 'dark' : 'light');
|
||||||
|
|
||||||
|
export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||||
|
const [theme, setTheme] = useState<Theme>(initialTheme);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.documentElement.classList.toggle('dark', theme === 'dark');
|
||||||
|
}, [theme]);
|
||||||
|
|
||||||
|
const toggleTheme = useCallback(() => {
|
||||||
|
setTheme((current) => {
|
||||||
|
const next = current === 'dark' ? 'light' : 'dark';
|
||||||
|
writePreference(THEME_KEY, next);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return <ThemeContext.Provider value={{ theme, toggleTheme }}>{children}</ThemeContext.Provider>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useTheme = () => {
|
||||||
|
const context = useContext(ThemeContext);
|
||||||
|
if (!context) throw new Error('useTheme must be used within ThemeProvider');
|
||||||
|
return context;
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { createContext, useContext, useState, useCallback } from 'react';
|
import React, { createContext, useContext, useState, useCallback } from 'react';
|
||||||
import { CheckCircle2, XCircle, Info, Download, X, FileText, Check } from 'lucide-react';
|
import { CheckCircle, DownloadSimple, Info, WarningCircle, X } from '@phosphor-icons/react';
|
||||||
|
|
||||||
export type ToastType = 'success' | 'error' | 'info' | 'download';
|
export type ToastType = 'success' | 'error' | 'info' | 'download';
|
||||||
|
|
||||||
@@ -18,99 +18,47 @@ export interface ToastContextType {
|
|||||||
|
|
||||||
const ToastContext = createContext<ToastContextType | undefined>(undefined);
|
const ToastContext = createContext<ToastContextType | undefined>(undefined);
|
||||||
|
|
||||||
|
const icons: Record<ToastType, React.ReactNode> = {
|
||||||
|
success: <CheckCircle className="ph" />,
|
||||||
|
error: <WarningCircle className="ph" />,
|
||||||
|
info: <Info className="ph" />,
|
||||||
|
download: <DownloadSimple className="ph" />,
|
||||||
|
};
|
||||||
|
|
||||||
export const ToastProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
export const ToastProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||||
const [toasts, setToasts] = useState<Toast[]>([]);
|
const [toasts, setToasts] = useState<Toast[]>([]);
|
||||||
|
|
||||||
const showToast = useCallback((message: string, type: ToastType = 'success', fileName?: string, fileSize?: string) => {
|
const push = useCallback((toast: Omit<Toast, 'id'>, duration: number) => {
|
||||||
const id = Date.now().toString() + Math.random().toString(36).substring(2, 5);
|
const id = Date.now().toString() + Math.random().toString(36).substring(2, 5);
|
||||||
setToasts((prev) => [...prev, { id, message, type, fileName, fileSize }]);
|
setToasts((prev) => [...prev, { ...toast, id }]);
|
||||||
setTimeout(() => {
|
setTimeout(() => setToasts((prev) => prev.filter((t) => t.id !== id)), duration);
|
||||||
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
||||||
}, 4000);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const showToast = useCallback((message: string, type: ToastType = 'success', fileName?: string, fileSize?: string) => {
|
||||||
|
push({ message, type, fileName, fileSize }, 4000);
|
||||||
|
}, [push]);
|
||||||
|
|
||||||
const showDownloadToast = useCallback((fileName: string, fileSize?: string) => {
|
const showDownloadToast = useCallback((fileName: string, fileSize?: string) => {
|
||||||
const id = Date.now().toString() + Math.random().toString(36).substring(2, 5);
|
push({ message: `O material "${fileName}" foi baixado com sucesso.`, type: 'download', fileName, fileSize }, 4500);
|
||||||
setToasts((prev) => [...prev, {
|
}, [push]);
|
||||||
id,
|
|
||||||
message: `O material "${fileName}" foi baixado com sucesso.`,
|
|
||||||
type: 'download',
|
|
||||||
fileName,
|
|
||||||
fileSize
|
|
||||||
}]);
|
|
||||||
setTimeout(() => {
|
|
||||||
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
||||||
}, 4500);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const removeToast = (id: string) => {
|
const removeToast = (id: string) => setToasts((prev) => prev.filter((t) => t.id !== id));
|
||||||
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToastContext.Provider value={{ showToast, showDownloadToast }}>
|
<ToastContext.Provider value={{ showToast, showDownloadToast }}>
|
||||||
{children}
|
{children}
|
||||||
<div className="fixed bottom-6 right-6 z-[300] flex flex-col gap-3 pointer-events-none">
|
<div className="toasts" role="status" aria-live="polite">
|
||||||
{toasts.map((toast) => {
|
{toasts.map((toast) => (
|
||||||
if (toast.type === 'download') {
|
<div key={toast.id} className={`toast ${toast.type}`}>
|
||||||
return (
|
{icons[toast.type]}
|
||||||
<div
|
{toast.type === 'download' ? (
|
||||||
key={toast.id}
|
<p>{toast.fileName}<small>Baixado{toast.fileSize ? ` · ${toast.fileSize}` : ''}</small></p>
|
||||||
className="pointer-events-auto relative overflow-hidden flex items-center gap-3.5 bg-[#0d0e12]/95 backdrop-blur-2xl border border-emerald-500/30 text-white p-4 rounded-2xl shadow-2xl shadow-emerald-500/15 animate-fade-in-up min-w-[320px] max-w-[420px]"
|
) : (
|
||||||
>
|
<p>{toast.message}</p>
|
||||||
{/* Emerald vertical bar */}
|
)}
|
||||||
<div className="absolute left-0 top-0 bottom-0 w-1 bg-gradient-to-b from-emerald-400 to-teal-500"></div>
|
<button type="button" className="iconbtn" onClick={() => removeToast(toast.id)} aria-label="Fechar aviso"><X className="ph" /></button>
|
||||||
|
</div>
|
||||||
<div className="w-10 h-10 rounded-xl bg-emerald-500/15 border border-emerald-500/30 flex items-center justify-center shrink-0 text-emerald-400 shadow-inner">
|
))}
|
||||||
<Download className="w-5 h-5 animate-bounce" style={{ animationIterationCount: 2 }} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex-1 min-w-0 pr-1">
|
|
||||||
<div className="flex items-center gap-2 mb-0.5">
|
|
||||||
<span className="text-[10px] font-extrabold tracking-wider uppercase text-emerald-400 bg-emerald-500/15 px-2 py-0.5 rounded-full border border-emerald-500/30 flex items-center gap-1">
|
|
||||||
<CheckCircle2 className="w-3 h-3 text-emerald-400" />
|
|
||||||
Download Concluído
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p className="text-sm font-bold text-white truncate leading-tight" title={toast.fileName || toast.message}>
|
|
||||||
{toast.fileName || toast.message}
|
|
||||||
</p>
|
|
||||||
<div className="flex items-center gap-2 text-xs text-slate-400 mt-1">
|
|
||||||
<span>Salvo no seu dispositivo</span>
|
|
||||||
{toast.fileSize && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span className="font-mono text-emerald-400/90 font-medium">{toast.fileSize}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={() => removeToast(toast.id)}
|
|
||||||
className="text-slate-500 hover:text-white p-1 rounded-lg hover:bg-white/10 transition-colors shrink-0"
|
|
||||||
>
|
|
||||||
<X className="w-4 h-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={toast.id}
|
|
||||||
className="pointer-events-auto flex items-center gap-3 bg-[#121318]/95 backdrop-blur-2xl border border-white/10 text-white px-5 py-4 rounded-2xl shadow-2xl animate-fade-in-up min-w-[300px]"
|
|
||||||
>
|
|
||||||
{toast.type === 'success' && <CheckCircle2 className="w-5 h-5 text-emerald-400 shrink-0" />}
|
|
||||||
{toast.type === 'error' && <XCircle className="w-5 h-5 text-rose-400 shrink-0" />}
|
|
||||||
{toast.type === 'info' && <Info className="w-5 h-5 text-sky-400 shrink-0" />}
|
|
||||||
<p className="flex-1 text-sm font-medium">{toast.message}</p>
|
|
||||||
<button onClick={() => removeToast(toast.id)} className="text-slate-500 hover:text-white shrink-0">
|
|
||||||
<X className="w-4 h-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
</ToastContext.Provider>
|
</ToastContext.Provider>
|
||||||
);
|
);
|
||||||
@@ -121,4 +69,3 @@ export const useToast = () => {
|
|||||||
if (!context) throw new Error('useToast must be used within ToastProvider');
|
if (!context) throw new Error('useToast must be used within ToastProvider');
|
||||||
return context;
|
return context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
135
design/DESIGN.md
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
# Compor Academy — especificação de design
|
||||||
|
|
||||||
|
Este documento descreve o novo visual do ComporHUB. A referência visual é o protótipo navegável da versão **UI Skills**. O mobile tem navegação própria e não é a versão desktop encolhida.
|
||||||
|
|
||||||
|
Arquivos nesta pasta:
|
||||||
|
|
||||||
|
| Arquivo | Para que serve |
|
||||||
|
|---|---|
|
||||||
|
| `prototype-reference.html` | Código-fonte legível do protótipo (CSS + JS + ícones inline). **É a fonte de verdade para valores exatos.** Abra no navegador para navegar; o seletor "Ver como" alterna Visitante / Aluno / Professor / Admin. |
|
||||||
|
| `compor-academy-prototipo-ui-skills.html` | O mesmo protótipo com as fontes embutidas, para abrir offline. |
|
||||||
|
| `compor-academy-mobile-todas-as-paginas.html` | Galeria com todas as telas mobile. |
|
||||||
|
| `compor-academy-logo-light.svg` / `-dark.svg` | Logo em vetor ("compor" + assinatura "academy"). |
|
||||||
|
|
||||||
|
## 1. Princípios
|
||||||
|
|
||||||
|
- Estilo Apple / app Apple TV: tipografia faz o trabalho, pouco texto, pouca coisa na tela.
|
||||||
|
- **Um único acento**: azul `#0a84ff`. Ele marca só a ação principal, a página atual e os links. Ícones de navegação ficam em cinza.
|
||||||
|
- Sem degradês, sem brilho e sem sombra em elementos parados. Superfícies se separam por um passo de tom (`--bg-2`), não por contorno.
|
||||||
|
- Sem etiquetas coloridas em formato de pílula. Status vira texto cinza com ícone quando ajuda. Vermelho só para erro que pede ação (ex.: "Falhou no envio · Reenviar").
|
||||||
|
- Sem rótulos pequenos acima de títulos e sem numeração decorativa. Números só onde a ordem é real (aulas, cursos de uma trilha).
|
||||||
|
- O modo escuro usa preto e tons de grafite. Nunca azul-escuro ou marrom.
|
||||||
|
- Sem emojis. Ícones: **Phosphor** (`@phosphor-icons/react`), peso regular; o peso `fill` marca a aba ativa no mobile. **Remover `lucide-react`.**
|
||||||
|
|
||||||
|
## 2. Tokens
|
||||||
|
|
||||||
|
```css
|
||||||
|
:root{
|
||||||
|
--bg:#ffffff; --bg-2:#f5f5f7; --bg-3:#e8e8ed; --raise:#ffffff;
|
||||||
|
--fg:#1d1d1f; --fg-2:#6e6e73; --fg-3:#86868b;
|
||||||
|
--line:rgba(0,0,0,.1); --line-2:rgba(0,0,0,.06);
|
||||||
|
--blue:#0a84ff; --blue-press:#0071e3; --blue-text:#0071e3;
|
||||||
|
--ok:#248a3d; --warn:#b25000; --bad:#d70015;
|
||||||
|
/* cor por área — também é a "capa" provisória de cursos e trilhas */
|
||||||
|
--c-midia:#1d1d1f; --c-midia-on:#ffffff; /* Mídia paga */
|
||||||
|
--c-conv:#0a84ff; --c-conv-on:#ffffff; /* Conversão */
|
||||||
|
--c-oper:#e8e8ed; --c-oper-on:#1d1d1f; /* Operação */
|
||||||
|
--side:#f2f2f4; --side-hover:rgba(0,0,0,.045);
|
||||||
|
--glass:rgba(250,250,252,.76); --glass-line:rgba(255,255,255,.75);
|
||||||
|
--r:18px; --r-s:12px;
|
||||||
|
}
|
||||||
|
.dark{
|
||||||
|
--bg:#151517; --bg-2:#232326; --bg-3:#313135; --raise:#232326;
|
||||||
|
--fg:#f5f5f7; --fg-2:#a1a1a6; --fg-3:#8e8e93;
|
||||||
|
--line:rgba(255,255,255,.14); --line-2:rgba(255,255,255,.08);
|
||||||
|
--blue-text:#2997ff; --ok:#30d158; --warn:#ff9f0a; --bad:#ff453a;
|
||||||
|
--c-midia:#000000; --c-oper:#34343a; --c-oper-on:#f5f5f7;
|
||||||
|
--side:#202023; --glass:rgba(44,44,48,.52); --glass-line:rgba(255,255,255,.14);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Tema**: claro por padrão, com botão para alternar e escolha salva. Não segue o sistema automaticamente.
|
||||||
|
- **Fonte**: `-apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui`. A Inter é só o fallback; em Mac e iPhone aparece a SF Pro.
|
||||||
|
- **Escala**: títulos de página 40px (mobile 32px), título do carrossel até 92px, títulos de seção 24px (mobile 20px), corpo 15–17px, legendas 13px. Títulos grandes com letter-spacing negativo (-0.03 a -0.045em). Números com `tabular-nums`.
|
||||||
|
- **Botões**: pílula; primário azul; secundário `--bg-2`; ao pressionar, `scale(.96)`.
|
||||||
|
|
||||||
|
## 3. Estrutura desktop (≥ 901px)
|
||||||
|
|
||||||
|
**Barra lateral de vidro flutuante** (padrão: vidro e **expandida**):
|
||||||
|
- Posição `fixed` com 12px de margem e raio 26px. Fundo `--glass` com `backdrop-filter: blur(40px) saturate(200%)` e borda `--glass-line`.
|
||||||
|
- O conteúdo fica 44px à direita dela (`--sw: 264px`; recolhida, `88px`).
|
||||||
|
- Topo: botão de recolher (ícone sidebar-simple), depois o logo.
|
||||||
|
- Soltos: **Buscar**, **Explorar**.
|
||||||
|
- Grupos recolhíveis (título em negrito com chevron; o estado aberto ou fechado fica salvo):
|
||||||
|
- **Aprendizado**: Trilhas, Minha aprendizagem (com contador).
|
||||||
|
- **Comunidade**: Discussões, Professores.
|
||||||
|
- **Materiais**: Biblioteca, Meus downloads.
|
||||||
|
- **Gestão** (só professor e admin): Gerenciar cursos, Administração.
|
||||||
|
- Item ativo: fundo azul e texto branco.
|
||||||
|
- Rodapé: avatar + nome (abre o menu da conta por cima da página, com `position: fixed` no `body` para não ser cortado), botão de tema. Visitante vê "Criar conta" e "Entrar".
|
||||||
|
- Recolhida: só ícones, logo vira "c" + ponto azul, com animação de largura.
|
||||||
|
|
||||||
|
**Explorar (home)**:
|
||||||
|
- Carrossel de largura total que passa por baixo do vidro, com o título "Explorar" sobre ele.
|
||||||
|
- Cada slide: só o título grande, a linha de meta, a descrição, "Assistir"/"Continuar aula N" e "Ver curso".
|
||||||
|
- Troca a cada 6s e pausa com o mouse em cima. Pontos centralizados; setas no canto inferior direito, visíveis só no hover.
|
||||||
|
- Abaixo, fileiras horizontais (scroll-snap) com setas que aparecem no hover:
|
||||||
|
- Continue assistindo.
|
||||||
|
- Mais assistidos.
|
||||||
|
- Trilhas (pôsteres verticais).
|
||||||
|
- Uma fileira por área.
|
||||||
|
- O título de cada fileira é um link com chevron.
|
||||||
|
|
||||||
|
**Capas**:
|
||||||
|
- Curso: bloco 16:10 na cor da área, com o título.
|
||||||
|
- Trilha: pôster 2:3 com **dois cartões empilhados atrás** (mesma cor, mais claros, 92% e 84% de escala). Ao passar o mouse, a pilha se abre.
|
||||||
|
- O progresso é sempre uma **barra dentro da capa**, na cor do texto da capa.
|
||||||
|
- Quando houver imagens reais (Bunny), elas substituem o bloco de cor nos mesmos formatos.
|
||||||
|
|
||||||
|
**Outras páginas**: Buscar, Trilhas (grade de pôsteres), Trilha, Curso, Aula, Minha aprendizagem, Discussões, Professores, Professor, Biblioteca, Meus downloads, Conta, Gerenciar cursos, Editar curso, Administração, Entrar, Criar conta. Veja cada uma no protótipo.
|
||||||
|
|
||||||
|
## 4. Estrutura mobile (≤ 900px) — navegação própria
|
||||||
|
|
||||||
|
- **Barra de abas** fixa embaixo: Explorar · Trilhas · Buscar · Comunidade · **Você**.
|
||||||
|
- Sem aba "Menu" e sem gaveta lateral.
|
||||||
|
- Aba ativa em azul, com ícone `fill`. Logado, a aba Você mostra o avatar.
|
||||||
|
- **Título grande** no topo de cada tela raiz.
|
||||||
|
- Toda tela de detalhe tem uma barra com **"‹ Voltar"**, que usa uma pilha de navegação real.
|
||||||
|
- **Ação principal fixa** acima da barra de abas, ao alcance do polegar:
|
||||||
|
- Curso: "Continuar aula N" + salvar.
|
||||||
|
- Trilha: "Continuar trilha".
|
||||||
|
- Aula: "Vista" + "Próxima aula". Na aula, a barra de abas some e o player fica preso no topo.
|
||||||
|
- **Você**: perfil no topo e listas agrupadas no estilo do Ajustes do iOS:
|
||||||
|
- Aprendizado: Minha aprendizagem, Meus downloads, Biblioteca.
|
||||||
|
- Gestão: só professor e admin.
|
||||||
|
- Conta, Aparência (modo escuro) e Sair.
|
||||||
|
- Visitante vê "Criar conta"/"Entrar".
|
||||||
|
- **Abas internas viram controles segmentados**:
|
||||||
|
- Curso: Aulas | Materiais | Sobre.
|
||||||
|
- Aula: Aulas | Materiais | Discussão.
|
||||||
|
- Comunidade: Discussões | Professores.
|
||||||
|
- Minha aprendizagem: Em andamento | Concluídos | Salvos.
|
||||||
|
- Admin: Usuários | Destaques | Atividade.
|
||||||
|
- **Tabelas e grades viram listas agrupadas**: miniatura + título + linha de detalhe + ›.
|
||||||
|
- **Explorar**: destaques viram cartões deslizáveis (sem troca automática) e as fileiras usam scroll-snap.
|
||||||
|
- **Buscar**: vazio mostra as áreas; ao digitar, separa Cursos / Trilhas / Professores.
|
||||||
|
- **Entrar/Criar conta**: centralizados na vertical.
|
||||||
|
- **Detalhes de toque** (skill mobile-native):
|
||||||
|
- Inputs com 16px.
|
||||||
|
- `-webkit-tap-highlight-color: transparent`.
|
||||||
|
- Hover só dentro de `@media (hover:hover)`.
|
||||||
|
- `touch-action: manipulation`.
|
||||||
|
- Áreas seguras com `env(safe-area-inset-*)`.
|
||||||
|
- `overscroll-behavior` nos trilhos horizontais.
|
||||||
|
- Controles com `user-select: none`.
|
||||||
|
- Toques de pelo menos 44px.
|
||||||
|
|
||||||
|
## 5. Movimento
|
||||||
|
|
||||||
|
- Entrada da página (subir 6–14px + fade) **só ao navegar para uma página nova**. Trocar abas e filtros não reanima nada.
|
||||||
|
- Feedback de interação ≤ 200ms, ease-out, apenas `transform` e `opacity`. Exceção: a largura da barra lateral ao recolher.
|
||||||
|
- Respeitar `prefers-reduced-motion`.
|
||||||
|
|
||||||
|
## 6. Logo
|
||||||
|
|
||||||
|
"compor" em negrito (Inter Display Bold, letter-spacing -0.045em) com "academy" logo abaixo, à direita, em **Mrs Saint Delafield**, azul `#0a84ff`, como assinatura. Use os SVGs desta pasta; na barra lateral pode ser texto + fonte.
|
||||||
1
design/compor-academy-logo-dark.svg
Normal file
|
After Width: | Height: | Size: 13 KiB |
1
design/compor-academy-logo-light.svg
Normal file
|
After Width: | Height: | Size: 13 KiB |
33
design/compor-academy-mobile-todas-as-paginas.html
Normal file
BIN
design/compor-academy-mobile.png
Normal file
|
After Width: | Height: | Size: 656 KiB |
1632
design/compor-academy-prototipo-ui-skills.html
Normal file
1028
design/compor-academy-prototipo.html
Normal file
1630
design/prototype-reference.html
Normal file
@@ -27,7 +27,7 @@ services:
|
|||||||
JWT_SECRET: ${JWT_SECRET:?Set a long random JWT_SECRET in Portainer}
|
JWT_SECRET: ${JWT_SECRET:?Set a long random JWT_SECRET in Portainer}
|
||||||
SUPERADMIN_EMAIL: ${SUPERADMIN_EMAIL:-}
|
SUPERADMIN_EMAIL: ${SUPERADMIN_EMAIL:-}
|
||||||
SUPERADMIN_PASSWORD: ${SUPERADMIN_PASSWORD:-}
|
SUPERADMIN_PASSWORD: ${SUPERADMIN_PASSWORD:-}
|
||||||
SUPERADMIN_NAME: ${SUPERADMIN_NAME:-Compor HUB Superadmin}
|
SUPERADMIN_NAME: ${SUPERADMIN_NAME:-Compor HUB Admin}
|
||||||
AUTH_RATE_LIMIT_MAX: ${AUTH_RATE_LIMIT_MAX:-10}
|
AUTH_RATE_LIMIT_MAX: ${AUTH_RATE_LIMIT_MAX:-10}
|
||||||
AUTH_RATE_LIMIT_WINDOW_SECONDS: ${AUTH_RATE_LIMIT_WINDOW_SECONDS:-900}
|
AUTH_RATE_LIMIT_WINDOW_SECONDS: ${AUTH_RATE_LIMIT_WINDOW_SECONDS:-900}
|
||||||
JWT_SESSION_TTL: ${JWT_SESSION_TTL:-7d}
|
JWT_SESSION_TTL: ${JWT_SESSION_TTL:-7d}
|
||||||
|
|||||||
@@ -7,6 +7,21 @@ server {
|
|||||||
# as the API default and stream bodies instead of buffering them on disk.
|
# as the API default and stream bodies instead of buffering them on disk.
|
||||||
client_max_body_size 5g;
|
client_max_body_size 5g;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript application/xml image/svg+xml;
|
||||||
|
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||||
|
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
||||||
|
add_header Strict-Transport-Security "max-age=31536000" always;
|
||||||
|
|
||||||
|
location /assets/ {
|
||||||
|
try_files $uri =404;
|
||||||
|
expires 1y;
|
||||||
|
}
|
||||||
|
|
||||||
# Docker Swarm may start this container before the API service receives a DNS
|
# Docker Swarm may start this container before the API service receives a DNS
|
||||||
# record. Resolving through Docker DNS at request time keeps Nginx alive while
|
# record. Resolving through Docker DNS at request time keeps Nginx alive while
|
||||||
# the API starts or is replaced during a rolling deployment.
|
# the API starts or is replaced during a rolling deployment.
|
||||||
|
|||||||
81
hooks/useCourse.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import { Course, Lesson } from '../types';
|
||||||
|
import { getCourseById, getLessonProgress, saveLessonCompletion } from '../services/db';
|
||||||
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
|
||||||
|
/** A course from the shared catalogue, or fetched on its own when it is not listed there. */
|
||||||
|
export const useCourse = (courseId?: string) => {
|
||||||
|
const { courseById, isLoading: catalogLoading } = useCatalog();
|
||||||
|
const listed = courseId ? courseById(courseId) : undefined;
|
||||||
|
const [fetched, setFetched] = useState<Course | null | undefined>(undefined);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!courseId || listed || catalogLoading) return;
|
||||||
|
let cancelled = false;
|
||||||
|
getCourseById(courseId).then((course) => { if (!cancelled) setFetched(course); });
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, [catalogLoading, courseId, listed]);
|
||||||
|
|
||||||
|
const course = listed || fetched || undefined;
|
||||||
|
const isLoading = !course && (catalogLoading || fetched === undefined);
|
||||||
|
return { course, isLoading, missing: !course && !isLoading };
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The learner's saved lesson progress for a course, with optimistic completion updates. */
|
||||||
|
export const useLessonProgress = (course?: Course) => {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const { reload: reloadCatalog } = useCatalog();
|
||||||
|
const [completedIds, setCompletedIds] = useState<string[]>([]);
|
||||||
|
const [watched, setWatched] = useState<Record<string, number>>({});
|
||||||
|
// Which course the progress belongs to, so a stale value is never read as loaded.
|
||||||
|
const [loadedFor, setLoadedFor] = useState<string | null>(null);
|
||||||
|
const lastSaved = useRef<Record<string, number>>({});
|
||||||
|
const completedRef = useRef<string[]>([]);
|
||||||
|
completedRef.current = completedIds;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCompletedIds([]);
|
||||||
|
setWatched({});
|
||||||
|
lastSaved.current = {};
|
||||||
|
if (!course || !user) { setLoadedFor(course?.id ?? ''); return; }
|
||||||
|
let cancelled = false;
|
||||||
|
getLessonProgress(course.id).then((progress) => {
|
||||||
|
if (cancelled) return;
|
||||||
|
setCompletedIds(progress.filter((item) => item.completedAt).map((item) => item.lessonId));
|
||||||
|
const seconds = Object.fromEntries(progress.map((item) => [item.lessonId, item.watchedSeconds]));
|
||||||
|
setWatched(seconds);
|
||||||
|
lastSaved.current = { ...seconds };
|
||||||
|
}).catch(() => setCompletedIds([])).finally(() => { if (!cancelled) setLoadedFor(course.id); });
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, [course?.id, user?.id]);
|
||||||
|
|
||||||
|
const markCompleted = useCallback((lessonId: string, watchedSeconds?: number) => {
|
||||||
|
if (!user || completedRef.current.includes(lessonId)) return;
|
||||||
|
const previous = completedRef.current;
|
||||||
|
setCompletedIds([...previous, lessonId]);
|
||||||
|
saveLessonCompletion(lessonId, true, watchedSeconds)
|
||||||
|
.then(() => reloadCatalog())
|
||||||
|
.catch(() => setCompletedIds(previous));
|
||||||
|
}, [reloadCatalog, user]);
|
||||||
|
|
||||||
|
const toggleCompleted = useCallback((lessonId: string) => {
|
||||||
|
if (!user) return;
|
||||||
|
if (completedRef.current.includes(lessonId)) {
|
||||||
|
const previous = completedRef.current;
|
||||||
|
setCompletedIds(previous.filter((id) => id !== lessonId));
|
||||||
|
saveLessonCompletion(lessonId, false)
|
||||||
|
.then(() => reloadCatalog())
|
||||||
|
.catch(() => setCompletedIds(previous));
|
||||||
|
} else {
|
||||||
|
markCompleted(lessonId);
|
||||||
|
}
|
||||||
|
}, [markCompleted, reloadCatalog, user]);
|
||||||
|
|
||||||
|
const completed = useMemo(() => new Set(completedIds), [completedIds]);
|
||||||
|
const next: Lesson | undefined = course?.lessons.find((lesson) => !completed.has(lesson.id)) || course?.lessons[0];
|
||||||
|
const nextIndex = next && course ? course.lessons.indexOf(next) : 0;
|
||||||
|
|
||||||
|
const loaded = loadedFor === (course?.id ?? '');
|
||||||
|
return { completed, watched, setWatched, lastSaved, loaded, markCompleted, toggleCompleted, next, nextIndex, doneCount: completed.size };
|
||||||
|
};
|
||||||
18
hooks/useMediaQuery.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
export const MOBILE_QUERY = '(max-width: 900px)';
|
||||||
|
|
||||||
|
export const useMediaQuery = (query: string) => {
|
||||||
|
const [matches, setMatches] = useState(() => typeof window !== 'undefined' && window.matchMedia(query).matches);
|
||||||
|
useEffect(() => {
|
||||||
|
const media = window.matchMedia(query);
|
||||||
|
const update = () => setMatches(media.matches);
|
||||||
|
update();
|
||||||
|
media.addEventListener('change', update);
|
||||||
|
return () => media.removeEventListener('change', update);
|
||||||
|
}, [query]);
|
||||||
|
return matches;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Mobile (≤900px) has its own navigation and screens, not the desktop squeezed. */
|
||||||
|
export const useIsMobile = () => useMediaQuery(MOBILE_QUERY);
|
||||||
63
hooks/useSavedCourses.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { savedCourseApi } from '../services/api';
|
||||||
|
|
||||||
|
const legacyKeyFor = (userId: string) => `ca-saved-courses:${userId}`;
|
||||||
|
|
||||||
|
const readLegacy = (userId?: string) => {
|
||||||
|
if (!userId) return [] as string[];
|
||||||
|
try {
|
||||||
|
const value = JSON.parse(localStorage.getItem(legacyKeyFor(userId)) || '[]');
|
||||||
|
return Array.isArray(value)
|
||||||
|
? value.filter((item): item is string => typeof item === 'string' && /^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(item))
|
||||||
|
: [];
|
||||||
|
} catch { return [] as string[]; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Saved courses follow the signed-in account and are stored by the API. */
|
||||||
|
export const useSavedCourses = () => {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const [ids, setIds] = useState<string[]>([]);
|
||||||
|
const [loaded, setLoaded] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
setIds([]);
|
||||||
|
setLoaded(false);
|
||||||
|
if (!user) { setLoaded(true); return; }
|
||||||
|
|
||||||
|
const load = async () => {
|
||||||
|
const legacy = readLegacy(user.id);
|
||||||
|
try {
|
||||||
|
if (legacy.length) {
|
||||||
|
// Move saves created before the API existed, then keep only the server copy.
|
||||||
|
const results = await Promise.allSettled(legacy.map((courseId) => savedCourseApi.save(courseId)));
|
||||||
|
if (results.every((result) => result.status === 'fulfilled')) {
|
||||||
|
localStorage.removeItem(legacyKeyFor(user.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const response = await savedCourseApi.list();
|
||||||
|
if (!cancelled) setIds(response.data.map((item) => item.courseId));
|
||||||
|
} catch {
|
||||||
|
if (!cancelled) setIds(legacy);
|
||||||
|
} finally {
|
||||||
|
if (!cancelled) setLoaded(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void load();
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, [user?.id]);
|
||||||
|
|
||||||
|
const toggle = useCallback((courseId: string) => {
|
||||||
|
if (!user) return;
|
||||||
|
const previous = ids;
|
||||||
|
const wasSaved = previous.includes(courseId);
|
||||||
|
const next = wasSaved ? previous.filter((id) => id !== courseId) : [...previous, courseId];
|
||||||
|
setIds(next);
|
||||||
|
const request = wasSaved ? savedCourseApi.remove(courseId) : savedCourseApi.save(courseId);
|
||||||
|
request.catch(() => setIds(previous));
|
||||||
|
}, [ids, user]);
|
||||||
|
|
||||||
|
return { ids, loaded, toggle, isSaved: (courseId: string) => ids.includes(courseId) };
|
||||||
|
};
|
||||||
99
index.css
@@ -1,99 +0,0 @@
|
|||||||
:root {
|
|
||||||
/* Typography Tokens */
|
|
||||||
--font-display: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
||||||
--font-body: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
||||||
|
|
||||||
/* Border Radii */
|
|
||||||
--radius-tag: 980px;
|
|
||||||
--radius-button: 980px;
|
|
||||||
--radius-card: 8px;
|
|
||||||
--radius-image: 8px;
|
|
||||||
--radius-input: 8px;
|
|
||||||
|
|
||||||
/* Shadows */
|
|
||||||
--shadow-xl: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
|
|
||||||
|
|
||||||
/* Layout */
|
|
||||||
--page-max-width: 1440px;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: var(--font-body);
|
|
||||||
background-color: #000000;
|
|
||||||
color: #f4f4f5;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6, .font-display, .font-heading {
|
|
||||||
font-family: var(--font-display);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
||||||
.hide-scrollbar::-webkit-scrollbar {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Hide scrollbar for IE, Edge and Firefox */
|
|
||||||
.hide-scrollbar {
|
|
||||||
-ms-overflow-style: none; /* IE and Edge */
|
|
||||||
scrollbar-width: none; /* Firefox */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Custom scrollbar for modals & panels */
|
|
||||||
::-webkit-scrollbar {
|
|
||||||
width: 6px;
|
|
||||||
height: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-track {
|
|
||||||
background: #09090b;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
|
||||||
background: #27272a;
|
|
||||||
border-radius: 980px;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: #3f3f46;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Smooth drag cursor */
|
|
||||||
.cursor-grab {
|
|
||||||
cursor: grab;
|
|
||||||
}
|
|
||||||
.cursor-grabbing {
|
|
||||||
cursor: grabbing;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Shared native controls used inside focused admin dialogs. */
|
|
||||||
.input {
|
|
||||||
width: 100%;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.1);
|
|
||||||
border-radius: 0.75rem;
|
|
||||||
background: #18181b;
|
|
||||||
padding: 0.625rem 0.75rem;
|
|
||||||
color: #fff;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input::placeholder {
|
|
||||||
color: #71717a;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fadeInUp {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(12px);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.animate-fade-in-up {
|
|
||||||
animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
||||||
}
|
|
||||||
87
index.html
@@ -2,86 +2,19 @@
|
|||||||
<html lang="pt-BR">
|
<html lang="pt-BR">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||||
<title>Compor HUB | Cursos & Central de Materiais</title>
|
<title>Compor Academy</title>
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
|
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
|
||||||
<link rel="stylesheet" href="/index.css">
|
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
// Apply saved theme and sidebar state before the first paint.
|
||||||
theme: {
|
try {
|
||||||
extend: {
|
if (localStorage.getItem('ca-theme') === 'dark') document.documentElement.classList.add('dark');
|
||||||
fontFamily: {
|
if (localStorage.getItem('ca-side') === '1') document.documentElement.classList.add('collapsed');
|
||||||
sans: ['"Manrope"', 'system-ui', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', 'sans-serif'],
|
} catch (e) {}
|
||||||
display: ['"Manrope"', 'system-ui', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'sans-serif'],
|
|
||||||
heading: ['"Manrope"', 'system-ui', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'sans-serif'],
|
|
||||||
body: ['"Manrope"', 'system-ui', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'sans-serif'],
|
|
||||||
},
|
|
||||||
fontSize: {
|
|
||||||
'caption': ['12px', { lineHeight: '1.5', letterSpacing: '-0.01em' }],
|
|
||||||
'body-sm': ['14px', { lineHeight: '1.5', letterSpacing: '-0.01em' }],
|
|
||||||
'body': ['16px', { lineHeight: '1.6', letterSpacing: '-0.01em' }],
|
|
||||||
'subheading': ['20px', { lineHeight: '1.35', letterSpacing: '-0.02em' }],
|
|
||||||
'heading-sm': ['26px', { lineHeight: '1.3', letterSpacing: '-0.025em' }],
|
|
||||||
'heading': ['36px', { lineHeight: '1.25', letterSpacing: '-0.03em' }],
|
|
||||||
'heading-lg': ['44px', { lineHeight: '1.2', letterSpacing: '-0.03em' }],
|
|
||||||
'display': ['52px', { lineHeight: '1.15', letterSpacing: '-0.035em' }],
|
|
||||||
},
|
|
||||||
letterSpacing: {
|
|
||||||
'caption': '-0.01em',
|
|
||||||
'body-sm': '-0.01em',
|
|
||||||
'body': '-0.01em',
|
|
||||||
'subheading': '-0.02em',
|
|
||||||
'heading-sm': '-0.025em',
|
|
||||||
'heading': '-0.03em',
|
|
||||||
'heading-lg': '-0.03em',
|
|
||||||
'display': '-0.035em',
|
|
||||||
},
|
|
||||||
borderRadius: {
|
|
||||||
'tag': '980px',
|
|
||||||
'button': '980px',
|
|
||||||
'card': '8px',
|
|
||||||
'image': '8px',
|
|
||||||
'input': '8px',
|
|
||||||
'pill': '980px',
|
|
||||||
},
|
|
||||||
boxShadow: {
|
|
||||||
'xl': '0 10px 30px -5px rgba(0, 0, 0, 0.3)',
|
|
||||||
'glow': '0 0 35px -5px rgba(249, 115, 22, 0.25)',
|
|
||||||
},
|
|
||||||
maxWidth: {
|
|
||||||
'page': '1440px',
|
|
||||||
},
|
|
||||||
colors: {
|
|
||||||
gray: {
|
|
||||||
850: '#1f1f1f',
|
|
||||||
900: '#121212',
|
|
||||||
950: '#0a0a0a',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<script type="importmap">
|
</head>
|
||||||
{
|
|
||||||
"imports": {
|
|
||||||
"react": "https://esm.sh/react@18.2.0",
|
|
||||||
"react/": "https://esm.sh/react@18.2.0/",
|
|
||||||
"react-dom": "https://esm.sh/react-dom@18.2.0",
|
|
||||||
"react-dom/": "https://esm.sh/react-dom@18.2.0/",
|
|
||||||
"react-dom/client": "https://esm.sh/react-dom@18.2.0/client",
|
|
||||||
"react-router-dom": "https://esm.sh/react-router-dom@6.22.3?external=react,react-dom",
|
|
||||||
"lucide-react": "https://esm.sh/lucide-react@0.344.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/index.tsx"></script>
|
<script type="module" src="/index.tsx"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import '@fontsource-variable/inter/opsz.css';
|
||||||
|
import '@fontsource/mrs-saint-delafield/400.css';
|
||||||
|
import './styles/tokens.css';
|
||||||
|
import './styles/legacy.css';
|
||||||
|
import './styles/app.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
|
||||||
// Covers uploaded to Bunny Storage are normally served directly by its CDN.
|
// Covers uploaded to Bunny Storage are normally served directly by its CDN.
|
||||||
|
|||||||
139
lib/demoCatalog.ts
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
import type { Attachment, Comment, Course } from '../types';
|
||||||
|
import type { InstructorProfileData, PublicLearningPath } from '../services/db';
|
||||||
|
|
||||||
|
// The content and ordering in design/prototype-reference.html. It is shown only
|
||||||
|
// when the API has no published catalogue, so a real catalogue always wins.
|
||||||
|
export const demoAreas = ['Mídia paga', 'Conversão', 'Operação'];
|
||||||
|
export const demoFeaturedCourseIds = ['escala', 'ga4', 'landing', 'automacao', 'tiktok'];
|
||||||
|
export const demoProfessorIds = ['mario', 'ana', 'lucas', 'julia', 'rafael', 'camila', 'diego', 'helena', 'bruno'];
|
||||||
|
|
||||||
|
const teachers = {
|
||||||
|
mario: { name: 'Mário Morgado', headline: 'Performance e growth', bio: 'Cuida de mídia paga para e-commerce e infoprodutos desde 2015.' },
|
||||||
|
ana: { name: 'Ana Ribeiro', headline: 'Google Ads', bio: 'Especialista em Google Ads para varejo online.' },
|
||||||
|
lucas: { name: 'Lucas Prado', headline: 'Copy e criativos', bio: 'Escreve anúncios e roteiros de vídeo curto para marcas de consumo.' },
|
||||||
|
julia: { name: 'Júlia Castro', headline: 'Automação e CRM', bio: 'Implanta CRM e automações em agências pequenas e médias.' },
|
||||||
|
rafael: { name: 'Rafael Lima', headline: 'Gestão de agência', bio: 'Sócio de agência, cuida de processos e precificação.' },
|
||||||
|
camila: { name: 'Camila Torres', headline: 'Social e conteúdo', bio: 'Lidera conteúdo orgânico e creators para marcas de moda e beleza.' },
|
||||||
|
diego: { name: 'Diego Martins', headline: 'Dados e mensuração', bio: 'Monta rastreamento, GA4 e dashboards para times de marketing.' },
|
||||||
|
helena: { name: 'Helena Duarte', headline: 'E-mail e CRM', bio: 'Cuida de réguas de e-mail e WhatsApp para e-commerce.' },
|
||||||
|
bruno: { name: 'Bruno Saraiva', headline: 'Vendas B2B', bio: 'Estrutura prospecção e funil comercial para agências e SaaS.' },
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
type TeacherId = keyof typeof teachers;
|
||||||
|
type AreaId = 'midia' | 'conv' | 'oper';
|
||||||
|
const areaName: Record<AreaId, string> = { midia: 'Mídia paga', conv: 'Conversão', oper: 'Operação' };
|
||||||
|
type Row = [id: string, title: string, area: AreaId, teacher: TeacherId, count: number, duration: string, views: number, description?: string];
|
||||||
|
const rows: Row[] = [
|
||||||
|
['escala', 'Escala de tráfego pago', 'midia', 'mario', 6, '3h 45min', 412, 'Estrutura de conta, criativos e orçamento para escalar Meta Ads e Google Ads sem perder o controle do CAC.'],
|
||||||
|
['pmax', 'Performance Max para e-commerce', 'midia', 'ana', 8, '2h 50min', 268],
|
||||||
|
['pesquisa', 'Pesquisa no Google', 'midia', 'ana', 5, '1h 35min', 301],
|
||||||
|
['criativos', 'Criativos que retêm', 'conv', 'lucas', 5, '1h 40min', 355],
|
||||||
|
['copy', 'Copy para anúncios', 'conv', 'lucas', 6, '1h 55min', 96],
|
||||||
|
['funis', 'Funis com CAC controlado', 'conv', 'mario', 7, '2h 20min', 240],
|
||||||
|
['processos', 'Processos da operação', 'oper', 'rafael', 4, '1h 30min', 122],
|
||||||
|
['crm', 'CRM e automação para agências', 'oper', 'julia', 6, '2h 10min', 187],
|
||||||
|
['preco', 'Precificação de serviços', 'oper', 'rafael', 4, '1h 15min', 58],
|
||||||
|
['tiktok', 'TikTok Ads do zero', 'midia', 'camila', 7, '2h 05min', 288],
|
||||||
|
['youtube', 'YouTube Ads para conversão', 'midia', 'ana', 6, '1h 50min', 174],
|
||||||
|
['remarketing', 'Remarketing que não irrita', 'midia', 'mario', 5, '1h 20min', 203],
|
||||||
|
['linkedin', 'LinkedIn Ads para B2B', 'midia', 'bruno', 5, '1h 30min', 97],
|
||||||
|
['orcamento', 'Orçamento de mídia mês a mês', 'midia', 'mario', 4, '1h 05min', 150],
|
||||||
|
['ga4', 'GA4 para quem anuncia', 'midia', 'diego', 8, '2h 40min', 331],
|
||||||
|
['pixel', 'Pixel, API de Conversões e eventos', 'midia', 'diego', 6, '1h 45min', 262],
|
||||||
|
['landing', 'Landing pages que convertem', 'conv', 'lucas', 7, '2h 15min', 309],
|
||||||
|
['oferta', 'Como montar uma oferta', 'conv', 'mario', 5, '1h 35min', 276],
|
||||||
|
['roteiros', 'Roteiros para vídeo curto', 'conv', 'camila', 6, '1h 40min', 241],
|
||||||
|
['email', 'Réguas de e-mail para e-commerce', 'conv', 'helena', 7, '2h 00min', 158],
|
||||||
|
['whatsapp', 'Vendas pelo WhatsApp', 'conv', 'helena', 5, '1h 25min', 219],
|
||||||
|
['testes', 'Testes A/B sem achismo', 'conv', 'diego', 4, '1h 10min', 88],
|
||||||
|
['creators', 'Trabalhando com creators', 'conv', 'camila', 5, '1h 30min', 132],
|
||||||
|
['dashboards', 'Dashboards para clientes', 'oper', 'diego', 6, '1h 55min', 194],
|
||||||
|
['onboarding', 'Onboarding de clientes', 'oper', 'rafael', 4, '1h 00min', 111],
|
||||||
|
['prospeccao', 'Prospecção para agências', 'oper', 'bruno', 6, '1h 50min', 167],
|
||||||
|
['contratos', 'Contratos e escopo', 'oper', 'rafael', 3, '50min', 74],
|
||||||
|
['automacao', 'Automação com n8n', 'oper', 'julia', 7, '2h 30min', 236],
|
||||||
|
['relatorios', 'Relatórios semanais em 20 minutos', 'oper', 'julia', 4, '55min', 102],
|
||||||
|
];
|
||||||
|
|
||||||
|
const lessonNames = ['Introdução e objetivos', 'Diagnóstico da conta', 'Montando a estrutura', 'Execução passo a passo', 'Medindo resultado', 'Erros comuns', 'Plano de ação', 'Revisão final'];
|
||||||
|
const lessonMinutes = [12, 24, 31, 27, 22, 18, 26, 15];
|
||||||
|
const escalaLessons: Array<[string, number]> = [
|
||||||
|
['Arquitetura de conta para escala', 22], ['Laboratório de criativos', 35],
|
||||||
|
['Performance Max no e-commerce', 41], ['Orçamento, CAC e ponto de equilíbrio', 38],
|
||||||
|
['Leitura de métricas', 44], ['Plano de escala de 90 dias', 45],
|
||||||
|
];
|
||||||
|
|
||||||
|
type FileRow = [name: string, type: Attachment['type'], size: string, courseId: string, lessonNumber: number];
|
||||||
|
const fileRows: FileRow[] = [
|
||||||
|
['Calculadora de ROAS e CAC', 'spreadsheet', '1,4 MB', 'escala', 1],
|
||||||
|
['Guia de estrutura de contas', 'pdf', '3,8 MB', 'escala', 1],
|
||||||
|
['Templates de criativos', 'zip', '48,2 MB', 'escala', 2],
|
||||||
|
['Checklist de auditoria de criativos', 'pdf', '890 KB', 'criativos', 2],
|
||||||
|
['Roteiros de vídeo curto', 'doc', '220 KB', 'criativos', 3],
|
||||||
|
['Planilha de funil e CAC', 'spreadsheet', '640 KB', 'funis', 1],
|
||||||
|
['Modelo de pipeline no CRM', 'pdf', '1,1 MB', 'crm', 2],
|
||||||
|
['Tabela de precificação', 'spreadsheet', '380 KB', 'preco', 1],
|
||||||
|
];
|
||||||
|
|
||||||
|
export const demoCourses: Course[] = rows.map(([id, title, area, teacher, count, duration, views, description]) => ({
|
||||||
|
id, title, category: areaName[area], thumbnail: '/course-placeholder.svg', duration, views,
|
||||||
|
description: description || 'Curso prático, com exemplos de contas reais e materiais para aplicar na sua operação.',
|
||||||
|
instructor: teachers[teacher].name, instructorId: teacher, instructorRole: teachers[teacher].headline,
|
||||||
|
status: 'published',
|
||||||
|
lessons: Array.from({ length: count }, (_, index) => {
|
||||||
|
const [lessonTitle, minutes] = id === 'escala' ? escalaLessons[index] : [lessonNames[index % lessonNames.length], lessonMinutes[index % lessonMinutes.length]] as [string, number];
|
||||||
|
return { id: `${id}-aula-${index + 1}`, title: lessonTitle, duration: `${minutes} min`, videoUrl: '', isFree: index < 2, description: '', attachments: [] };
|
||||||
|
}),
|
||||||
|
attachments: [],
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (const [index, [name, type, size, courseId, lessonNumber]] of fileRows.entries()) {
|
||||||
|
const course = demoCourses.find((item) => item.id === courseId);
|
||||||
|
const lesson = course?.lessons[lessonNumber - 1];
|
||||||
|
if (lesson) lesson.attachments?.push({ id: `demo-file-${index + 1}`, name, type, size, url: '#', lessonId: lesson.id });
|
||||||
|
}
|
||||||
|
|
||||||
|
type PathRow = [id: string, title: string, area: AreaId, courseIds: string[], description: string];
|
||||||
|
const pathRows: PathRow[] = [
|
||||||
|
['gestor', 'Gestor de tráfego', 'midia', ['escala', 'pmax', 'pesquisa'], 'Do primeiro anúncio à conta que escala.'],
|
||||||
|
['oferta', 'Oferta, copy e funil', 'conv', ['criativos', 'copy', 'funis'], 'Como o anúncio vira venda.'],
|
||||||
|
['agencia', 'Agência que escala', 'oper', ['processos', 'crm', 'preco'], 'A operação por trás das contas.'],
|
||||||
|
['mensuracao', 'Mensuração de ponta a ponta', 'midia', ['pixel', 'ga4', 'dashboards'], 'Do evento no site ao relatório.'],
|
||||||
|
['social', 'Social e vídeo curto', 'conv', ['tiktok', 'roteiros', 'creators'], 'Conteúdo que vira anúncio.'],
|
||||||
|
['retencao', 'Venda e recompra', 'conv', ['oferta', 'email', 'whatsapp'], 'Depois do clique, até a segunda compra.'],
|
||||||
|
['google', 'Google Ads completo', 'midia', ['pesquisa', 'pmax', 'youtube'], 'Pesquisa, Performance Max e YouTube.'],
|
||||||
|
['comercial', 'Comercial da agência', 'oper', ['prospeccao', 'contratos', 'onboarding'], 'Do primeiro contato ao cliente rodando.'],
|
||||||
|
];
|
||||||
|
|
||||||
|
export const demoPaths: PublicLearningPath[] = pathRows.map(([id, title, , courseIds, description]) => ({
|
||||||
|
id, title, description, coverImageUrl: null, coverImageZoom: 1, coverImagePositionX: 50, coverImagePositionY: 50,
|
||||||
|
courses: courseIds.map((courseId, index) => {
|
||||||
|
const course = demoCourses.find((item) => item.id === courseId)!;
|
||||||
|
return { id: course.id, title: course.title, category: course.category, coverImageUrl: null, position: index + 1 };
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const demoProfessor = (id: string): InstructorProfileData | null => {
|
||||||
|
const teacher = teachers[id as TeacherId];
|
||||||
|
if (!teacher) return null;
|
||||||
|
return { id, name: teacher.name, role: 'instructor', avatarImageUrl: null, headline: teacher.headline, bio: teacher.bio,
|
||||||
|
websiteUrl: null, linkedinUrl: null, instagramUrl: null, youtubeUrl: null,
|
||||||
|
courses: demoCourses.filter((course) => course.instructorId === id) };
|
||||||
|
};
|
||||||
|
|
||||||
|
type DiscussionRow = [user: string, courseId: string, lessonNumber: number, text: string, date: string, answered: boolean];
|
||||||
|
const discussionRows: DiscussionRow[] = [
|
||||||
|
['Thiago Mendes', 'criativos', 2, 'Qual hook rate vocês usam como corte para pausar um criativo?', 'há 5 h', true],
|
||||||
|
['Bruna Souza', 'escala', 1, 'Separar campanha de teste por público ou por criativo?', 'há 7 h', true],
|
||||||
|
['Lara Nunes', 'ga4', 3, 'O evento de compra aparece duplicado no GA4. Onde começo a investigar?', 'há 9 h', false],
|
||||||
|
['Pedro Alves', 'automacao', 4, 'Alguém tem um fluxo no n8n para mandar o relatório semanal por WhatsApp?', 'ontem', false],
|
||||||
|
['Marina Rocha', 'landing', 2, 'Formulário longo ou curto para lead B2B? Testei os dois e o curto ganhou.', 'ontem', true],
|
||||||
|
['Gustavo Reis', 'preco', 1, 'Vocês cobram fee fixo ou percentual sobre a verba de mídia?', '2 nov', false],
|
||||||
|
['Aline Prado', 'tiktok', 5, 'Spark Ads com creator pequeno vale a pena para começar?', '1 nov', true],
|
||||||
|
];
|
||||||
|
|
||||||
|
export const demoThreads: Array<{ comment: Comment; course: Course }> = discussionRows.map(([user, courseId, lessonNumber, text, date, answered], index) => {
|
||||||
|
const course = demoCourses.find((item) => item.id === courseId)!;
|
||||||
|
return { course, comment: { id: `demo-comment-${index + 1}`, courseId, lessonId: course.lessons[lessonNumber - 1]?.id, user, text, date,
|
||||||
|
reply: answered ? 'Resposta do professor' : undefined } };
|
||||||
|
});
|
||||||
14
lib/downloads.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { Attachment } from '../types';
|
||||||
|
|
||||||
|
export type DownloadEntry = { attachment: Attachment; courseId: string; courseTitle: string; downloadedAt: string };
|
||||||
|
const keyFor = (userId: string) => `ca-downloads:${userId}`;
|
||||||
|
export const readDownloads = (userId?: string): DownloadEntry[] => {
|
||||||
|
if (!userId) return [];
|
||||||
|
try { const value = JSON.parse(localStorage.getItem(keyFor(userId)) || '[]'); return Array.isArray(value) ? value : []; }
|
||||||
|
catch { return []; }
|
||||||
|
};
|
||||||
|
export const recordDownload = (userId: string, attachment: Attachment, courseId: string, courseTitle: string) => {
|
||||||
|
const entry: DownloadEntry = { attachment, courseId, courseTitle, downloadedAt: new Date().toISOString() };
|
||||||
|
const next = [entry, ...readDownloads(userId).filter((item) => item.attachment.id !== attachment.id)].slice(0, 100);
|
||||||
|
try { localStorage.setItem(keyFor(userId), JSON.stringify(next)); window.dispatchEvent(new Event('ca-downloads')); } catch { /* A completed download does not depend on local history. */ }
|
||||||
|
};
|
||||||
50
lib/format.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { Course, Lesson } from '../types';
|
||||||
|
|
||||||
|
export const initials = (name: string) => name
|
||||||
|
.split(/\s+/)
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((word) => word[0])
|
||||||
|
.slice(0, 2)
|
||||||
|
.join('')
|
||||||
|
.toUpperCase();
|
||||||
|
|
||||||
|
export const plural = (count: number, one: string, many: string) => `${count} ${count === 1 ? one : many}`;
|
||||||
|
|
||||||
|
export const lessonCount = (course: Course) => plural(course.lessons.length, 'aula', 'aulas');
|
||||||
|
|
||||||
|
/** "6 aulas · 3h 45min", omitting the duration while videos are still processing. */
|
||||||
|
export const courseMeta = (course: Course) => {
|
||||||
|
const parts = [lessonCount(course)];
|
||||||
|
if (course.duration && course.duration !== '—' && course.duration !== 'Processando') parts.push(course.duration);
|
||||||
|
return parts.join(' · ');
|
||||||
|
};
|
||||||
|
|
||||||
|
export const lessonDuration = (lesson: Lesson) => (lesson.duration && lesson.duration !== '—' ? lesson.duration : '');
|
||||||
|
|
||||||
|
const parseMinutes = (duration: string) => {
|
||||||
|
const hours = Number(/(\d+)h/.exec(duration)?.[1] || 0);
|
||||||
|
const minutes = Number(/(\d+)\s*min/.exec(duration)?.[1] || 0);
|
||||||
|
return hours * 60 + minutes;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const formatMinutes = (total: number) => {
|
||||||
|
const hours = Math.floor(total / 60);
|
||||||
|
const rest = total % 60;
|
||||||
|
if (!hours) return `${rest}min`;
|
||||||
|
return rest ? `${hours}h ${String(rest).padStart(2, '0')}min` : `${hours}h`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const totalDuration = (courses: Course[]) => {
|
||||||
|
const minutes = courses.reduce((sum, course) => sum + parseMinutes(course.duration || ''), 0);
|
||||||
|
return minutes ? formatMinutes(minutes) : '';
|
||||||
|
};
|
||||||
|
|
||||||
|
export const shortDate = (value?: string | null) => {
|
||||||
|
if (!value) return '';
|
||||||
|
const date = new Date(value);
|
||||||
|
if (Number.isNaN(date.getTime())) return '';
|
||||||
|
const months = ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'];
|
||||||
|
return `${date.getDate()} ${months[date.getMonth()]}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const hasRealCover = (source?: string | null) => Boolean(source && !source.endsWith('/course-placeholder.svg'));
|
||||||
19
lib/navigation.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/** Which top-level destination a pathname belongs to (highlights the sidebar and tab bar). */
|
||||||
|
export type NavKey =
|
||||||
|
| 'search' | 'explore' | 'trails' | 'learning' | 'community' | 'professors'
|
||||||
|
| 'library' | 'downloads' | 'manage' | 'admin' | 'you' | 'none';
|
||||||
|
|
||||||
|
export const navKeyFor = (pathname: string): NavKey => {
|
||||||
|
if (pathname === '/' || pathname.startsWith('/cursos')) return 'explore';
|
||||||
|
if (pathname.startsWith('/buscar')) return 'search';
|
||||||
|
if (pathname.startsWith('/trilhas')) return 'trails';
|
||||||
|
if (pathname.startsWith('/meu-aprendizado')) return 'learning';
|
||||||
|
if (pathname.startsWith('/comunidade')) return 'community';
|
||||||
|
if (pathname.startsWith('/professores') || pathname.startsWith('/instrutores') || pathname.startsWith('/perfis')) return 'professors';
|
||||||
|
if (pathname.startsWith('/materiais')) return 'library';
|
||||||
|
if (pathname.startsWith('/downloads')) return 'downloads';
|
||||||
|
if (pathname.startsWith('/gerenciar')) return 'manage';
|
||||||
|
if (pathname.startsWith('/admin')) return 'admin';
|
||||||
|
if (pathname.startsWith('/voce') || pathname.startsWith('/perfil')) return 'you';
|
||||||
|
return 'none';
|
||||||
|
};
|
||||||
24
lib/routes.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
export const paths = {
|
||||||
|
explore: '/',
|
||||||
|
search: '/buscar',
|
||||||
|
trails: '/trilhas',
|
||||||
|
trail: (trailId: string) => `/trilhas/${trailId}`,
|
||||||
|
course: (courseId: string) => `/cursos/${courseId}`,
|
||||||
|
lesson: (courseId: string, lessonId: string) => `/cursos/${courseId}/aulas/${lessonId}`,
|
||||||
|
continueCourse: (courseId: string) => `/cursos/${courseId}/continuar`,
|
||||||
|
learning: '/meu-aprendizado',
|
||||||
|
community: '/comunidade',
|
||||||
|
professors: '/professores',
|
||||||
|
professor: (instructorId: string) => `/instrutores/${instructorId}`,
|
||||||
|
library: '/materiais',
|
||||||
|
downloads: '/downloads',
|
||||||
|
account: '/perfil',
|
||||||
|
you: '/voce',
|
||||||
|
manage: '/gerenciar',
|
||||||
|
editCourse: (courseId: string) => `/gerenciar/${courseId}`,
|
||||||
|
newCourse: '/gerenciar/novo',
|
||||||
|
admin: '/admin',
|
||||||
|
adminTrail: (trailId: string) => `/admin/trilhas/${trailId}`,
|
||||||
|
signIn: '/entrar',
|
||||||
|
signUp: '/criar-conta',
|
||||||
|
};
|
||||||
17
lib/storage.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// Per-viewer UI preferences (theme, sidebar). Storage can be unavailable in
|
||||||
|
// private windows, so every access is guarded and falls back to the default.
|
||||||
|
export const readPreference = (key: string): string | null => {
|
||||||
|
try {
|
||||||
|
return window.localStorage.getItem(key);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const writePreference = (key: string, value: string) => {
|
||||||
|
try {
|
||||||
|
window.localStorage.setItem(key, value);
|
||||||
|
} catch {
|
||||||
|
// Preference simply isn't remembered.
|
||||||
|
}
|
||||||
|
};
|
||||||
1009
package-lock.json
generated
@@ -19,10 +19,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/cors": "^11.0.0",
|
"@fastify/cors": "^11.0.0",
|
||||||
"@fastify/jwt": "^9.1.0",
|
"@fastify/jwt": "^9.1.0",
|
||||||
|
"@fontsource-variable/inter": "^5.3.0",
|
||||||
|
"@fontsource/mrs-saint-delafield": "^5.3.0",
|
||||||
|
"@phosphor-icons/react": "^2.1.10",
|
||||||
"dotenv": "^16.6.1",
|
"dotenv": "^16.6.1",
|
||||||
"fastify": "^5.3.2",
|
"fastify": "^5.3.2",
|
||||||
"fastify-plugin": "^5.0.1",
|
"fastify-plugin": "^5.0.1",
|
||||||
"lucide-react": "0.344.0",
|
|
||||||
"nodemailer": "^10.0.1",
|
"nodemailer": "^10.0.1",
|
||||||
"pg": "^8.16.3",
|
"pg": "^8.16.3",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
@@ -35,6 +37,9 @@
|
|||||||
"@types/nodemailer": "^8.0.1",
|
"@types/nodemailer": "^8.0.1",
|
||||||
"@types/pg": "^8.15.4",
|
"@types/pg": "^8.15.4",
|
||||||
"@vitejs/plugin-react": "^5.0.0",
|
"@vitejs/plugin-react": "^5.0.0",
|
||||||
|
"autoprefixer": "^10.6.2",
|
||||||
|
"postcss": "^8.5.32",
|
||||||
|
"tailwindcss": "^3.4.17",
|
||||||
"tsx": "^4.19.4",
|
"tsx": "^4.19.4",
|
||||||
"typescript": "~5.8.2",
|
"typescript": "~5.8.2",
|
||||||
"vite": "^6.2.0"
|
"vite": "^6.2.0"
|
||||||
|
|||||||
@@ -23,5 +23,5 @@ export const AccessTokenPage: React.FC<{ mode: 'invite' | 'reset' }> = ({ mode }
|
|||||||
} catch { setError('Este link é inválido, expirou ou não pôde ser usado.'); }
|
} catch { setError('Este link é inválido, expirou ou não pôde ser usado.'); }
|
||||||
finally { setSaving(false); }
|
finally { setSaving(false); }
|
||||||
};
|
};
|
||||||
return <main className="min-h-screen pt-32 px-6 flex justify-center"><form noValidate onSubmit={submit} className="w-full max-w-md rounded-2xl border border-white/10 bg-zinc-950 p-7 space-y-4"><h1 className="text-2xl font-bold">{mode === 'invite' ? 'Criar seu acesso' : 'Redefinir senha'}</h1>{mode === 'invite' && <input value={name} onChange={(event) => setName(event.target.value)} placeholder="Seu nome" className="w-full rounded-xl bg-zinc-900 p-3" />}<input type="password" value={password} onChange={(event) => setPassword(event.target.value)} placeholder="Nova senha (mínimo 8 caracteres)" className="w-full rounded-xl bg-zinc-900 p-3" />{error && <p className="text-sm text-red-400">{error}</p>}<button disabled={!token || saving} className="w-full rounded-xl bg-orange-500 p-3 font-semibold">{saving ? 'Salvando...' : mode === 'invite' ? 'Criar conta' : 'Redefinir senha'}</button></form></main>;
|
return <main className="wrap page enter"><div className="auth"><h1>{mode === 'invite' ? 'Criar seu acesso' : 'Redefinir senha'}</h1><p>{mode === 'invite' ? 'Defina seu nome e uma senha para começar.' : 'Escolha uma nova senha para sua conta.'}</p><form noValidate onSubmit={submit}>{mode === 'invite' && <div className="field"><label htmlFor="access-name">Nome</label><input id="access-name" value={name} onChange={(event) => setName(event.target.value)} autoComplete="name" required /></div>}<div className="field"><label htmlFor="access-password">Nova senha</label><input id="access-password" type="password" value={password} onChange={(event) => setPassword(event.target.value)} autoComplete="new-password" required /><small>Pelo menos 8 caracteres.</small></div>{error && <p className="formmsg bad" role="alert">{error}</p>}<button type="submit" disabled={!token || saving} className="btn">{saving ? 'Salvando…' : mode === 'invite' ? 'Criar conta' : 'Redefinir senha'}</button></form></div></main>;
|
||||||
};
|
};
|
||||||
|
|||||||
82
pages/AuthPage.tsx
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Link, Navigate, useLocation, useNavigate } from 'react-router-dom';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { UserRole } from '../types';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
|
||||||
|
export const homeFor = (role: UserRole) => (role === 'superadmin' ? paths.admin : role === 'professor' ? paths.manage : paths.explore);
|
||||||
|
|
||||||
|
interface AuthPageProps {
|
||||||
|
mode: 'signin' | 'signup';
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AuthPage: React.FC<AuthPageProps> = ({ mode }) => {
|
||||||
|
const isRegistering = mode === 'signup';
|
||||||
|
const { user, login, register } = useAuth();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
const lead = (location.state as { message?: string } | null)?.message;
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
|
const [password, setPassword] = useState('');
|
||||||
|
const [name, setName] = useState('');
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
if (user && !isSubmitting) return <Navigate to={homeFor(user.role)} replace />;
|
||||||
|
|
||||||
|
const handleSubmit = async (event: React.FormEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
setError('');
|
||||||
|
if (!email.trim() || !/^\S+@\S+\.\S+$/.test(email)) {
|
||||||
|
setError('Informe um e-mail válido.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isRegistering && name.trim().length < 2) {
|
||||||
|
setError('Informe seu nome.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (password.length < 8) {
|
||||||
|
setError('A senha deve ter pelo menos 8 caracteres.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setIsSubmitting(true);
|
||||||
|
const signedInUser = isRegistering ? await register(name, email, password) : await login(email, password);
|
||||||
|
|
||||||
|
if (!signedInUser) {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
setError(isRegistering
|
||||||
|
? 'Não foi possível criar sua conta. Use um e-mail válido e uma senha com pelo menos 8 caracteres.'
|
||||||
|
: 'Credenciais inválidas. Verifique seu e-mail e senha.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
navigate(homeFor(signedInUser.role), { replace: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="wrap page auth-page enter">
|
||||||
|
<div className="auth">
|
||||||
|
<h1>{isRegistering ? 'Criar conta' : 'Entrar'}</h1>
|
||||||
|
<p>{lead || (isRegistering ? 'Gratuita. Dá acesso a todos os cursos e materiais.' : 'Use o e-mail da sua conta Compor.')}</p>
|
||||||
|
<form noValidate onSubmit={handleSubmit}>
|
||||||
|
{isRegistering && (
|
||||||
|
<div className="field"><label htmlFor="auth-name">Nome</label><input id="auth-name" value={name} onChange={(event) => setName(event.target.value)} autoComplete="name" required /></div>
|
||||||
|
)}
|
||||||
|
<div className="field"><label htmlFor="auth-email">E-mail</label><input id="auth-email" type="email" value={email} onChange={(event) => setEmail(event.target.value)} autoComplete="email" autoCapitalize="none" required /></div>
|
||||||
|
<div className="field">
|
||||||
|
<label htmlFor="auth-password">Senha</label>
|
||||||
|
<input id="auth-password" type="password" value={password} onChange={(event) => setPassword(event.target.value)} autoComplete={isRegistering ? 'new-password' : 'current-password'} required />
|
||||||
|
{isRegistering && <small>Pelo menos 8 caracteres.</small>}
|
||||||
|
</div>
|
||||||
|
{error && <p className="formmsg bad" role="alert">{error}</p>}
|
||||||
|
<button className="btn" type="submit" disabled={isSubmitting}>{isSubmitting ? 'Aguarde…' : isRegistering ? 'Criar conta' : 'Entrar'}</button>
|
||||||
|
</form>
|
||||||
|
<p className="alt">
|
||||||
|
{isRegistering
|
||||||
|
? <>Já tem conta? <Link className="link" to={paths.signIn}>Entrar</Link></>
|
||||||
|
: <>Não tem conta? <Link className="link" to={paths.signUp}>Criar conta</Link></>}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
};
|
||||||
61
pages/CommunityPage.tsx
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
|
import { CaretRightIcon, PlusIcon } from '@phosphor-icons/react';
|
||||||
|
import { Comment, Course } from '../types';
|
||||||
|
import { getCommunityComments } from '../services/db';
|
||||||
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { Avatar } from '../components/ui/Avatar';
|
||||||
|
import { ChatMockIcon, PlusMockIcon, TeacherMockIcon } from '../components/ui/MockupIcons';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
|
||||||
|
type Thread = { comment: Comment; course: Course };
|
||||||
|
|
||||||
|
const lessonNumberFor = (comment: Comment, course: Course) => {
|
||||||
|
if (!comment.lessonId) return 0;
|
||||||
|
return course.lessons.findIndex((lesson) => lesson.id === comment.lessonId) + 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CommunityPage: React.FC = () => {
|
||||||
|
const { courses, professors } = useCatalog();
|
||||||
|
const { user } = useAuth();
|
||||||
|
const location = useLocation();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
const [threads, setThreads] = useState<Thread[]>([]);
|
||||||
|
const [view, setView] = useState<'discussoes' | 'professores'>(() => new URLSearchParams(location.search).get('tab') === 'professores' ? 'professores' : 'discussoes');
|
||||||
|
const [filter, setFilter] = useState<'todas' | 'abertas' | 'professor'>('todas');
|
||||||
|
useEffect(() => {
|
||||||
|
const courseById = new Map(courses.map((course) => [course.id, course]));
|
||||||
|
let cancelled = false;
|
||||||
|
getCommunityComments(100).then((comments) => {
|
||||||
|
if (cancelled) return;
|
||||||
|
setThreads(comments.flatMap((comment) => {
|
||||||
|
const course = courseById.get(comment.courseId);
|
||||||
|
return course ? [{ comment, course }] : [];
|
||||||
|
}));
|
||||||
|
}).catch(() => { if (!cancelled) setThreads([]); });
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, [courses]);
|
||||||
|
useEffect(() => { if (new URLSearchParams(location.search).get('tab') === 'professores') setView('professores'); }, [location.search]);
|
||||||
|
const visible = threads.filter(({ comment }) => filter === 'todas' || (filter === 'abertas' ? !comment.reply : Boolean(comment.reply)));
|
||||||
|
if (isMobile) return <main className="m-page m-gut enter"><header className="m-large"><h1>Comunidade</h1>{user && view === 'discussoes' && <Link className="m-icb" to={courses[0] ? paths.course(courses[0].id) : paths.explore} aria-label="Nova pergunta"><PlusIcon className="ph" /></Link>}</header>
|
||||||
|
<div className="m-seg" role="tablist"><button type="button" role="tab" aria-selected={view === 'discussoes'} onClick={() => setView('discussoes')}>Discussões</button><button type="button" role="tab" aria-selected={view === 'professores'} onClick={() => setView('professores')}>Professores</button></div>
|
||||||
|
{view === 'professores' ? <section className="m-group"><div className="m-list">{professors.map((professor) => <Link className="m-row" key={professor.id} to={paths.professor(professor.id)}><Avatar name={professor.name} src={professor.avatarImageUrl} size="sm" /><span className="m-rt"><b>{professor.name}</b><small>{professor.headline ? `${professor.headline} · ` : ''}{professor.courses.length} {professor.courses.length === 1 ? 'curso' : 'cursos'}</small></span><CaretRightIcon className="m-chev" /></Link>)}</div></section> : <><div className="m-chips" role="group" aria-label="Filtrar discussões">{[['todas', 'Todas'], ['abertas', 'Sem resposta'], ['professor', 'Com professor']].map(([key, label]) => <button key={key} type="button" aria-pressed={filter === key} onClick={() => setFilter(key as typeof filter)}>{label}</button>)}</div><section className="m-group"><div className="m-list multi">{visible.map(({ comment, course }) => <Link className="m-row" key={comment.id} to={comment.lessonId ? paths.lesson(course.id, comment.lessonId) : paths.course(course.id)}><Avatar name={comment.user} size="sm" /><span className="m-rt"><b>{comment.text}</b><small>{comment.user} · {course.title} · {comment.date}</small></span>{comment.reply && <span className="m-chev" aria-label="Professor respondeu"><TeacherMockIcon className="ph" /></span>}</Link>)}</div>{!visible.length && <p className="m-empty">Nenhuma discussão por aqui ainda.</p>}</section></>}
|
||||||
|
</main>;
|
||||||
|
return <main className="wrap page enter">
|
||||||
|
<header className="ptitle"><div><h1>Discussões</h1><p>Perguntas e resultados dos alunos, organizados por aula.</p></div>{user ? <Link className="btn" to={courses[0] ? paths.course(courses[0].id) : paths.explore}><PlusMockIcon className="ph" /> Nova pergunta</Link> : <Link className="btn sec" to={paths.signIn}>Entrar para participar</Link>}</header>
|
||||||
|
<div className="seg" role="group" aria-label="Filtrar discussões" style={{ marginBottom: 20 }}>
|
||||||
|
{([['todas', 'Todas'], ['abertas', 'Sem resposta'], ['professor', 'Respondidas por professor']] as const).map(([key, label]) => <button key={key} type="button" aria-pressed={filter === key} onClick={() => setFilter(key)}>{label}</button>)}
|
||||||
|
</div>
|
||||||
|
<div className="list">{visible.map(({ comment, course }) => {
|
||||||
|
const lessonNumber = lessonNumberFor(comment, course);
|
||||||
|
return <Link className="row discussion-row" key={comment.id} to={comment.lessonId ? paths.lesson(course.id, comment.lessonId) : paths.course(course.id)}>
|
||||||
|
<Avatar name={comment.user} size="sm" />
|
||||||
|
<span className="t">{comment.text}<small>{[comment.user, `${course.title}${lessonNumber ? `, aula ${lessonNumber}` : ''}`, comment.date].join(' · ')}</small></span>
|
||||||
|
<span className="r">{comment.reply && <span className="ic-prof" title="Professor respondeu" aria-label="Professor respondeu"><TeacherMockIcon className="ph" /></span>}<span className="ic-cnt" aria-label={`${comment.reply ? 1 : 0} respostas`}><ChatMockIcon className="ph" /> {comment.reply ? 1 : 0}</span></span>
|
||||||
|
</Link>;
|
||||||
|
})}</div>
|
||||||
|
{!visible.length && <p className="empty">Nenhuma discussão por aqui ainda.</p>}
|
||||||
|
</main>;
|
||||||
|
};
|
||||||
161
pages/CoursePage.tsx
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Link, Navigate, useParams } from 'react-router-dom';
|
||||||
|
import { BookmarkSimpleIcon, CaretRightIcon, CheckIcon, CircleNotchIcon, PlayIcon } from '@phosphor-icons/react';
|
||||||
|
import { Attachment, Course } from '../types';
|
||||||
|
import { useCourse, useLessonProgress } from '../hooks/useCourse';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
import { ArtImage, Cover, courseFraming, useCoverImage } from '../components/catalog/Artwork';
|
||||||
|
import { MaterialRow, useMaterialAction } from '../components/course/Materials';
|
||||||
|
import { Avatar } from '../components/ui/Avatar';
|
||||||
|
import { courseMeta, lessonDuration, plural } from '../lib/format';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
import { useSavedCourses } from '../hooks/useSavedCourses';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
import { MaterialButton, attachmentIcon } from '../components/course/Materials';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
export type CourseMaterial = { attachment: Attachment; detail: string; lessonIndex?: number };
|
||||||
|
|
||||||
|
export const courseMaterials = (course: Course): CourseMaterial[] => [
|
||||||
|
...(course.attachments || []).map((attachment) => ({ attachment, detail: 'Material do curso' })),
|
||||||
|
...course.lessons.flatMap((lesson, index) => (lesson.attachments || []).map((attachment) => ({ attachment, detail: `Aula ${index + 1}`, lessonIndex: index }))),
|
||||||
|
];
|
||||||
|
|
||||||
|
export const signUpState = { message: 'Crie uma conta gratuita para assistir a esta aula.' };
|
||||||
|
|
||||||
|
const PlayerPreview: React.FC<{ course: Course; to: string }> = ({ course, to }) => {
|
||||||
|
const image = useCoverImage(course.thumbnail);
|
||||||
|
const first = course.lessons[0];
|
||||||
|
return (
|
||||||
|
<Link className="player" to={to} state={to === paths.signUp ? signUpState : undefined} aria-label={first ? `Assistir aula 1: ${first.title}` : 'Assistir'}>
|
||||||
|
{image.show && <ArtImage source={course.thumbnail} framing={courseFraming(course)} onMissing={image.onMissing} />}
|
||||||
|
<div className="pl"><span className="playbtn"><PlayIcon className="ph" weight="fill" /></span></div>
|
||||||
|
{first && <div className="ctl num"><span>Aula 1 · {first.title}</span><span style={{ flex: 1 }} /><span>{lessonDuration(first)}</span></div>}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CoursePage: React.FC = () => {
|
||||||
|
const { courseId } = useParams<{ courseId: string }>();
|
||||||
|
const { course, isLoading, missing } = useCourse(courseId);
|
||||||
|
const { user } = useAuth();
|
||||||
|
const { paths: trails } = useCatalog();
|
||||||
|
const progress = useLessonProgress(course);
|
||||||
|
const action = useMaterialAction();
|
||||||
|
const saved = useSavedCourses();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
const [mobileTab, setMobileTab] = useState<'aulas' | 'materiais' | 'sobre'>('aulas');
|
||||||
|
|
||||||
|
if (isLoading) return <main className="wrap page"><div className="loading"><CircleNotchIcon className="ph spin" /></div></main>;
|
||||||
|
if (missing || !course) return <main className="wrap page"><p className="empty">Este curso não está disponível.</p></main>;
|
||||||
|
|
||||||
|
const trail = trails.find((item) => item.courses.some((entry) => entry.id === course.id));
|
||||||
|
const materials = courseMaterials(course);
|
||||||
|
const next = progress.next;
|
||||||
|
const watchTo = (lessonId?: string) => (user && lessonId ? paths.lesson(course.id, lessonId) : paths.signUp);
|
||||||
|
const started = progress.doneCount > 0;
|
||||||
|
|
||||||
|
if (isMobile) return <main className="m-page has-cta enter">
|
||||||
|
<div className="m-gut">
|
||||||
|
<Cover course={course} progress={user ? Math.round(progress.doneCount / Math.max(course.lessons.length, 1) * 100) : undefined} className="m-cover" />
|
||||||
|
<header className="m-title"><h1>{course.title}</h1><p className="num">{[course.instructor, courseMeta(course)].filter(Boolean).join(' · ')}</p></header>
|
||||||
|
{user && progress.doneCount > 0 && <div className="m-progress"><span className="prog"><i style={{ width: `${Math.round(progress.doneCount / Math.max(course.lessons.length, 1) * 100)}%` }} /></span><span>{progress.doneCount} de {course.lessons.length} aulas</span></div>}
|
||||||
|
<div className="m-seg" role="tablist">{([['aulas', 'Aulas'], ['materiais', 'Materiais'], ['sobre', 'Sobre']] as const).map(([key, label]) => <button type="button" role="tab" key={key} aria-selected={mobileTab === key} onClick={() => setMobileTab(key)}>{label}</button>)}</div>
|
||||||
|
<div className="m-pane">
|
||||||
|
{mobileTab === 'aulas' && <section className="m-group"><div className="m-list">{course.lessons.map((lesson, index) => <Link className="m-row" key={lesson.id} to={watchTo(lesson.id)} state={user ? undefined : signUpState}><span className="m-n num">{progress.completed.has(lesson.id) ? <CheckIcon className="ph" /> : index + 1}</span><span className="m-rt"><b>{lesson.title}</b><small>{lessonDuration(lesson)}</small></span><CaretRightIcon className="m-chev" /></Link>)}</div></section>}
|
||||||
|
{mobileTab === 'materiais' && <section className="m-group"><div className="m-list">{materials.map((item) => <div className="m-row" key={item.attachment.id}><span className="m-ic">{attachmentIcon(item.attachment.type)}</span><span className="m-rt"><b>{item.attachment.name}</b><small>{item.detail} · {item.attachment.size}</small></span><MaterialButton attachment={item.attachment} action={action} label={false} className="m-icb" /></div>)}</div>{!materials.length && <p className="m-empty">Este curso não tem materiais para baixar.</p>}</section>}
|
||||||
|
{mobileTab === 'sobre' && <><p className="m-body">{course.description}</p>{course.instructorId && <section className="m-group"><h2>Professor</h2><div className="m-list"><Link className="m-row" to={paths.professor(course.instructorId)}><Avatar name={course.instructor || 'Professor'} size="sm" /><span className="m-rt"><b>{course.instructor}</b></span><CaretRightIcon className="m-chev" /></Link></div></section>}{trail && <section className="m-group"><h2>Trilha</h2><div className="m-list"><Link className="m-row" to={paths.trail(trail.id)}><span className="m-rt"><b>{trail.title}</b></span><CaretRightIcon className="m-chev" /></Link></div></section>}</>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="m-cta">{user && <button type="button" className="btn sec m-half save-icon" onClick={() => saved.toggle(course.id)} aria-label={saved.isSaved(course.id) ? 'Remover dos salvos' : 'Salvar curso'} aria-pressed={saved.isSaved(course.id)}><BookmarkSimpleIcon className="ph" weight={saved.isSaved(course.id) ? 'fill' : 'regular'} /></button>}<Link className="btn m-big" to={user && next ? paths.lesson(course.id, next.id) : paths.signUp} state={user ? undefined : signUpState}>{user && started ? `Continuar aula ${progress.nextIndex + 1}` : user ? 'Assistir' : 'Criar conta para assistir'}</Link></div>
|
||||||
|
</main>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="wrap page enter">
|
||||||
|
<div className="crumb">
|
||||||
|
<Link to={paths.explore}>Explorar</Link><CaretRightIcon className="ph" weight="bold" />
|
||||||
|
<Link to={`${paths.search}?area=${encodeURIComponent(course.category)}`}>{course.category}</Link><CaretRightIcon className="ph" weight="bold" />
|
||||||
|
<span>{course.title}</span>
|
||||||
|
</div>
|
||||||
|
<section className="chead">
|
||||||
|
<div>
|
||||||
|
<h1>{course.title}</h1>
|
||||||
|
{course.description && <p className="d">{course.description}</p>}
|
||||||
|
<p className="meta num">{[course.instructor, courseMeta(course)].filter(Boolean).join(' · ')}</p>
|
||||||
|
<div className="acts">
|
||||||
|
{user ? (
|
||||||
|
next && <Link className="btn lg" to={paths.lesson(course.id, next.id)}><PlayIcon className="ph" weight="fill" /> {started ? `Continuar aula ${progress.nextIndex + 1}` : 'Assistir'}</Link>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Link className="btn lg" to={paths.signUp} state={signUpState}>Criar conta para assistir</Link>
|
||||||
|
<Link className="btn lg sec" to={paths.signIn}>Entrar</Link>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{user && <button className="btn lg sec" type="button" onClick={() => saved.toggle(course.id)} aria-pressed={saved.isSaved(course.id)}><BookmarkSimpleIcon className="ph" weight={saved.isSaved(course.id) ? 'fill' : 'regular'} /> {saved.isSaved(course.id) ? 'Salvo' : 'Salvar'}</button>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{course.lessons.length > 0 ? <PlayerPreview course={course} to={watchTo(course.lessons[0]?.id)} /> : <Cover course={course} variant="big" />}
|
||||||
|
</section>
|
||||||
|
<div className="split">
|
||||||
|
<div>
|
||||||
|
<section className="shelf" style={{ marginTop: 0 }}>
|
||||||
|
<header><h2>Aulas</h2><span className="count num">{courseMeta(course)}</span></header>
|
||||||
|
{course.lessons.length === 0 ? <p className="empty">As aulas deste curso ainda estão sendo preparadas.</p> : (
|
||||||
|
<ol className="list">
|
||||||
|
{course.lessons.map((lesson, index) => (
|
||||||
|
<li key={lesson.id}>
|
||||||
|
<Link className="row" to={watchTo(lesson.id)} state={user ? undefined : signUpState}>
|
||||||
|
<span className="i num">{progress.completed.has(lesson.id) ? <span className="done" aria-label="Concluída"><CheckIcon className="ph" weight="bold" /></span> : index + 1}</span>
|
||||||
|
<span className="t">{lesson.title}</span>
|
||||||
|
<span className="r num">{lessonDuration(lesson)}</span>
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<aside className="side">
|
||||||
|
{course.instructorId && (
|
||||||
|
<Link className="box person" to={paths.professor(course.instructorId)} style={{ display: 'flex' }}>
|
||||||
|
<Avatar name={course.instructor || 'Professor'} />
|
||||||
|
<span>{course.instructor}<small>Professor</small></span>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
{trail && (
|
||||||
|
<Link className="box" to={paths.trail(trail.id)}>
|
||||||
|
<h3 style={{ marginBottom: 4 }}>Faz parte da trilha</h3>
|
||||||
|
<span className="link">{trail.title} <CaretRightIcon className="ph" weight="bold" /></span>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
<div className="box">
|
||||||
|
<h3>Materiais</h3>
|
||||||
|
{materials.length ? materials.map((item) => <MaterialRow key={item.attachment.id} attachment={item.attachment} detail={item.detail} action={action} compact />) : <p className="small">Este curso não tem materiais para baixar.</p>}
|
||||||
|
</div>
|
||||||
|
{user && course.lessons.length > 0 && (
|
||||||
|
<div className="box">
|
||||||
|
<h3>Seu progresso</h3>
|
||||||
|
<span className="prog" style={{ display: 'block', margin: '0 0 10px' }}><i style={{ width: `${Math.round((progress.doneCount / course.lessons.length) * 100)}%` }} /></span>
|
||||||
|
<p className="small num">{progress.doneCount} de {plural(course.lessons.length, 'aula', 'aulas')}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Opens the learner's next unfinished lesson. */
|
||||||
|
export const ContinueCourse: React.FC = () => {
|
||||||
|
const { courseId } = useParams<{ courseId: string }>();
|
||||||
|
const { course, isLoading, missing } = useCourse(courseId);
|
||||||
|
const { user, isLoading: authLoading } = useAuth();
|
||||||
|
const progress = useLessonProgress(course);
|
||||||
|
|
||||||
|
if (authLoading || isLoading || (course && !progress.loaded)) return <main className="wrap page"><div className="loading"><CircleNotchIcon className="ph spin" /></div></main>;
|
||||||
|
if (missing || !course) return <Navigate to={paths.explore} replace />;
|
||||||
|
if (!user) return <Navigate to={paths.signUp} state={signUpState} replace />;
|
||||||
|
if (!progress.next) return <Navigate to={paths.course(course.id)} replace />;
|
||||||
|
return <Navigate to={paths.lesson(course.id, progress.next.id)} replace />;
|
||||||
|
};
|
||||||
51
pages/DownloadsPage.tsx
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { CircleNotchIcon } from '@phosphor-icons/react';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { attachmentIcon, attachmentLabel, useMaterialAction } from '../components/course/Materials';
|
||||||
|
import { DownloadHistoryEntry, getDownloadHistory } from '../services/db';
|
||||||
|
import { DownloadMockIcon } from '../components/ui/MockupIcons';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
|
||||||
|
const months = ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'];
|
||||||
|
const downloadedLabel = (value: string) => {
|
||||||
|
const date = new Date(value);
|
||||||
|
if (Number.isNaN(date.getTime())) return '';
|
||||||
|
const today = new Date();
|
||||||
|
const day = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
||||||
|
const current = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
||||||
|
const days = Math.round((current.getTime() - day.getTime()) / 86_400_000);
|
||||||
|
if (days <= 0) return 'hoje';
|
||||||
|
if (days === 1) return 'ontem';
|
||||||
|
return `${date.getDate()} ${months[date.getMonth()]}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DownloadsPage: React.FC = () => {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const action = useMaterialAction();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
const [entries, setEntries] = useState<DownloadHistoryEntry[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
if (!user) { setEntries([]); setLoading(false); return; }
|
||||||
|
setLoading(true);
|
||||||
|
getDownloadHistory()
|
||||||
|
.then((history) => { if (!cancelled) setEntries(history); })
|
||||||
|
.catch(() => { if (!cancelled) setEntries([]); })
|
||||||
|
.finally(() => { if (!cancelled) setLoading(false); });
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, [user?.id]);
|
||||||
|
|
||||||
|
if (isMobile) return <main className="m-page m-gut enter">
|
||||||
|
<header className="m-large"><h1>Meus downloads</h1></header>
|
||||||
|
{loading ? <p className="m-empty">Carregando…</p> : entries.length ? <section className="m-group"><div className="m-list">{entries.map(({ attachment, courseTitle, downloadedAt }) => <div className="m-row" key={attachment.id}><span className="m-ic">{attachmentIcon(attachment.type)}</span><span className="m-rt"><b>{attachment.name}</b><small>{courseTitle} · baixado {downloadedLabel(downloadedAt)}</small></span><button className="m-icb" type="button" onClick={() => void action.open(attachment)} aria-label={`Baixar ${attachment.name} novamente`} disabled={action.busyId === attachment.id}><DownloadMockIcon className="ph" /></button></div>)}</div></section> : <p className="m-empty">Seus downloads aparecerão aqui.</p>}
|
||||||
|
</main>;
|
||||||
|
|
||||||
|
return <main className="wrap page enter">
|
||||||
|
<header className="ptitle"><div><h1>Meus downloads</h1><p>Arquivos que você já baixou das aulas.</p></div><Link className="btn sec" to={paths.library}>Ver biblioteca</Link></header>
|
||||||
|
{loading ? <div className="loading"><CircleNotchIcon className="ph spin" /></div> : entries.length ? <div className="list">{entries.map(({ attachment, courseTitle, lessonNumber, downloadedAt }) => <div className="file" key={attachment.id} style={{ padding: '14px 4px' }}><span className="ic">{attachmentIcon(attachment.type)}</span><span>{attachment.name}<small className="num">{[courseTitle, lessonNumber ? `aula ${lessonNumber}` : '', attachmentLabel(attachment.type), attachment.size, `baixado ${downloadedLabel(downloadedAt)}`].filter(Boolean).join(' · ')}</small></span><button type="button" className="btn sec" onClick={() => void action.open(attachment)} disabled={action.busyId === attachment.id}><DownloadMockIcon className="ph" /> {attachment.type === 'link' ? 'Abrir de novo' : 'Baixar de novo'}</button></div>)}</div> : <div className="empty"><DownloadMockIcon className="ph" style={{ fontSize: 24, marginBottom: 8 }} /><p>Seus downloads aparecerão aqui.</p><Link className="link" to={paths.library}>Explorar a biblioteca</Link></div>}
|
||||||
|
</main>;
|
||||||
|
};
|
||||||
48
pages/ExplorePage.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { CircleNotchIcon } from '@phosphor-icons/react';
|
||||||
|
import { Hero } from '../components/catalog/Hero';
|
||||||
|
import { Shelf } from '../components/catalog/Shelf';
|
||||||
|
import { ContinueCard, CourseCard, TrailPoster } from '../components/catalog/Artwork';
|
||||||
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
|
||||||
|
export const ExplorePage: React.FC = () => {
|
||||||
|
const { courses, paths: trails, areas, isLoading, failed } = useCatalog();
|
||||||
|
const { user } = useAuth();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
const going = user ? courses.filter((course) => (course.progress || 0) > 0 && (course.progress || 0) < 100) : [];
|
||||||
|
const mostWatched = courses.length > 0 && (
|
||||||
|
<Shelf title="Mais assistidos" to={paths.search}>
|
||||||
|
{[...courses].sort((a, b) => (b.views || 0) - (a.views || 0)).slice(0, 10).map((course) => <CourseCard key={course.id} course={course} />)}
|
||||||
|
</Shelf>
|
||||||
|
);
|
||||||
|
const trailsShelf = trails.length > 0 && (
|
||||||
|
<Shelf title="Trilhas" to={paths.trails} kind="tall">
|
||||||
|
{trails.map((trail) => <TrailPoster key={trail.id} path={trail} />)}
|
||||||
|
</Shelf>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Hero />
|
||||||
|
<main className="wrap page has-hero enter">
|
||||||
|
{isLoading && <div className="loading"><CircleNotchIcon className="ph spin" /></div>}
|
||||||
|
{!isLoading && failed && <p className="empty">Não foi possível carregar os cursos. Tente novamente em instantes.</p>}
|
||||||
|
{!isLoading && !failed && courses.length === 0 && <p className="empty">Ainda não há cursos publicados.</p>}
|
||||||
|
{going.length > 0 && (
|
||||||
|
<Shelf title="Continue assistindo" to={paths.learning} kind="wide">
|
||||||
|
{going.map((course) => <ContinueCard key={course.id} course={course} />)}
|
||||||
|
</Shelf>
|
||||||
|
)}
|
||||||
|
{isMobile ? <>{trailsShelf}{mostWatched}</> : <>{mostWatched}{trailsShelf}</>}
|
||||||
|
{areas.map((area) => (
|
||||||
|
<Shelf key={area} title={area} to={`${paths.search}?area=${encodeURIComponent(area)}`}>
|
||||||
|
{courses.filter((course) => course.category === area).map((course) => <CourseCard key={course.id} course={course} />)}
|
||||||
|
</Shelf>
|
||||||
|
))}
|
||||||
|
</main>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,34 +1,38 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { ExternalLink, Globe2, Instagram, Linkedin, Loader2, UserRound, Youtube } from 'lucide-react';
|
import { Link, useParams } from 'react-router-dom';
|
||||||
import { useParams } from 'react-router-dom';
|
import { ArrowSquareOutIcon, CaretRightIcon, CircleNotchIcon, GlobeIcon, InstagramLogoIcon, LinkedinLogoIcon, YoutubeLogoIcon } from '@phosphor-icons/react';
|
||||||
import { Course } from '../types';
|
import { Course } from '../types';
|
||||||
import { getPublicProfile, InstructorProfileData } from '../services/db';
|
import { getPublicProfile, InstructorProfileData } from '../services/db';
|
||||||
import { CourseCoverImage } from '../components/CourseCoverImage';
|
import { CourseCoverImage } from '../components/CourseCoverImage';
|
||||||
import { CourseCard } from '../components/CourseCard';
|
import { CourseCard, Thumb } from '../components/catalog/Artwork';
|
||||||
|
import { Avatar } from '../components/ui/Avatar';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
|
||||||
const networks = [
|
const networks = [
|
||||||
{ key: 'websiteUrl', label: 'Site', icon: Globe2 },
|
{ key: 'websiteUrl', label: 'Site', icon: GlobeIcon },
|
||||||
{ key: 'linkedinUrl', label: 'LinkedIn', icon: Linkedin },
|
{ key: 'linkedinUrl', label: 'LinkedIn', icon: LinkedinLogoIcon },
|
||||||
{ key: 'instagramUrl', label: 'Instagram', icon: Instagram },
|
{ key: 'instagramUrl', label: 'Instagram', icon: InstagramLogoIcon },
|
||||||
{ key: 'youtubeUrl', label: 'YouTube', icon: Youtube },
|
{ key: 'youtubeUrl', label: 'YouTube', icon: YoutubeLogoIcon },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const InstructorProfile: React.FC<{ onPlay: (course: Course) => void }> = ({ onPlay }) => {
|
export const InstructorProfile: React.FC<{ onPlay: (course: Course) => void }> = () => {
|
||||||
const { instructorId, profileId } = useParams<{ instructorId?: string; profileId?: string }>();
|
const { instructorId, profileId } = useParams<{ instructorId?: string; profileId?: string }>();
|
||||||
const publicProfileId = instructorId || profileId;
|
const id = instructorId || profileId;
|
||||||
|
const isMobile = useIsMobile();
|
||||||
const [profile, setProfile] = useState<InstructorProfileData | null>(null);
|
const [profile, setProfile] = useState<InstructorProfileData | null>(null);
|
||||||
const [state, setState] = useState<'loading' | 'ready' | 'missing'>('loading');
|
const [loading, setLoading] = useState(true);
|
||||||
|
useEffect(() => { if (!id) return; setLoading(true); getPublicProfile(id).then(setProfile).catch(() => setProfile(null)).finally(() => setLoading(false)); }, [id]);
|
||||||
useEffect(() => {
|
if (loading) return <main className="wrap page"><div className="loading"><CircleNotchIcon className="ph spin" /></div></main>;
|
||||||
if (!publicProfileId) return;
|
if (!profile) return <main className="wrap page"><p className="empty">Este perfil não está público.</p></main>;
|
||||||
setState('loading');
|
|
||||||
getPublicProfile(publicProfileId).then((data) => { setProfile(data); setState('ready'); }).catch(() => setState('missing'));
|
|
||||||
}, [publicProfileId]);
|
|
||||||
|
|
||||||
if (state === 'loading') return <main className="min-h-[65vh] pt-32 flex items-center justify-center"><Loader2 className="h-8 w-8 animate-spin text-orange-400" /></main>;
|
|
||||||
if (state === 'missing' || !profile) return <main className="mx-auto flex min-h-[65vh] max-w-5xl items-center px-6 pt-24"><div><p className="text-sm font-semibold uppercase tracking-widest text-orange-400">Perfil indisponível</p><h1 className="mt-3 text-3xl font-bold">Este perfil não está público.</h1></div></main>;
|
|
||||||
|
|
||||||
const isInstructor = profile.role === 'instructor' || profile.role === 'admin';
|
const isInstructor = profile.role === 'instructor' || profile.role === 'admin';
|
||||||
|
if (isMobile) return <main className="m-page m-gut enter"><header className="m-person"><Avatar name={profile.name} src={profile.avatarImageUrl || undefined} size="xl" /><h1>{profile.name}</h1>{profile.headline && <p>{profile.headline}</p>}{profile.bio && <p className="m-body">{profile.bio}</p>}</header>
|
||||||
return <main className="min-h-screen pb-20 pt-20"><section className="border-b border-white/10 bg-gradient-to-br from-orange-500/15 via-zinc-950 to-black"><div className="mx-auto grid max-w-6xl gap-7 px-6 py-12 sm:px-8 md:grid-cols-[auto_1fr] md:items-center md:py-16"><div className="h-32 w-32 overflow-hidden rounded-full border-4 border-zinc-900 bg-zinc-800 shadow-2xl shadow-black/50">{profile.avatarImageUrl ? <CourseCoverImage source={profile.avatarImageUrl} alt={`Foto de ${profile.name}`} className="h-full w-full object-cover" /> : <div className="flex h-full w-full items-center justify-center bg-orange-500/15"><UserRound className="h-14 w-14 text-orange-300" /></div>}</div><div><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">{isInstructor ? 'Instrutor' : 'Aluno'}</p><h1 className="mt-2 text-3xl font-bold tracking-tight text-white sm:text-5xl">{profile.name}</h1>{profile.headline && <p className="mt-3 text-lg text-gray-300">{profile.headline}</p>}<div className="mt-5 flex flex-wrap gap-2">{networks.map(({ key, label, icon: Icon }) => { const url = profile[key]; return url ? <a key={key} href={url} target="_blank" rel="noreferrer" className="inline-flex items-center gap-2 rounded-xl border border-white/15 bg-white/5 px-3.5 py-2 text-sm font-semibold text-white transition hover:border-orange-500/40 hover:bg-orange-500/10"><Icon className="h-4 w-4 text-orange-400" />{label}<ExternalLink className="h-3 w-3 text-gray-500" /></a> : null; })}</div></div></div></section><div className={`mx-auto max-w-6xl gap-12 px-6 py-12 sm:px-8 ${isInstructor ? 'grid lg:grid-cols-[minmax(0,0.7fr)_minmax(0,1.3fr)]' : 'max-w-3xl'}`}><aside><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Sobre</p><h2 className="mt-2 text-2xl font-bold text-white">Conheça {profile.name.split(' ')[0]}</h2><p className="mt-5 whitespace-pre-line text-sm leading-7 text-gray-300">{profile.bio || `${isInstructor ? 'Este instrutor' : 'Este aluno'} ainda não adicionou uma apresentação.`}</p></aside>{isInstructor && <section><div className="mb-6 flex items-end justify-between gap-4"><div><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Conteúdo</p><h2 className="mt-2 text-2xl font-bold text-white">Cursos publicados</h2></div><span className="rounded-full bg-white/5 px-3 py-1.5 text-xs font-semibold text-gray-300">{profile.courses.length} {profile.courses.length === 1 ? 'curso' : 'cursos'}</span></div>{profile.courses.length ? <div className="grid gap-7 sm:grid-cols-2">{profile.courses.map((course) => <CourseCard key={course.id} course={course} variant="landscape" onClick={onPlay} />)}</div> : <div className="rounded-2xl border border-dashed border-white/15 p-8 text-center text-sm text-gray-500">Nenhum curso publicado ainda.</div>}</section>}</div></main>;
|
{isInstructor && <section className="m-group"><h2>{profile.courses.length} {profile.courses.length === 1 ? 'curso' : 'cursos'}</h2><div className="m-list">{profile.courses.map((course) => <Link className="m-row" key={course.id} to={paths.course(course.id)}><Thumb course={course} /><span className="m-rt"><b>{course.title}</b><small>{course.lessons.length} aulas · {course.duration}</small></span><CaretRightIcon className="m-chev" /></Link>)}</div></section>}
|
||||||
|
</main>;
|
||||||
|
return <main className="wrap page enter"><div className="crumb"><Link to={paths.professors}>Professores</Link><CaretRightIcon className="ph" /><span>{profile.name}</span></div>
|
||||||
|
<header className="profile-head">{profile.avatarImageUrl ? <span className="av xl"><CourseCoverImage source={profile.avatarImageUrl} alt={`Foto de ${profile.name}`} /></span> : <Avatar name={profile.name} size="xl" />}<div><h1>{profile.name}</h1>{profile.headline && <p>{profile.headline}</p>}</div></header>
|
||||||
|
{profile.bio && <p className="profile-bio">{profile.bio}</p>}
|
||||||
|
<div className="profile-links">{networks.map(({ key, label, icon: Icon }) => { const url = profile[key]; return url ? <a className="btn sec" key={key} href={url} target="_blank" rel="noreferrer"><Icon className="ph" />{label}<ArrowSquareOutIcon className="ph" /></a> : null; })}</div>
|
||||||
|
{isInstructor && <section className="shelf"><header><h2>Cursos</h2><span className="count num">{profile.courses.length}</span></header>{profile.courses.length ? <div className="grid">{profile.courses.map((course) => <CourseCard key={course.id} course={course} />)}</div> : <p className="empty">Nenhum curso publicado ainda.</p>}</section>}
|
||||||
|
</main>;
|
||||||
};
|
};
|
||||||
|
|||||||
215
pages/LessonPage.tsx
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
|
import { Link, Navigate, useNavigate, useParams } from 'react-router-dom';
|
||||||
|
import { CaretRightIcon, CheckIcon, CircleNotchIcon, PlayIcon } from '@phosphor-icons/react';
|
||||||
|
import { Comment, Course, Lesson } from '../types';
|
||||||
|
import { getComments, incrementViews, saveComment, saveLessonProgress } from '../services/db';
|
||||||
|
import { useCourse, useLessonProgress } from '../hooks/useCourse';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { useToast } from '../context/ToastContext';
|
||||||
|
import { LessonVideo } from '../components/course/LessonVideo';
|
||||||
|
import { MaterialRow, useMaterialAction } from '../components/course/Materials';
|
||||||
|
import { Avatar } from '../components/ui/Avatar';
|
||||||
|
import { lessonDuration } from '../lib/format';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
import { signUpState } from './CoursePage';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
import { attachmentIcon, MaterialButton } from '../components/course/Materials';
|
||||||
|
|
||||||
|
export type LessonTab = 'aulas' | 'materiais' | 'discussao';
|
||||||
|
|
||||||
|
/** Everything the lesson screen does, shared by the desktop and mobile layouts. */
|
||||||
|
export const useLessonScreen = (course: Course | undefined, lesson: Lesson | undefined) => {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const { showToast } = useToast();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const progress = useLessonProgress(course);
|
||||||
|
const [comments, setComments] = useState<Comment[]>([]);
|
||||||
|
const [draft, setDraft] = useState('');
|
||||||
|
const [posting, setPosting] = useState(false);
|
||||||
|
const advanceTimer = useRef<number>();
|
||||||
|
const trackedView = useRef<string>('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!user || !course || !lesson) return;
|
||||||
|
const key = `${course.id}:${lesson.id}`;
|
||||||
|
if (trackedView.current === key) return;
|
||||||
|
trackedView.current = key;
|
||||||
|
void incrementViews(course.id);
|
||||||
|
}, [course?.id, lesson?.id, user?.id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!course || !user) { setComments([]); return; }
|
||||||
|
getComments(course.id).then(setComments).catch(() => setComments([]));
|
||||||
|
}, [course?.id, user?.id]);
|
||||||
|
|
||||||
|
useEffect(() => () => window.clearTimeout(advanceTimer.current), []);
|
||||||
|
|
||||||
|
const index = course && lesson ? course.lessons.indexOf(lesson) : -1;
|
||||||
|
const nextLesson = course && index >= 0 ? course.lessons[index + 1] : undefined;
|
||||||
|
|
||||||
|
const onTime = (seconds: number, duration?: number) => {
|
||||||
|
if (!user || !lesson) return;
|
||||||
|
const lessonId = lesson.id;
|
||||||
|
const watchedSeconds = Math.floor(seconds);
|
||||||
|
if (watchedSeconds > 0 && watchedSeconds - (progress.lastSaved.current[lessonId] || 0) >= 30) {
|
||||||
|
progress.lastSaved.current[lessonId] = watchedSeconds;
|
||||||
|
progress.setWatched((current) => ({ ...current, [lessonId]: watchedSeconds }));
|
||||||
|
saveLessonProgress(lessonId, watchedSeconds).catch(() => undefined);
|
||||||
|
}
|
||||||
|
// Automatically mark as complete when reaching 95%+.
|
||||||
|
if (duration && duration > 0 && Math.round((seconds / duration) * 100) >= 95) progress.markCompleted(lessonId, Math.round(seconds));
|
||||||
|
};
|
||||||
|
|
||||||
|
const onEnded = (seconds: number, autoAdvance: boolean) => {
|
||||||
|
if (!lesson) return;
|
||||||
|
progress.markCompleted(lesson.id, seconds);
|
||||||
|
if (autoAdvance && nextLesson && course && user) {
|
||||||
|
advanceTimer.current = window.setTimeout(() => navigate(paths.lesson(course.id, nextLesson.id)), 1000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const postComment = async (event?: React.FormEvent) => {
|
||||||
|
event?.preventDefault();
|
||||||
|
if (!draft.trim() || !course) return;
|
||||||
|
setPosting(true);
|
||||||
|
try {
|
||||||
|
const saved = await saveComment({ courseId: course.id, lessonId: lesson?.id, text: draft });
|
||||||
|
setComments((current) => [saved, ...current]);
|
||||||
|
setDraft('');
|
||||||
|
} catch {
|
||||||
|
// The server remains the source of truth; keep the text for a retry.
|
||||||
|
showToast('Não foi possível publicar agora. Tente de novo.', 'error');
|
||||||
|
} finally {
|
||||||
|
setPosting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const materials = lesson?.attachments || [];
|
||||||
|
const courseLevel = course?.attachments || [];
|
||||||
|
return { progress, comments, draft, setDraft, posting, postComment, onTime, onEnded, index, nextLesson, materials, courseLevel };
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CommentItem: React.FC<{ comment: Comment; lessonNumber?: number }> = ({ comment, lessonNumber }) => (
|
||||||
|
<div className="comment">
|
||||||
|
<Avatar name={comment.user} size="sm" />
|
||||||
|
<div>
|
||||||
|
<div className="h"><b>{comment.user}</b>{[lessonNumber ? `Aula ${lessonNumber}` : '', comment.date].filter(Boolean).join(' · ')}</div>
|
||||||
|
<p>{comment.text}</p>
|
||||||
|
{comment.reply && (
|
||||||
|
<div className="reply">
|
||||||
|
<div className="h"><b>Resposta</b><span className="tagp">Professor</span>{comment.replyDate ? ` ${comment.replyDate}` : ''}</div>
|
||||||
|
<p>{comment.reply}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const LessonPage: React.FC = () => {
|
||||||
|
const { courseId, lessonId } = useParams<{ courseId: string; lessonId: string }>();
|
||||||
|
const { user, isLoading: authLoading } = useAuth();
|
||||||
|
const { course, isLoading, missing } = useCourse(courseId);
|
||||||
|
const lesson = course?.lessons.find((item) => item.id === lessonId);
|
||||||
|
const screen = useLessonScreen(course, lesson);
|
||||||
|
const action = useMaterialAction();
|
||||||
|
const [tab, setTab] = useState<LessonTab>('aulas');
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
|
if (authLoading || isLoading) return <main className="wrap page"><div className="loading"><CircleNotchIcon className="ph spin" /></div></main>;
|
||||||
|
if (!user) return <Navigate to={paths.signUp} state={signUpState} replace />;
|
||||||
|
if (missing || !course) return <Navigate to={paths.explore} replace />;
|
||||||
|
if (!lesson) return <Navigate to={paths.course(course.id)} replace />;
|
||||||
|
|
||||||
|
const { progress, comments, index, nextLesson } = screen;
|
||||||
|
const lessonNumber = (comment: Comment) => (comment.lessonId ? course.lessons.findIndex((item) => item.id === comment.lessonId) + 1 : 0);
|
||||||
|
const done = progress.completed.has(lesson.id);
|
||||||
|
const pct = course.lessons.length ? Math.round((progress.doneCount / course.lessons.length) * 100) : 0;
|
||||||
|
|
||||||
|
if (isMobile) return <main className="m-page has-cta enter">
|
||||||
|
<LessonVideo key={lesson.id} className="m-player" courseId={course.id} lesson={lesson} resumeAt={progress.watched[lesson.id] || 0} onTime={screen.onTime} onEnded={screen.onEnded} />
|
||||||
|
<div className="m-gut"><header className="m-title"><h1>{lesson.title}</h1><p className="num">Aula {index + 1} de {course.lessons.length}{course.instructor ? ` · ${course.instructor}` : ''}</p></header>
|
||||||
|
<div className="m-seg" role="tablist">{([['aulas', 'Aulas'], ['materiais', 'Materiais'], ['discussao', 'Discussão']] as const).map(([key, label]) => <button key={key} type="button" role="tab" aria-selected={tab === key} onClick={() => setTab(key)}>{label}</button>)}</div>
|
||||||
|
<div className="m-pane">
|
||||||
|
{tab === 'aulas' && <section className="m-group"><div className="m-list">{course.lessons.map((item, itemIndex) => <Link className="m-row" to={paths.lesson(course.id, item.id)} key={item.id} aria-current={item.id === lesson.id ? 'page' : undefined}><span className="m-n num">{progress.completed.has(item.id) ? <CheckIcon className="ph" /> : item.id === lesson.id ? <PlayIcon className="ph" weight="fill" /> : itemIndex + 1}</span><span className="m-rt"><b>{item.title}</b><small>{lessonDuration(item)}</small></span><CaretRightIcon className="m-chev" /></Link>)}</div></section>}
|
||||||
|
{tab === 'materiais' && <section className="m-group"><div className="m-list">{[...screen.materials, ...screen.courseLevel].map((attachment) => <div className="m-row" key={attachment.id}><span className="m-ic">{attachmentIcon(attachment.type)}</span><span className="m-rt"><b>{attachment.name}</b><small>{attachment.size}</small></span><MaterialButton attachment={attachment} action={action} label={false} className="m-icb" /></div>)}</div>{screen.materials.length + screen.courseLevel.length === 0 && <p className="m-empty">Esta aula não tem materiais.</p>}</section>}
|
||||||
|
{tab === 'discussao' && <><form className="m-compose" onSubmit={screen.postComment}><textarea rows={1} value={screen.draft} onChange={(event) => screen.setDraft(event.target.value)} placeholder="Escreva uma pergunta" aria-label="Escrever comentário" /><button className="btn m-sm" type="submit" disabled={!screen.draft.trim() || screen.posting}>Enviar</button></form><div className="m-thread">{comments.map((comment) => <CommentItem key={comment.id} comment={comment} />)}{!comments.length && <p className="m-empty">Nenhuma pergunta ainda.</p>}</div></>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="m-cta"><button type="button" className="btn sec m-half" onClick={() => progress.toggleCompleted(lesson.id)} aria-pressed={done}><CheckIcon className="ph" />{done ? 'Vista' : 'Marcar vista'}</button>{nextLesson ? <Link className="btn m-half" to={paths.lesson(course.id, nextLesson.id)}>Próxima aula</Link> : <Link className="btn m-half" to={paths.course(course.id)}>Concluir</Link>}</div>
|
||||||
|
</main>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="wrap page enter">
|
||||||
|
<div className="crumb">
|
||||||
|
<Link to={paths.explore}>Explorar</Link><CaretRightIcon className="ph" weight="bold" />
|
||||||
|
<Link to={paths.course(course.id)}>{course.title}</Link><CaretRightIcon className="ph" weight="bold" />
|
||||||
|
<span>Aula {index + 1}</span>
|
||||||
|
</div>
|
||||||
|
<div className="split">
|
||||||
|
<div>
|
||||||
|
<LessonVideo key={lesson.id} courseId={course.id} lesson={lesson} resumeAt={progress.watched[lesson.id] || 0} onTime={screen.onTime} onEnded={screen.onEnded} />
|
||||||
|
<div className="ltitle">
|
||||||
|
<div>
|
||||||
|
<h1>{lesson.title}</h1>
|
||||||
|
<small className="num">Aula {index + 1} de {course.lessons.length}{course.instructor ? ` · ${course.instructor}` : ''}</small>
|
||||||
|
</div>
|
||||||
|
<div className="acts">
|
||||||
|
<button type="button" className="btn sec" onClick={() => progress.toggleCompleted(lesson.id)} aria-pressed={done}>
|
||||||
|
{done ? <><CheckIcon className="ph" weight="bold" /> Vista</> : 'Marcar como vista'}
|
||||||
|
</button>
|
||||||
|
{nextLesson && <Link className="btn" to={paths.lesson(course.id, nextLesson.id)}>Próxima aula</Link>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="tabs" role="tablist">
|
||||||
|
{([['aulas', 'Aulas', course.lessons.length], ['materiais', 'Materiais', screen.materials.length + screen.courseLevel.length], ['discussao', 'Discussão', comments.length]] as const).map(([key, label, count]) => (
|
||||||
|
<button key={key} type="button" role="tab" aria-selected={tab === key} onClick={() => setTab(key)}>{label}<span className="num">{count}</span></button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="pane">
|
||||||
|
{tab === 'aulas' && (
|
||||||
|
<ol className="lessons">
|
||||||
|
{course.lessons.map((item, itemIndex) => (
|
||||||
|
<li key={item.id}>
|
||||||
|
<Link className="row" to={paths.lesson(course.id, item.id)} aria-current={item.id === lesson.id ? 'true' : undefined}>
|
||||||
|
<span className="i num">{progress.completed.has(item.id) ? <span className="done"><CheckIcon className="ph" weight="bold" /></span> : item.id === lesson.id ? <PlayIcon className="ph" weight="fill" /> : itemIndex + 1}</span>
|
||||||
|
<span className="t">{item.title}</span>
|
||||||
|
<span className="r num">{lessonDuration(item)}</span>
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
|
)}
|
||||||
|
{tab === 'materiais' && (
|
||||||
|
screen.materials.length + screen.courseLevel.length === 0 ? <p className="empty">Esta aula não tem materiais.</p> : (
|
||||||
|
<>
|
||||||
|
{screen.materials.map((attachment) => <MaterialRow key={attachment.id} attachment={attachment} action={action} />)}
|
||||||
|
{screen.courseLevel.length > 0 && <>
|
||||||
|
{screen.materials.length > 0 && <h3 className="muted" style={{ fontSize: 13, fontWeight: 500, margin: '20px 0 4px' }}>Do curso</h3>}
|
||||||
|
{screen.courseLevel.map((attachment) => <MaterialRow key={attachment.id} attachment={attachment} action={action} />)}
|
||||||
|
</>}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
{tab === 'discussao' && (
|
||||||
|
<>
|
||||||
|
<form className="composer" onSubmit={screen.postComment}>
|
||||||
|
<textarea rows={2} value={screen.draft} onChange={(event) => screen.setDraft(event.target.value)} placeholder="Pergunte ou compartilhe um resultado" aria-label="Escrever comentário" />
|
||||||
|
<button className="btn" type="submit" disabled={!screen.draft.trim() || screen.posting}>Publicar</button>
|
||||||
|
</form>
|
||||||
|
{comments.length === 0 ? <p className="empty">Nenhuma pergunta ainda. Seja o primeiro a perguntar.</p> : comments.map((comment) => <CommentItem key={comment.id} comment={comment} lessonNumber={comment.lessonId && comment.lessonId !== lesson.id ? lessonNumber(comment) : undefined} />)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<aside className="side">
|
||||||
|
<Link className="box" to={paths.course(course.id)}>
|
||||||
|
<h3>{course.title}</h3>
|
||||||
|
<span className="prog" style={{ display: 'block', margin: '0 0 8px' }}><i style={{ width: `${pct}%` }} /></span>
|
||||||
|
<p className="small num" style={{ fontSize: 13 }}>{progress.doneCount} de {course.lessons.length} aulas concluídas</p>
|
||||||
|
</Link>
|
||||||
|
{lesson.description && <div className="box"><h3>Sobre esta aula</h3><p className="small" style={{ whiteSpace: 'pre-line' }}>{lesson.description}</p></div>}
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,84 +1,45 @@
|
|||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import { ArrowLeft, BookOpen, Download, ExternalLink, Filter, FolderOpen, LayoutGrid, List, Loader2, Play, Search, X } from 'lucide-react';
|
import { Link } from 'react-router-dom';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { Attachment, Course } from '../types';
|
||||||
import { Attachment, AttachmentType, Course } from '../types';
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
import { getCourses } from '../services/db';
|
import { useAuth } from '../context/AuthContext';
|
||||||
import { downloadCourseAsset } from '../services/api';
|
import { attachmentIcon, attachmentLabel, useMaterialAction } from '../components/course/Materials';
|
||||||
import { getAttachmentBadge, getAttachmentIcon } from '../components/MaterialCard';
|
import { DownloadMockIcon, SearchMockIcon } from '../components/ui/MockupIcons';
|
||||||
import { useToast } from '../context/ToastContext';
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
|
||||||
interface MaterialsPageProps { onPlayCourse: (course: Course) => void; }
|
type Material = { attachment: Attachment; course: Course; lessonTitle?: string; lessonNumber?: number };
|
||||||
type Material = { id: string; attachment: Attachment; course: Course; lessonTitle?: string; };
|
|
||||||
type SortOption = 'recent' | 'name' | 'type';
|
|
||||||
|
|
||||||
const filterTypes: Array<{ value: 'all' | AttachmentType; label: string }> = [
|
export const MaterialsPage: React.FC<{ onPlayCourse: (course: Course) => void }> = () => {
|
||||||
{ value: 'all', label: 'Todos os formatos' }, { value: 'pdf', label: 'PDF' }, { value: 'spreadsheet', label: 'Planilha' }, { value: 'doc', label: 'Documento' }, { value: 'zip', label: 'Arquivo compactado' }, { value: 'image', label: 'Imagem' }, { value: 'link', label: 'Link' },
|
const { courses, isLoading } = useCatalog();
|
||||||
];
|
const { user } = useAuth();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
const formatDate = (date?: string) => date ? new Intl.DateTimeFormat('pt-BR', { dateStyle: 'medium' }).format(new Date(date)) : 'Data não informada';
|
const action = useMaterialAction();
|
||||||
const materialDate = (material: Material) => {
|
|
||||||
const value = material.attachment.createdAt ? new Date(material.attachment.createdAt).getTime() : 0;
|
|
||||||
return Number.isNaN(value) ? 0 : value;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MaterialsPage: React.FC<MaterialsPageProps> = ({ onPlayCourse }) => {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { showDownloadToast, showToast } = useToast();
|
|
||||||
const [courses, setCourses] = useState<Course[]>([]);
|
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
const [selectedTrail, setSelectedTrail] = useState('all');
|
|
||||||
const [selectedCourse, setSelectedCourse] = useState('all');
|
|
||||||
const [selectedType, setSelectedType] = useState<'all' | AttachmentType>('all');
|
|
||||||
const [sort, setSort] = useState<SortOption>('recent');
|
|
||||||
const [view, setView] = useState<'grid' | 'list'>('grid');
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
window.scrollTo(0, 0);
|
|
||||||
getCourses().then(setCourses).catch(() => showToast('Não foi possível carregar os materiais.', 'error')).finally(() => setIsLoading(false));
|
|
||||||
}, [showToast]);
|
|
||||||
|
|
||||||
const materials = useMemo<Material[]>(() => courses.flatMap((course) => [
|
const materials = useMemo<Material[]>(() => courses.flatMap((course) => [
|
||||||
...(course.attachments || []).map((attachment) => ({ id: `course-${course.id}-${attachment.id}`, attachment, course })),
|
...(course.attachments || []).map((attachment) => ({ attachment, course })),
|
||||||
...course.lessons.flatMap((lesson) => (lesson.attachments || []).map((attachment) => ({ id: `lesson-${course.id}-${lesson.id}-${attachment.id}`, attachment, course, lessonTitle: lesson.title }))),
|
...course.lessons.flatMap((lesson, index) => (lesson.attachments || []).map((attachment) => ({ attachment, course, lessonTitle: lesson.title, lessonNumber: index + 1 }))),
|
||||||
]), [courses]);
|
]), [courses]);
|
||||||
const trails = useMemo<string[]>(() => Array.from(new Set<string>(courses.map((course) => course.category))).filter(Boolean).sort((a, b) => a.localeCompare(b, 'pt-BR')), [courses]);
|
const q = query.trim().toLocaleLowerCase('pt-BR');
|
||||||
const courseOptions = useMemo(() => courses.filter((course) => selectedTrail === 'all' || course.category === selectedTrail).sort((a, b) => a.title.localeCompare(b.title, 'pt-BR')), [courses, selectedTrail]);
|
const visible = materials.filter((material) => !q || [material.attachment.name, material.course.title, material.lessonTitle].some((value) => value?.toLocaleLowerCase('pt-BR').includes(q)));
|
||||||
const filteredMaterials = useMemo(() => materials.filter((material) => {
|
const open = (material: Material) => { void action.open(material.attachment); };
|
||||||
const normalized = query.trim().toLocaleLowerCase('pt-BR');
|
|
||||||
const searchMatches = !normalized || [material.attachment.name, material.attachment.description, material.course.title, material.course.category, material.lessonTitle].some((value) => value?.toLocaleLowerCase('pt-BR').includes(normalized));
|
|
||||||
return searchMatches && (selectedTrail === 'all' || material.course.category === selectedTrail) && (selectedCourse === 'all' || material.course.id === selectedCourse) && (selectedType === 'all' || material.attachment.type === selectedType);
|
|
||||||
}).sort((left, right) => {
|
|
||||||
if (sort === 'name') return left.attachment.name.localeCompare(right.attachment.name, 'pt-BR');
|
|
||||||
if (sort === 'type') return left.attachment.type.localeCompare(right.attachment.type, 'pt-BR') || left.attachment.name.localeCompare(right.attachment.name, 'pt-BR');
|
|
||||||
return materialDate(right) - materialDate(left) || left.attachment.name.localeCompare(right.attachment.name, 'pt-BR');
|
|
||||||
}), [materials, query, selectedTrail, selectedCourse, selectedType, sort]);
|
|
||||||
const hasFilters = Boolean(query) || selectedTrail !== 'all' || selectedCourse !== 'all' || selectedType !== 'all';
|
|
||||||
const clearFilters = () => { setQuery(''); setSelectedTrail('all'); setSelectedCourse('all'); setSelectedType('all'); };
|
|
||||||
const openMaterial = async (material: Material) => {
|
|
||||||
if (material.attachment.type === 'link') {
|
|
||||||
showToast(`Abrindo “${material.attachment.name}”.`, 'info');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await downloadCourseAsset(material.attachment.id, material.attachment.name);
|
|
||||||
showDownloadToast(material.attachment.name, material.attachment.size);
|
|
||||||
} catch (error) {
|
|
||||||
showToast(error instanceof Error ? error.message : 'Não foi possível baixar este material.', 'error');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return <main className="min-h-screen bg-black pb-20 pt-24 text-white"><div className="mx-auto max-w-7xl px-5 sm:px-8">
|
if (isMobile) {
|
||||||
<header className="border-b border-white/10 pb-7"><button onClick={() => navigate('/')} className="mb-5 inline-flex items-center gap-1.5 text-sm text-gray-400 transition hover:text-orange-300"><ArrowLeft className="h-4 w-4" /> Início</button><div><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Central de recursos</p><h1 className="mt-2 text-3xl font-bold tracking-tight sm:text-4xl">Biblioteca de materiais</h1><p className="mt-3 max-w-2xl text-sm leading-6 text-gray-400">Materiais disponibilizados pelos instrutores nos cursos e aulas da plataforma.</p></div></header>
|
const courseIds = Array.from(new Set(visible.map((material) => material.course.id)));
|
||||||
|
return <main className="m-page m-gut enter">
|
||||||
|
<header className="m-large"><h1>Biblioteca</h1></header>
|
||||||
|
<p className="m-lead">Planilhas, guias e modelos das aulas.</p>
|
||||||
|
{courseIds.map((courseId) => {
|
||||||
|
const group = visible.filter((material) => material.course.id === courseId);
|
||||||
|
return <section className="m-group" key={courseId}><h2>{group[0].course.title}</h2><div className="m-list">{group.map((material) => <div className="m-row" key={`${material.course.id}-${material.lessonNumber || 0}-${material.attachment.id}`}><span className="m-ic">{attachmentIcon(material.attachment.type)}</span><span className="m-rt"><b>{material.attachment.name}</b><small>{[material.lessonNumber ? `Aula ${material.lessonNumber}` : '', attachmentLabel(material.attachment.type), material.attachment.size].filter(Boolean).join(' · ')}</small></span>{user ? <button className="m-icb" type="button" onClick={() => open(material)} aria-label={`Baixar ${material.attachment.name}`}><DownloadMockIcon className="ph" /></button> : null}</div>)}</div></section>;
|
||||||
|
})}
|
||||||
|
{!visible.length && !isLoading && <p className="m-empty">Nenhum material encontrado.</p>}
|
||||||
|
{!user && <div className="m-cta"><Link className="btn m-big" to={paths.signIn}>Entrar para baixar</Link></div>}
|
||||||
|
</main>;
|
||||||
|
}
|
||||||
|
|
||||||
<section className="mt-6 rounded-2xl border border-white/10 bg-zinc-950/80 p-4 sm:p-5"><div className="grid gap-3 lg:grid-cols-[minmax(0,1.5fr)_repeat(3,minmax(0,.7fr))]"><label className="relative block"><Search className="pointer-events-none absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-500" /><input value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Buscar por material, curso ou aula" className="w-full rounded-xl border border-white/10 bg-zinc-900 py-3 pl-10 pr-10 text-sm text-white outline-none transition focus:border-orange-500/70 focus:ring-2 focus:ring-orange-500/15" />{query && <button onClick={() => setQuery('')} className="absolute right-3 top-1/2 -translate-y-1/2 rounded p-1 text-gray-400 hover:text-white" aria-label="Limpar busca"><X className="h-4 w-4" /></button>}</label><FilterSelect value={selectedTrail} onChange={(value) => { setSelectedTrail(value); setSelectedCourse('all'); }} label="Trilha" options={[{ value: 'all', label: 'Todas as trilhas' }, ...trails.map((trail) => ({ value: trail, label: trail }))]} /><FilterSelect value={selectedCourse} onChange={setSelectedCourse} label="Curso" options={[{ value: 'all', label: 'Todos os cursos' }, ...courseOptions.map((course) => ({ value: course.id, label: course.title }))]} /><FilterSelect value={selectedType} onChange={(value) => setSelectedType(value as 'all' | AttachmentType)} label="Formato" options={filterTypes} /></div><div className="mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-white/5 pt-4"><div className="flex items-center gap-2 text-xs text-gray-500"><Filter className="h-3.5 w-3.5 text-orange-400" /> {filteredMaterials.length} {filteredMaterials.length === 1 ? 'resultado' : 'resultados'}</div><div className="flex items-center gap-2">{hasFilters && <button onClick={clearFilters} className="rounded-lg px-3 py-2 text-xs font-semibold text-gray-300 transition hover:bg-white/10 hover:text-white">Limpar filtros</button>}<label className="sr-only" htmlFor="materials-sort">Ordenar por</label><select id="materials-sort" value={sort} onChange={(event) => setSort(event.target.value as SortOption)} className="rounded-lg border border-white/10 bg-zinc-900 px-3 py-2 text-xs font-semibold text-white outline-none"><option value="recent">Mais recentes</option><option value="name">Nome</option><option value="type">Formato</option></select><div className="flex rounded-lg border border-white/10 bg-zinc-900 p-1"><button onClick={() => setView('grid')} aria-label="Visualização em grade" className={`rounded p-1.5 ${view === 'grid' ? 'bg-orange-500 text-white' : 'text-gray-400 hover:text-white'}`}><LayoutGrid className="h-4 w-4" /></button><button onClick={() => setView('list')} aria-label="Visualização em lista" className={`rounded p-1.5 ${view === 'list' ? 'bg-orange-500 text-white' : 'text-gray-400 hover:text-white'}`}><List className="h-4 w-4" /></button></div></div></div></section>
|
return <main className="wrap page enter">
|
||||||
|
<header className="ptitle"><div><h1>Materiais</h1><p>Planilhas, guias e modelos das aulas.</p></div><label className="search"><SearchMockIcon className="ph" /><input type="search" value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Buscar materiais" aria-label="Buscar materiais" /></label></header>
|
||||||
<section className="mt-6">{isLoading ? <div className="flex min-h-72 items-center justify-center"><Loader2 className="h-7 w-7 animate-spin text-orange-400" /></div> : filteredMaterials.length === 0 ? <EmptyState hasMaterials={materials.length > 0} onClear={clearFilters} /> : view === 'grid' ? <div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-3">{filteredMaterials.map((material) => <MaterialGridCard key={material.id} material={material} onOpen={openMaterial} onCourse={onPlayCourse} />)}</div> : <div className="overflow-hidden rounded-2xl border border-white/10 bg-zinc-950/80"><div className="hidden grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)_10rem_8rem] gap-4 border-b border-white/10 px-5 py-3 text-xs font-semibold uppercase tracking-wider text-gray-500 md:grid"><span>Material</span><span>Curso e aula</span><span>Adicionado em</span><span className="text-right">Ações</span></div>{filteredMaterials.map((material) => <MaterialListRow key={material.id} material={material} onOpen={openMaterial} onCourse={onPlayCourse} />)}</div>}</section>
|
{isLoading ? <p className="empty">Carregando materiais…</p> : visible.length ? <div className="tablewrap"><table className="t-mat"><thead><tr><th>Arquivo</th><th>Curso</th><th>Aula</th><th>Tamanho</th><th></th></tr></thead><tbody>{visible.map((material) => <tr key={`${material.course.id}-${material.lessonNumber || 0}-${material.attachment.id}`}><td><span className="file-name"><span className="ic">{attachmentIcon(material.attachment.type)}</span><span>{material.attachment.name}<small>{attachmentLabel(material.attachment.type)}</small></span></span></td><td><Link className="link" to={paths.course(material.course.id)}>{material.course.title}</Link></td><td className="num">{material.lessonNumber || '—'}</td><td className="num">{material.attachment.size || '—'}</td><td className="right">{user ? <button type="button" className="btn sec" onClick={() => open(material)} disabled={action.busyId === material.attachment.id}><DownloadMockIcon className="ph" /> {material.attachment.type === 'link' ? 'Abrir' : 'Baixar'}</button> : <Link className="btn sec" to={paths.signIn}>Entrar para baixar</Link>}</td></tr>)}</tbody></table></div> : <p className="empty">Nenhum material encontrado.</p>}
|
||||||
</div></main>;
|
</main>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const FilterSelect: React.FC<{ value: string; label: string; options: Array<{ value: string; label: string }>; onChange: (value: string) => void }> = ({ value, label, options, onChange }) => <label className="block"><span className="sr-only">{label}</span><select value={value} onChange={(event) => onChange(event.target.value)} className="w-full rounded-xl border border-white/10 bg-zinc-900 px-3 py-3 text-sm text-white outline-none transition focus:border-orange-500/70"><option value="" disabled>{label}</option>{options.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}</select></label>;
|
|
||||||
const EmptyState: React.FC<{ hasMaterials: boolean; onClear: () => void }> = ({ hasMaterials, onClear }) => <div className="flex min-h-80 flex-col items-center justify-center rounded-2xl border border-dashed border-white/15 bg-zinc-950/50 px-6 text-center"><div className="flex h-14 w-14 items-center justify-center rounded-2xl bg-orange-500/10"><FolderOpen className="h-7 w-7 text-orange-400" /></div><h2 className="mt-5 text-lg font-bold text-white">{hasMaterials ? 'Nenhum material corresponde aos filtros' : 'A biblioteca ainda não tem materiais'}</h2><p className="mt-2 max-w-md text-sm leading-6 text-gray-500">{hasMaterials ? 'Tente alterar a busca ou os filtros selecionados.' : 'Quando um instrutor adicionar materiais a um curso ou aula, eles aparecerão aqui.'}</p>{hasMaterials && <button onClick={onClear} className="mt-5 rounded-xl bg-orange-500 px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-orange-600">Limpar filtros</button>}</div>;
|
|
||||||
const MaterialMeta: React.FC<{ material: Material }> = ({ material }) => <div className="min-w-0"><p className="truncate text-xs font-semibold text-orange-300">{material.course.category}</p><p className="mt-1 flex items-center gap-1.5 truncate text-xs text-gray-400"><BookOpen className="h-3.5 w-3.5 shrink-0" />{material.course.title}</p>{material.lessonTitle && <p className="mt-1 truncate text-xs text-gray-500">Aula: {material.lessonTitle}</p>}</div>;
|
|
||||||
const MaterialGridCard: React.FC<{ material: Material; onOpen: (material: Material) => void | Promise<void>; onCourse: (course: Course) => void }> = ({ material, onOpen, onCourse }) => { const { attachment } = material; const badge = getAttachmentBadge(attachment.type); const isLink = attachment.type === 'link'; return <article className="flex min-h-64 flex-col rounded-2xl border border-white/10 bg-zinc-950/80 p-5 transition hover:border-orange-500/35 hover:bg-zinc-900/80"><div className="flex items-start justify-between gap-4"><div className="rounded-xl bg-white/5 p-3">{getAttachmentIcon(attachment.type)}</div><span className={`rounded-full px-2.5 py-1 text-[10px] font-bold uppercase tracking-wider ${badge.bg}`}>{badge.label}</span></div><div className="mt-5"><h2 className="line-clamp-2 text-base font-bold text-white">{attachment.name}</h2>{attachment.description && <p className="mt-2 line-clamp-2 text-sm leading-5 text-gray-400">{attachment.description}</p>}</div><div className="mt-5 border-t border-white/10 pt-4"><MaterialMeta material={material} /><div className="mt-4 flex items-center justify-between gap-3 text-xs text-gray-500"><span>{attachment.size || 'Tamanho não informado'}</span><span>{formatDate(attachment.createdAt)}</span></div></div><div className="mt-5 flex items-center gap-2"><button onClick={() => onCourse(material.course)} className="inline-flex items-center gap-1.5 rounded-lg border border-white/10 px-3 py-2 text-xs font-semibold text-gray-300 transition hover:bg-white/10 hover:text-white"><Play className="h-3.5 w-3.5 text-orange-400" /> Abrir curso</button>{isLink ? <a href={attachment.url} target="_blank" rel="noreferrer" onClick={() => void onOpen(material)} className="ml-auto inline-flex items-center gap-1.5 rounded-lg bg-orange-500 px-3 py-2 text-xs font-semibold text-white transition hover:bg-orange-600"><ExternalLink className="h-3.5 w-3.5" />Abrir</a> : <button type="button" onClick={() => void onOpen(material)} className="ml-auto inline-flex items-center gap-1.5 rounded-lg bg-orange-500 px-3 py-2 text-xs font-semibold text-white transition hover:bg-orange-600"><Download className="h-3.5 w-3.5" />Baixar</button>}</div></article>; };
|
|
||||||
const MaterialListRow: React.FC<{ material: Material; onOpen: (material: Material) => void | Promise<void>; onCourse: (course: Course) => void }> = ({ material, onOpen, onCourse }) => { const { attachment } = material; const isLink = attachment.type === 'link'; return <article className="grid gap-4 border-b border-white/5 px-5 py-4 last:border-0 md:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)_10rem_8rem] md:items-center"><div className="flex min-w-0 items-center gap-3"><div className="shrink-0">{getAttachmentIcon(attachment.type)}</div><div className="min-w-0"><p className="truncate text-sm font-semibold text-white">{attachment.name}</p><p className="mt-1 text-xs text-gray-500">{attachment.size || 'Tamanho não informado'}</p></div></div><MaterialMeta material={material} /><p className="text-xs text-gray-500">{formatDate(attachment.createdAt)}</p><div className="flex items-center gap-2 md:justify-end"><button onClick={() => onCourse(material.course)} className="rounded-lg p-2 text-gray-400 transition hover:bg-white/10 hover:text-orange-300" title="Abrir curso"><Play className="h-4 w-4" /></button>{isLink ? <a href={attachment.url} target="_blank" rel="noreferrer" onClick={() => void onOpen(material)} className="inline-flex items-center gap-1.5 rounded-lg bg-orange-500 px-3 py-2 text-xs font-semibold text-white transition hover:bg-orange-600"><ExternalLink className="h-3.5 w-3.5" />Abrir</a> : <button type="button" onClick={() => void onOpen(material)} className="inline-flex items-center gap-1.5 rounded-lg bg-orange-500 px-3 py-2 text-xs font-semibold text-white transition hover:bg-orange-600"><Download className="h-3.5 w-3.5" />Baixar</button>}</div></article>; };
|
|
||||||
|
|||||||
@@ -1,40 +1,60 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { BookOpenCheck, Loader2, PlayCircle } from 'lucide-react';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { CircleNotchIcon } from '@phosphor-icons/react';
|
||||||
import { Course } from '../types';
|
import { Course } from '../types';
|
||||||
import { getMyLearningCourses } from '../services/db';
|
import { getMyLearningCourses } from '../services/db';
|
||||||
import { CourseCoverImage } from '../components/CourseCoverImage';
|
import { CourseCard, Cover, Thumb } from '../components/catalog/Artwork';
|
||||||
|
import { PlayMockIcon } from '../components/ui/MockupIcons';
|
||||||
|
import { useSavedCourses } from '../hooks/useSavedCourses';
|
||||||
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
|
||||||
export const MyLearning: React.FC<{ onPlay: (course: Course) => void }> = ({ onPlay }) => {
|
export const MyLearning: React.FC<{ onPlay: (course: Course) => void }> = () => {
|
||||||
const [courses, setCourses] = useState<Course[]>([]);
|
const [courses, setCourses] = useState<Course[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [tab, setTab] = useState<'andamento' | 'concluidos' | 'salvos'>('andamento');
|
||||||
|
const saved = useSavedCourses();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
const { courses: catalogCourses } = useCatalog();
|
||||||
|
useEffect(() => { getMyLearningCourses().then(setCourses).catch(() => setCourses([])).finally(() => setLoading(false)); }, []);
|
||||||
|
const going = courses.filter((course) => (course.progress || 0) < 100);
|
||||||
|
const done = courses.filter((course) => (course.progress || 0) >= 100);
|
||||||
|
const savedCourses = catalogCourses.filter((course) => saved.isSaved(course.id));
|
||||||
|
const first = going[0];
|
||||||
|
const completedCount = first ? Math.round(((first.progress || 0) / 100) * first.lessons.length) : 0;
|
||||||
|
const nextLesson = first?.lessons[Math.min(completedCount, Math.max(first.lessons.length - 1, 0))];
|
||||||
|
|
||||||
useEffect(() => {
|
if (loading) return <main className="wrap page enter"><div className="loading"><CircleNotchIcon className="ph spin" /></div></main>;
|
||||||
getMyLearningCourses().then(setCourses).catch(() => setCourses([])).finally(() => setLoading(false));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
if (isMobile) {
|
||||||
<main className="min-h-screen max-w-[1440px] mx-auto pt-28 pb-20 px-6 md:px-12">
|
const chosen = tab === 'andamento' ? going : tab === 'concluidos' ? done : savedCourses;
|
||||||
<div className="mb-10">
|
return <main className="m-page m-gut enter"><header className="m-large"><h1>Minha aprendizagem</h1></header>
|
||||||
<div className="flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-orange-400 mb-3"><BookOpenCheck className="w-4 h-4" /> Minha área</div>
|
<div className="m-seg" role="tablist">{[['andamento', 'Em andamento'], ['concluidos', 'Concluídos'], ['salvos', 'Salvos']].map(([key, label]) => <button type="button" role="tab" key={key} aria-selected={tab === key} onClick={() => setTab(key as typeof tab)}>{label}</button>)}</div>
|
||||||
<h1 className="text-3xl md:text-4xl font-bold text-white">Continue aprendendo</h1>
|
{chosen.length ? <section className="m-group"><div className="m-list">{chosen.map((course) => {
|
||||||
<p className="mt-2 text-gray-400">Retome suas aulas exatamente de onde parou.</p>
|
const progress = course.progress || 0;
|
||||||
|
const lessonIndex = Math.min(Math.round((progress / 100) * course.lessons.length), Math.max(course.lessons.length - 1, 0));
|
||||||
|
const linkedLesson = course.lessons[lessonIndex];
|
||||||
|
const to = tab === 'andamento' && linkedLesson ? paths.lesson(course.id, linkedLesson.id) : paths.course(course.id);
|
||||||
|
const sub = tab === 'andamento' ? `Aula ${lessonIndex + 1} de ${course.lessons.length}` : tab === 'concluidos' ? 'Concluído' : `${course.lessons.length} aulas`;
|
||||||
|
return <Link className="m-row" key={course.id} to={to}><Thumb course={course} className="m-th" /><span className="m-rt"><b>{course.title}</b><small>{sub}</small></span>{tab === 'andamento' && <span className="m-mini"><span className="m-bar"><i style={{ width: `${progress}%` }} /></span></span>}</Link>;
|
||||||
|
})}</div></section> : <p className="m-empty">Nada por aqui ainda.</p>}
|
||||||
|
</main>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <main className="wrap page enter">
|
||||||
|
<div className="ptitle"><div><h1>Minha aprendizagem</h1></div></div>
|
||||||
|
{first && <Link className="box contbox" to={paths.continueCourse(first.id)}>
|
||||||
|
<Cover course={first} variant="mini" />
|
||||||
|
<div>
|
||||||
|
<h2>{nextLesson?.title || first.title}</h2>
|
||||||
|
<p className="num" style={{ fontSize: 14, color: 'var(--fg-2)', marginTop: 4 }}>Continuar de onde parou · {first.title}, aula {Math.min(completedCount + 1, first.lessons.length)} de {first.lessons.length}</p>
|
||||||
|
<div className="prog"><i style={{ width: `${Math.round(first.progress || 0)}%` }} /></div>
|
||||||
</div>
|
</div>
|
||||||
{loading ? <div className="h-64 flex justify-center items-center"><Loader2 className="w-8 h-8 animate-spin text-orange-400" /></div> : courses.length === 0 ? (
|
<span className="btn"><PlayMockIcon className="ph" /> Continuar</span>
|
||||||
<div className="rounded-2xl border border-white/10 bg-zinc-950/80 py-16 px-6 text-center">
|
</Link>}
|
||||||
<BookOpenCheck className="w-10 h-10 text-orange-400 mx-auto mb-4" />
|
<section className="shelf"><header><h2>Em andamento</h2></header><div className="grid">{going.map((course) => <CourseCard key={course.id} course={course} />)}</div></section>
|
||||||
<h2 className="font-bold text-white text-lg">Você ainda não iniciou nenhum curso</h2>
|
<section className="shelf"><header><h2>Concluídos</h2></header><div className="grid">{done.map((course) => <CourseCard key={course.id} course={course} />)}</div></section>
|
||||||
<p className="mt-2 text-sm text-gray-400">Escolha uma aula na página de cursos para começar.</p>
|
<section className="shelf"><header><h2>Salvos</h2></header><div className="grid">{savedCourses.map((course) => <CourseCard key={course.id} course={course} />)}</div></section>
|
||||||
</div>
|
</main>;
|
||||||
) : (
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-5">
|
|
||||||
{courses.map((course) => (
|
|
||||||
<button key={course.id} onClick={() => onPlay(course)} className="group overflow-hidden rounded-2xl border border-white/10 bg-zinc-950/80 text-left hover:border-orange-500/50 transition-colors">
|
|
||||||
<div className="aspect-video relative overflow-hidden bg-zinc-900"><CourseCoverImage source={course.thumbnail} alt="" className="h-full w-full object-cover opacity-75 transition-opacity group-hover:opacity-100" style={{ transform: `scale(${course.coverImageZoom || 1})`, objectPosition: `${course.coverImagePositionX ?? 50}% ${course.coverImagePositionY ?? 50}%` }} /><div className="absolute inset-0 bg-gradient-to-t from-black/80 to-transparent" /><span className="absolute left-4 bottom-4 inline-flex items-center gap-2 rounded-full bg-orange-500 px-3 py-2 text-xs font-bold text-white"><PlayCircle className="w-4 h-4" /> Continuar</span></div>
|
|
||||||
<div className="p-5"><p className="text-xs text-orange-400 font-semibold uppercase tracking-wider">{course.category}</p><h2 className="mt-2 font-bold text-white">{course.title}</h2><div className="mt-4 h-1.5 overflow-hidden rounded-full bg-white/10"><div className="h-full rounded-full bg-orange-500" style={{ width: `${course.progress || 0}%` }} /></div><p className="mt-2 text-xs text-gray-400">{course.progress || 0}% concluído</p></div>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|||||||
13
pages/ProfessorsPage.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Link, Navigate } from 'react-router-dom';
|
||||||
|
import { Avatar } from '../components/ui/Avatar';
|
||||||
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
|
||||||
|
export const ProfessorsPage: React.FC = () => {
|
||||||
|
const { professors } = useCatalog();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
if (isMobile) return <Navigate to="/comunidade?tab=professores" replace />;
|
||||||
|
return <main className="wrap page enter"><header className="ptitle"><div><h1>Professores</h1><p>Quem ensina na Compor.</p></div></header><div className="pcards">{professors.map((professor) => <Link className="pcard" key={professor.id} to={paths.professor(professor.id)}><Avatar name={professor.name} src={professor.avatarImageUrl} size="xl" /><b>{professor.name}</b>{professor.headline && <small>{professor.headline}</small>}<small className="num">{professor.courses.length} {professor.courses.length === 1 ? 'curso' : 'cursos'}</small></Link>)}</div></main>;
|
||||||
|
};
|
||||||
@@ -1,135 +1,58 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { Camera, ExternalLink, Globe2, Instagram, Linkedin, Loader2, Save, UserRound, Youtube } from 'lucide-react';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { ArrowSquareOutIcon, CameraIcon, CircleNotchIcon, GlobeIcon, InstagramLogoIcon, LinkedinLogoIcon, YoutubeLogoIcon } from '@phosphor-icons/react';
|
||||||
import { useAuth } from '../context/AuthContext';
|
import { useAuth } from '../context/AuthContext';
|
||||||
import { Profile, ProfileInput, instructorApi, profileApi } from '../services/api';
|
import { Profile, ProfileInput, instructorApi, profileApi } from '../services/api';
|
||||||
import { CourseCoverImage } from '../components/CourseCoverImage';
|
import { CourseCoverImage } from '../components/CourseCoverImage';
|
||||||
|
import { Switch } from '../components/ui/Switch';
|
||||||
import { useToast } from '../context/ToastContext';
|
import { useToast } from '../context/ToastContext';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { paths } from '../lib/routes';
|
||||||
|
|
||||||
const emptyProfile = (user: { id: string; email: string; name: string; role: string }): Profile => ({
|
const emptyProfile = (user: { id: string; email: string; name: string; role: string }): Profile => ({
|
||||||
id: user.id,
|
id: user.id, email: user.email, name: user.name,
|
||||||
email: user.email,
|
|
||||||
name: user.name,
|
|
||||||
role: user.role === 'superadmin' ? 'admin' : user.role === 'professor' ? 'instructor' : 'student',
|
role: user.role === 'superadmin' ? 'admin' : user.role === 'professor' ? 'instructor' : 'student',
|
||||||
avatarImageUrl: null,
|
avatarImageUrl: null, headline: '', bio: '', websiteUrl: null, linkedinUrl: null, instagramUrl: null, youtubeUrl: null, isPublic: true,
|
||||||
headline: '',
|
|
||||||
bio: '',
|
|
||||||
websiteUrl: null,
|
|
||||||
linkedinUrl: null,
|
|
||||||
instagramUrl: null,
|
|
||||||
youtubeUrl: null,
|
|
||||||
isPublic: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const inputClass = 'w-full rounded-xl border border-white/10 bg-zinc-900 px-4 py-3 text-sm text-white outline-none transition focus:border-orange-500/70 focus:ring-2 focus:ring-orange-500/15';
|
|
||||||
|
|
||||||
export const ProfilePage: React.FC = () => {
|
export const ProfilePage: React.FC = () => {
|
||||||
const { user, updateCurrentUser } = useAuth();
|
const { user, updateCurrentUser } = useAuth();
|
||||||
const { showToast } = useToast();
|
const { showToast } = useToast();
|
||||||
const navigate = useNavigate();
|
|
||||||
const fileInput = useRef<HTMLInputElement>(null);
|
const fileInput = useRef<HTMLInputElement>(null);
|
||||||
const [profile, setProfile] = useState<Profile | null>(null);
|
const [profile, setProfile] = useState<Profile | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
const [isUploading, setIsUploading] = useState(false);
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
profileApi.me()
|
profileApi.me().then((response) => setProfile(response.data)).catch(() => { setProfile(emptyProfile(user)); showToast('Não foi possível carregar todos os dados do perfil.', 'error'); }).finally(() => setIsLoading(false));
|
||||||
.then((response) => setProfile(response.data))
|
|
||||||
.catch(() => {
|
|
||||||
setProfile(emptyProfile(user));
|
|
||||||
showToast('Não foi possível carregar todos os dados do perfil.', 'error');
|
|
||||||
})
|
|
||||||
.finally(() => setIsLoading(false));
|
|
||||||
}, [showToast, user]);
|
}, [showToast, user]);
|
||||||
|
if (isLoading || !profile || !user) return <main className="wrap page"><div className="loading"><CircleNotchIcon className="ph spin" /></div></main>;
|
||||||
if (isLoading || !profile || !user) {
|
|
||||||
return <main className="min-h-[65vh] pt-32 flex items-center justify-center"><Loader2 className="h-8 w-8 animate-spin text-orange-400" /></main>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const update = <K extends keyof Profile>(key: K, value: Profile[K]) => setProfile((current) => current ? { ...current, [key]: value } : current);
|
const update = <K extends keyof Profile>(key: K, value: Profile[K]) => setProfile((current) => current ? { ...current, [key]: value } : current);
|
||||||
|
|
||||||
const uploadAvatar = async (file?: File) => {
|
const uploadAvatar = async (file?: File) => {
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
if (!file.type.startsWith('image/')) {
|
if (!file.type.startsWith('image/')) { showToast('Selecione uma imagem JPG, PNG ou WebP.', 'error'); return; }
|
||||||
showToast('Selecione uma imagem JPG, PNG ou WebP.', 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setIsUploading(true);
|
setIsUploading(true);
|
||||||
try {
|
try { const response = await instructorApi.uploadCover(file); update('avatarImageUrl', response.data.coverImageUrl); showToast('Foto enviada. Salve o perfil para publicar a alteração.', 'success'); }
|
||||||
const response = await instructorApi.uploadCover(file);
|
catch { showToast('Não foi possível enviar a foto.', 'error'); }
|
||||||
update('avatarImageUrl', response.data.coverImageUrl);
|
finally { setIsUploading(false); }
|
||||||
showToast('Foto enviada. Salve o perfil para publicar a alteração.', 'success');
|
|
||||||
} catch {
|
|
||||||
showToast('Não foi possível enviar a foto.', 'error');
|
|
||||||
} finally {
|
|
||||||
setIsUploading(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = async (event: React.FormEvent) => {
|
const save = async (event: React.FormEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const input: ProfileInput = {
|
const input: ProfileInput = { name: profile.name, avatarImageUrl: profile.avatarImageUrl, headline: profile.headline, bio: profile.bio, websiteUrl: profile.websiteUrl, linkedinUrl: profile.linkedinUrl, instagramUrl: profile.instagramUrl, youtubeUrl: profile.youtubeUrl, isPublic: profile.isPublic };
|
||||||
name: profile.name,
|
|
||||||
avatarImageUrl: profile.avatarImageUrl,
|
|
||||||
headline: profile.headline,
|
|
||||||
bio: profile.bio,
|
|
||||||
websiteUrl: profile.websiteUrl,
|
|
||||||
linkedinUrl: profile.linkedinUrl,
|
|
||||||
instagramUrl: profile.instagramUrl,
|
|
||||||
youtubeUrl: profile.youtubeUrl,
|
|
||||||
isPublic: profile.isPublic,
|
|
||||||
};
|
|
||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
try {
|
try { const response = await profileApi.update(input); setProfile(response.data); updateCurrentUser({ id: user.id, email: user.email, name: response.data.name, role: response.data.role }); showToast('Perfil salvo com sucesso.', 'success'); }
|
||||||
const response = await profileApi.update(input);
|
catch { showToast('Não foi possível salvar o perfil. Verifique os links informados.', 'error'); }
|
||||||
setProfile(response.data);
|
finally { setIsSaving(false); }
|
||||||
updateCurrentUser({ id: user.id, email: user.email, name: response.data.name, role: response.data.role });
|
|
||||||
showToast('Perfil salvo com sucesso.', 'success');
|
|
||||||
} catch {
|
|
||||||
showToast('Não foi possível salvar o perfil. Verifique os links informados.', 'error');
|
|
||||||
} finally {
|
|
||||||
setIsSaving(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
return <main className="wrap page enter profile-page">
|
||||||
return (
|
<header className="ptitle"><div><h1>Conta</h1><p>Seus dados, apresentação e links.</p></div>{profile.isPublic && <Link className="btn sec" to={`/perfis/${user.id}`}><ArrowSquareOutIcon className="ph" /> Ver perfil público</Link>}</header>
|
||||||
<main className="mx-auto min-h-screen w-full max-w-5xl px-5 pb-20 pt-28 sm:px-8">
|
<form onSubmit={save} className="profile-form">
|
||||||
<div className="mb-8 flex flex-col justify-between gap-5 sm:flex-row sm:items-end">
|
<div className="profile-avatar"><span className="av xl">{profile.avatarImageUrl ? <CourseCoverImage source={profile.avatarImageUrl} alt={`Foto de ${profile.name}`} /> : profile.name.slice(0, 2).toUpperCase()}</span><button type="button" className="link" disabled={isUploading} onClick={() => fileInput.current?.click()}><CameraIcon className="ph" /> Trocar foto</button><input ref={fileInput} type="file" accept="image/jpeg,image/png,image/webp" hidden onChange={(event) => { void uploadAvatar(event.target.files?.[0]); event.currentTarget.value = ''; }} /></div>
|
||||||
<div>
|
<div className="profile-fields"><section className="form"><h2>Dados pessoais</h2><div className="field"><label htmlFor="profile-name">Nome</label><input id="profile-name" value={profile.name} onChange={(event) => update('name', event.target.value)} maxLength={120} required /></div><div className="field"><label htmlFor="profile-email">E-mail</label><input id="profile-email" value={user.email} disabled /></div><div className="field"><label htmlFor="profile-headline">Título profissional</label><input id="profile-headline" value={profile.headline} onChange={(event) => update('headline', event.target.value)} maxLength={180} /></div><div className="field"><label htmlFor="profile-bio">Sobre você</label><textarea id="profile-bio" value={profile.bio} onChange={(event) => update('bio', event.target.value)} maxLength={3000} /></div></section>
|
||||||
<p className="mb-2 text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Sua conta</p>
|
<section className="form"><h2>Links e visibilidade</h2><p className="muted">Use links completos, começando com https://.</p><UrlField icon={<GlobeIcon />} label="Site" value={profile.websiteUrl} onChange={(value) => update('websiteUrl', value || null)} /><UrlField icon={<LinkedinLogoIcon />} label="LinkedIn" value={profile.linkedinUrl} onChange={(value) => update('linkedinUrl', value || null)} /><UrlField icon={<InstagramLogoIcon />} label="Instagram" value={profile.instagramUrl} onChange={(value) => update('instagramUrl', value || null)} /><UrlField icon={<YoutubeLogoIcon />} label="YouTube" value={profile.youtubeUrl} onChange={(value) => update('youtubeUrl', value || null)} /><div className="toggle"><span>Perfil público<small>Permite que outras pessoas vejam sua apresentação e seus cursos.</small></span><Switch checked={profile.isPublic} onChange={(checked) => update('isPublic', checked)} label="Perfil público" /></div></section></div>
|
||||||
<h1 className="text-3xl font-bold tracking-tight text-white sm:text-4xl">Meu perfil</h1>
|
<button className="btn lg profile-save" type="submit" disabled={isSaving}>{isSaving ? 'Salvando…' : 'Salvar'}</button>
|
||||||
<p className="mt-2 max-w-xl text-sm text-gray-400">Apresente quem você é, compartilhe seus links e escolha a visibilidade do seu perfil.</p>
|
</form>
|
||||||
</div>
|
</main>;
|
||||||
{profile.isPublic && <button onClick={() => navigate(`/perfis/${user.id}`)} className="inline-flex items-center justify-center gap-2 rounded-xl border border-white/15 bg-white/5 px-4 py-3 text-sm font-semibold text-white transition hover:bg-white/10"><ExternalLink className="h-4 w-4" /> Ver perfil público</button>}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form onSubmit={save} className="overflow-hidden rounded-3xl border border-white/10 bg-zinc-950/80 shadow-2xl shadow-black/30">
|
|
||||||
<section className="border-b border-white/10 bg-gradient-to-r from-orange-500/15 via-zinc-950 to-zinc-950 p-6 sm:p-8">
|
|
||||||
<div className="flex flex-col gap-5 sm:flex-row sm:items-center">
|
|
||||||
<div className="relative h-28 w-28 shrink-0 overflow-hidden rounded-full border-4 border-zinc-950 bg-zinc-900 shadow-xl">
|
|
||||||
{profile.avatarImageUrl ? <CourseCoverImage source={profile.avatarImageUrl} alt={`Foto de ${profile.name}`} className="h-full w-full object-cover" /> : <div className="flex h-full w-full items-center justify-center bg-orange-500/15"><UserRound className="h-11 w-11 text-orange-300" /></div>}
|
|
||||||
<button type="button" disabled={isUploading} onClick={() => fileInput.current?.click()} className="absolute inset-x-0 bottom-0 flex h-9 items-center justify-center bg-black/70 text-xs font-semibold text-white transition hover:bg-black/90 disabled:opacity-60">{isUploading ? <Loader2 className="h-4 w-4 animate-spin" /> : <><Camera className="mr-1.5 h-3.5 w-3.5" /> Alterar</>}</button>
|
|
||||||
</div>
|
|
||||||
<div><h2 className="text-xl font-bold text-white">{profile.name}</h2><p className="mt-1 text-sm text-gray-400">{user.email}</p><p className="mt-3 text-xs text-orange-200/80">A foto e a apresentação ficam visíveis quando seu perfil estiver público.</p></div>
|
|
||||||
</div>
|
|
||||||
<input ref={fileInput} type="file" accept="image/jpeg,image/png,image/webp" className="hidden" onChange={(event) => { void uploadAvatar(event.target.files?.[0]); event.currentTarget.value = ''; }} />
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div className="grid gap-8 p-6 sm:p-8 lg:grid-cols-[1fr_0.8fr]">
|
|
||||||
<section className="space-y-5">
|
|
||||||
<label className="block"><span className="mb-2 block text-sm font-semibold text-white">Nome</span><input value={profile.name} onChange={(event) => update('name', event.target.value)} className={inputClass} maxLength={120} required /></label>
|
|
||||||
<label className="block"><span className="mb-2 block text-sm font-semibold text-white">Título profissional</span><input value={profile.headline} onChange={(event) => update('headline', event.target.value)} placeholder="Ex.: Especialista em crescimento e mídia paga" className={inputClass} maxLength={180} /></label>
|
|
||||||
<label className="block"><span className="mb-2 block text-sm font-semibold text-white">Sobre você</span><textarea value={profile.bio} onChange={(event) => update('bio', event.target.value)} placeholder="Conte brevemente sobre você, seus interesses ou sua experiência." className={`${inputClass} min-h-40 resize-y`} maxLength={3000} /></label>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section className="rounded-2xl border border-white/10 bg-black/30 p-5 sm:p-6"><div className="mb-5"><h2 className="font-bold text-white">Links e visibilidade</h2><p className="mt-1 text-xs leading-relaxed text-gray-500">Use links completos, começando com https://.</p></div><div className="space-y-4"><UrlField icon={<Globe2 />} label="Site" value={profile.websiteUrl} onChange={(value) => update('websiteUrl', value || null)} placeholder="https://seusite.com" /><UrlField icon={<Linkedin />} label="LinkedIn" value={profile.linkedinUrl} onChange={(value) => update('linkedinUrl', value || null)} placeholder="https://linkedin.com/in/seu-perfil" /><UrlField icon={<Instagram />} label="Instagram" value={profile.instagramUrl} onChange={(value) => update('instagramUrl', value || null)} placeholder="https://instagram.com/seu-perfil" /><UrlField icon={<Youtube />} label="YouTube" value={profile.youtubeUrl} onChange={(value) => update('youtubeUrl', value || null)} placeholder="https://youtube.com/@seu-canal" /></div><label className="mt-6 flex cursor-pointer items-start gap-3 rounded-xl border border-white/10 bg-white/[0.03] p-4"><input type="checkbox" checked={profile.isPublic} onChange={(event) => update('isPublic', event.target.checked)} className="mt-0.5 h-4 w-4 accent-orange-500" /><span><span className="block text-sm font-semibold text-white">Perfil público</span><span className="mt-1 block text-xs leading-relaxed text-gray-500">Permite que outras pessoas vejam sua apresentação e seus links. Perfis de instrutores também exibem seus cursos publicados.</span></span></label></section>
|
|
||||||
</div>
|
|
||||||
<div className="flex justify-end border-t border-white/10 bg-black/20 p-5 sm:px-8"><button disabled={isSaving} className="inline-flex min-w-40 items-center justify-center gap-2 rounded-xl bg-orange-500 px-5 py-3 text-sm font-bold text-white shadow-lg shadow-orange-500/20 transition hover:bg-orange-600 disabled:opacity-60">{isSaving ? <Loader2 className="h-4 w-4 animate-spin" /> : <Save className="h-4 w-4" />} Salvar perfil</button></div>
|
|
||||||
</form>
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const UrlField: React.FC<{ icon: React.ReactNode; label: string; value: string | null; placeholder: string; onChange: (value: string) => void }> = ({ icon, label, value, placeholder, onChange }) => <label className="block"><span className="mb-2 flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-gray-400"><span className="text-orange-400 [&>svg]:h-4 [&>svg]:w-4">{icon}</span>{label}</span><input type="url" value={value || ''} onChange={(event) => onChange(event.target.value)} placeholder={placeholder} className={inputClass} /></label>;
|
const UrlField: React.FC<{ icon: React.ReactNode; label: string; value: string | null; onChange: (value: string) => void }> = ({ icon, label, value, onChange }) => <div className="field"><label>{icon} {label}<input type="url" value={value || ''} onChange={(event) => onChange(event.target.value)} placeholder="https://" /></label></div>;
|
||||||
|
|||||||
74
pages/SearchPage.tsx
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { Link, useSearchParams } from 'react-router-dom';
|
||||||
|
import { CourseCard, Thumb, TrailPoster } from '../components/catalog/Artwork';
|
||||||
|
import { Avatar } from '../components/ui/Avatar';
|
||||||
|
import { SearchMockIcon } from '../components/ui/MockupIcons';
|
||||||
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
import { searchCatalog, SearchResults } from '../services/db';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
|
||||||
|
const emptyResults: SearchResults = { courses: [], paths: [], professors: [] };
|
||||||
|
|
||||||
|
export const SearchPage: React.FC = () => {
|
||||||
|
const { courseById, pathTone } = useCatalog();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
const [params] = useSearchParams();
|
||||||
|
const [query, setQuery] = useState(params.get('q') || params.get('area') || '');
|
||||||
|
const [results, setResults] = useState<SearchResults>(emptyResults);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [failed, setFailed] = useState(false);
|
||||||
|
const normalized = query.trim().length > 0;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
setIsLoading(true);
|
||||||
|
const timer = window.setTimeout(() => {
|
||||||
|
searchCatalog(query)
|
||||||
|
.then((response) => {
|
||||||
|
if (cancelled) return;
|
||||||
|
setResults(response);
|
||||||
|
setFailed(false);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
if (cancelled) return;
|
||||||
|
setResults(emptyResults);
|
||||||
|
setFailed(true);
|
||||||
|
})
|
||||||
|
.finally(() => { if (!cancelled) setIsLoading(false); });
|
||||||
|
}, 250);
|
||||||
|
return () => { cancelled = true; window.clearTimeout(timer); };
|
||||||
|
}, [query]);
|
||||||
|
|
||||||
|
if (isMobile) return <main className="m-page m-gut enter">
|
||||||
|
<header className="m-large"><h1>Buscar</h1></header>
|
||||||
|
<label className="m-search"><SearchMockIcon className="ph" /><input type="search" value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Cursos, trilhas e professores" aria-label="Buscar" autoComplete="off" /></label>
|
||||||
|
{isLoading ? <p className="m-empty">Carregando…</p> : failed ? <p className="m-empty">Não foi possível buscar agora. Tente novamente.</p> : <>
|
||||||
|
{results.courses.length > 0 && <section className="m-group"><h2>Cursos</h2><div className="m-list">{results.courses.map((course) => { const listed = courseById(course.id); const shown = listed ? { ...course, progress: listed.progress } : course; return <Link className="m-row" key={course.id} to={paths.course(course.id)}><Thumb course={shown} className="m-th" /><span className="m-rt"><b>{course.title}</b><small>{course.instructor} · {course.lessons.length} aulas</small></span></Link>; })}</div></section>}
|
||||||
|
{normalized && results.paths.length > 0 && <section className="m-group"><h2>Trilhas</h2><div className="m-list">{results.paths.map((trail) => <Link className="m-row" key={trail.id} to={paths.trail(trail.id)}><span className={`m-part xs tr-${pathTone(trail)}`} aria-hidden="true" /><span className="m-rt"><b>{trail.title}</b><small>{trail.courses.length} cursos</small></span></Link>)}</div></section>}
|
||||||
|
{normalized && results.professors.length > 0 && <section className="m-group"><h2>Professores</h2><div className="m-list">{results.professors.map((professor) => <Link className="m-row" key={professor.id} to={paths.professor(professor.id)}><Avatar name={professor.name} src={professor.avatarImageUrl} size="sm" /><span className="m-rt"><b>{professor.name}</b>{professor.headline && <small>{professor.headline}</small>}</span></Link>)}</div></section>}
|
||||||
|
{!results.courses.length && !results.paths.length && !results.professors.length && <p className="m-empty">Nada encontrado para “{query}”.<br />Tente “Meta Ads” ou “CRM”.</p>}
|
||||||
|
</>}
|
||||||
|
</main>;
|
||||||
|
|
||||||
|
return <main className="wrap page enter">
|
||||||
|
<div className="ptitle"><div><h1>Buscar</h1></div></div> <label className="search bigsearch"><SearchMockIcon className="ph" /><input type="search" value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Cursos, trilhas e professores" aria-label="Buscar" autoComplete="off" /></label>
|
||||||
|
{isLoading ? <p className="empty" style={{ marginTop: 32 }}>Carregando…</p> : failed ? <p className="empty" style={{ marginTop: 32 }}>Não foi possível buscar agora. Tente novamente.</p> : <>
|
||||||
|
{normalized && results.professors.length > 0 && <section className="shelf">
|
||||||
|
<div className="rowhead"><h2>Professores</h2></div>
|
||||||
|
<div className="pcards">{results.professors.map((professor) => <Link className="pcard" to={paths.professor(professor.id)} key={professor.id}><Avatar name={professor.name} src={professor.avatarImageUrl} size="xl" /><b>{professor.name}</b>{professor.headline && <small>{professor.headline}</small>}<span className="num">{professor.courseCount} {professor.courseCount === 1 ? 'curso' : 'cursos'}</span></Link>)}</div>
|
||||||
|
</section>}
|
||||||
|
{normalized && results.paths.length > 0 && <section className="shelf">
|
||||||
|
<div className="rowhead"><h2>Trilhas</h2></div>
|
||||||
|
<div className="pgrid">{results.paths.map((trail) => <TrailPoster key={trail.id} path={trail} />)}</div>
|
||||||
|
</section>}
|
||||||
|
<section className="shelf">
|
||||||
|
<div className="rowhead"><h2>{normalized ? <>Cursos <span className="num" style={{ color: 'var(--fg-3)', fontWeight: 500 }}>{results.courses.length}</span></> : 'Todos os cursos'}</h2></div>
|
||||||
|
{results.courses.length ? <div className="grid">{results.courses.map((course) => {
|
||||||
|
const listed = courseById(course.id);
|
||||||
|
return <CourseCard key={course.id} course={listed ? { ...course, progress: listed.progress, views: listed.views, lastActivity: listed.lastActivity } : course} />;
|
||||||
|
})}</div> : <p className="empty">Nenhum curso encontrado. Tente outro termo, como “Meta Ads” ou “CRM”.</p>}
|
||||||
|
</section>
|
||||||
|
</>}
|
||||||
|
</main>;
|
||||||
|
};
|
||||||
@@ -1,34 +1,43 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React from 'react';
|
||||||
import { ArrowLeft, BookOpen, Loader2 } from 'lucide-react';
|
import { Link, useParams } from 'react-router-dom';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { CaretRightIcon, CircleNotchIcon, PlayIcon } from '@phosphor-icons/react';
|
||||||
import { Course } from '../types';
|
import { Course } from '../types';
|
||||||
import { getCourses, getLearningPaths, PublicLearningPath } from '../services/db';
|
import { Cover, Thumb, pathCourses, pathProgress, Progress } from '../components/catalog/Artwork';
|
||||||
import { CourseCoverImage } from '../components/CourseCoverImage';
|
import { Avatar } from '../components/ui/Avatar';
|
||||||
import { CourseCard } from '../components/CourseCard';
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { courseMeta, plural, totalDuration } from '../lib/format';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
|
||||||
export const TrailPage: React.FC<{ onPlay: (course: Course) => void }> = ({ onPlay }) => {
|
export const TrailPage: React.FC<{ onPlay: (course: Course) => void }> = () => {
|
||||||
const { trailId } = useParams<{ trailId: string }>();
|
const { trailId } = useParams<{ trailId: string }>();
|
||||||
const navigate = useNavigate();
|
const { paths: trails, courseById, pathTone, isLoading } = useCatalog();
|
||||||
const [trail, setTrail] = useState<PublicLearningPath | null>(null);
|
const { user } = useAuth();
|
||||||
const [courses, setCourses] = useState<Course[]>([]);
|
const isMobile = useIsMobile();
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const trail = trails.find((item) => item.id === trailId);
|
||||||
|
const courses = trail ? pathCourses(trail, courseById) : [];
|
||||||
useEffect(() => {
|
const progress = pathProgress(courses);
|
||||||
if (!trailId) return;
|
const totalLessons = courses.reduce((sum, course) => sum + course.lessons.length, 0);
|
||||||
Promise.all([getLearningPaths(), getCourses()])
|
const seen = Math.round(totalLessons * progress / 100);
|
||||||
.then(([paths, availableCourses]) => {
|
const next = courses.find((course) => (course.progress || 0) < 100) || courses[0];
|
||||||
const found = paths.find((item) => item.id === trailId) || null;
|
const teachers = Array.from(new Map(courses.filter((course) => course.instructorId).map((course) => [course.instructorId, { id: course.instructorId!, name: course.instructor || 'Professor' }])).values());
|
||||||
setTrail(found);
|
if (isLoading) return <main className="wrap page"><div className="loading"><CircleNotchIcon className="ph spin" /></div></main>;
|
||||||
if (found) {
|
if (!trail) return <main className="wrap page"><p className="empty">Esta trilha não está disponível.</p></main>;
|
||||||
const byId = new Map(availableCourses.map((course) => [course.id, course]));
|
if (isMobile) return <main className="m-page has-cta m-gut enter">
|
||||||
setCourses(found.courses.map((course) => byId.get(course.id)).filter((course): course is Course => Boolean(course)));
|
<header className="m-hero-d"><span className={`m-part sm tr-${pathTone(trail)}`} aria-hidden="true" /><div><small>{courses[0]?.category}</small><h1>{trail.title}</h1><p>{trail.description}</p><p className="m-meta num">{plural(courses.length, 'curso', 'cursos')} · {plural(totalLessons, 'aula', 'aulas')}{totalDuration(courses) ? ` · ${totalDuration(courses)}` : ''}</p></div></header>
|
||||||
}
|
{user && seen > 0 && <div className="m-progress"><span className="m-bar"><i style={{ width: `${Math.round(progress)}%` }} /></span><span className="num">{seen} de {totalLessons} aulas</span></div>}
|
||||||
})
|
<section className="m-group"><h2>Cursos, em ordem</h2><div className="m-list">{courses.map((course, index) => <Link className="m-row" key={course.id} to={paths.course(course.id)}><span className="m-n num">{index + 1}</span><Thumb course={course} className="thumb" /><span className="m-rt"><b>{course.title}</b><small>{course.instructor} · {plural(course.lessons.length, 'aula', 'aulas')}</small></span><CaretRightIcon className="m-chev" /></Link>)}</div></section>
|
||||||
.finally(() => setIsLoading(false));
|
{next && <div className="m-cta"><Link className="btn m-big" to={user ? paths.continueCourse(next.id) : paths.signUp}>{user ? seen ? 'Continuar trilha' : 'Começar trilha' : 'Criar conta para começar'}</Link></div>}
|
||||||
}, [trailId]);
|
</main>;
|
||||||
|
return <main className="wrap page enter">
|
||||||
if (isLoading) return <main className="flex min-h-[65vh] items-center justify-center pt-24"><Loader2 className="h-8 w-8 animate-spin text-orange-400" /></main>;
|
<div className="crumb"><Link to={paths.trails}>Trilhas</Link><CaretRightIcon className="ph" /><span>{trail.title}</span></div>
|
||||||
if (!trail) return <main className="mx-auto flex min-h-[65vh] max-w-6xl items-center px-6 pt-24"><div><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Trilha indisponível</p><h1 className="mt-3 text-3xl font-bold text-white">Esta trilha não está publicada.</h1></div></main>;
|
<div className="split"><div>
|
||||||
|
<header className="ptitle"><div><h1>{trail.title}</h1><p>{trail.description}</p><p className="num">{plural(courses.length, 'curso', 'cursos')} · {plural(totalLessons, 'aula', 'aulas')}{totalDuration(courses) ? ` · ${totalDuration(courses)}` : ''}</p></div></header>
|
||||||
return <main className="min-h-screen pb-20 pt-20"><section className="relative overflow-hidden border-b border-white/10 bg-zinc-950"><div className="absolute inset-0 opacity-30">{trail.coverImageUrl && <CourseCoverImage source={trail.coverImageUrl} alt="" className="h-full w-full object-cover" style={{ transform: `scale(${trail.coverImageZoom})`, objectPosition: `${trail.coverImagePositionX}% ${trail.coverImagePositionY}%` }} />}</div><div className="absolute inset-0 bg-gradient-to-r from-black via-black/90 to-black/45" /><div className="relative mx-auto max-w-6xl px-6 py-14 sm:px-8 sm:py-20"><button onClick={() => navigate('/')} className="mb-8 inline-flex items-center gap-2 text-sm font-semibold text-gray-300 transition hover:text-orange-300"><ArrowLeft className="h-4 w-4" /> Voltar para cursos</button><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Trilha de cursos</p><h1 className="mt-3 max-w-3xl text-4xl font-bold tracking-tight text-white sm:text-5xl">{trail.title}</h1>{trail.description && <p className="mt-5 max-w-2xl text-base leading-7 text-gray-300">{trail.description}</p>}<div className="mt-7 inline-flex items-center gap-2 rounded-full border border-white/15 bg-black/30 px-4 py-2 text-sm font-semibold text-white"><BookOpen className="h-4 w-4 text-orange-400" />{courses.length} {courses.length === 1 ? 'curso na trilha' : 'cursos na trilha'}</div></div></section><section className="mx-auto max-w-6xl px-6 py-12 sm:px-8"><div className="mb-7"><p className="text-xs font-bold uppercase tracking-[0.18em] text-orange-400">Sua sequência</p><h2 className="mt-2 text-2xl font-bold text-white">Cursos da trilha</h2></div>{courses.length ? <div className="grid gap-7 sm:grid-cols-2 lg:grid-cols-3">{courses.map((course, index) => <div key={course.id}><p className="mb-3 text-xs font-bold text-orange-300">{String(index + 1).padStart(2, '0')} · Curso</p><CourseCard course={course} variant="landscape" onClick={onPlay} /></div>)}</div> : <div className="rounded-2xl border border-dashed border-white/15 p-10 text-center text-sm text-gray-500">Nenhum curso publicado nesta trilha.</div>}</section></main>;
|
<ol className="list">{courses.map((course, index) => <li key={course.id}><Link className="row trail-course" to={paths.course(course.id)}><span className="i num">{index + 1}</span><Cover course={course} variant="mini" /><span className="t">{course.title}<small>{course.instructor} · {courseMeta(course)}</small></span><span className="r num">{course.progress ? `${Math.round(course.progress)}%` : ''}<CaretRightIcon className="ph" /></span></Link></li>)}</ol>
|
||||||
|
</div><aside className="side"><div className="box"><h3>Seu progresso</h3>{user ? <><Progress value={progress} /><p className="small num">{seen} de {totalLessons} aulas</p></> : <p className="small">Entre para acompanhar seu progresso nesta trilha.</p>}{next && <Link className="btn" style={{ marginTop: 16 }} to={user ? paths.continueCourse(next.id) : paths.signUp}><PlayIcon className="ph" />{seen ? 'Continuar trilha' : 'Começar trilha'}</Link>}</div>
|
||||||
|
{teachers.length > 0 && <div className="box"><h3>Professores</h3>{teachers.map((teacher) => <Link key={teacher.id} className="person trail-teacher" to={paths.professor(teacher.id)}><Avatar name={teacher.name} size="sm" /><span>{teacher.name}</span></Link>)}</div>}
|
||||||
|
</aside></div>
|
||||||
|
{isMobile && next && <div className="m-cta"><Link className="btn m-big" to={user ? paths.continueCourse(next.id) : paths.signUp}>{seen ? 'Continuar trilha' : 'Começar trilha'}</Link></div>}
|
||||||
|
</main>;
|
||||||
};
|
};
|
||||||
|
|||||||
11
pages/TrailsPage.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { CircleNotchIcon } from '@phosphor-icons/react';
|
||||||
|
import { TrailPoster } from '../components/catalog/Artwork';
|
||||||
|
import { useCatalog } from '../context/CatalogContext';
|
||||||
|
|
||||||
|
export const TrailsPage: React.FC = () => {
|
||||||
|
const { paths, isLoading } = useCatalog();
|
||||||
|
return <main className="wrap page enter"><header className="ptitle"><div><h1>Trilhas</h1><p>Cursos em sequência. Faça na ordem ou escolha um curso solto.</p></div></header>
|
||||||
|
{isLoading ? <div className="loading"><CircleNotchIcon className="ph spin" /></div> : paths.length ? <div className="pgrid">{paths.map((path) => <TrailPoster key={path.id} path={path} />)}</div> : <p className="empty">Ainda não há trilhas publicadas.</p>}
|
||||||
|
</main>;
|
||||||
|
};
|
||||||
29
pages/YouPage.tsx
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Link, Navigate, useNavigate } from 'react-router-dom';
|
||||||
|
import { BooksIcon, CaretRightIcon, DownloadSimpleIcon, FolderIcon, GearIcon, MoonIcon, SignOutIcon, UserIcon, VideoCameraIcon } from '@phosphor-icons/react';
|
||||||
|
import { useAuth } from '../context/AuthContext';
|
||||||
|
import { useTheme } from '../context/ThemeContext';
|
||||||
|
import { Avatar } from '../components/ui/Avatar';
|
||||||
|
import { paths } from '../lib/routes';
|
||||||
|
import { useIsMobile } from '../hooks/useMediaQuery';
|
||||||
|
|
||||||
|
type Entry = { label: string; to: string; icon: React.ComponentType<{ className?: string }> };
|
||||||
|
const Group: React.FC<{ title: string; entries: Entry[] }> = ({ title, entries }) => <section className="m-group"><h2>{title}</h2><div className="m-list">{entries.map(({ label, to, icon: Icon }) => <Link className="m-row" to={to} key={label}><span className="m-ic"><Icon className="ph" /></span><span className="m-rt"><b>{label}</b></span><CaretRightIcon className="m-chev" /></Link>)}</div></section>;
|
||||||
|
|
||||||
|
export const YouPage: React.FC = () => {
|
||||||
|
const { user, logout } = useAuth();
|
||||||
|
const { theme, toggleTheme } = useTheme();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
const canTeach = user?.role === 'professor' || user?.role === 'superadmin';
|
||||||
|
if (!isMobile) return <Navigate to={user ? paths.account : paths.signIn} replace />;
|
||||||
|
return <main className="m-page m-gut enter"><header className="m-large"><h1>Você</h1></header>
|
||||||
|
{user ? <><Link className="m-me" to={paths.account}><Avatar name={user.name} src={user.avatar} /><span><b>{user.name}</b><small>{user.email}</small></span><CaretRightIcon className="m-chev" /></Link>
|
||||||
|
<Group title="Aprendizado" entries={[{ label: 'Minha aprendizagem', to: paths.learning, icon: BooksIcon }, { label: 'Meus downloads', to: paths.downloads, icon: DownloadSimpleIcon }, { label: 'Biblioteca', to: paths.library, icon: FolderIcon }]} />
|
||||||
|
{canTeach && <Group title="Gestão" entries={[{ label: 'Gerenciar cursos', to: paths.manage, icon: VideoCameraIcon }, ...(user.role === 'superadmin' ? [{ label: 'Administração', to: paths.admin, icon: GearIcon }] : [])]} />}
|
||||||
|
<Group title="Conta" entries={[{ label: 'Dados pessoais', to: paths.account, icon: UserIcon }]} />
|
||||||
|
</> : <><div className="m-signin"><UserIcon className="m-ic xl" /><h2>Entre para continuar</h2><p>Com uma conta gratuita você assiste aos cursos, salva o progresso e participa da comunidade.</p><Link className="btn m-big" to={paths.signUp}>Criar conta</Link><Link className="btn sec m-big" to={paths.signIn}>Entrar</Link></div><Group title="Materiais" entries={[{ label: 'Biblioteca', to: paths.library, icon: FolderIcon }]} /></>}
|
||||||
|
<section className="m-group"><h2>Aparência</h2><div className="m-list"><div className="m-row"><span className="m-ic"><MoonIcon className="ph" /></span><span className="m-rt"><b>Modo escuro</b></span><button className="sw" type="button" role="switch" aria-checked={theme === 'dark'} aria-label="Modo escuro" onClick={toggleTheme} /></div></div></section>
|
||||||
|
{user && <section className="m-group"><div className="m-list"><button className="m-row m-danger" type="button" onClick={() => { logout(); navigate(paths.explore); }}><span className="m-ic"><SignOutIcon className="ph" /></span><span className="m-rt"><b>Sair</b></span></button></div></section>}
|
||||||
|
</main>;
|
||||||
|
};
|
||||||
1
postcss.config.cjs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module.exports = { plugins: { tailwindcss: {}, autoprefixer: {} } };
|
||||||
1
public/compor-academy-logo-dark.svg
Normal file
|
After Width: | Height: | Size: 13 KiB |
1
public/compor-academy-logo-light.svg
Normal file
|
After Width: | Height: | Size: 13 KiB |
@@ -1,12 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#1d1d1f"/><text x="27" y="44" text-anchor="middle" font-family="-apple-system,BlinkMacSystemFont,Inter,system-ui,sans-serif" font-size="38" font-weight="700" letter-spacing="-2" fill="#f5f5f7">c</text><circle cx="45" cy="40" r="5" fill="#0a84ff"/></svg>
|
||||||
<defs>
|
|
||||||
<linearGradient id="favOrangeGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
||||||
<stop offset="0%" stop-color="#FB923C" />
|
|
||||||
<stop offset="100%" stop-color="#EA580C" />
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
<circle cx="50" cy="50" r="48" fill="#121214" />
|
|
||||||
<circle cx="38" cy="40" r="14" fill="url(#favOrangeGrad)" />
|
|
||||||
<circle cx="68" cy="40" r="14" fill="url(#favOrangeGrad)" />
|
|
||||||
<circle cx="53" cy="66" r="14" fill="url(#favOrangeGrad)" />
|
|
||||||
</svg>
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 357 B |
24
server/migrations/016_views_saved_courses_downloads.sql
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
-- Course view counters shown in the catalogue and in the management screen.
|
||||||
|
alter table courses
|
||||||
|
add column if not exists view_count integer not null default 0;
|
||||||
|
|
||||||
|
-- Courses saved by a learner. Stored server-side so the list follows the account.
|
||||||
|
create table if not exists saved_courses (
|
||||||
|
user_id uuid not null references users(id) on delete cascade,
|
||||||
|
course_id uuid not null references courses(id) on delete cascade,
|
||||||
|
created_at timestamptz not null default now(),
|
||||||
|
primary key (user_id, course_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
create index if not exists saved_courses_course_index on saved_courses (course_id);
|
||||||
|
|
||||||
|
-- Download history for the "Meus downloads" screen. It replaces the previous
|
||||||
|
-- browser-only list, so the history follows the account across devices.
|
||||||
|
create table if not exists download_history (
|
||||||
|
user_id uuid not null references users(id) on delete cascade,
|
||||||
|
asset_id uuid not null references assets(id) on delete cascade,
|
||||||
|
downloaded_at timestamptz not null default now(),
|
||||||
|
primary key (user_id, asset_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
create index if not exists download_history_user_index on download_history (user_id, downloaded_at desc);
|
||||||
@@ -12,9 +12,12 @@ import { adminRoutes } from './routes/admin.js';
|
|||||||
import { mediaRoutes } from './routes/media.js';
|
import { mediaRoutes } from './routes/media.js';
|
||||||
import { bunnyWebhookRoutes } from './routes/bunny-webhooks.js';
|
import { bunnyWebhookRoutes } from './routes/bunny-webhooks.js';
|
||||||
import { profileRoutes } from './routes/profiles.js';
|
import { profileRoutes } from './routes/profiles.js';
|
||||||
|
import { savedCourseRoutes } from './routes/saved-courses.js';
|
||||||
|
import { downloadRoutes } from './routes/downloads.js';
|
||||||
|
import { searchRoutes } from './routes/search.js';
|
||||||
|
|
||||||
export function buildApp() {
|
export function buildApp() {
|
||||||
const app = Fastify({ logger: true });
|
const app = Fastify({ logger: true, trustProxy: true });
|
||||||
|
|
||||||
// Bunny signs the exact webhook byte sequence. Preserve the raw JSON body
|
// Bunny signs the exact webhook byte sequence. Preserve the raw JSON body
|
||||||
// before parsing it so the signature can be verified server-side.
|
// before parsing it so the signature can be verified server-side.
|
||||||
@@ -80,6 +83,9 @@ export function buildApp() {
|
|||||||
app.register(authRoutes, { prefix: '/api/v1/auth' });
|
app.register(authRoutes, { prefix: '/api/v1/auth' });
|
||||||
app.register(profileRoutes, { prefix: '/api/v1/profiles' });
|
app.register(profileRoutes, { prefix: '/api/v1/profiles' });
|
||||||
app.register(courseRoutes, { prefix: '/api/v1/courses' });
|
app.register(courseRoutes, { prefix: '/api/v1/courses' });
|
||||||
|
app.register(savedCourseRoutes, { prefix: '/api/v1/saved-courses' });
|
||||||
|
app.register(downloadRoutes, { prefix: '/api/v1/downloads' });
|
||||||
|
app.register(searchRoutes, { prefix: '/api/v1/search' });
|
||||||
app.register(manageCourseRoutes, { prefix: '/api/v1/manage/courses' });
|
app.register(manageCourseRoutes, { prefix: '/api/v1/manage/courses' });
|
||||||
app.register(mediaRoutes, { prefix: '/api/v1/manage/media' });
|
app.register(mediaRoutes, { prefix: '/api/v1/manage/media' });
|
||||||
app.register(bunnyWebhookRoutes, { prefix: '/api/v1/webhooks' });
|
app.register(bunnyWebhookRoutes, { prefix: '/api/v1/webhooks' });
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const environmentSchema = z.object({
|
|||||||
JWT_SECRET: z.string().min(32).default('development-only-secret-change-before-production'),
|
JWT_SECRET: z.string().min(32).default('development-only-secret-change-before-production'),
|
||||||
SUPERADMIN_EMAIL: optionalEnvironmentValue(z.string().email()),
|
SUPERADMIN_EMAIL: optionalEnvironmentValue(z.string().email()),
|
||||||
SUPERADMIN_PASSWORD: optionalEnvironmentValue(z.string().min(8)),
|
SUPERADMIN_PASSWORD: optionalEnvironmentValue(z.string().min(8)),
|
||||||
SUPERADMIN_NAME: z.string().min(1).max(120).default('Compor HUB Superadmin'),
|
SUPERADMIN_NAME: z.string().min(1).max(120).default('Compor HUB Admin'),
|
||||||
AUTH_RATE_LIMIT_MAX: z.coerce.number().int().min(1).max(1000).default(10),
|
AUTH_RATE_LIMIT_MAX: z.coerce.number().int().min(1).max(1000).default(10),
|
||||||
AUTH_RATE_LIMIT_WINDOW_SECONDS: z.coerce.number().int().min(60).max(86_400).default(900),
|
AUTH_RATE_LIMIT_WINDOW_SECONDS: z.coerce.number().int().min(60).max(86_400).default(900),
|
||||||
JWT_SESSION_TTL: z.string().regex(/^\d+[smhd]$/).default('7d'),
|
JWT_SESSION_TTL: z.string().regex(/^\d+[smhd]$/).default('7d'),
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ export const adminRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
app.get('/users', adminAccess, async () => {
|
app.get('/users', adminAccess, async () => {
|
||||||
const result = await pool.query(
|
const result = await pool.query(
|
||||||
`select id, email, display_name as name, role, is_active as "isActive",
|
`select id, email, display_name as name, role, is_active as "isActive",
|
||||||
created_at as "createdAt"
|
created_at as "createdAt",
|
||||||
|
(select max(lp.updated_at) from lesson_progress lp where lp.user_id = users.id) as "lastAccessAt"
|
||||||
from users
|
from users
|
||||||
order by created_at desc`,
|
order by created_at desc`,
|
||||||
);
|
);
|
||||||
@@ -136,7 +137,9 @@ export const adminRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
(select count(*)::int from users where is_active) as "activeUsers",
|
(select count(*)::int from users where is_active) as "activeUsers",
|
||||||
(select count(*)::int from courses where status = 'published') as "publishedCourses",
|
(select count(*)::int from courses where status = 'published') as "publishedCourses",
|
||||||
(select count(*)::int from lesson_progress where completed_at is not null) as "completedLessons",
|
(select count(*)::int from lesson_progress where completed_at is not null) as "completedLessons",
|
||||||
(select count(*)::int from comments) as "comments"`,
|
(select count(*)::int from comments) as "comments",
|
||||||
|
(select count(*)::int from account_access_tokens
|
||||||
|
where purpose = 'invitation' and used_at is null and expires_at > now()) as "pendingInvitations"`,
|
||||||
);
|
);
|
||||||
return { data: result.rows[0] };
|
return { data: result.rows[0] };
|
||||||
});
|
});
|
||||||
@@ -370,7 +373,7 @@ export const adminRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
[input.email, input.role, hashToken(rawToken), config.INVITATION_TTL_HOURS, request.user.id],
|
[input.email, input.role, hashToken(rawToken), config.INVITATION_TTL_HOURS, request.user.id],
|
||||||
);
|
);
|
||||||
await recordAudit({ actorId: request.user.id, action: 'invitation.created', subjectType: 'invitation', metadata: { email: input.email, role: input.role }, ipAddress: request.ip });
|
await recordAudit({ actorId: request.user.id, action: 'invitation.created', subjectType: 'invitation', metadata: { email: input.email, role: input.role }, ipAddress: request.ip });
|
||||||
return reply.code(201).send({ data: { inviteUrl: `${config.FRONTEND_ORIGIN}/#/invite?token=${rawToken}` } });
|
return reply.code(201).send({ data: { inviteUrl: `${config.FRONTEND_ORIGIN}/invite?token=${rawToken}` } });
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/users/:userId/password-reset', adminAccess, async (request, reply) => {
|
app.post('/users/:userId/password-reset', adminAccess, async (request, reply) => {
|
||||||
@@ -384,7 +387,7 @@ export const adminRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
[account.rows[0].email, account.rows[0].role, hashToken(rawToken), config.PASSWORD_RESET_TTL_HOURS, request.user.id],
|
[account.rows[0].email, account.rows[0].role, hashToken(rawToken), config.PASSWORD_RESET_TTL_HOURS, request.user.id],
|
||||||
);
|
);
|
||||||
await recordAudit({ actorId: request.user.id, action: 'password_reset.created', subjectType: 'user', subjectId: userId, metadata: { email: account.rows[0].email }, ipAddress: request.ip });
|
await recordAudit({ actorId: request.user.id, action: 'password_reset.created', subjectType: 'user', subjectId: userId, metadata: { email: account.rows[0].email }, ipAddress: request.ip });
|
||||||
return { data: { resetUrl: `${config.FRONTEND_ORIGIN}/#/reset-password?token=${rawToken}` } };
|
return { data: { resetUrl: `${config.FRONTEND_ORIGIN}/reset-password?token=${rawToken}` } };
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch('/users/:userId', adminAccess, async (request, reply) => {
|
app.patch('/users/:userId', adminAccess, async (request, reply) => {
|
||||||
@@ -392,7 +395,7 @@ export const adminRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
const input = updateUserSchema.parse(request.body);
|
const input = updateUserSchema.parse(request.body);
|
||||||
|
|
||||||
if (userId === request.user.id && (input.role !== undefined && input.role !== 'admin' || input.isActive === false)) {
|
if (userId === request.user.id && (input.role !== undefined && input.role !== 'admin' || input.isActive === false)) {
|
||||||
return reply.code(400).send({ error: 'Você não pode remover seu próprio acesso de superadmin.' });
|
return reply.code(400).send({ error: 'Você não pode remover seu próprio acesso de admin.' });
|
||||||
}
|
}
|
||||||
if (input.email) {
|
if (input.email) {
|
||||||
const duplicate = await pool.query('select 1 from users where email = $1 and id <> $2', [input.email, userId]);
|
const duplicate = await pool.query('select 1 from users where email = $1 and id <> $2', [input.email, userId]);
|
||||||
@@ -406,7 +409,8 @@ export const adminRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
role = coalesce($4::user_role, role),
|
role = coalesce($4::user_role, role),
|
||||||
is_active = coalesce($5, is_active)
|
is_active = coalesce($5, is_active)
|
||||||
where id = $1
|
where id = $1
|
||||||
returning id, email, display_name as name, role, is_active as "isActive", created_at as "createdAt"`,
|
returning id, email, display_name as name, role, is_active as "isActive", created_at as "createdAt",
|
||||||
|
(select max(lp.updated_at) from lesson_progress lp where lp.user_id = users.id) as "lastAccessAt"`,
|
||||||
[userId, input.name ?? null, input.email ?? null, input.role ?? null, input.isActive ?? null],
|
[userId, input.name ?? null, input.email ?? null, input.role ?? null, input.isActive ?? null],
|
||||||
);
|
);
|
||||||
const account = result.rows[0];
|
const account = result.rows[0];
|
||||||
@@ -417,7 +421,7 @@ export const adminRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
|
|
||||||
app.delete('/users/:userId', adminAccess, async (request, reply) => {
|
app.delete('/users/:userId', adminAccess, async (request, reply) => {
|
||||||
const { userId } = userParamsSchema.parse(request.params);
|
const { userId } = userParamsSchema.parse(request.params);
|
||||||
if (userId === request.user.id) return reply.code(400).send({ error: 'Você não pode excluir sua própria conta de superadmin.' });
|
if (userId === request.user.id) return reply.code(400).send({ error: 'Você não pode excluir sua própria conta de admin.' });
|
||||||
|
|
||||||
const client = await pool.connect();
|
const client = await pool.connect();
|
||||||
try {
|
try {
|
||||||
@@ -431,7 +435,7 @@ export const adminRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
const admins = await client.query<{ count: string }>("select count(*) from users where role = 'admin' and is_active");
|
const admins = await client.query<{ count: string }>("select count(*) from users where role = 'admin' and is_active");
|
||||||
if (Number(admins.rows[0].count) <= 1) {
|
if (Number(admins.rows[0].count) <= 1) {
|
||||||
await client.query('rollback');
|
await client.query('rollback');
|
||||||
return reply.code(400).send({ error: 'O último superadmin ativo não pode ser excluído.' });
|
return reply.code(400).send({ error: 'O último admin ativo não pode ser excluído.' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Courses remain available. Their ownership is transferred to the admin
|
// Courses remain available. Their ownership is transferred to the admin
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ export const courseSelect = (publicOnly = false, includeUnreadyMedia = false) =>
|
|||||||
c.cover_image_position_y as "coverImagePositionY",
|
c.cover_image_position_y as "coverImagePositionY",
|
||||||
c.status,
|
c.status,
|
||||||
c.published_at as "publishedAt",
|
c.published_at as "publishedAt",
|
||||||
|
c.updated_at as "updatedAt",
|
||||||
|
c.created_at as "createdAt",
|
||||||
|
c.view_count as views,
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'id', u.id,
|
'id', u.id,
|
||||||
'name', u.display_name
|
'name', u.display_name
|
||||||
@@ -96,15 +99,15 @@ export const courseSelect = (publicOnly = false, includeUnreadyMedia = false) =>
|
|||||||
join users u on u.id = c.instructor_id
|
join users u on u.id = c.instructor_id
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const courseRoutes: FastifyPluginAsync = async (app) => {
|
export const withoutProtectedMedia = (course: Record<string, unknown>) => ({
|
||||||
const withoutProtectedMedia = (course: Record<string, unknown>) => ({
|
...course,
|
||||||
...course,
|
assets: [],
|
||||||
assets: [],
|
lessons: Array.isArray(course.lessons)
|
||||||
lessons: Array.isArray(course.lessons)
|
? course.lessons.map((lesson) => ({ ...lesson, media: [], assets: [] }))
|
||||||
? course.lessons.map((lesson) => ({ ...lesson, media: [], assets: [] }))
|
: [],
|
||||||
: [],
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
export const courseRoutes: FastifyPluginAsync = async (app) => {
|
||||||
const hasSession = async (request: { jwtVerify: () => Promise<unknown> }) => {
|
const hasSession = async (request: { jwtVerify: () => Promise<unknown> }) => {
|
||||||
try {
|
try {
|
||||||
await request.jwtVerify();
|
await request.jwtVerify();
|
||||||
@@ -166,21 +169,43 @@ export const courseRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
|
|
||||||
app.get('/', async (request) => {
|
app.get('/', async (request) => {
|
||||||
const authenticated = await hasSession(request);
|
const authenticated = await hasSession(request);
|
||||||
|
// Guests receive the published catalogue without protected media. Signed-in
|
||||||
|
// learners also receive their own progress directly on each course so the
|
||||||
|
// home screen can show "Continue assistindo" without extra requests.
|
||||||
|
const catalogue = `
|
||||||
|
${courseSelect()}
|
||||||
|
left join platform_settings featured_setting on featured_setting.key = 'home.featuredCourseId'
|
||||||
|
left join platform_settings order_setting on order_setting.key = 'home.courseOrder'
|
||||||
|
where c.status = 'published'
|
||||||
|
order by
|
||||||
|
case when c.id::text = coalesce(featured_setting.value #>> '{}', '') then 0 else 1 end,
|
||||||
|
coalesce((
|
||||||
|
select position::int
|
||||||
|
from jsonb_array_elements_text(coalesce(order_setting.value, '[]'::jsonb)) with ordinality as ordered(id, position)
|
||||||
|
where ordered.id = c.id::text
|
||||||
|
), 999999),
|
||||||
|
c.published_at desc`;
|
||||||
|
|
||||||
|
if (!authenticated) {
|
||||||
|
const result = await pool.query(catalogue);
|
||||||
|
return { data: result.rows.map(withoutProtectedMedia) };
|
||||||
|
}
|
||||||
|
|
||||||
const result = await pool.query(
|
const result = await pool.query(
|
||||||
`${courseSelect()}
|
`select base.*, coalesce(progress.progress, 0)::int as progress, progress."lastActivity"
|
||||||
left join platform_settings featured_setting on featured_setting.key = 'home.featuredCourseId'
|
from (${catalogue}) base
|
||||||
left join platform_settings order_setting on order_setting.key = 'home.courseOrder'
|
left join lateral (
|
||||||
where c.status = 'published'
|
select
|
||||||
order by
|
case when count(l.id) = 0 then 0
|
||||||
case when c.id::text = coalesce(featured_setting.value #>> '{}', '') then 0 else 1 end,
|
else floor(100.0 * count(l.id) filter (where lp.completed_at is not null) / count(l.id))::int end as progress,
|
||||||
coalesce((
|
max(lp.updated_at) as "lastActivity"
|
||||||
select position::int
|
from lessons l
|
||||||
from jsonb_array_elements_text(coalesce(order_setting.value, '[]'::jsonb)) with ordinality as ordered(id, position)
|
left join lesson_progress lp on lp.lesson_id = l.id and lp.user_id = $1
|
||||||
where ordered.id = c.id::text
|
where l.course_id = base.id
|
||||||
), 999999),
|
) progress on true`,
|
||||||
c.published_at desc`,
|
[request.user.id],
|
||||||
);
|
);
|
||||||
return { data: authenticated ? result.rows : result.rows.map(withoutProtectedMedia) };
|
return { data: result.rows };
|
||||||
});
|
});
|
||||||
|
|
||||||
// Paths intentionally reference existing courses instead of copying them.
|
// Paths intentionally reference existing courses instead of copying them.
|
||||||
@@ -247,6 +272,19 @@ export const courseRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
return { data: result.rows };
|
return { data: result.rows };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.post('/:courseId/view', { preHandler: app.authenticate }, async (request, reply) => {
|
||||||
|
const { courseId } = paramsSchema.parse(request.params);
|
||||||
|
const result = await pool.query<{ views: number }>(
|
||||||
|
`update courses
|
||||||
|
set view_count = view_count + 1
|
||||||
|
where id = $1 and status = 'published'
|
||||||
|
returning view_count as views`,
|
||||||
|
[courseId],
|
||||||
|
);
|
||||||
|
if (!result.rows[0]) return reply.code(404).send({ error: 'Curso não encontrado.' });
|
||||||
|
return { data: result.rows[0] };
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/:courseId', async (request, reply) => {
|
app.get('/:courseId', async (request, reply) => {
|
||||||
const authenticated = await hasSession(request);
|
const authenticated = await hasSession(request);
|
||||||
const { courseId } = paramsSchema.parse(request.params);
|
const { courseId } = paramsSchema.parse(request.params);
|
||||||
|
|||||||
52
server/src/routes/downloads.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import type { FastifyPluginAsync } from 'fastify';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { pool } from '../db/pool.js';
|
||||||
|
|
||||||
|
const paramsSchema = z.object({ assetId: z.string().uuid() });
|
||||||
|
|
||||||
|
export const downloadRoutes: FastifyPluginAsync = async (app) => {
|
||||||
|
const authenticated = { preHandler: app.authenticate };
|
||||||
|
|
||||||
|
app.get('/', authenticated, async (request) => {
|
||||||
|
const result = await pool.query(
|
||||||
|
`select a.id, a.name, a.kind, a.url, a.size_bytes as "sizeBytes",
|
||||||
|
a.description, a.created_at as "createdAt",
|
||||||
|
c.id as "courseId", c.title as "courseTitle",
|
||||||
|
lesson.position as "lessonNumber",
|
||||||
|
dh.downloaded_at as "downloadedAt"
|
||||||
|
from download_history dh
|
||||||
|
join assets a on a.id = dh.asset_id
|
||||||
|
left join lessons lesson on lesson.id = a.lesson_id
|
||||||
|
left join courses c on c.id = coalesce(a.course_id, lesson.course_id)
|
||||||
|
where dh.user_id = $1
|
||||||
|
order by dh.downloaded_at desc
|
||||||
|
limit 200`,
|
||||||
|
[request.user.id],
|
||||||
|
);
|
||||||
|
return { data: result.rows };
|
||||||
|
});
|
||||||
|
|
||||||
|
app.post('/:assetId', authenticated, async (request, reply) => {
|
||||||
|
const { assetId } = paramsSchema.parse(request.params);
|
||||||
|
const result = await pool.query<{ course_status: string; instructor_id: string }>(
|
||||||
|
`select c.status as course_status, c.instructor_id
|
||||||
|
from assets a
|
||||||
|
left join lessons lesson on lesson.id = a.lesson_id
|
||||||
|
left join courses c on c.id = coalesce(a.course_id, lesson.course_id)
|
||||||
|
where a.id = $1`,
|
||||||
|
[assetId],
|
||||||
|
);
|
||||||
|
const asset = result.rows[0];
|
||||||
|
if (!asset) return reply.code(404).send({ error: 'Material não encontrado.' });
|
||||||
|
if (asset.course_status !== 'published' && request.user.role !== 'admin' && asset.instructor_id !== request.user.id) {
|
||||||
|
return reply.code(404).send({ error: 'Material não encontrado.' });
|
||||||
|
}
|
||||||
|
|
||||||
|
await pool.query(
|
||||||
|
`insert into download_history (user_id, asset_id) values ($1, $2)
|
||||||
|
on conflict (user_id, asset_id) do update set downloaded_at = now()`,
|
||||||
|
[request.user.id, assetId],
|
||||||
|
);
|
||||||
|
return reply.code(204).send();
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -22,6 +22,10 @@ const commentSchema = z.object({
|
|||||||
});
|
});
|
||||||
const commentParamsSchema = z.object({ commentId: z.string().uuid() });
|
const commentParamsSchema = z.object({ commentId: z.string().uuid() });
|
||||||
const replySchema = z.object({ text: z.string().trim().min(1).max(4000) });
|
const replySchema = z.object({ text: z.string().trim().min(1).max(4000) });
|
||||||
|
const communityQuerySchema = z.object({
|
||||||
|
limit: z.coerce.number().int().min(1).max(100).default(50),
|
||||||
|
offset: z.coerce.number().int().min(0).default(0),
|
||||||
|
});
|
||||||
|
|
||||||
const ensurePublishedCourse = async (courseId: string) => {
|
const ensurePublishedCourse = async (courseId: string) => {
|
||||||
const result = await pool.query(
|
const result = await pool.query(
|
||||||
@@ -38,6 +42,25 @@ const canViewCourseComments = async (courseId: string, user: { id: string; role:
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const learningRoutes: FastifyPluginAsync = async (app) => {
|
export const learningRoutes: FastifyPluginAsync = async (app) => {
|
||||||
|
// Public, paginated feed used by the community screen. Individual course
|
||||||
|
// threads remain authenticated because they are part of the lesson area.
|
||||||
|
app.get('/community/comments', async (request) => {
|
||||||
|
const { limit, offset } = communityQuerySchema.parse(request.query);
|
||||||
|
const result = await pool.query(
|
||||||
|
`select c.id, c.course_id as "courseId", c.lesson_id as "lessonId", c.body as text,
|
||||||
|
c.created_at as "createdAt", u.display_name as "user",
|
||||||
|
cr.body as reply, cr.created_at as "replyCreatedAt"
|
||||||
|
from comments c
|
||||||
|
join users u on u.id = c.author_id
|
||||||
|
join courses co on co.id = c.course_id and co.status = 'published'
|
||||||
|
left join comment_replies cr on cr.comment_id = c.id
|
||||||
|
order by c.created_at desc
|
||||||
|
limit $1 offset $2`,
|
||||||
|
[limit, offset],
|
||||||
|
);
|
||||||
|
return { data: result.rows };
|
||||||
|
});
|
||||||
|
|
||||||
const canModerateComment = async (commentId: string, user: { id: string; role: string }) => {
|
const canModerateComment = async (commentId: string, user: { id: string; role: string }) => {
|
||||||
const result = await pool.query<{ instructor_id: string }>(
|
const result = await pool.query<{ instructor_id: string }>(
|
||||||
`select c.instructor_id
|
`select c.instructor_id
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ async function insertAssets(client: PoolClient, parent: { courseId?: string; les
|
|||||||
|
|
||||||
async function assertActiveCategory(category: string) {
|
async function assertActiveCategory(category: string) {
|
||||||
const result = await pool.query('select 1 from course_categories where name = $1 and is_active', [category]);
|
const result = await pool.query('select 1 from course_categories where name = $1 and is_active', [category]);
|
||||||
if (!result.rowCount) throw new CourseContentConflict('Selecione uma trilha ativa criada pelo superadmin.');
|
if (!result.rowCount) throw new CourseContentConflict('Selecione uma trilha ativa criada pelo admin.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertPublishable(input: CourseInput) {
|
function assertPublishable(input: CourseInput) {
|
||||||
@@ -185,8 +185,18 @@ export const manageCourseRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
const filters = request.user.role === 'admin'
|
const filters = request.user.role === 'admin'
|
||||||
? { sql: "where c.status <> 'archived' order by c.created_at desc", values: [] as string[] }
|
? { sql: "where c.status <> 'archived' order by c.created_at desc", values: [] as string[] }
|
||||||
: { sql: "where c.instructor_id = $1 and c.status <> 'archived' order by c.created_at desc", values: [request.user.id] };
|
: { sql: "where c.instructor_id = $1 and c.status <> 'archived' order by c.created_at desc", values: [request.user.id] };
|
||||||
const result = await pool.query(`${courseSelect(false, true)} ${filters.sql}`, filters.values);
|
const withLearners = await pool.query(
|
||||||
return { data: result.rows };
|
`select base.*, coalesce((
|
||||||
|
select count(distinct lp.user_id)
|
||||||
|
from lessons l
|
||||||
|
join lesson_progress lp on lp.lesson_id = l.id
|
||||||
|
where l.course_id = base.id
|
||||||
|
), 0)::int as learners
|
||||||
|
from (${courseSelect(false, true)} ${filters.sql}) base
|
||||||
|
order by base."createdAt" desc`,
|
||||||
|
filters.values,
|
||||||
|
);
|
||||||
|
return { data: withLearners.rows };
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/analytics', manageAccess, async (request) => {
|
app.get('/analytics', manageAccess, async (request) => {
|
||||||
@@ -197,7 +207,10 @@ export const manageCourseRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
count(distinct l.id)::int as "lessons",
|
count(distinct l.id)::int as "lessons",
|
||||||
count(distinct lp.user_id)::int as "learners",
|
count(distinct lp.user_id)::int as "learners",
|
||||||
count(distinct lp.lesson_id) filter (where lp.completed_at is not null)::int as "completedLessons",
|
count(distinct lp.lesson_id) filter (where lp.completed_at is not null)::int as "completedLessons",
|
||||||
count(distinct cm.id)::int as "comments"
|
count(distinct cm.id)::int as "comments",
|
||||||
|
count(distinct cm.id) filter (where not exists (
|
||||||
|
select 1 from comment_replies cr where cr.comment_id = cm.id
|
||||||
|
))::int as "unansweredComments"
|
||||||
from courses c
|
from courses c
|
||||||
left join lessons l on l.course_id = c.id
|
left join lessons l on l.course_id = c.id
|
||||||
left join lesson_progress lp on lp.lesson_id = l.id
|
left join lesson_progress lp on lp.lesson_id = l.id
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import { courseSelect } from './courses.js';
|
|||||||
|
|
||||||
const profileParamsSchema = z.object({ profileId: z.string().uuid() });
|
const profileParamsSchema = z.object({ profileId: z.string().uuid() });
|
||||||
const instructorParamsSchema = z.object({ instructorId: z.string().uuid() });
|
const instructorParamsSchema = z.object({ instructorId: z.string().uuid() });
|
||||||
|
const instructorListSchema = z.object({
|
||||||
|
q: z.string().trim().max(120).optional().default(''),
|
||||||
|
});
|
||||||
|
|
||||||
const optionalUrl = z.union([z.string().url().max(500), z.literal(''), z.null()]).optional()
|
const optionalUrl = z.union([z.string().url().max(500), z.literal(''), z.null()]).optional()
|
||||||
.transform((value) => value || null);
|
.transform((value) => value || null);
|
||||||
@@ -124,6 +127,24 @@ export const profileRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
return getPublicProfile(profileId, reply);
|
return getPublicProfile(profileId, reply);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/instructors', async (request) => {
|
||||||
|
const { q } = instructorListSchema.parse(request.query);
|
||||||
|
const result = await pool.query(
|
||||||
|
`select u.id, u.display_name as name, u.role,
|
||||||
|
u.avatar_image_url as "avatarImageUrl",
|
||||||
|
u.profile_headline as headline,
|
||||||
|
(select count(*)::int from courses c
|
||||||
|
where c.instructor_id = u.id and c.status = 'published') as "courseCount"
|
||||||
|
from users u
|
||||||
|
where u.profile_is_public and u.is_active
|
||||||
|
and u.role in ('instructor', 'admin')
|
||||||
|
and ($1 = '' or u.display_name ilike $2 or u.profile_headline ilike $2)
|
||||||
|
order by u.display_name`,
|
||||||
|
[q, `%${q}%`],
|
||||||
|
);
|
||||||
|
return { data: result.rows };
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/instructors/:instructorId', async (request, reply) => {
|
app.get('/instructors/:instructorId', async (request, reply) => {
|
||||||
const { instructorId } = instructorParamsSchema.parse(request.params);
|
const { instructorId } = instructorParamsSchema.parse(request.params);
|
||||||
return getPublicProfile(instructorId, reply, true);
|
return getPublicProfile(instructorId, reply, true);
|
||||||
|
|||||||
40
server/src/routes/saved-courses.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import type { FastifyPluginAsync } from 'fastify';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { pool } from '../db/pool.js';
|
||||||
|
|
||||||
|
const paramsSchema = z.object({ courseId: z.string().uuid() });
|
||||||
|
|
||||||
|
export const savedCourseRoutes: FastifyPluginAsync = async (app) => {
|
||||||
|
const authenticated = { preHandler: app.authenticate };
|
||||||
|
|
||||||
|
app.get('/', authenticated, async (request) => {
|
||||||
|
const result = await pool.query<{ courseId: string; createdAt: string }>(
|
||||||
|
`select sc.course_id as "courseId", sc.created_at as "createdAt"
|
||||||
|
from saved_courses sc
|
||||||
|
join courses c on c.id = sc.course_id and c.status = 'published'
|
||||||
|
where sc.user_id = $1
|
||||||
|
order by sc.created_at desc`,
|
||||||
|
[request.user.id],
|
||||||
|
);
|
||||||
|
return { data: result.rows };
|
||||||
|
});
|
||||||
|
|
||||||
|
app.put('/:courseId', authenticated, async (request, reply) => {
|
||||||
|
const { courseId } = paramsSchema.parse(request.params);
|
||||||
|
const course = await pool.query("select id from courses where id = $1 and status = 'published'", [courseId]);
|
||||||
|
if (!course.rowCount) return reply.code(404).send({ error: 'Curso não encontrado.' });
|
||||||
|
|
||||||
|
await pool.query(
|
||||||
|
`insert into saved_courses (user_id, course_id) values ($1, $2)
|
||||||
|
on conflict (user_id, course_id) do nothing`,
|
||||||
|
[request.user.id, courseId],
|
||||||
|
);
|
||||||
|
return reply.code(204).send();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.delete('/:courseId', authenticated, async (request, reply) => {
|
||||||
|
const { courseId } = paramsSchema.parse(request.params);
|
||||||
|
await pool.query('delete from saved_courses where user_id = $1 and course_id = $2', [request.user.id, courseId]);
|
||||||
|
return reply.code(204).send();
|
||||||
|
});
|
||||||
|
};
|
||||||
76
server/src/routes/search.ts
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import type { FastifyPluginAsync } from 'fastify';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import { pool } from '../db/pool.js';
|
||||||
|
import { courseSelect, withoutProtectedMedia } from './courses.js';
|
||||||
|
|
||||||
|
const searchSchema = z.object({
|
||||||
|
q: z.string().trim().max(120).optional().default(''),
|
||||||
|
area: z.string().trim().max(120).optional().default(''),
|
||||||
|
limit: z.coerce.number().int().min(1).max(100).default(50),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const searchRoutes: FastifyPluginAsync = async (app) => {
|
||||||
|
app.get('/', async (request) => {
|
||||||
|
const { q, area, limit } = searchSchema.parse(request.query);
|
||||||
|
const term = `%${q}%`;
|
||||||
|
|
||||||
|
const [courses, paths, professors] = await Promise.all([
|
||||||
|
pool.query(
|
||||||
|
`${courseSelect()}
|
||||||
|
where c.status = 'published'
|
||||||
|
and ($1 = '' or c.title ilike $2 or c.description ilike $2 or c.category ilike $2 or u.display_name ilike $2)
|
||||||
|
and ($3 = '' or c.category = $3)
|
||||||
|
order by c.published_at desc
|
||||||
|
limit $4`,
|
||||||
|
[q, term, area, limit],
|
||||||
|
),
|
||||||
|
pool.query(
|
||||||
|
`select
|
||||||
|
p.id, p.title, p.description,
|
||||||
|
coalesce(p.cover_image_url, (
|
||||||
|
select value #>> '{}' from platform_settings where key = 'media.defaultCoverImageUrl'
|
||||||
|
)) as "coverImageUrl",
|
||||||
|
p.cover_image_zoom as "coverImageZoom",
|
||||||
|
p.cover_image_position_x as "coverImagePositionX",
|
||||||
|
p.cover_image_position_y as "coverImagePositionY",
|
||||||
|
coalesce(jsonb_agg(jsonb_build_object(
|
||||||
|
'id', c.id, 'title', c.title, 'category', c.category,
|
||||||
|
'coverImageUrl', coalesce(c.cover_image_url, (
|
||||||
|
select value #>> '{}' from platform_settings where key = 'media.defaultCoverImageUrl'
|
||||||
|
)), 'position', pc.position
|
||||||
|
) order by pc.position) filter (where c.id is not null), '[]'::jsonb) as courses
|
||||||
|
from learning_paths p
|
||||||
|
join learning_path_courses pc on pc.learning_path_id = p.id
|
||||||
|
join courses c on c.id = pc.course_id and c.status = 'published'
|
||||||
|
where p.status = 'published'
|
||||||
|
and ($1 = '' or p.title ilike $2 or p.description ilike $2)
|
||||||
|
group by p.id
|
||||||
|
order by p.published_at desc
|
||||||
|
limit $3`,
|
||||||
|
[q, term, limit],
|
||||||
|
),
|
||||||
|
pool.query(
|
||||||
|
`select u.id, u.display_name as name, u.role,
|
||||||
|
u.avatar_image_url as "avatarImageUrl",
|
||||||
|
u.profile_headline as headline,
|
||||||
|
(select count(*)::int from courses c
|
||||||
|
where c.instructor_id = u.id and c.status = 'published') as "courseCount"
|
||||||
|
from users u
|
||||||
|
where u.profile_is_public and u.is_active
|
||||||
|
and u.role in ('instructor', 'admin')
|
||||||
|
and ($1 = '' or u.display_name ilike $2 or u.profile_headline ilike $2)
|
||||||
|
order by u.display_name
|
||||||
|
limit $3`,
|
||||||
|
[q, term, limit],
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
courses: courses.rows.map(withoutProtectedMedia),
|
||||||
|
paths: paths.rows,
|
||||||
|
professors: professors.rows,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -34,13 +34,35 @@ export interface ManagedUser {
|
|||||||
role: ApiRole;
|
role: ApiRole;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
lastAccessAt: string | null;
|
||||||
}
|
}
|
||||||
export interface ManagedUserDetail extends ManagedUser {
|
export interface ManagedUserDetail extends ManagedUser {
|
||||||
completedLessons: number;
|
completedLessons: number;
|
||||||
lastLearningAt: string | null;
|
lastLearningAt: string | null;
|
||||||
}
|
}
|
||||||
export interface PlatformAnalytics { totalUsers: number; activeUsers: number; publishedCourses: number; completedLessons: number; comments: number; }
|
export interface PlatformAnalytics { totalUsers: number; activeUsers: number; publishedCourses: number; completedLessons: number; comments: number; pendingInvitations: number; }
|
||||||
export interface InstructorAnalytics { courses: number; lessons: number; learners: number; completedLessons: number; comments: number; }
|
export interface InstructorAnalytics { courses: number; lessons: number; learners: number; completedLessons: number; comments: number; unansweredComments: number; }
|
||||||
|
export interface InstructorSummary {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
role: ApiRole;
|
||||||
|
avatarImageUrl: string | null;
|
||||||
|
headline: string;
|
||||||
|
courseCount: number;
|
||||||
|
}
|
||||||
|
export interface DownloadRecord {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
kind: 'document' | 'spreadsheet' | 'archive' | 'image' | 'link';
|
||||||
|
url: string;
|
||||||
|
sizeBytes: number | null;
|
||||||
|
description: string;
|
||||||
|
createdAt: string;
|
||||||
|
courseId: string | null;
|
||||||
|
courseTitle: string | null;
|
||||||
|
lessonNumber: number | null;
|
||||||
|
downloadedAt: string;
|
||||||
|
}
|
||||||
export interface AuditEntry { id: string; action: string; subjectType: string; subjectId: string | null; metadata: Record<string, unknown>; createdAt: string; actorName: string; }
|
export interface AuditEntry { id: string; action: string; subjectType: string; subjectId: string | null; metadata: Record<string, unknown>; createdAt: string; actorName: string; }
|
||||||
export interface BunnyVideo { id: string; title: string; status: 'processing' | 'ready' | 'failed'; providerStatus: number; encodeProgress: number; durationSeconds: number | null; }
|
export interface BunnyVideo { id: string; title: string; status: 'processing' | 'ready' | 'failed'; providerStatus: number; encodeProgress: number; durationSeconds: number | null; }
|
||||||
export interface LessonPlayback { provider: string; kind: 'embed' | 'video'; embedUrl?: string; source?: string; expiresAt?: string; }
|
export interface LessonPlayback { provider: string; kind: 'embed' | 'video'; embedUrl?: string; source?: string; expiresAt?: string; }
|
||||||
@@ -239,6 +261,7 @@ export const profileApi = {
|
|||||||
async update(input: ProfileInput) { return apiRequest<{ data: Profile }>('/profiles/me', { method: 'PATCH', body: JSON.stringify(input) }); },
|
async update(input: ProfileInput) { return apiRequest<{ data: Profile }>('/profiles/me', { method: 'PATCH', body: JSON.stringify(input) }); },
|
||||||
async public(profileId: string) { return apiRequest<{ data: Profile & { courses: unknown[] } }>(`/profiles/${profileId}`); },
|
async public(profileId: string) { return apiRequest<{ data: Profile & { courses: unknown[] } }>(`/profiles/${profileId}`); },
|
||||||
async instructor(instructorId: string) { return apiRequest<{ data: Profile & { courses: unknown[] } }>(`/profiles/instructors/${instructorId}`); },
|
async instructor(instructorId: string) { return apiRequest<{ data: Profile & { courses: unknown[] } }>(`/profiles/instructors/${instructorId}`); },
|
||||||
|
async instructors() { return apiRequest<{ data: InstructorSummary[] }>('/profiles/instructors'); },
|
||||||
};
|
};
|
||||||
|
|
||||||
export const instructorApi = {
|
export const instructorApi = {
|
||||||
@@ -267,4 +290,18 @@ export const courseApi = {
|
|||||||
async playback(courseId: string, lessonId: string) {
|
async playback(courseId: string, lessonId: string) {
|
||||||
return apiRequest<{ data: LessonPlayback }>(`/courses/${courseId}/lessons/${lessonId}/playback`);
|
return apiRequest<{ data: LessonPlayback }>(`/courses/${courseId}/lessons/${lessonId}/playback`);
|
||||||
},
|
},
|
||||||
|
async trackView(courseId: string) {
|
||||||
|
return apiRequest<{ data: { views: number } }>(`/courses/${courseId}/view`, { method: 'POST' });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const savedCourseApi = {
|
||||||
|
async list() { return apiRequest<{ data: Array<{ courseId: string; createdAt: string }> }>('/saved-courses'); },
|
||||||
|
async save(courseId: string) { return apiRequest<void>(`/saved-courses/${courseId}`, { method: 'PUT' }); },
|
||||||
|
async remove(courseId: string) { return apiRequest<void>(`/saved-courses/${courseId}`, { method: 'DELETE' }); },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const downloadApi = {
|
||||||
|
async list() { return apiRequest<{ data: DownloadRecord[] }>('/downloads'); },
|
||||||
|
async record(assetId: string) { return apiRequest<void>(`/downloads/${assetId}`, { method: 'POST' }); },
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Attachment, AttachmentType, Comment, Course, Lesson, LessonMedia } from '../types';
|
import { Attachment, AttachmentType, Comment, Course, Lesson, LessonMedia } from '../types';
|
||||||
import { apiRequest } from './api';
|
import { apiRequest, courseApi, downloadApi, DownloadRecord, InstructorSummary } from './api';
|
||||||
|
|
||||||
export const initDB = async (): Promise<void> => undefined;
|
export const initDB = async (): Promise<void> => undefined;
|
||||||
|
|
||||||
@@ -24,6 +24,9 @@ export type ApiCourse = {
|
|||||||
coverImagePositionY: number;
|
coverImagePositionY: number;
|
||||||
status: 'draft' | 'published' | 'archived';
|
status: 'draft' | 'published' | 'archived';
|
||||||
progress?: number;
|
progress?: number;
|
||||||
|
views?: number;
|
||||||
|
learners?: number;
|
||||||
|
updatedAt?: string;
|
||||||
lastActivity?: string | null;
|
lastActivity?: string | null;
|
||||||
instructor: { id: string; name: string };
|
instructor: { id: string; name: string };
|
||||||
lessons: Array<{
|
lessons: Array<{
|
||||||
@@ -133,6 +136,9 @@ export const toCourse = (course: ApiCourse): Course => ({
|
|||||||
instructorId: course.instructor.id,
|
instructorId: course.instructor.id,
|
||||||
status: course.status === 'draft' ? 'draft' : 'published',
|
status: course.status === 'draft' ? 'draft' : 'published',
|
||||||
progress: course.progress,
|
progress: course.progress,
|
||||||
|
views: course.views,
|
||||||
|
learners: course.learners,
|
||||||
|
updatedAt: course.updatedAt,
|
||||||
lastActivity: course.lastActivity || undefined,
|
lastActivity: course.lastActivity || undefined,
|
||||||
duration: toCourseDuration(course.lessons),
|
duration: toCourseDuration(course.lessons),
|
||||||
lessons: course.lessons.map((lesson): Lesson => {
|
lessons: course.lessons.map((lesson): Lesson => {
|
||||||
@@ -367,4 +373,50 @@ export const saveLessonProgress = async (lessonId: string, watchedSeconds: numbe
|
|||||||
await apiRequest(`/lessons/${lessonId}/progress`, { method: 'PUT', body: JSON.stringify({ watchedSeconds }) });
|
await apiRequest(`/lessons/${lessonId}/progress`, { method: 'PUT', body: JSON.stringify({ watchedSeconds }) });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const incrementViews = async (_courseId: string): Promise<void> => undefined;
|
export const incrementViews = async (courseId: string): Promise<void> => {
|
||||||
|
await courseApi.trackView(courseId).catch(() => undefined);
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchResults = {
|
||||||
|
courses: Course[];
|
||||||
|
paths: PublicLearningPath[];
|
||||||
|
professors: InstructorSummary[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const searchCatalog = async (query: string, area = ''): Promise<SearchResults> => {
|
||||||
|
const params = new URLSearchParams({ q: query });
|
||||||
|
if (area) params.set('area', area);
|
||||||
|
const response = await apiRequest<{ data: { courses: ApiCourse[]; paths: PublicLearningPath[]; professors: InstructorSummary[] } }>(`/search?${params.toString()}`);
|
||||||
|
return {
|
||||||
|
...response.data,
|
||||||
|
courses: response.data.courses.map(toCourse),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DownloadHistoryEntry = {
|
||||||
|
attachment: Attachment;
|
||||||
|
courseId: string;
|
||||||
|
courseTitle: string;
|
||||||
|
lessonNumber: number | null;
|
||||||
|
downloadedAt: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDownloadHistory = async (): Promise<DownloadHistoryEntry[]> => {
|
||||||
|
const response = await downloadApi.list();
|
||||||
|
return response.data.map((record: DownloadRecord) => ({
|
||||||
|
attachment: toAttachment(record),
|
||||||
|
courseId: record.courseId || '',
|
||||||
|
courseTitle: record.courseTitle || 'Curso removido',
|
||||||
|
lessonNumber: record.lessonNumber,
|
||||||
|
downloadedAt: record.downloadedAt,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const recordDownloadHistory = async (assetId: string): Promise<void> => {
|
||||||
|
await downloadApi.record(assetId);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getCommunityComments = async (limit = 100, offset = 0): Promise<Comment[]> => {
|
||||||
|
const response = await apiRequest<{ data: ApiComment[] }>(`/community/comments?limit=${limit}&offset=${offset}`);
|
||||||
|
return response.data.map(toComment);
|
||||||
|
};
|
||||||
|
|||||||
900
styles/app.css
Normal file
@@ -0,0 +1,900 @@
|
|||||||
|
/*
|
||||||
|
* Compor Academy — componentes.
|
||||||
|
* Cores e medidas vêm de styles/tokens.css; não declare cores soltas aqui.
|
||||||
|
* Referência: design/prototype-reference.html (versão UI Skills).
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ---------- base ---------- */
|
||||||
|
*, *::before, *::after { box-sizing: border-box }
|
||||||
|
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100% }
|
||||||
|
body {
|
||||||
|
margin: 0; min-height: 100vh;
|
||||||
|
background: var(--bg); color: var(--fg);
|
||||||
|
font-family: var(--font); font-size: 15px; line-height: 1.47; letter-spacing: -.012em;
|
||||||
|
-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
|
||||||
|
transition: background-color .35s var(--ease), color .35s var(--ease);
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, p, ol, ul, figure, dl, dd { margin: 0; padding: 0 }
|
||||||
|
ol, ul { list-style: none }
|
||||||
|
a { color: inherit; text-decoration: none }
|
||||||
|
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit }
|
||||||
|
button { background: none; border: 0; cursor: pointer; padding: 0 }
|
||||||
|
button:disabled { cursor: default }
|
||||||
|
img { display: block; max-width: 100% }
|
||||||
|
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px }
|
||||||
|
h1, h2, h3 { font-variation-settings: "opsz" 32; text-wrap: balance }
|
||||||
|
p, small { text-wrap: pretty }
|
||||||
|
.ph { flex: none; vertical-align: -.125em }
|
||||||
|
.num { font-variant-numeric: tabular-nums }
|
||||||
|
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0 }
|
||||||
|
.muted { color: var(--fg-2) }
|
||||||
|
.faint { color: var(--fg-3) }
|
||||||
|
.bad-text { color: var(--bad) }
|
||||||
|
.ok-text { color: var(--ok) }
|
||||||
|
[hidden] { display: none !important }
|
||||||
|
|
||||||
|
.wrap {
|
||||||
|
max-width: 1180px; margin: 0 auto;
|
||||||
|
padding-left: max(24px, env(safe-area-inset-left, 0px));
|
||||||
|
padding-right: max(24px, env(safe-area-inset-right, 0px));
|
||||||
|
}
|
||||||
|
.page { padding-block: 40px 96px; min-height: 60vh }
|
||||||
|
.page.has-hero { padding-top: 36px }
|
||||||
|
|
||||||
|
/* ---------- motion ---------- */
|
||||||
|
@keyframes rise { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
|
||||||
|
@keyframes mfade { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
|
||||||
|
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
|
||||||
|
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
|
||||||
|
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.97) } to { opacity: 1; transform: none } }
|
||||||
|
@keyframes grow { from { transform: scaleX(0) } to { transform: scaleX(1) } }
|
||||||
|
@keyframes fill { to { transform: scaleX(1) } }
|
||||||
|
@keyframes spin { to { transform: rotate(360deg) } }
|
||||||
|
.enter { animation: rise .28s var(--ease) }
|
||||||
|
.enter .prog i, .enter .inprog i { transform-origin: left; animation: grow .9s var(--ease) .2s both }
|
||||||
|
.spin { animation: spin 1.2s linear infinite }
|
||||||
|
|
||||||
|
/* ---------- buttons ---------- */
|
||||||
|
.btn {
|
||||||
|
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
||||||
|
height: 36px; padding: 0 16px; border-radius: 980px;
|
||||||
|
background: var(--blue); color: var(--white); font-size: 14px; font-weight: 500; white-space: nowrap;
|
||||||
|
transition: background-color .2s, transform .15s var(--ease), opacity .2s;
|
||||||
|
}
|
||||||
|
@media (hover: hover) { .btn:hover { background: var(--blue-press) } }
|
||||||
|
.btn:active, .iconbtn:active { transform: scale(.96) }
|
||||||
|
.btn:disabled { opacity: .5; transform: none }
|
||||||
|
.btn.lg { height: 44px; padding: 0 22px; font-size: 16px }
|
||||||
|
.btn.sec { background: var(--bg-2); color: var(--fg) }
|
||||||
|
@media (hover: hover) { .btn.sec:hover { background: var(--bg-3) } }
|
||||||
|
.btn.ghost { background: transparent; color: var(--blue-text); padding: 0 4px }
|
||||||
|
@media (hover: hover) { .btn.ghost:hover { background: transparent; text-decoration: underline } }
|
||||||
|
.btn.danger { background: var(--bg-2); color: var(--bad) }
|
||||||
|
@media (hover: hover) { .btn.danger:hover { background: var(--bg-3) } }
|
||||||
|
.btn.block { width: 100% }
|
||||||
|
.btn .ph { font-size: 15px }
|
||||||
|
.iconbtn {
|
||||||
|
width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
|
||||||
|
font-size: 18px; color: var(--fg); flex: none;
|
||||||
|
transition: background-color .2s, transform .15s var(--ease), opacity .2s;
|
||||||
|
}
|
||||||
|
@media (hover: hover) { .iconbtn:hover { background: var(--bg-2) } }
|
||||||
|
.iconbtn:disabled { opacity: .35 }
|
||||||
|
.iconbtn.danger { color: var(--bad) }
|
||||||
|
.link { color: var(--blue-text); display: inline-flex; align-items: center; gap: 2px }
|
||||||
|
@media (hover: hover) { .link:hover { text-decoration: underline } }
|
||||||
|
.link .ph { font-size: 12px }
|
||||||
|
|
||||||
|
/* ---------- page heads ---------- */
|
||||||
|
.ptitle { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 32px }
|
||||||
|
.ptitle h1 { font-size: 40px; line-height: 1.05; font-weight: 700; letter-spacing: -.035em }
|
||||||
|
.ptitle p { color: var(--fg-2); margin-top: 6px; font-size: 15px }
|
||||||
|
.ptitle .acts { display: flex; gap: 8px; flex-wrap: wrap }
|
||||||
|
.crumb { font-size: 13px; color: var(--fg-3); display: flex; gap: 6px; align-items: center; margin-bottom: 16px; flex-wrap: wrap }
|
||||||
|
@media (hover: hover) { .crumb a:hover { color: var(--fg) } }
|
||||||
|
.crumb .ph { font-size: 11px }
|
||||||
|
.shelf { margin-top: 56px }
|
||||||
|
.shelf:first-child { margin-top: 0 }
|
||||||
|
.shelf > header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 16px }
|
||||||
|
.shelf h2 { font-size: 24px; font-weight: 700; letter-spacing: -.025em }
|
||||||
|
.shelf > header .count { color: var(--fg-2); font-size: 14px }
|
||||||
|
.note { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--r-s); background: var(--bg-2); font-size: 14px }
|
||||||
|
.note b { font-weight: 600 }
|
||||||
|
.empty { padding: 48px 0; text-align: center; color: var(--fg-2) }
|
||||||
|
.loading { padding: 96px 0; display: grid; place-items: center; color: var(--fg-3); font-size: 24px }
|
||||||
|
|
||||||
|
/* ---------- segmented, tabs, chips, search ---------- */
|
||||||
|
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg-2); gap: 2px; overflow-x: auto; max-width: 100%; scrollbar-width: none }
|
||||||
|
.seg button { height: 30px; padding: 0 14px; border-radius: 8px; font-size: 13px; color: var(--fg-2); white-space: nowrap; transition: background-color .2s, box-shadow .2s }
|
||||||
|
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--fg); font-weight: 500 }
|
||||||
|
:root.dark .seg button[aria-pressed="true"] { background: var(--bg-3) }
|
||||||
|
.tabs { display: flex; gap: 8px; margin-top: 28px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none }
|
||||||
|
.tabs::-webkit-scrollbar { display: none }
|
||||||
|
.tabs button { padding: 8px 14px; border-radius: 980px; font-size: 14px; color: var(--fg-2); white-space: nowrap; transition: color .2s, background-color .2s }
|
||||||
|
.tabs button[aria-selected="true"] { background: var(--bg-2); color: var(--fg); font-weight: 500 }
|
||||||
|
.tabs button span { color: var(--fg-3); margin-left: 4px }
|
||||||
|
.pane { padding-top: 20px }
|
||||||
|
.chips2 { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 8px }
|
||||||
|
.chips2 button { height: 32px; padding: 0 14px; border-radius: 980px; background: var(--bg-2); font-size: 14px; transition: background-color .2s, transform .15s }
|
||||||
|
@media (hover: hover) { .chips2 button:hover { background: var(--bg-3) } }
|
||||||
|
.chips2 button:active { transform: scale(.96) }
|
||||||
|
.chips2 button[aria-pressed="true"] { background: var(--fg); color: var(--bg) }
|
||||||
|
.search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 10px; background: var(--bg-2); color: var(--fg-2); min-width: 0; width: 260px; max-width: 100% }
|
||||||
|
.search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; color: var(--fg); font-size: 14px }
|
||||||
|
.search input::-webkit-search-cancel-button { -webkit-appearance: none }
|
||||||
|
.bigsearch { width: 100%; height: 48px; border-radius: 12px; font-size: 17px; padding: 0 16px }
|
||||||
|
.bigsearch input { font-size: 17px }
|
||||||
|
.bigsearch .ph { font-size: 18px }
|
||||||
|
|
||||||
|
/* ---------- artwork: course covers and trilha posters ---------- */
|
||||||
|
.tr-midia { --cc: var(--c-midia); --co: var(--c-midia-on) }
|
||||||
|
.tr-conv { --cc: var(--c-conv); --co: var(--c-conv-on) }
|
||||||
|
.tr-oper { --cc: var(--c-oper); --co: var(--c-oper-on) }
|
||||||
|
.has-img { --co: var(--white) }
|
||||||
|
.art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit }
|
||||||
|
.cover {
|
||||||
|
position: relative; aspect-ratio: 16/10; max-width: 100%; border-radius: var(--r); overflow: hidden;
|
||||||
|
background: var(--cc); color: var(--co);
|
||||||
|
display: flex; flex-direction: column; justify-content: flex-end; padding: 16px 18px;
|
||||||
|
box-shadow: inset 0 0 0 1px var(--art-edge);
|
||||||
|
}
|
||||||
|
.cover .t { position: relative; font-size: 20px; line-height: 1.12; font-weight: 700; letter-spacing: -.025em; max-width: 90%; text-wrap: balance }
|
||||||
|
.cover.hp { padding-bottom: 34px }
|
||||||
|
.cover.big { aspect-ratio: 16/9; padding: 24px 28px }
|
||||||
|
.cover.big .t { font-size: 30px; max-width: 70% }
|
||||||
|
.cover.mini { padding: 0; border-radius: 10px }
|
||||||
|
.cover.mini .t, .cover.mini .inprog { display: none }
|
||||||
|
.cover .inprog, .poster .inprog {
|
||||||
|
position: absolute; left: 16px; right: 16px; bottom: 14px; height: 4px; border-radius: 2px;
|
||||||
|
background: color-mix(in srgb, var(--co) 28%, transparent); overflow: hidden; z-index: 1;
|
||||||
|
}
|
||||||
|
.poster .inprog { left: 18px; right: 18px; bottom: 16px }
|
||||||
|
.cover .inprog i, .poster .inprog i { display: block; height: 100%; background: var(--co); border-radius: 2px; transform-origin: left }
|
||||||
|
.has-img .inprog { box-shadow: 0 0 0 1px var(--art-progress-edge) }
|
||||||
|
.prog { height: 4px; border-radius: 2px; background: var(--bg-3); overflow: hidden; margin-top: 10px }
|
||||||
|
.prog i { display: block; height: 100%; background: var(--blue); border-radius: 2px }
|
||||||
|
.thumb { display: block; width: 44px; height: 28px; border-radius: 6px; background: var(--cc); flex: none; position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px var(--art-edge) }
|
||||||
|
|
||||||
|
.card { display: block; min-width: 0 }
|
||||||
|
.card .cover { transition: transform .18s ease-out }
|
||||||
|
.card .m { margin-top: 10px; font-size: 13px; color: var(--fg-2) }
|
||||||
|
.card .m b { display: block; color: var(--fg); font-size: 14px; font-weight: 600; margin-bottom: 1px }
|
||||||
|
.card .m .one { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
|
||||||
|
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 20px }
|
||||||
|
@media (max-width: 1180px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)) } }
|
||||||
|
@media (max-width: 720px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) } }
|
||||||
|
|
||||||
|
/* trilha posters: vertical 2:3, two real cards stacked behind */
|
||||||
|
.poster-card { position: relative; display: block; min-width: 0; isolation: isolate; padding-top: 14px }
|
||||||
|
.poster {
|
||||||
|
position: relative; z-index: 2; aspect-ratio: 2/3; max-width: 100%; border-radius: var(--r); overflow: hidden;
|
||||||
|
background: var(--cc); color: var(--co);
|
||||||
|
display: flex; flex-direction: column; justify-content: flex-end; padding: 18px 18px 20px;
|
||||||
|
box-shadow: inset 0 0 0 1px var(--art-edge); transition: transform .18s ease-out;
|
||||||
|
}
|
||||||
|
.poster > div { position: relative }
|
||||||
|
.poster .t { display: block; font-size: 26px; line-height: 1.08; font-weight: 700; letter-spacing: -.03em; text-wrap: balance }
|
||||||
|
.poster .n { display: block; margin-top: 10px; font-size: 13px; opacity: .72 }
|
||||||
|
.poster:has(.inprog) { padding-bottom: 34px }
|
||||||
|
.poster-card::before, .poster-card::after {
|
||||||
|
content: ""; position: absolute; top: 14px; left: 0; right: 0; aspect-ratio: 2/3; border-radius: var(--r);
|
||||||
|
pointer-events: none; transform-origin: top center; transition: transform .25s ease-out;
|
||||||
|
}
|
||||||
|
.poster-card::before { z-index: 1; background: color-mix(in srgb, var(--cc) 62%, var(--bg)); transform: translateY(-7px) scale(.92) }
|
||||||
|
.poster-card::after { z-index: 0; background: color-mix(in srgb, var(--cc) 32%, var(--bg)); transform: translateY(-14px) scale(.84) }
|
||||||
|
.tr-oper.poster-card::before { background: color-mix(in srgb, var(--cc) 94%, var(--fg) 6%) }
|
||||||
|
.tr-oper.poster-card::after { background: color-mix(in srgb, var(--cc) 97%, var(--fg) 3%) }
|
||||||
|
:root.dark .tr-midia.poster-card::before { background: color-mix(in srgb, var(--black) 82%, var(--fg) 18%) }
|
||||||
|
:root.dark .tr-midia.poster-card::after { background: color-mix(in srgb, var(--black) 90%, var(--fg) 10%) }
|
||||||
|
.pgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 20px }
|
||||||
|
@media (max-width: 1180px) { .pgrid { grid-template-columns: repeat(3, minmax(0, 1fr)) } }
|
||||||
|
|
||||||
|
@media (hover: hover) {
|
||||||
|
.card:hover .cover, .poster-card:hover .poster { transform: translateY(-2px) }
|
||||||
|
.poster-card:hover::before { transform: translateY(-10px) scale(.92) }
|
||||||
|
.poster-card:hover::after { transform: translateY(-19px) scale(.84) }
|
||||||
|
.poster-card:hover .poster { transform: translateY(-3px) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- rows (shelves) ---------- */
|
||||||
|
.rowhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px }
|
||||||
|
.rowhead h2 { font-size: 24px; font-weight: 700; letter-spacing: -.025em }
|
||||||
|
.rowhead .nav2 { display: flex; align-items: center; gap: 6px; opacity: 0; transition: opacity .25s }
|
||||||
|
.rowhead .nav2 .iconbtn { width: 30px; height: 30px; font-size: 14px; background: var(--bg-2) }
|
||||||
|
.rowhead .nav2:focus-within { opacity: 1 }
|
||||||
|
@media (hover: hover) { .shelf:hover .rowhead .nav2 { opacity: 1 } }
|
||||||
|
.shead { display: inline-flex; align-items: center; gap: 4px; color: var(--fg) }
|
||||||
|
.shead .ph { font-size: 16px; color: var(--fg-3); transition: transform .25s var(--ease), color .2s }
|
||||||
|
@media (hover: hover) { .shead:hover .ph { transform: translateX(3px); color: var(--fg) } }
|
||||||
|
.rail {
|
||||||
|
display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 3 * 20px) / 4); gap: 20px;
|
||||||
|
overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none;
|
||||||
|
overscroll-behavior-x: contain; padding: 8px 0 14px; margin: -8px 0 -14px;
|
||||||
|
}
|
||||||
|
.rail::-webkit-scrollbar { display: none }
|
||||||
|
.rail > * { scroll-snap-align: start }
|
||||||
|
.rail.wide { grid-auto-columns: calc((100% - 2 * 20px) / 3) }
|
||||||
|
.rail.tall { grid-auto-columns: calc((100% - 4 * 20px) / 5); padding-top: 20px; margin-top: -20px }
|
||||||
|
@media (max-width: 1180px) {
|
||||||
|
.rail { grid-auto-columns: calc((100% - 2 * 20px) / 3) }
|
||||||
|
.rail.wide { grid-auto-columns: calc((100% - 20px) / 2) }
|
||||||
|
.rail.tall { grid-auto-columns: calc((100% - 3 * 20px) / 4) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- people ---------- */
|
||||||
|
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px }
|
||||||
|
.pcard { border-radius: var(--r); padding: 22px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: var(--bg-2); transition: transform .18s ease-out, background-color .2s }
|
||||||
|
.pcard .av { margin-bottom: 14px; width: 64px; height: 64px; font-size: 22px }
|
||||||
|
.pcard b { font-size: 16px; font-weight: 600 }
|
||||||
|
.pcard small { color: var(--fg-2); font-size: 13px }
|
||||||
|
.pcard > span.num { margin-top: 12px; font-size: 13px; color: var(--fg-3) }
|
||||||
|
@media (hover: hover) { .pcard:hover { transform: translateY(-2px); background: var(--bg-3) } }
|
||||||
|
.person { display: flex; align-items: center; gap: 12px; min-width: 0 }
|
||||||
|
.person small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
.av { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-3); color: var(--fg); display: grid; place-items: center; font-size: 14px; font-weight: 600; flex: none; overflow: hidden; position: relative; letter-spacing: 0 }
|
||||||
|
.av img { width: 100%; height: 100%; object-fit: cover }
|
||||||
|
.av.sm { width: 30px; height: 30px; font-size: 12px }
|
||||||
|
.av.md { width: 72px; height: 72px; font-size: 24px }
|
||||||
|
.av.xl { width: 96px; height: 96px; font-size: 32px }
|
||||||
|
|
||||||
|
/* ---------- lists ---------- */
|
||||||
|
.list { display: grid; gap: 2px }
|
||||||
|
.row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 4px; border-radius: 12px; transition: background-color .2s; text-align: left; width: 100% }
|
||||||
|
.row .i { color: var(--fg-3); font-size: 14px; display: inline-flex; justify-content: center }
|
||||||
|
.row .t { font-weight: 500; min-width: 0 }
|
||||||
|
.row .t small { display: block; color: var(--fg-2); font-weight: 400; font-size: 13px }
|
||||||
|
.row .r { color: var(--fg-2); font-size: 13px; display: flex; gap: 14px; align-items: center; justify-content: flex-end }
|
||||||
|
@media (hover: hover) { a.row:hover, button.row:hover { background: var(--bg-2) } }
|
||||||
|
.done { color: var(--ok); display: inline-flex; align-items: center; gap: 6px }
|
||||||
|
.lessons .row { grid-template-columns: 28px minmax(0, 1fr) auto; padding: 11px 10px; border-radius: 10px }
|
||||||
|
.lessons .row[aria-current] { background: var(--bg-2) }
|
||||||
|
.lessons .row[aria-current] .i { color: var(--blue) }
|
||||||
|
.file { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0 }
|
||||||
|
.file .ic { width: 24px; height: 24px; display: grid; place-items: center; font-size: 20px; color: var(--fg-2) }
|
||||||
|
.file small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--fg-2); white-space: nowrap }
|
||||||
|
.state .ph { font-size: 16px }
|
||||||
|
.state.bad { color: var(--bad) }
|
||||||
|
.state .link { font-size: 14px; margin-left: 6px }
|
||||||
|
.ic-cnt { display: inline-flex; align-items: center; gap: 6px }
|
||||||
|
.ic-prof { display: inline-flex; color: var(--blue); font-size: 16px }
|
||||||
|
.cmeta { display: grid !important; grid-template-columns: 18px 44px; gap: 12px; align-items: center; justify-items: start }
|
||||||
|
|
||||||
|
/* ---------- layouts ---------- */
|
||||||
|
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 48px; align-items: start }
|
||||||
|
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr) } }
|
||||||
|
.side { display: flex; flex-direction: column; gap: 20px; min-width: 0 }
|
||||||
|
.box { border-radius: var(--r); padding: 20px; background: var(--bg-2); min-width: 0 }
|
||||||
|
.box h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px }
|
||||||
|
.box p.small { font-size: 14px; color: var(--fg-2) }
|
||||||
|
a.box { display: block; transition: transform .18s ease-out, background-color .2s }
|
||||||
|
@media (hover: hover) { a.box:hover { transform: translateY(-2px); background: var(--bg-3) } }
|
||||||
|
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px }
|
||||||
|
.kv dt { color: var(--fg-2) }
|
||||||
|
.kv dd { margin: 0; text-align: right }
|
||||||
|
.contbox { display: grid; grid-template-columns: minmax(0, 180px) minmax(0, 1fr) auto; gap: 24px; align-items: center }
|
||||||
|
.contbox h2 { font-size: 22px; letter-spacing: -.025em; margin-top: 2px }
|
||||||
|
.contbox .cover { width: 180px }
|
||||||
|
.learning-seg { margin-bottom: 24px }
|
||||||
|
.trail-course { grid-template-columns: 28px 132px minmax(0, 1fr) auto; gap: 16px; min-height: 108px }
|
||||||
|
.trail-course .cover { width: 132px; aspect-ratio: 16/10 }
|
||||||
|
.trail-teacher { margin-top: 12px }
|
||||||
|
.profile-head { display: flex; gap: 24px; align-items: center; margin: 24px 0 }
|
||||||
|
.profile-head h1 { font-size: 40px; line-height: 1.05; letter-spacing: -.035em }
|
||||||
|
.profile-head p { color: var(--fg-2); margin-top: 6px; font-size: 16px }
|
||||||
|
.profile-bio { max-width: 68ch; white-space: pre-line; color: var(--fg-2); font-size: 16px }
|
||||||
|
.profile-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px }
|
||||||
|
.profile-avatar { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 16px 0 32px }
|
||||||
|
.profile-avatar .av { width: 96px; height: 96px }
|
||||||
|
.profile-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px }
|
||||||
|
.profile-fields h2 { font-size: 24px; letter-spacing: -.025em }
|
||||||
|
.profile-fields .form { max-width: none }
|
||||||
|
.profile-fields .field label > svg { width: 16px; height: 16px; vertical-align: middle }
|
||||||
|
.profile-save { margin-top: 28px }
|
||||||
|
.file-name { display: flex; align-items: center; gap: 12px }
|
||||||
|
.file-name .ic { font-size: 20px; color: var(--fg-2) }
|
||||||
|
.file-name small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
.discussion-row { grid-template-columns: 40px minmax(0, 1fr) auto; padding: 16px 4px }
|
||||||
|
.discussion-row .t { overflow: hidden; text-overflow: ellipsis }
|
||||||
|
.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 48px }
|
||||||
|
.subnav { display: flex; flex-direction: column; gap: 2px; font-size: 14px }
|
||||||
|
.subnav a, .subnav button { padding: 8px 12px; border-radius: 8px; color: var(--fg-2); text-align: left }
|
||||||
|
.subnav [aria-current] { background: var(--bg-2); color: var(--fg); font-weight: 500 }
|
||||||
|
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px }
|
||||||
|
.toolbar .sp { flex: 1 }
|
||||||
|
|
||||||
|
/* ---------- course head and player ---------- */
|
||||||
|
.chead { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 40px; align-items: center; margin-bottom: 48px }
|
||||||
|
@media (max-width: 1100px) { .chead { grid-template-columns: minmax(0, 1fr) } }
|
||||||
|
.chead h1 { font-size: 40px; line-height: 1.06; font-weight: 700; letter-spacing: -.035em }
|
||||||
|
.chead p.d { margin-top: 14px; color: var(--fg-2); font-size: 16px; max-width: 52ch }
|
||||||
|
.chead .meta { margin-top: 16px; font-size: 14px; color: var(--fg-2) }
|
||||||
|
.chead .acts { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap }
|
||||||
|
.player { position: relative; display: block; aspect-ratio: 16/9; max-width: 100%; border-radius: var(--r); background: var(--black); color: var(--white); overflow: hidden }
|
||||||
|
.player iframe, .player video, .player > img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: contain }
|
||||||
|
.player > img { object-fit: cover; opacity: .55 }
|
||||||
|
.player .pl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--video-muted); font-size: 14px }
|
||||||
|
.player .pl .playbtn { width: 64px; height: 64px; border-radius: 50%; background: var(--white); color: var(--black); display: grid; place-items: center; font-size: 22px }
|
||||||
|
.player .pl .playbtn .ph { margin-left: 3px }
|
||||||
|
.player .ctl { position: absolute; left: 20px; right: 20px; bottom: 16px; display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--video-muted) }
|
||||||
|
.player .msg { display: grid; gap: 14px; justify-items: center; max-width: 42ch }
|
||||||
|
.player .msg b { color: var(--white); font-size: 17px; font-weight: 600 }
|
||||||
|
.ltitle { margin-top: 20px; display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap }
|
||||||
|
.ltitle h1 { font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15 }
|
||||||
|
.ltitle small { display: block; color: var(--fg-2); font-size: 14px; margin-top: 4px }
|
||||||
|
.ltitle .acts { display: flex; gap: 8px }
|
||||||
|
.ldesc { margin-top: 16px; color: var(--fg-2); max-width: 68ch; white-space: pre-line }
|
||||||
|
.comment { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding-block: 14px }
|
||||||
|
.comment .h { font-size: 13px; color: var(--fg-2) }
|
||||||
|
.comment .h b { color: var(--fg); font-weight: 600; margin-right: 6px }
|
||||||
|
.comment p { margin-top: 4px; white-space: pre-line }
|
||||||
|
.comment .reply { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg-2) }
|
||||||
|
.comment .tools { margin-top: 8px; display: flex; gap: 14px; font-size: 13px }
|
||||||
|
.tagp { font-size: 11px; font-weight: 600; color: var(--blue-text); margin-left: 6px }
|
||||||
|
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px; border-radius: 14px; background: var(--bg-2) }
|
||||||
|
.composer textarea { flex: 1; min-width: 0; border: 0; background: none; outline: none; resize: none; min-height: 44px; color: var(--fg) }
|
||||||
|
|
||||||
|
/* ---------- tables ---------- */
|
||||||
|
.tablewrap { overflow-x: auto }
|
||||||
|
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px }
|
||||||
|
th { text-align: left; font-weight: 500; color: var(--fg-2); font-size: 13px; padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap }
|
||||||
|
td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle }
|
||||||
|
tr:last-child td { border-bottom: 0 }
|
||||||
|
tbody tr.click { cursor: pointer }
|
||||||
|
@media (hover: hover) { tbody tr.click:hover td { background: var(--bg-2) } }
|
||||||
|
td.right, th.right { text-align: right }
|
||||||
|
td .acts { display: inline-flex; gap: 4px; justify-content: flex-end }
|
||||||
|
.st { font-size: 14px; color: var(--fg-2) }
|
||||||
|
.st.bad { color: var(--bad) }
|
||||||
|
select.sel { height: 30px; border-radius: 8px; border: 0; background: var(--bg-2); padding: 0 8px; font-size: 13px }
|
||||||
|
.select-trigger { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; height: 30px; min-width: 96px; padding: 0 8px 0 10px; border-radius: 8px; background: var(--bg-2); color: var(--fg); font-size: 13px; text-align: left; transition: background-color .2s }
|
||||||
|
@media (hover: hover) { .select-trigger:hover { background: var(--bg-3) } }
|
||||||
|
.select-trigger:disabled { opacity: .5; cursor: not-allowed }
|
||||||
|
.select-trigger:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px }
|
||||||
|
.select-trigger .ph { font-size: 12px; color: var(--fg-3); flex: none }
|
||||||
|
.select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
|
||||||
|
.select-trigger.field { display: flex; width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 15px }
|
||||||
|
.select-trigger.mobile { display: flex; flex: 1; width: auto; height: auto; min-height: 36px; padding: 8px 0; border-radius: 0; background: transparent; font-size: 16px }
|
||||||
|
.select-trigger.mobile .ph { font-size: 14px }
|
||||||
|
.select-menu { position: fixed; z-index: 61; max-height: 260px; overflow-y: auto; background: var(--raise); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: var(--menu-shadow); animation: pop .18s var(--ease) both; transform-origin: top left }
|
||||||
|
.select-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 10px; border-radius: 8px; font-size: 14px; text-align: left; color: var(--fg) }
|
||||||
|
@media (hover: hover) { .select-menu button:hover { background: var(--bg-2) } }
|
||||||
|
.select-menu button[aria-selected="true"] { font-weight: 600 }
|
||||||
|
.select-menu button .ph { color: var(--blue-text); font-size: 16px; flex: none }
|
||||||
|
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 32px }
|
||||||
|
.stats.five { grid-template-columns: repeat(5, minmax(0, 1fr)) }
|
||||||
|
.stats > div { background: var(--bg-2); border-radius: 14px; padding: 16px 18px }
|
||||||
|
.stats small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
.stats b { font-size: 24px; font-weight: 600; letter-spacing: -.02em }
|
||||||
|
|
||||||
|
/* ---------- forms ---------- */
|
||||||
|
.form { display: grid; gap: 16px; max-width: 520px }
|
||||||
|
.form.wide { max-width: none }
|
||||||
|
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
|
||||||
|
.field label, .field > span.lb { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px }
|
||||||
|
.field input, .field textarea, .field select, input.input, select.input, textarea.input {
|
||||||
|
width: 100%; height: 40px; border-radius: 10px; border: 0; background: var(--bg-2);
|
||||||
|
padding: 0 12px; font-size: 15px; color: var(--fg); outline: none;
|
||||||
|
}
|
||||||
|
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible, .input:focus-visible { outline: 2px solid var(--blue); outline-offset: 0 }
|
||||||
|
.field textarea, textarea.input { height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.45 }
|
||||||
|
.field small { display: block; color: var(--fg-2); font-size: 12px; margin-top: 6px }
|
||||||
|
.field input::placeholder, .field textarea::placeholder, .input::placeholder { color: var(--fg-3) }
|
||||||
|
.formmsg { font-size: 14px; color: var(--fg-2) }
|
||||||
|
.formmsg.bad { color: var(--bad) }
|
||||||
|
.formmsg.ok { color: var(--ok) }
|
||||||
|
.drop { border-radius: 14px; padding: 28px; text-align: center; color: var(--fg-2); font-size: 14px; background: var(--bg-2); display: block; width: 100%; transition: background-color .2s }
|
||||||
|
.drop .ph { font-size: 24px; display: block; margin: 0 auto 8px; color: var(--fg-3) }
|
||||||
|
.drop.over { background: var(--bg-3) }
|
||||||
|
@media (hover: hover) { button.drop:hover, label.drop:hover { background: var(--bg-3) } }
|
||||||
|
.drop small { display: block; color: var(--fg-3); font-size: 12px; margin-top: 4px }
|
||||||
|
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-block: 12px }
|
||||||
|
.toggle small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
.sw { width: 42px; height: 26px; border-radius: 13px; background: var(--bg-3); position: relative; flex: none; transition: background-color .25s }
|
||||||
|
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); box-shadow: var(--switch-shadow); transition: transform .2s }
|
||||||
|
.sw[aria-checked="true"] { background: var(--blue) }
|
||||||
|
.sw[aria-checked="true"]::after { transform: translateX(16px) }
|
||||||
|
.sw:disabled { opacity: .5 }
|
||||||
|
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer }
|
||||||
|
.check input { width: 16px; height: 16px; accent-color: var(--blue) }
|
||||||
|
|
||||||
|
/* ---------- auth ---------- */
|
||||||
|
.auth { width: 100%; max-width: 380px; margin: 40px auto 0; text-align: center }
|
||||||
|
.auth h1 { font-size: 32px; font-weight: 700; letter-spacing: -.03em }
|
||||||
|
.auth > p { color: var(--fg-2); margin-top: 8px }
|
||||||
|
.auth form { margin-top: 28px; text-align: left; display: grid; gap: 14px }
|
||||||
|
.auth form .btn { width: 100%; height: 44px; font-size: 15px }
|
||||||
|
.auth .seg { width: 100%; display: flex }
|
||||||
|
.auth .seg button { flex: 1 }
|
||||||
|
.auth .alt { margin-top: 20px; font-size: 14px; color: var(--fg-2) }
|
||||||
|
/* Desktop: center the auth card in the viewport (auto margins keep it reachable when it overflows). */
|
||||||
|
@media (min-width: 901px) {
|
||||||
|
.auth-page { min-height: 100svh; display: flex; flex-direction: column; padding-block: 40px }
|
||||||
|
.auth-page .auth { margin-block: auto }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- dialogs and toasts ---------- */
|
||||||
|
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 70; animation: fade .2s both; display: grid; place-items: center; padding: 16px; overflow-y: auto }
|
||||||
|
.dialog { position: relative; width: 100%; max-width: 520px; background: var(--raise); border-radius: var(--r); padding: 24px; box-shadow: var(--menu-shadow); animation: pop .22s var(--ease) both; max-height: calc(100vh - 32px); overflow-y: auto }
|
||||||
|
.dialog.wide { max-width: 760px }
|
||||||
|
.dialog > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px }
|
||||||
|
.dialog > header h2 { font-size: 22px; font-weight: 700; letter-spacing: -.025em }
|
||||||
|
.dialog > header p { color: var(--fg-2); font-size: 14px; margin-top: 4px }
|
||||||
|
.dialog > footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px }
|
||||||
|
.toasts { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 90; display: grid; gap: 8px; pointer-events: none }
|
||||||
|
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 14px; background: var(--raise); color: var(--fg); box-shadow: var(--menu-shadow); font-size: 14px; animation: pop .22s var(--ease) both }
|
||||||
|
:root:not(.dark) .toast { box-shadow: 0 0 0 1px var(--line-2), var(--menu-shadow) }
|
||||||
|
.toast .ph { font-size: 18px; color: var(--fg-2) }
|
||||||
|
.toast.error .ph { color: var(--bad) }
|
||||||
|
.toast p { flex: 1; min-width: 0 }
|
||||||
|
.toast small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
|
||||||
|
/* ---------- logo ---------- */
|
||||||
|
.logo { display: inline-flex; color: var(--fg); line-height: 0; flex: none }
|
||||||
|
.logo svg { display: block; height: auto }
|
||||||
|
.logo .sig { fill: var(--blue) }
|
||||||
|
.mark { display: none; font-size: 22px; font-weight: 700; letter-spacing: -.05em; line-height: 1; position: relative; color: var(--fg) }
|
||||||
|
.mark::after { content: ""; position: absolute; right: -7px; bottom: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--blue) }
|
||||||
|
|
||||||
|
/* ---------- desktop shell: floating glass sidebar ---------- */
|
||||||
|
.main { min-width: 0; display: flex; flex-direction: column; padding-left: var(--sw); transition: padding-left .35s var(--ease) }
|
||||||
|
.main > main, .main > .m-page { width: 100% }
|
||||||
|
.sidebar {
|
||||||
|
position: fixed; top: 12px; bottom: 12px; left: 12px; width: 240px; z-index: 25;
|
||||||
|
display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
|
||||||
|
border-radius: 26px; border: 1px solid var(--glass-line); background: var(--glass);
|
||||||
|
backdrop-filter: blur(40px) saturate(200%); -webkit-backdrop-filter: blur(40px) saturate(200%);
|
||||||
|
box-shadow: none;
|
||||||
|
padding: 16px 12px 14px; transition: width .35s var(--ease), padding .35s var(--ease), background-color .35s;
|
||||||
|
}
|
||||||
|
.side-top { display: flex; justify-content: flex-start; padding: 0 4px 6px }
|
||||||
|
.side-top .iconbtn { color: var(--fg-2); font-size: 20px }
|
||||||
|
@media (hover: hover) { .side-top .iconbtn:hover { background: var(--glass-hover) } }
|
||||||
|
.sidebar > .logo { margin: 6px 12px 28px; align-self: flex-start }
|
||||||
|
.sgroup { margin-top: 14px }
|
||||||
|
.sgroup.solo { margin-top: 0; display: grid; gap: 2px }
|
||||||
|
.ghead { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 32px; padding: 6px 12px; border-radius: 8px; font-size: 15px; font-weight: 700; letter-spacing: -.02em; color: var(--fg); transition: background-color .2s }
|
||||||
|
.ghead .ph { font-size: 12px; color: var(--fg-3); transition: transform .3s var(--ease) }
|
||||||
|
.sgroup.shut .ghead .ph { transform: rotate(-90deg) }
|
||||||
|
@media (hover: hover) { .ghead:hover { background: var(--glass-hover) } }
|
||||||
|
.gbody { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .35s var(--ease) }
|
||||||
|
.gbody > div { overflow: hidden; display: grid; gap: 2px; padding-top: 4px }
|
||||||
|
.sgroup.shut .gbody { grid-template-rows: 0fr }
|
||||||
|
.sitem { position: relative; display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: 10px; font-size: 15px; color: var(--fg); transition: background-color .2s, color .2s, transform .15s var(--ease) }
|
||||||
|
.sitem .ph { font-size: 19px; color: var(--fg-2); transition: color .2s }
|
||||||
|
@media (hover: hover) { .sitem:hover { background: var(--glass-hover) } }
|
||||||
|
.sitem:active { transform: scale(.96) }
|
||||||
|
.sitem[aria-current] { background: var(--blue); color: var(--white) }
|
||||||
|
.sitem[aria-current] .ph, .sitem[aria-current] .cnt { color: var(--white) }
|
||||||
|
.sitem .cnt { margin-left: auto; font-size: 12px; color: var(--fg-3); font-variant-numeric: tabular-nums }
|
||||||
|
.lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .2s }
|
||||||
|
.side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; align-items: stretch; gap: 10px }
|
||||||
|
.frow { display: flex; align-items: center; gap: 6px; min-width: 0 }
|
||||||
|
.frow > .who-row { flex: 1; min-width: 0 }
|
||||||
|
@media (hover: hover) { .frow > .iconbtn:hover { background: var(--glass-hover) } }
|
||||||
|
.who-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 10px; font-size: 14px; font-weight: 600; text-align: left; color: var(--fg); transition: background-color .2s }
|
||||||
|
@media (hover: hover) { .who-row:hover { background: var(--glass-hover) } }
|
||||||
|
.guestav { background: var(--bg-3); color: var(--fg-2); font-size: 15px }
|
||||||
|
.guestbtn { width: 100%; height: 38px }
|
||||||
|
:root.collapsed { --sw: 88px }
|
||||||
|
:root.collapsed .sidebar { width: 64px; padding-left: 8px; padding-right: 8px }
|
||||||
|
:root.collapsed .side-top { justify-content: center; padding: 0 0 6px }
|
||||||
|
:root.collapsed .sidebar > .logo { margin: 6px auto 28px; align-self: center }
|
||||||
|
:root.collapsed .sidebar > .logo svg { display: none }
|
||||||
|
:root.collapsed .mark { display: block }
|
||||||
|
:root.collapsed .sitem { justify-content: center; padding: 10px 0 }
|
||||||
|
:root.collapsed .sitem .lbl, :root.collapsed .sitem .cnt { display: none }
|
||||||
|
:root.collapsed .ghead { width: auto; justify-content: center; padding: 0; min-height: 0; height: 12px; background: transparent; margin: 8px 10px; overflow: hidden; pointer-events: none }
|
||||||
|
:root.collapsed .ghead .ph, :root.collapsed .ghead .lbl { display: none }
|
||||||
|
:root.collapsed .sgroup.shut .gbody { grid-template-rows: 1fr }
|
||||||
|
:root.collapsed .side-foot .frow { flex-direction: column; gap: 8px }
|
||||||
|
:root.collapsed .who-row { justify-content: center; padding: 4px 0 }
|
||||||
|
:root.collapsed .who-row .lbl, :root.collapsed .guestbtn { display: none }
|
||||||
|
.main .wrap { padding-left: 44px; padding-right: 48px; max-width: 1240px }
|
||||||
|
|
||||||
|
/* account menu: floats above the page (fixed on body) so the sidebar never clips it */
|
||||||
|
.menu { position: fixed; z-index: 60; width: 220px; background: var(--raise); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: var(--menu-shadow); animation: pop .22s var(--ease) both; transform-origin: bottom left }
|
||||||
|
.menu .who { padding: 10px 10px 12px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; min-width: 0 }
|
||||||
|
.menu .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
|
||||||
|
.menu .who small { display: block; color: var(--fg-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
|
||||||
|
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font-size: 14px; text-align: left }
|
||||||
|
@media (hover: hover) { .menu a:hover, .menu button:hover { background: var(--bg-2) } }
|
||||||
|
.menu .ph { font-size: 16px; color: var(--fg-2) }
|
||||||
|
.rowmenu { position: relative; display: inline-flex }
|
||||||
|
.menu-scrim { position: fixed; inset: 0; z-index: 59; background: transparent; border: 0; padding: 0 }
|
||||||
|
|
||||||
|
/* ---------- hero carousel (full-bleed, runs under the glass) ---------- */
|
||||||
|
.hero { position: relative; overflow: hidden; isolation: isolate; height: min(64vh, 600px); min-height: 480px; background: var(--c-midia); margin-left: calc(-1 * var(--sw)); transition: margin-left .35s var(--ease) }
|
||||||
|
.hero .wrap { max-width: 1240px; margin-left: calc(var(--sw) + max(0px, (100% - var(--sw) - 1240px) / 2)); margin-right: 0; padding-left: 44px; padding-right: 48px }
|
||||||
|
.slide { position: absolute; inset: 0; background: var(--cc); color: var(--co); opacity: 0; visibility: hidden; transition: opacity .5s ease-out, visibility 0s .5s }
|
||||||
|
.slide.on { opacity: 1; visibility: visible; transition: opacity .5s ease-out, visibility 0s }
|
||||||
|
.slide > .art-img { border-radius: 0 }
|
||||||
|
.slide.has-img::before { content: ""; position: absolute; inset: 0; background: var(--image-scrim); z-index: 1 }
|
||||||
|
.slide .sl { position: relative; z-index: 2; height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); align-items: end; padding-block: 120px 84px }
|
||||||
|
.slide .copy > * { opacity: 0; transform: translateY(18px); transition: opacity .45s ease-out, transform .45s ease-out }
|
||||||
|
.slide.on .copy > * { opacity: 1; transform: none }
|
||||||
|
.slide.on .copy > *:nth-child(2) { transition-delay: .08s }
|
||||||
|
.slide.on .copy > *:nth-child(3) { transition-delay: .16s }
|
||||||
|
.slide.on .copy > *:nth-child(4) { transition-delay: .24s }
|
||||||
|
.slide h2 { font-size: clamp(48px, 6.2vw, 92px); line-height: .98; font-weight: 700; letter-spacing: -.045em; max-width: 15ch }
|
||||||
|
.slide .meta { margin-top: 18px; font-size: 17px; opacity: .85 }
|
||||||
|
.slide p { margin-top: 10px; font-size: 17px; line-height: 1.42; opacity: .85; max-width: 52ch }
|
||||||
|
.slide .acts { margin-top: 26px; display: flex; gap: 10px; flex-wrap: wrap }
|
||||||
|
.slide .b1 { background: var(--co); color: var(--cc) }
|
||||||
|
.slide.has-img .b1 { color: var(--black) }
|
||||||
|
@media (hover: hover) { .slide .b1:hover { background: var(--co); opacity: .9 } }
|
||||||
|
.slide .b2 { background: transparent; color: var(--co); box-shadow: inset 0 0 0 1px currentColor; opacity: .9 }
|
||||||
|
@media (hover: hover) { .slide .b2:hover { background: transparent; opacity: 1 } }
|
||||||
|
.htitle { position: absolute; inset: 0 0 auto; z-index: 2; padding-top: 28px; pointer-events: none }
|
||||||
|
.htitle h1 { font-size: 28px; font-weight: 700; letter-spacing: -.03em; color: var(--hc, var(--white)); transition: color .6s }
|
||||||
|
.hdots { position: absolute; left: 0; right: 0; bottom: 26px; z-index: 2; display: flex; justify-content: center; gap: 8px; color: var(--hc, var(--white)) }
|
||||||
|
.dot { position: relative; width: 8px; height: 8px; border-radius: 4px; background: currentColor; opacity: .35; overflow: hidden; transition: width .5s var(--ease), opacity .3s }
|
||||||
|
.dot.on { width: 40px; opacity: 1; background: color-mix(in srgb, currentColor 30%, transparent) }
|
||||||
|
.dot.on i { position: absolute; inset: 0; background: currentColor; transform-origin: left; transform: scaleX(0); animation: fill var(--dur, 6s) linear forwards }
|
||||||
|
.hero.paused .dot.on i { animation-play-state: paused }
|
||||||
|
.harrow { position: absolute; bottom: 16px; z-index: 3; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; color: var(--hc, var(--white)); opacity: 0; background: color-mix(in srgb, currentColor 14%, transparent); transition: opacity .25s, background-color .2s, transform .15s }
|
||||||
|
@media (hover: hover) { .harrow:hover { background: color-mix(in srgb, currentColor 24%, transparent) } }
|
||||||
|
.harrow:active { transform: scale(.94) }
|
||||||
|
.harrow.l { right: 96px } .harrow.r { right: 48px }
|
||||||
|
.harrow:focus-visible { opacity: 1 }
|
||||||
|
@media (hover: hover) { .hero:hover .harrow { opacity: 1 } }
|
||||||
|
|
||||||
|
/* ---------- editor bits (gerenciar) ---------- */
|
||||||
|
.lessonrow { display: grid; grid-template-columns: 20px 28px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 4px; border-radius: 12px }
|
||||||
|
.lessonrow .grip { color: var(--fg-3); display: inline-flex; flex-direction: column; gap: 0 }
|
||||||
|
.lessonrow .grip button { color: var(--fg-3); font-size: 14px; line-height: 1 }
|
||||||
|
.lessonrow .grip button:disabled { opacity: .3 }
|
||||||
|
.lessonrow .i { color: var(--fg-3); font-size: 14px; text-align: center }
|
||||||
|
.lessonrow .t small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
.lessonrow .acts { display: flex; gap: 2px }
|
||||||
|
.coveredit { position: relative; aspect-ratio: 16/9; border-radius: var(--r-s); overflow: hidden; background: var(--bg-3) }
|
||||||
|
.coveredit .cover { aspect-ratio: auto; position: absolute; inset: 0; border-radius: 0 }
|
||||||
|
.coveredit .drag { position: absolute; inset: 0; cursor: grab; touch-action: none; display: grid; place-items: center; color: var(--white); font-size: 13px; z-index: 2 }
|
||||||
|
.coveredit .drag span { background: var(--drag-bg); padding: 6px 12px; border-radius: 980px }
|
||||||
|
.coveredit .drag:active { cursor: grabbing }
|
||||||
|
.zoomctl { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; color: var(--fg-2) }
|
||||||
|
.zoomctl .iconbtn { width: 30px; height: 30px; font-size: 15px; background: var(--bg-3) }
|
||||||
|
.zoomctl .iconbtn[aria-pressed="true"] { background: var(--blue); color: var(--white) }
|
||||||
|
.steps { display: flex; gap: 6px; margin-bottom: 28px; flex-wrap: wrap }
|
||||||
|
.steps button { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 980px; background: var(--bg-2); font-size: 14px; color: var(--fg-2) }
|
||||||
|
.steps button[aria-current] { background: var(--fg); color: var(--bg); font-weight: 500 }
|
||||||
|
.steps button .num { font-weight: 600 }
|
||||||
|
.pick { display: grid; gap: 2px; max-height: 280px; overflow-y: auto; padding: 4px; border-radius: var(--r-s); background: var(--bg-2) }
|
||||||
|
.pick button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 14px }
|
||||||
|
@media (hover: hover) { .pick button:hover { background: var(--bg-3) } }
|
||||||
|
.pick button[aria-pressed="true"] { color: var(--blue-text) }
|
||||||
|
.pick button small { margin-left: auto; color: var(--fg-2); font-size: 13px }
|
||||||
|
|
||||||
|
/* ---------- mobile ≤900px: its own navigation ---------- */
|
||||||
|
.tabbar { display: none }
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
:root { --sw: 0px }
|
||||||
|
.sidebar { display: none }
|
||||||
|
.main { padding-left: 0 }
|
||||||
|
body { overscroll-behavior-y: none }
|
||||||
|
input, textarea, select { font-size: 16px !important }
|
||||||
|
button, a, [role=tab] { touch-action: manipulation }
|
||||||
|
button, .tabbar a, .m-seg, .m-chips, .btn { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none }
|
||||||
|
.wrap, .main .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
|
||||||
|
.page { padding-top: calc(16px + env(safe-area-inset-top, 0px)); padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)) }
|
||||||
|
.ptitle h1, .chead h1 { font-size: 32px }
|
||||||
|
.crumb { display: none }
|
||||||
|
.shelf h2, .rowhead h2 { font-size: 20px }
|
||||||
|
.shelf { margin-top: 36px }
|
||||||
|
.split { gap: 28px }
|
||||||
|
.contbox { grid-template-columns: 72px minmax(0, 1fr); gap: 14px; padding: 16px }
|
||||||
|
.contbox .cover { width: 72px }
|
||||||
|
.contbox > .btn { grid-column: 1 / -1; width: 100% }
|
||||||
|
.contbox h2 { font-size: 18px !important }
|
||||||
|
.stats, .stats.five { grid-template-columns: repeat(2, minmax(0, 1fr)) }
|
||||||
|
.settings { grid-template-columns: minmax(0, 1fr); gap: 24px }
|
||||||
|
.form .two { grid-template-columns: minmax(0, 1fr) }
|
||||||
|
.grid, .pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 12px }
|
||||||
|
.pcards { grid-template-columns: repeat(2, minmax(0, 1fr)) }
|
||||||
|
.pcard { padding: 16px }
|
||||||
|
.toasts { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); left: max(16px, env(safe-area-inset-left, 0px)) }
|
||||||
|
.toast { min-width: 0; max-width: none }
|
||||||
|
/* tables become stacked rows: first cell is the title, the rest sit under it */
|
||||||
|
.tablewrap { overflow: visible }
|
||||||
|
table { min-width: 0 }
|
||||||
|
thead { display: none }
|
||||||
|
tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 12px 0; border-bottom: 1px solid var(--line-2) }
|
||||||
|
tbody td { display: block; padding: 0; border: 0; font-size: 13px; color: var(--fg-2) }
|
||||||
|
tbody td:first-child { flex: 1 0 100%; font-size: 15px; color: var(--fg) }
|
||||||
|
tbody td:last-child:not(:first-child) { margin-left: auto }
|
||||||
|
tbody td:empty { display: none }
|
||||||
|
.t-mat td:nth-child(3)::before { content: "Aula " }
|
||||||
|
.t-ger td:nth-child(3)::after { content: " aulas" }
|
||||||
|
.t-ger td:nth-child(4)::after { content: " alunos" }
|
||||||
|
.t-ger td:nth-child(5)::before { content: "Atualizado em " }
|
||||||
|
.lessonrow { grid-template-columns: 20px 24px minmax(0, 1fr) auto; }
|
||||||
|
.lessonrow > .state { grid-column: 3 / -1 }
|
||||||
|
.dialog { padding: 20px }
|
||||||
|
|
||||||
|
.tabbar {
|
||||||
|
display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; min-height: 58px;
|
||||||
|
padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
|
||||||
|
background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
|
||||||
|
box-shadow: 0 -1px 0 var(--line-2);
|
||||||
|
}
|
||||||
|
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; min-height: 48px; justify-content: center; color: var(--fg-3); font-size: 10px; font-weight: 500; letter-spacing: 0 }
|
||||||
|
.tabbar .ph { font-size: 24px }
|
||||||
|
.tabbar [aria-current] { color: var(--blue) }
|
||||||
|
.tabbar a:active { opacity: .6 }
|
||||||
|
.immersive .tabbar { display: none }
|
||||||
|
.enter { animation: mfade .28s ease-out }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Management screens retain their existing form behavior while using Academy tones. */
|
||||||
|
.legacy-skin { min-width: 0; color: var(--fg); background: var(--bg) }
|
||||||
|
.legacy-skin main { color: var(--fg); background: var(--bg) !important; padding-top: 40px }
|
||||||
|
.legacy-skin [class*="bg-zinc"], .legacy-skin [class*="bg-black"] { background-color: var(--bg-2) !important }
|
||||||
|
.legacy-skin [class*="bg-white/"] { background-color: var(--bg-2) !important }
|
||||||
|
.legacy-skin [class*="text-white"] { color: var(--fg) !important }
|
||||||
|
.legacy-skin [class*="text-gray"], .legacy-skin [class*="text-zinc"] { color: var(--fg-2) !important }
|
||||||
|
.legacy-skin [class*="text-orange"] { color: var(--blue-text) !important }
|
||||||
|
.legacy-skin [class*="bg-orange"] { background-color: var(--blue) !important; color: var(--white) !important }
|
||||||
|
.legacy-skin [class*="bg-orange"][class*="text-white"] { color: var(--white) !important }
|
||||||
|
.legacy-skin [class*="border-white"], .legacy-skin [class*="border-zinc"] { border-color: var(--line) !important }
|
||||||
|
.legacy-skin [class*="bg-gradient"] { background-image: none !important }
|
||||||
|
.legacy-skin [class*="bg-emerald"], .legacy-skin [class*="bg-amber"] { background-color: transparent !important }
|
||||||
|
.legacy-skin [class*="text-emerald"], .legacy-skin [class*="text-amber"] { color: var(--fg-2) !important }
|
||||||
|
.legacy-skin [class*="bg-black/80"] { background-color: var(--scrim) !important }
|
||||||
|
.legacy-skin [class*="shadow"] { box-shadow: none !important }
|
||||||
|
.legacy-skin button[class*="bg-orange"], .legacy-skin a[class*="bg-orange"] { border-radius: 980px !important }
|
||||||
|
.legacy-skin input, .legacy-skin textarea, .legacy-skin select { color: var(--fg); background: var(--bg-2); border-color: var(--line) }
|
||||||
|
.legacy-skin h1 { font-size: 40px; line-height: 1.05; letter-spacing: -.035em }
|
||||||
|
.legacy-skin h2 { letter-spacing: -.025em }
|
||||||
|
.manage-page .seg { margin-bottom: 24px }
|
||||||
|
.admin-page .seg { margin-bottom: 24px }
|
||||||
|
.admin-more { margin-top: 24px }
|
||||||
|
.admin-more summary { cursor: pointer; color: var(--blue-text); font-size: 15px; font-weight: 600; padding: 12px 0; min-height: 44px }
|
||||||
|
.admin-more > section { margin-top: 18px }
|
||||||
|
.manage-course-title { display: flex; align-items: center; gap: 12px; text-align: left; min-width: 0 }
|
||||||
|
.manage-course-title b { display: block; font-weight: 600; color: var(--fg) }
|
||||||
|
.manage-course-title small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
.manage-comment { border-radius: var(--r-s); background: var(--bg-2); padding: 20px; margin-bottom: 10px; display: grid; gap: 10px }
|
||||||
|
.manage-comment small { display: block; color: var(--fg-2); font-size: 13px }
|
||||||
|
.manage-comment .reply { padding: 12px; border-radius: var(--r-s); background: var(--raise) }
|
||||||
|
.manage-comment .bad-text { justify-self: start }
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.legacy-skin main { padding-top: 16px; padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)) }
|
||||||
|
.legacy-skin h1 { font-size: 32px }
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
*, *::before, *::after { transition: none !important }
|
||||||
|
.enter, .menu, .dialog, .toast, .enter .prog i, .enter .inprog i { animation: none !important }
|
||||||
|
.dot.on i { animation: none; transform: scaleX(1) }
|
||||||
|
.rail, .m-rail, .m-feat { scroll-behavior: auto }
|
||||||
|
.spin { animation: none }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- mobile building blocks (used only by mobile screens) ---------- */
|
||||||
|
.m-page { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)) }
|
||||||
|
.m-page.has-cta { padding-bottom: calc(180px + env(safe-area-inset-bottom, 0px)) }
|
||||||
|
.immersive .m-page { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) }
|
||||||
|
.m-gut { margin-left: max(16px, env(safe-area-inset-left, 0px)); margin-right: max(16px, env(safe-area-inset-right, 0px)) }
|
||||||
|
.m-large { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); margin-bottom: 12px }
|
||||||
|
.m-large h1 { font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -.03em }
|
||||||
|
.m-act { display: flex; gap: 8px; align-items: center; padding-bottom: 3px }
|
||||||
|
.m-av { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-3); display: grid; place-items: center; font-size: 13px; font-weight: 600; overflow: hidden }
|
||||||
|
.m-av img { width: 100%; height: 100%; object-fit: cover }
|
||||||
|
.btn.m-sm { height: 34px; padding: 0 14px; font-size: 14px }
|
||||||
|
.m-lead { color: var(--fg-2); font-size: 15px; margin-top: -4px; margin-bottom: 16px }
|
||||||
|
.m-nav { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 48px; padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(4px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px) }
|
||||||
|
.m-back { display: inline-flex; align-items: center; gap: 2px; color: var(--blue-text); font-size: 17px; min-height: 44px; padding: 0 8px; justify-self: start; max-width: 100%; min-width: 0 }
|
||||||
|
.m-back span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
|
||||||
|
.m-back .ph { font-size: 20px }
|
||||||
|
.m-back:active { opacity: .5 }
|
||||||
|
.m-nt { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw }
|
||||||
|
.m-nr { justify-self: end; display: flex; gap: 4px }
|
||||||
|
.m-tb { color: var(--blue-text); font-size: 17px; font-weight: 600; min-height: 44px; padding: 0 8px }
|
||||||
|
.m-tb:disabled { opacity: .4 }
|
||||||
|
.m-icb { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: var(--blue-text); flex: none }
|
||||||
|
.m-icb:active { background: var(--bg-2) }
|
||||||
|
.m-icb.lg { width: 52px; height: 52px; background: var(--bg-2); color: var(--fg) }
|
||||||
|
|
||||||
|
.m-feat-wrap { margin-bottom: 8px }
|
||||||
|
.m-feat { display: grid; grid-auto-flow: column; grid-auto-columns: calc(100% - 2 * max(16px, env(safe-area-inset-left, 0px)) - 8px); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 max(16px, env(safe-area-inset-left, 0px)); padding: 0 max(16px, env(safe-area-inset-left, 0px)); scrollbar-width: none; overscroll-behavior-x: contain }
|
||||||
|
.m-feat::-webkit-scrollbar { display: none }
|
||||||
|
.m-fc { position: relative; scroll-snap-align: start; border-radius: 22px; background: var(--cc); color: var(--co); min-height: min(440px, 62svh); display: flex; align-items: flex-end; overflow: hidden; box-shadow: inset 0 0 0 1px var(--art-edge) }
|
||||||
|
.m-fc.has-img::before { content: ""; position: absolute; inset: 0; background: var(--image-scrim); z-index: 1 }
|
||||||
|
.m-fc-link { position: absolute; inset: 0; z-index: 2 }
|
||||||
|
.m-fc-in { position: relative; z-index: 3; padding: 22px; pointer-events: none }
|
||||||
|
.m-fc-in small { font-size: 13px; font-weight: 500; opacity: .75 }
|
||||||
|
.m-fc h2 { font-size: 32px; line-height: 1.02; letter-spacing: -.035em; margin: 6px 0 0; text-wrap: balance }
|
||||||
|
.m-fc p { font-size: 14px; opacity: .8; margin-top: 10px }
|
||||||
|
.m-fc-btn { pointer-events: auto; margin-top: 18px; height: 46px; padding: 0 20px; font-size: 16px; background: var(--co); color: var(--cc) }
|
||||||
|
.m-fc.has-img .m-fc-btn { color: var(--black) }
|
||||||
|
@media (hover: hover) { .m-fc-btn:hover { background: var(--co) } }
|
||||||
|
.m-dots { display: flex; justify-content: center; gap: 6px; margin-top: 12px }
|
||||||
|
.m-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--fg-3); opacity: .4; transition: width .25s ease-out, opacity .25s }
|
||||||
|
.m-dots i.on { width: 18px; opacity: 1; background: var(--fg) }
|
||||||
|
|
||||||
|
.m-sec { margin-top: 28px }
|
||||||
|
.m-sh { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px }
|
||||||
|
.m-sh h2 { font-size: 20px; font-weight: 700; letter-spacing: -.02em }
|
||||||
|
.m-sh a { color: var(--blue-text); font-size: 15px; min-height: 32px; display: inline-flex; align-items: center }
|
||||||
|
.m-rail { display: grid; grid-auto-flow: column; grid-auto-columns: 44%; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 max(16px, env(safe-area-inset-left, 0px)); scroll-padding: 0 max(16px, env(safe-area-inset-left, 0px)); scrollbar-width: none; overscroll-behavior-x: contain }
|
||||||
|
.m-rail::-webkit-scrollbar { display: none }
|
||||||
|
.m-rail.wide { grid-auto-columns: 72% }
|
||||||
|
.m-rail.tall { grid-auto-columns: 38%; padding-top: 14px }
|
||||||
|
.m-rail > * { scroll-snap-align: start }
|
||||||
|
.m-card, .m-poster { display: block; min-width: 0 }
|
||||||
|
.m-card:active .m-art, .m-poster:active .m-part { transform: scale(.97) }
|
||||||
|
.m-art, .m-part { position: relative; display: flex; align-items: flex-end; border-radius: 14px; overflow: hidden; background: var(--cc); color: var(--co); padding: 12px; transition: transform .12s ease-out; box-shadow: inset 0 0 0 1px var(--art-edge) }
|
||||||
|
.m-art { aspect-ratio: 4/3 }
|
||||||
|
.m-card.wide .m-art { aspect-ratio: 16/9 }
|
||||||
|
.m-art .t, .m-part .t { position: relative; font-size: 15px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; text-wrap: balance }
|
||||||
|
.m-art .m-bar { position: absolute; left: 12px; right: 12px; bottom: 10px }
|
||||||
|
.m-art:has(.m-bar) { padding-bottom: 24px }
|
||||||
|
.m-card b { display: block; margin-top: 8px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
|
||||||
|
.m-card small, .m-poster small { display: block; font-size: 13px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
|
||||||
|
.m-poster small { margin-top: 8px }
|
||||||
|
.m-part { aspect-ratio: 2/3; overflow: visible }
|
||||||
|
.m-part > .art-img { border-radius: 14px }
|
||||||
|
.m-part .t { font-size: 17px }
|
||||||
|
.m-part.sm { width: 72px; height: auto; flex: none; border-radius: 10px; padding: 0 }
|
||||||
|
.m-part.xs { width: 28px; aspect-ratio: 2/3; border-radius: 6px; padding: 0; flex: none }
|
||||||
|
.m-part.sm > .art-img, .m-part.xs > .art-img { border-radius: inherit }
|
||||||
|
.m-poster .m-part { box-shadow: inset 0 0 0 1px var(--art-edge), 0 -6px 0 -2px color-mix(in srgb, var(--cc) 55%, var(--bg)), 0 -11px 0 -5px color-mix(in srgb, var(--cc) 28%, var(--bg)) }
|
||||||
|
.m-pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 12px; padding-top: 12px }
|
||||||
|
.m-bar { display: block; height: 4px; border-radius: 2px; background: color-mix(in srgb, currentColor 25%, transparent); overflow: hidden }
|
||||||
|
.m-bar i { display: block; height: 100%; background: currentColor; border-radius: 2px }
|
||||||
|
|
||||||
|
.m-group { margin-top: 22px }
|
||||||
|
.m-group > h2 { font-size: 13px; font-weight: 500; color: var(--fg-2); margin: 0 0 8px 16px }
|
||||||
|
.m-list { background: var(--bg-2); border-radius: 14px; overflow: hidden }
|
||||||
|
.m-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 14px; text-align: left; position: relative; color: var(--fg); touch-action: manipulation }
|
||||||
|
.m-row + .m-row::before { content: ""; position: absolute; top: 0; right: 0; left: 56px; height: 1px; background: var(--line-2) }
|
||||||
|
a.m-row:active, button.m-row:active { background: var(--bg-3) }
|
||||||
|
.m-row[aria-current] { background: color-mix(in srgb, var(--blue) 10%, var(--bg-2)) }
|
||||||
|
.m-rt { flex: 1; min-width: 0 }
|
||||||
|
.m-rt b { display: block; font-size: 16px; font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
|
||||||
|
.m-rt small { display: block; font-size: 13px; color: var(--fg-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
|
||||||
|
.multi .m-rt b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical }
|
||||||
|
.m-rtr { font-size: 14px; color: var(--fg-2); flex: none }
|
||||||
|
.m-chev { color: var(--fg-3); font-size: 13px; flex: none; display: inline-flex }
|
||||||
|
.m-n { width: 22px; text-align: center; color: var(--fg-3); font-size: 14px; flex: none; display: inline-flex; justify-content: center }
|
||||||
|
.m-done { color: var(--ok); font-size: 18px; display: inline-flex }
|
||||||
|
.m-now { color: var(--blue); font-size: 15px; display: inline-flex }
|
||||||
|
.m-th { width: 44px; height: 33px; border-radius: 7px; background: var(--cc); flex: none; position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px var(--art-edge) }
|
||||||
|
.m-ic { width: 30px; display: inline-flex; justify-content: center; font-size: 22px; color: var(--fg-2); flex: none }
|
||||||
|
.m-ic.xl { font-size: 56px; width: auto }
|
||||||
|
.m-mini { width: 56px; display: block; color: var(--blue) }
|
||||||
|
.m-cnt { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-2) }
|
||||||
|
.m-cnt .ph { font-size: 16px }
|
||||||
|
.m-foot { font-size: 13px; color: var(--fg-2); margin: 8px 16px 0 }
|
||||||
|
.m-danger b { color: var(--bad); text-align: center }
|
||||||
|
.m-err { color: var(--bad) }
|
||||||
|
.m-add .m-ic, .m-add b { color: var(--blue-text) }
|
||||||
|
.m-grip { color: var(--fg-3); font-size: 18px; display: inline-flex }
|
||||||
|
.m-sel { border: 0; background: none; color: var(--fg-2); font-size: 16px; text-align: right }
|
||||||
|
|
||||||
|
.m-seg { display: flex; padding: 2px; border-radius: 10px; background: var(--bg-2); margin-top: 6px }
|
||||||
|
.m-seg button { flex: 1; min-height: 36px; border-radius: 8px; font-size: 14px; color: var(--fg); white-space: nowrap; padding: 0 6px }
|
||||||
|
.m-seg button[aria-selected="true"] { background: var(--raise); font-weight: 600; box-shadow: var(--control-shadow) }
|
||||||
|
:root.dark .m-seg button[aria-selected="true"] { background: var(--bg-3) }
|
||||||
|
.m-pane { padding-bottom: 8px }
|
||||||
|
.m-search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 12px; background: var(--bg-2); color: var(--fg-2); margin-top: 4px }
|
||||||
|
.m-search .ph { font-size: 17px }
|
||||||
|
.m-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--fg); font-size: 16px; height: 100% }
|
||||||
|
.m-pane > .m-search { margin-top: 14px }
|
||||||
|
.m-chips { display: flex; gap: 8px; overflow-x: auto; margin-top: 14px; scrollbar-width: none }
|
||||||
|
.m-chips button { flex: none; min-height: 34px; padding: 0 14px; border-radius: 980px; background: var(--bg-2); font-size: 14px }
|
||||||
|
.m-chips button[aria-pressed="true"] { background: var(--fg); color: var(--bg) }
|
||||||
|
|
||||||
|
.m-cover { position: relative; aspect-ratio: 16/10; margin-top: 4px; border-radius: 18px; overflow: hidden; background: var(--cc); color: var(--co); display: flex; align-items: flex-end; padding: 18px; box-shadow: inset 0 0 0 1px var(--art-edge) }
|
||||||
|
.m-cover .t { position: relative; font-size: 24px; line-height: 1.08; font-weight: 700; letter-spacing: -.03em; max-width: 85% }
|
||||||
|
.m-cover .m-bar { position: absolute; left: 18px; right: 18px; bottom: 14px }
|
||||||
|
.m-cover:has(.m-bar) { padding-bottom: 30px }
|
||||||
|
.m-cover.sm { aspect-ratio: 16/8 }
|
||||||
|
.m-title { margin-top: 16px; margin-bottom: 14px }
|
||||||
|
.m-title h1 { font-size: 24px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; text-wrap: balance }
|
||||||
|
.m-title p { font-size: 14px; color: var(--fg-2); margin-top: 4px }
|
||||||
|
.m-hero-d { display: flex; gap: 16px; align-items: flex-start; margin-top: 8px }
|
||||||
|
.m-hero-d small { font-size: 13px; color: var(--fg-2) }
|
||||||
|
.m-hero-d h1 { font-size: 24px; line-height: 1.1; letter-spacing: -.025em; margin: 2px 0 6px }
|
||||||
|
.m-hero-d p { font-size: 14px; color: var(--fg-2) }
|
||||||
|
.m-meta { font-size: 13px; color: var(--fg-3); margin-top: 8px }
|
||||||
|
.m-progress { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--blue); font-size: 13px }
|
||||||
|
.m-progress .m-bar { flex: 1 }
|
||||||
|
.m-progress span { color: var(--fg-2) }
|
||||||
|
.m-body { font-size: 16px; line-height: 1.5; margin-top: 16px; text-wrap: pretty; white-space: pre-line }
|
||||||
|
.m-empty { color: var(--fg-2); text-align: center; padding: 48px 0; font-size: 15px }
|
||||||
|
.m-under { display: flex; justify-content: space-between; margin-top: 10px; font-size: 15px }
|
||||||
|
.m-under .link { min-height: 36px; font-size: 15px }
|
||||||
|
|
||||||
|
.m-player { position: sticky; top: calc(48px + env(safe-area-inset-top, 0px)); z-index: 15; aspect-ratio: 16/9; background: var(--black); color: var(--white); display: grid; place-items: center; overflow: hidden }
|
||||||
|
.m-player iframe, .m-player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0 }
|
||||||
|
.m-player .msg { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 16px; font-size: 14px; color: var(--video-muted) }
|
||||||
|
.m-thread { margin-top: 8px }
|
||||||
|
.m-compose { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; padding: 8px; border-radius: 16px; background: var(--bg-2) }
|
||||||
|
.m-compose textarea { flex: 1; min-width: 0; border: 0; background: none; resize: none; outline: none; padding: 8px 6px; min-height: 40px; color: var(--fg) }
|
||||||
|
.m-compose input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 8px 6px; min-height: 40px; color: var(--fg) }
|
||||||
|
|
||||||
|
.m-person { text-align: center; margin-top: 8px }
|
||||||
|
.m-person .av { margin: 0 auto 12px }
|
||||||
|
.m-person h1 { font-size: 26px; letter-spacing: -.025em }
|
||||||
|
.m-person > p { color: var(--fg-2); margin-top: 4px }
|
||||||
|
.m-person .m-body { color: var(--fg); text-align: left }
|
||||||
|
.m-person.sm { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 8px }
|
||||||
|
.m-person.sm .av { margin: 0 }
|
||||||
|
.m-me { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--bg-2) }
|
||||||
|
.m-me .av { width: 52px; height: 52px; font-size: 18px }
|
||||||
|
.m-me b { display: block; font-size: 18px; font-weight: 600 }
|
||||||
|
.m-me small { color: var(--fg-2); font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis }
|
||||||
|
.m-me > span:nth-child(2) { flex: 1; min-width: 0 }
|
||||||
|
.m-signin { text-align: center; padding: 24px 8px 4px; display: grid; gap: 10px; justify-items: center }
|
||||||
|
.m-signin h2 { font-size: 22px; margin: 4px 0 0 }
|
||||||
|
.m-signin p { color: var(--fg-2); font-size: 15px; max-width: 32ch; margin-bottom: 8px }
|
||||||
|
.m-signin .btn { width: 100% }
|
||||||
|
|
||||||
|
.m-form { margin-top: 8px; display: grid; gap: 12px }
|
||||||
|
.m-field { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 14px; position: relative }
|
||||||
|
.m-field + .m-field::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line-2) }
|
||||||
|
.m-field > span { width: 72px; font-size: 16px; flex: none }
|
||||||
|
.m-field input, .m-field select, .m-field textarea { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--fg); font-size: 16px; padding: 8px 0 }
|
||||||
|
.m-field.col { flex-direction: column; align-items: stretch; gap: 2px }
|
||||||
|
.m-field.col > span { width: auto; font-size: 13px; color: var(--fg-2); padding-top: 8px }
|
||||||
|
.m-auth { min-height: calc(100svh - 48px - 110px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; justify-content: center; padding-bottom: 24px }
|
||||||
|
.m-auth .m-large { padding-top: 0 }
|
||||||
|
.m-alt { text-align: center; color: var(--fg-2); font-size: 15px }
|
||||||
|
.m-okmsg { color: var(--ok); text-align: center }
|
||||||
|
.m-errmsg { color: var(--bad); text-align: center; font-size: 15px }
|
||||||
|
|
||||||
|
.m-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 4px }
|
||||||
|
.m-stats div { background: var(--bg-2); border-radius: 12px; padding: 10px 8px; text-align: center; min-width: 0 }
|
||||||
|
.m-stats b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -.02em }
|
||||||
|
.m-stats small { font-size: 11px; color: var(--fg-2) }
|
||||||
|
|
||||||
|
.m-cta { position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom, 0px)); z-index: 25; display: flex; gap: 10px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px) }
|
||||||
|
.immersive .m-cta { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) }
|
||||||
|
.btn.m-big { flex: 1; height: 50px; font-size: 17px; border-radius: 14px }
|
||||||
|
.btn.m-half { flex: 1; height: 50px; font-size: 16px; border-radius: 14px }
|
||||||
|
.m-tav { width: 26px; height: 26px; border-radius: 50%; background: var(--bg-3); color: var(--fg-2); display: grid; place-items: center; font-size: 10px; font-weight: 600; overflow: hidden }
|
||||||
|
.m-tav img { width: 100%; height: 100%; object-fit: cover }
|
||||||
|
.m-tav.on { background: var(--blue); color: var(--white) }
|
||||||
|
.m-reply { display: flex; gap: 8px; align-items: center; margin-top: 10px }
|
||||||
|
.m-reply input { min-width: 0; flex: 1; height: 40px; border: 0; border-radius: 8px; background: var(--raise); padding: 0 10px }
|
||||||
|
.m-reply .link { flex: none; padding: 8px }
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.page.has-hero { padding-top: 0 }
|
||||||
|
.main > .m-page.m-gut { width: auto; margin-inline: 0; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)) }
|
||||||
|
.page.has-hero .shelf:first-child { margin-top: 28px }
|
||||||
|
.rail, .rail.wide { grid-auto-columns: 72%; gap: 12px }
|
||||||
|
.rail.tall { grid-auto-columns: 42%; gap: 12px }
|
||||||
|
.rowhead .nav2 { display: none }
|
||||||
|
.m-feat-wrap { padding-top: 0 }
|
||||||
|
.m-feat-wrap .m-large { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
|
||||||
|
.m-feat-wrap .m-fc { min-height: min(440px, 62svh) }
|
||||||
|
.m-feat-wrap .m-fc .art-img { object-fit: cover }
|
||||||
|
.m-page .m-cover.cover { aspect-ratio: 16/10; padding: 18px; border-radius: 18px }
|
||||||
|
.m-page .m-cover.cover .t { font-size: 24px; max-width: 85% }
|
||||||
|
.m-page .m-cover.cover .inprog { left: 18px; right: 18px }
|
||||||
|
.m-page .m-progress .prog { flex: 1; margin: 0 }
|
||||||
|
.m-page .m-seg { margin-top: 18px }
|
||||||
|
.enter:has(.m-cta) { animation: fade .28s ease-out both }
|
||||||
|
.m-cta .save-icon { flex: 0 0 50px; padding: 0; }
|
||||||
|
.m-cta .save-icon .ph { font-size: 21px }
|
||||||
|
.m-player .pl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px }
|
||||||
|
.m-player .pl .ph { font-size: 28px }
|
||||||
|
.m-player .pl.msg { color: var(--video-muted) }
|
||||||
|
.m-row .m-icb { color: var(--fg-2) }
|
||||||
|
.has-mobile-cta { padding-bottom: calc(180px + env(safe-area-inset-bottom, 0px)) }
|
||||||
|
.has-mobile-cta .side .btn { display: none }
|
||||||
|
.trail-course { grid-template-columns: 22px 72px minmax(0, 1fr) auto; gap: 10px; padding: 10px 0 }
|
||||||
|
.trail-course .cover { width: 72px; aspect-ratio: 16/10 }
|
||||||
|
.trail-course .r { font-size: 12px }
|
||||||
|
.trail-course .r .ph { display: none }
|
||||||
|
.profile-fields { grid-template-columns: 1fr; gap: 32px }
|
||||||
|
.profile-head { flex-direction: column; text-align: center; gap: 12px }
|
||||||
|
.profile-head h1 { font-size: 26px }
|
||||||
|
.search-page .grid, .search-page .pgrid { grid-template-columns: 1fr }
|
||||||
|
.community-view { display: flex; width: 100%; margin-bottom: 14px }
|
||||||
|
.community-view button { flex: 1; min-height: 36px }
|
||||||
|
.discussion-row { grid-template-columns: 32px minmax(0, 1fr) auto }
|
||||||
|
.auth { margin-top: 0; min-height: calc(100svh - 170px); display: flex; flex-direction: column; justify-content: center }
|
||||||
|
.auth form { width: 100% }
|
||||||
|
}
|
||||||
2
styles/legacy.css
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/* Layout utilities retained for management forms until their markup is migrated. */
|
||||||
|
@tailwind utilities;
|
||||||
130
styles/tokens.css
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
* Compor Academy — design tokens.
|
||||||
|
* Este é o ÚNICO lugar onde cores, raios e fontes são definidos.
|
||||||
|
* O tema escuro é ativado pela classe `.dark` no <html> (ThemeContext).
|
||||||
|
*/
|
||||||
|
:root {
|
||||||
|
color-scheme: light;
|
||||||
|
|
||||||
|
/* superfícies e texto */
|
||||||
|
--bg: #ffffff;
|
||||||
|
--bg-rgb: 255 255 255;
|
||||||
|
--bg-2: #f5f5f7;
|
||||||
|
--bg-2-rgb: 245 245 247;
|
||||||
|
--bg-3: #e8e8ed;
|
||||||
|
--bg-3-rgb: 232 232 237;
|
||||||
|
--raise: #ffffff;
|
||||||
|
--fg: #1d1d1f;
|
||||||
|
--fg-rgb: 29 29 31;
|
||||||
|
--fg-2: #6e6e73;
|
||||||
|
--fg-2-rgb: 110 110 115;
|
||||||
|
--fg-3: #86868b;
|
||||||
|
--fg-3-rgb: 134 134 139;
|
||||||
|
--line: rgba(0, 0, 0, .1);
|
||||||
|
--line-2: rgba(0, 0, 0, .06);
|
||||||
|
|
||||||
|
/* acento único */
|
||||||
|
--blue: #0a84ff;
|
||||||
|
--blue-rgb: 10 132 255;
|
||||||
|
--blue-press: #0071e3;
|
||||||
|
--blue-press-rgb: 0 113 227;
|
||||||
|
--blue-text: #0071e3;
|
||||||
|
--blue-soft: rgba(10, 132, 255, .1);
|
||||||
|
|
||||||
|
/* estados */
|
||||||
|
--ok: #248a3d;
|
||||||
|
--ok-rgb: 36 138 61;
|
||||||
|
--warn: #b25000;
|
||||||
|
--warn-rgb: 178 80 0;
|
||||||
|
--bad: #d70015;
|
||||||
|
--bad-rgb: 215 0 21;
|
||||||
|
|
||||||
|
/* cor por área — também é a "capa" provisória de cursos e trilhas */
|
||||||
|
--c-midia: #1d1d1f; --c-midia-on: #ffffff; /* Mídia paga */
|
||||||
|
--c-conv: #0a84ff; --c-conv-on: #ffffff; /* Conversão */
|
||||||
|
--c-oper: #e8e8ed; --c-oper-on: #1d1d1f; /* Operação */
|
||||||
|
|
||||||
|
/* barras e vidro */
|
||||||
|
--nav: rgba(255, 255, 255, .88);
|
||||||
|
--side: #f2f2f4;
|
||||||
|
--side-hover: rgba(0, 0, 0, .045);
|
||||||
|
--glass: rgba(250, 250, 252, .76);
|
||||||
|
--glass-line: rgba(255, 255, 255, .75);
|
||||||
|
--glass-edge: rgba(0, 0, 0, .06);
|
||||||
|
--glass-hover: rgba(255, 255, 255, .55);
|
||||||
|
--glass-shadow: 0 18px 50px -12px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .06);
|
||||||
|
--menu-shadow: 0 12px 32px rgba(0, 0, 0, .12);
|
||||||
|
--art-edge: rgba(0, 0, 0, .08);
|
||||||
|
--scrim: rgba(0, 0, 0, .32);
|
||||||
|
--white: #ffffff;
|
||||||
|
--white-rgb: 255 255 255;
|
||||||
|
--black: #000000;
|
||||||
|
--black-rgb: 0 0 0;
|
||||||
|
--video-muted: rgba(255, 255, 255, .72);
|
||||||
|
--image-scrim: rgba(0, 0, 0, .42);
|
||||||
|
--control-shadow: 0 1px 3px rgba(0, 0, 0, .12);
|
||||||
|
--art-progress-edge: rgba(0, 0, 0, .15);
|
||||||
|
--drag-bg: rgba(0, 0, 0, .6);
|
||||||
|
--switch-shadow: 0 1px 2px rgba(0, 0, 0, .2);
|
||||||
|
|
||||||
|
/* forma */
|
||||||
|
--r: 18px;
|
||||||
|
--r-s: 12px;
|
||||||
|
|
||||||
|
/* tipografia */
|
||||||
|
--font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter Variable", "Inter", system-ui, sans-serif;
|
||||||
|
--sig: "Mrs Saint Delafield", cursive;
|
||||||
|
|
||||||
|
/* movimento */
|
||||||
|
--ease: cubic-bezier(.22, .8, .24, 1);
|
||||||
|
--ease-io: cubic-bezier(.65, 0, .35, 1);
|
||||||
|
|
||||||
|
/* layout */
|
||||||
|
--sw: 264px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root.dark {
|
||||||
|
color-scheme: dark;
|
||||||
|
|
||||||
|
--bg: #151517;
|
||||||
|
--bg-rgb: 21 21 23;
|
||||||
|
--bg-2: #232326;
|
||||||
|
--bg-2-rgb: 35 35 38;
|
||||||
|
--bg-3: #313135;
|
||||||
|
--bg-3-rgb: 49 49 53;
|
||||||
|
--raise: #232326;
|
||||||
|
--fg: #f5f5f7;
|
||||||
|
--fg-rgb: 245 245 247;
|
||||||
|
--fg-2: #a1a1a6;
|
||||||
|
--fg-2-rgb: 161 161 166;
|
||||||
|
--fg-3: #8e8e93;
|
||||||
|
--fg-3-rgb: 142 142 147;
|
||||||
|
--line: rgba(255, 255, 255, .14);
|
||||||
|
--line-2: rgba(255, 255, 255, .08);
|
||||||
|
|
||||||
|
--blue-text: #2997ff;
|
||||||
|
--blue-soft: rgba(10, 132, 255, .18);
|
||||||
|
|
||||||
|
--ok: #30d158;
|
||||||
|
--ok-rgb: 48 209 88;
|
||||||
|
--warn: #ff9f0a;
|
||||||
|
--warn-rgb: 255 159 10;
|
||||||
|
--bad: #ff453a;
|
||||||
|
--bad-rgb: 255 69 58;
|
||||||
|
|
||||||
|
--c-midia: #000000;
|
||||||
|
--c-oper: #34343a; --c-oper-on: #f5f5f7;
|
||||||
|
|
||||||
|
--nav: rgba(21, 21, 23, .84);
|
||||||
|
--side: #202023;
|
||||||
|
--side-hover: rgba(255, 255, 255, .06);
|
||||||
|
--glass: rgba(44, 44, 48, .52);
|
||||||
|
--glass-line: rgba(255, 255, 255, .14);
|
||||||
|
--glass-edge: rgba(0, 0, 0, .3);
|
||||||
|
--glass-hover: rgba(255, 255, 255, .08);
|
||||||
|
--glass-shadow: 0 18px 50px -12px rgba(0, 0, 0, .6);
|
||||||
|
--menu-shadow: 0 12px 32px rgba(0, 0, 0, .5);
|
||||||
|
--art-edge: rgba(255, 255, 255, .08);
|
||||||
|
--scrim: rgba(0, 0, 0, .5);
|
||||||
|
--control-shadow: 0 1px 3px rgba(0, 0, 0, .28);
|
||||||
|
}
|
||||||
21
tailwind.config.cjs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
const color = (token) => `rgb(var(--${token}-rgb) / <alpha-value>)`;
|
||||||
|
module.exports = {
|
||||||
|
content: ['./pages/**/*.{ts,tsx}', './components/**/*.{ts,tsx}'],
|
||||||
|
corePlugins: { preflight: false },
|
||||||
|
theme: {
|
||||||
|
colors: {
|
||||||
|
transparent: 'transparent', current: 'currentColor', inherit: 'inherit',
|
||||||
|
black: color('black'), white: color('white'),
|
||||||
|
orange: { 100: color('blue'), 200: color('blue'), 300: color('blue'), 400: color('blue'), 500: color('blue'), 600: color('blue-press') },
|
||||||
|
blue: { 400: color('blue'), 500: color('blue') },
|
||||||
|
sky: { 400: color('blue'), 500: color('blue') },
|
||||||
|
gray: { 200: color('fg'), 300: color('fg'), 400: color('fg-2'), 500: color('fg-2'), 600: color('fg-3') },
|
||||||
|
zinc: { 200: color('fg'), 800: color('bg-3'), 850: color('bg-2'), 900: color('bg-2'), 950: color('bg') },
|
||||||
|
emerald: { 300: color('ok'), 400: color('ok'), 500: color('ok') },
|
||||||
|
amber: { 300: color('warn'), 400: color('warn'), 500: color('warn') },
|
||||||
|
red: { 300: color('bad'), 400: color('bad'), 500: color('bad') },
|
||||||
|
rose: { 400: color('bad'), 500: color('bad') },
|
||||||
|
purple: { 400: color('fg-2'), 500: color('fg-2') },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
2
types.ts
@@ -50,6 +50,8 @@ export interface Course {
|
|||||||
lessons: Lesson[];
|
lessons: Lesson[];
|
||||||
progress?: number; // 0 to 100
|
progress?: number; // 0 to 100
|
||||||
views?: number;
|
views?: number;
|
||||||
|
learners?: number;
|
||||||
|
updatedAt?: string;
|
||||||
duration: string; // Total duration or lesson count
|
duration: string; // Total duration or lesson count
|
||||||
description: string;
|
description: string;
|
||||||
instructor?: string;
|
instructor?: string;
|
||||||
|
|||||||