base table

This commit is contained in:
Artyom Tsyrulnikov
2025-07-13 11:32:05 +03:00
commit f74f52f1a4
32 changed files with 2284 additions and 0 deletions

15
.eslintrc.cjs Normal file
View File

@@ -0,0 +1,15 @@
module.exports = {
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": "warn",
"no-undef": "off",
},
};

24
.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

8
.prettierignore Normal file
View File

@@ -0,0 +1,8 @@
# Ignore artifacts:
build
coverage
**/.git
**/.svn
**/.hg
**/node_modules

9
.prettierrc.json Normal file
View File

@@ -0,0 +1,9 @@
{
"trailingComma": "all",
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"bracketSameLine": false
}

63
README.md Normal file
View File

@@ -0,0 +1,63 @@
# TypeScript React Tailwind Vite Template
This template provides a starting point for creating React projects with TypeScript, Tailwind CSS, and Vite.
## Overview
This template allows you to quickly set up a React project with TypeScript, Tailwind CSS, and Vite. It provides a modern development environment with features such as hot module replacement and fast refresh, making it easy to develop and customize your React applications.
## Features
- TypeScript: Develop with confidence using static type-checking and improved tooling.
- React: Build dynamic user interfaces with the popular React library.
- Tailwind CSS: Easily style and customize your components using the utility-first approach of Tailwind CSS.
- Vite: Enjoy fast development and instant hot module replacement with Vite's lightning-fast dev server.
## Installation
To create a new project using this template, follow these steps:
1. Ensure that you have Node.js installed on your machine.
2. Open a terminal and navigate to the directory where you want to create your project.
3. Run the following command to create a new project using the template:
```bash
npx create-vite@latest --template typescript-react-tailwind-vite my-project
```
Replace my-project with the desired name for your project.
4. Once the command completes, navigate into the project directory:
```bash
cd my-project
```
5. Install the dependencies:
```bash
npm install
```
## Usage
To start the development server and run the project, use the following command:
```bash
npm run dev
```
This will start the development server and open your project in the browser. Any changes you make to the source code will be automatically reflected in the browser.
## Building for Production
To build the project for production, use the following command:
```bash
npm run build
```
This will create an optimized build of your project in the dist directory.

13
index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TS + React + Tailwind</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/app/main.tsx"></script>
</body>
</html>

40
package.json Normal file
View File

@@ -0,0 +1,40 @@
{
"name": "typescript-react-tailwind-vite",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"format": "prettier --write ."
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"redux": "^4.2.1"
},
"devDependencies": {
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@vitejs/plugin-react-swc": "^3.0.0",
"autoprefixer": "^10.4.14",
"daisyui": "^3.1.7",
"eslint": "^8.38.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"path": "^0.12.7",
"postcss": "^8.4.24",
"prettier": "2.8.8",
"prettier-plugin-tailwindcss": "^0.4.1",
"react-redux": "^8.1.1",
"react-router-dom": "^6.14.1",
"tailwindcss": "^3.3.2",
"typescript": "^5.0.2",
"vite": "^4.3.9"
}
}

6
postcss.config.js Normal file
View File

@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

3
prettier.config.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
plugins: [require("prettier-plugin-tailwindcss")],
};

BIN
public/images/hero.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

1
public/vite.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

19
src/app/App.tsx Normal file
View File

@@ -0,0 +1,19 @@
import { FC } from "react";
import { Route, Routes } from "react-router-dom";
import { Layout } from "@/app/Layout";
import { Home, NoMatch } from "@/pages";
const App: FC = () => {
return (
<>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="*" element={<NoMatch />} />
</Route>
</Routes>
</>
);
};
export default App;

14
src/app/Layout/Layout.tsx Normal file
View File

@@ -0,0 +1,14 @@
import { FC } from "react";
import { Outlet } from "react-router-dom";
const Layout: FC = () => {
return (
<div className="h-screen overflow-hidden">
<main className="h-full">
<Outlet />
</main>
</div>
);
};
export default Layout;

3
src/app/Layout/index.ts Normal file
View File

@@ -0,0 +1,3 @@
import Layout from "./Layout";
export { Layout };

6
src/app/hooks.ts Normal file
View File

@@ -0,0 +1,6 @@
import { useDispatch, useSelector } from "react-redux";
import type { TypedUseSelectorHook } from "react-redux";
import type { RootState, AppDispatch } from "./store";
export const useAppDispatch: () => AppDispatch = useDispatch;
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

3
src/app/index.css Normal file
View File

@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

15
src/app/main.tsx Normal file
View File

@@ -0,0 +1,15 @@
import ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import { Provider } from "react-redux";
import { store } from "@/app/store";
import App from "./App.tsx";
import "./index.css";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<BrowserRouter>
<Provider store={store}>
<App />
</Provider>
</BrowserRouter>,
);

8
src/app/store.ts Normal file
View File

@@ -0,0 +1,8 @@
import { configureStore } from "@reduxjs/toolkit";
export const store = configureStore({
reducer: {},
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

3
src/pages/Home/index.ts Normal file
View File

@@ -0,0 +1,3 @@
import Home from "./ui/Page/Page";
export { Home };

View File

@@ -0,0 +1,12 @@
import { FC } from "react";
import { Spreadsheet } from "../../../../widgets";
const Home: FC = () => {
return (
<div className="h-screen bg-gray-50">
<Spreadsheet />
</div>
);
};
export default Home;

View File

@@ -0,0 +1,3 @@
import NoMatch from "./ui/Page/Page";
export { NoMatch };

View File

@@ -0,0 +1,20 @@
import { FC } from "react";
import { Link } from "react-router-dom";
const NoMatch: FC = () => {
return (
<section>
<div className="flex min-h-screen w-screen flex-col items-center justify-center gap-y-5">
<h1 className="bg-gradient-to-l from-primary-content via-secondary to-primary bg-clip-text text-9xl font-bold text-transparent">
404
</h1>
<p className="text-3xl font-medium text-neutral">Page not found</p>
<Link className="btn-primary-content btn px-16" to="/">
Go back
</Link>
</div>
</section>
);
};
export default NoMatch;

4
src/pages/index.ts Normal file
View File

@@ -0,0 +1,4 @@
import { Home } from "./Home";
import { NoMatch } from "./NoMatch";
export { Home, NoMatch };

View File

@@ -0,0 +1 @@
export { default as Spreadsheet } from './ui/Spreadsheet/Spreadsheet';

View File

@@ -0,0 +1,112 @@
import { FC, useState } from 'react';
interface CellData {
value: string;
isSelected: boolean;
}
const Spreadsheet: FC = () => {
const [cells, setCells] = useState<CellData[][]>(() => {
// Создаем сетку 20x10 с пустыми ячейками
return Array(20).fill(null).map(() =>
Array(10).fill(null).map(() => ({ value: '', isSelected: false }))
);
});
const [selectedCell, setSelectedCell] = useState<{row: number, col: number} | null>(null);
const handleCellClick = (row: number, col: number) => {
setSelectedCell({ row, col });
};
const handleCellChange = (row: number, col: number, value: string) => {
setCells(prev => {
const newCells = [...prev];
newCells[row][col] = { ...newCells[row][col], value };
return newCells;
});
};
const getColumnLabel = (index: number) => {
return String.fromCharCode(65 + index); // A, B, C, ...
};
return (
<div className="w-full h-full bg-white">
{/* Formula bar */}
<div className="border-b border-gray-200 p-2 bg-white">
<div className="flex items-center space-x-2">
<div className="text-sm text-gray-600 min-w-[60px]">
{selectedCell ? `${getColumnLabel(selectedCell.col)}${selectedCell.row + 1}` : ''}
</div>
<div className="flex-1">
<input
type="text"
className="w-full px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Введите формулу..."
value={selectedCell ? cells[selectedCell.row][selectedCell.col].value : ''}
onChange={(e) => {
if (selectedCell) {
handleCellChange(selectedCell.row, selectedCell.col, e.target.value);
}
}}
/>
</div>
</div>
</div>
{/* Spreadsheet */}
<div className="overflow-auto h-[calc(100vh-200px)]">
<table className="border-collapse">
<thead>
<tr>
{/* Empty corner cell */}
<th className="w-12 h-8 bg-gray-100 border border-gray-300 text-xs text-gray-600 font-medium sticky top-0 left-0 z-20"></th>
{/* Column headers */}
{Array.from({ length: 10 }, (_, i) => (
<th
key={i}
className="w-24 h-8 bg-gray-100 border border-gray-300 text-xs text-gray-600 font-medium text-center sticky top-0 z-10"
>
{getColumnLabel(i)}
</th>
))}
</tr>
</thead>
<tbody>
{cells.map((row, rowIndex) => (
<tr key={rowIndex}>
{/* Row header */}
<td className="w-12 h-8 bg-gray-100 border border-gray-300 text-xs text-gray-600 font-medium text-center sticky left-0 z-10">
{rowIndex + 1}
</td>
{/* Data cells */}
{row.map((cell, colIndex) => (
<td
key={colIndex}
className={`w-24 h-8 border border-gray-300 relative cursor-cell ${
selectedCell?.row === rowIndex && selectedCell?.col === colIndex
? 'bg-blue-100 border-blue-500 border-2'
: 'hover:bg-gray-50'
}`}
onClick={() => handleCellClick(rowIndex, colIndex)}
>
<input
type="text"
className="w-full h-full px-1 text-sm bg-transparent border-none outline-none resize-none"
value={cell.value}
onChange={(e) => handleCellChange(rowIndex, colIndex, e.target.value)}
onFocus={() => setSelectedCell({ row: rowIndex, col: colIndex })}
/>
</td>
))}
</tr>
))}
</tbody>
</table>
</div>
</div>
);
};
export default Spreadsheet;

2
src/widgets/index.ts Normal file
View File

@@ -0,0 +1,2 @@
export { Spreadsheet } from "./Spreadsheet";

8
tailwind.config.js Normal file
View File

@@ -0,0 +1,8 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};

38
tsconfig.json Normal file
View File

@@ -0,0 +1,38 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
/* Path */
"baseUrl": "./",
"paths": {
"@/*": ["src/*"],
"shared/*": ["src/shared/*"],
"entities/*": ["src/entities/*"],
"features/*": ["src/features/*"],
"widgets/*": ["src/widgets/*"],
"pages/*": ["src/pages/*"],
"processes/*": ["src/processes/*"],
"app/*": ["src/app/*"]
}
},
"include": ["src", "types/vite-env.d.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
}

10
tsconfig.node.json Normal file
View File

@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

1
types/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

16
vite.config.ts Normal file
View File

@@ -0,0 +1,16 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": path.resolve("src"),
"@widgets": path.resolve("src/widgets"),
"@features": path.resolve("src/features"),
"@entities": path.resolve("src/entities"),
},
},
});

1804
yarn.lock Normal file

File diff suppressed because it is too large Load Diff