Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -1,73 +1,53 @@
|
||||
# React + TypeScript + Vite
|
||||
# YvCode
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
A lightweight code-canvas editor to create export-ready images for social media (code blocks, text, arrows, backgrounds, and branding).
|
||||
|
||||
Currently, two official plugins are available:
|
||||

|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
## Features
|
||||
|
||||
## React Compiler
|
||||
- Canvas editor built on Konva (move/resize/rotate elements)
|
||||
- Elements: Code block, Text, Arrow
|
||||
- Backgrounds: solid + gradient, optional brand strip
|
||||
- Branding overlay (name/title/avatar + social handles)
|
||||
- Layers panel (reorder, lock, hide/show)
|
||||
- Export image: PNG or JPEG (2x)
|
||||
- Project files: export/import as JSON
|
||||
- Recent projects list (local)
|
||||
- Undo/Redo + keyboard shortcuts
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
## Keyboard shortcuts
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
- New canvas: `⌘N`
|
||||
- Open project JSON: `⌘O`
|
||||
- Export project JSON: `⌘S`
|
||||
- Undo / Redo: `⌘Z` / `⇧⌘Z`
|
||||
- Duplicate selected: `⌘D`
|
||||
- Delete selected: `Backspace` / `Delete`
|
||||
- Zoom in/out: `⌘+` / `⌘-`
|
||||
- Toggle grid: `⌘;`
|
||||
- Tools: Select `V`, Code `C`, Text `T`, Arrow `A`
|
||||
- Deselect: `Esc`
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
## Getting started
|
||||
|
||||
```js
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
Requirements: Node.js (recommended: latest LTS)
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
Then open the URL printed by Vite.
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
## Scripts
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
- `npm run dev` — start the dev server
|
||||
- `npm run build` — typecheck and build for production
|
||||
- `npm run preview` — preview the production build
|
||||
- `npm run lint` — run ESLint
|
||||
|
||||
## Docs
|
||||
|
||||
- Product spec: [docs/spec.md](docs/spec.md)
|
||||
- UI design notes: [docs/design.md](docs/design.md)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 652 KiB |
Reference in New Issue
Block a user