/
MorSergey
/
diff-equations
Обзор
Документация
Войти
/
MorSergey
/
diff-equations
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/shared/ui/Table.tsx
72 строки
2 KB
admin
init
22 окт 2025, 15:18
22 окт 2025, 15:18
412f98f
Код
Авторство
О чём код?
interface TableData { step: number; x: number; y: number; } interface TableProps { data: TableData[]; title: string; isLoading?: boolean; } export const Table = ({ data, title, isLoading = false }: TableProps) => { if (isLoading) { return ( <div className="bg-white rounded-lg shadow-lg p-6"> <h3 className="text-xl font-semibold mb-4 text-gray-800"> {title} </h3> <div className="flex justify-center items-center h-32"> <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div> <span className="ml-3 text-gray-600">Вычисление...</span> </div> </div> ); } return ( <div className="bg-white rounded-lg shadow-lg p-6"> <h3 className="text-xl font-semibold mb-4 text-gray-800"> {title} </h3> <div className="overflow-x-auto max-h-96"> <table className="min-w-full table-auto"> <thead className="bg-gray-50 sticky top-0"> <tr> <th className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"> Шаг </th> <th className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"> x </th> <th className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"> y </th> </tr> </thead> <tbody className="bg-white divide-y divide-gray-200"> {data.map((point, index) => ( <tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}> <td className="px-4 py-3 whitespace-nowrap text-sm font-medium text-gray-900"> {point.step} </td> <td className="px-4 py-3 whitespace-nowrap text-sm text-gray-700 font-mono"> {point.x.toFixed(2)} </td> <td className="px-4 py-3 whitespace-nowrap text-sm text-gray-700 font-mono"> {point.y.toFixed(4)} </td> </tr> ))} </tbody> </table> </div> <div className="mt-4 text-sm text-gray-500"> Всего точек: {data.length} </div> </div> ); };