poon-choi 0.0.0-stage โ 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -3
- package/README.tanstack-start.md +224 -0
- package/README.zh.md +107 -0
- package/bin/index.ts +37 -0
- package/package.json +65 -4
- package/src/components/DropStage.tsx +64 -0
- package/src/components/FitModeToggle.tsx +34 -0
- package/src/components/Footer.tsx +44 -0
- package/src/components/GapColorPicker.tsx +53 -0
- package/src/components/Header.tsx +78 -0
- package/src/components/PresetColorDropdown.tsx +166 -0
- package/src/components/ThemeToggle.tsx +81 -0
- package/src/components/ThumbnailStrip.tsx +147 -0
- package/src/components/VerticalSeparator.tsx +5 -0
- package/src/hooks/useToast.tsx +23 -0
- package/src/lib/config.ts +48 -0
- package/src/lib/draw.ts +78 -0
- package/src/lib/file.ts +23 -0
- package/src/lib/utils.ts +7 -0
- package/src/routeTree.gen.ts +86 -0
- package/src/router.tsx +19 -0
- package/src/routes/__root.tsx +68 -0
- package/src/routes/about.tsx +23 -0
- package/src/routes/index.css +300 -0
- package/src/routes/index.tsx +511 -0
- package/src/styles.css +375 -0
package/README.md
CHANGED
|
@@ -1,3 +1,110 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# ๐ฅ poon-choi
|
|
2
|
+
|
|
3
|
+
English | [ไธญๆ](./README.zh.md)
|
|
4
|
+
|
|
5
|
+
> A tiny local server that plates up your images into a WeChat cover โ like a **poon choi**, one basin holding many ingredients, layer by layer.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/poon-choi)
|
|
8
|
+
[](https://www.npmjs.com/package/poon-choi)
|
|
9
|
+
[](./LICENSE)
|
|
10
|
+
|
|
11
|
+
**poon-choi** (็่) is a Cantonese dish where many ingredients are stacked in one basin and shared from the top down. This tool does the same for images: drop in 1โ6 pictures, and it plates them into a single **2.35:1 WeChat cover (900ร383)**, plus a **1:1 thumbnail (383ร383)**.
|
|
12
|
+
|
|
13
|
+
No build step, no config. One command and a local server.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpx poon-choi
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Opens the tool on a local port and prints the URL. Then just drag images into the page.
|
|
22
|
+
|
|
23
|
+
### Pick your own port
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpx poon-choi --port 5173
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
poon-choi [options]
|
|
33
|
+
|
|
34
|
+
Options:
|
|
35
|
+
-p, --port <number> Port to listen on (default: 3000)
|
|
36
|
+
-h, --help Show this help
|
|
37
|
+
-v, --version Show version
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Examples
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# default port
|
|
44
|
+
pnpx poon-choi
|
|
45
|
+
|
|
46
|
+
# custom port
|
|
47
|
+
pnpx poon-choi --port 5173
|
|
48
|
+
|
|
49
|
+
# short flag
|
|
50
|
+
pnpx poon-choi -p 3000
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Then open the printed URL (e.g. `http://localhost:5173`) in your browser.
|
|
54
|
+
|
|
55
|
+
> Prefer a global install?
|
|
56
|
+
>
|
|
57
|
+
> ```bash
|
|
58
|
+
> npm i -g poon-choi
|
|
59
|
+
> poon-choi --port 5173
|
|
60
|
+
> ```
|
|
61
|
+
|
|
62
|
+
## What it does
|
|
63
|
+
|
|
64
|
+
* **Input** โ drag & drop, click to pick, or paste from clipboard. Hard cap of **6 images**; extras are ignored with a toast. Non-image and corrupt files are skipped individually.
|
|
65
|
+
|
|
66
|
+
* **Layout** โ auto-arranged by image count:
|
|
67
|
+
|
|
68
|
+
| Images | Layout |
|
|
69
|
+
| ------ | --------------------------------------- |
|
|
70
|
+
| 1 | full-bleed cover-crop |
|
|
71
|
+
| 2 | two equal columns |
|
|
72
|
+
| 3 | three equal columns |
|
|
73
|
+
| 4 | 2ร2 grid |
|
|
74
|
+
| 5โ6 | 3ร2 grid (5 leaves the last cell blank) |
|
|
75
|
+
|
|
76
|
+
* **Fit mode** โ `Cover` (center crop, fills the cell) or `Contain` (whole image, padded with the gap color). Toggle anytime.
|
|
77
|
+
|
|
78
|
+
* **Gap color** โ color picker, a preset palette with visible swatches, and a "cycle through presets" button.
|
|
79
|
+
|
|
80
|
+
* **Boundaries** โ a subtle 1px inner edge per cell so white-on-white images stay distinguishable.
|
|
81
|
+
|
|
82
|
+
* **Reorder** โ drag thumbnails to reorder (free-form insert); remove with ร. On touch devices, โ/โ buttons appear.
|
|
83
|
+
|
|
84
|
+
* **Export**
|
|
85
|
+
* `wechat-cover-900x383.jpg` โ the 2.35:1 cover
|
|
86
|
+
* `wechat-cover-thumbnail-383x383.jpg` โ 1:1 center-crop thumbnail
|
|
87
|
+
* JPEG, quality โ 0.92; preview is DPR-aware, export is exact pixel size.
|
|
88
|
+
|
|
89
|
+
## Why "poon-choi"?
|
|
90
|
+
|
|
91
|
+
Poon choi is a shared basin of many ingredients โ bottom layer of radish and taro soaking up the juices, prized abalone and prawns on top. This tool stacks your images into one basin-shaped cover, each in its own cell, shared as a single frame. One basin, many ingredients.
|
|
92
|
+
|
|
93
|
+
## Requirements
|
|
94
|
+
|
|
95
|
+
* Node.js **22.18.0+**
|
|
96
|
+
* A modern browser (Chrome, Edge, Firefox, Safari)
|
|
97
|
+
|
|
98
|
+
***
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pnpm install
|
|
104
|
+
pnpm dev # start the local server in watch mode
|
|
105
|
+
pnpm build # build for distribution
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Welcome to your new TanStack Start app!
|
|
2
|
+
|
|
3
|
+
# Getting Started
|
|
4
|
+
|
|
5
|
+
To run this application:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
pnpm dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
# Building For Production
|
|
13
|
+
|
|
14
|
+
To build this application for production:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Styling
|
|
21
|
+
|
|
22
|
+
This project uses [Tailwind CSS](https://tailwindcss.com/) for styling.
|
|
23
|
+
|
|
24
|
+
### Removing Tailwind CSS
|
|
25
|
+
|
|
26
|
+
If you prefer not to use Tailwind CSS:
|
|
27
|
+
|
|
28
|
+
1. Remove the demo pages in `src/routes/demo/`
|
|
29
|
+
2. Replace the Tailwind import in `src/styles.css` with your own styles
|
|
30
|
+
3. Remove `tailwindcss()` from the plugins array in `vite.config.ts`
|
|
31
|
+
4. Remove `@tailwindcss/vite` and `tailwindcss` from `package.json`
|
|
32
|
+
|
|
33
|
+
## Linting & Formatting
|
|
34
|
+
|
|
35
|
+
This project uses [Biome](https://biomejs.dev/) for linting and formatting. The following scripts are available:
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm lint
|
|
40
|
+
pnpm format
|
|
41
|
+
pnpm check
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Deploy to Render
|
|
46
|
+
|
|
47
|
+
This project includes a Render Blueprint:
|
|
48
|
+
|
|
49
|
+
1. Push this repo to GitHub, GitLab, or Bitbucket
|
|
50
|
+
2. In Render, choose **New > Blueprint** and connect this repo
|
|
51
|
+
3. Render reads `render.yaml` and creates the web service
|
|
52
|
+
4. In the Render Dashboard, add any secrets from `.env.example` under **Environment**
|
|
53
|
+
5. Deploy
|
|
54
|
+
|
|
55
|
+
The Nitro server handles SSR, server functions, API routes, and static assets.
|
|
56
|
+
Render provides `PORT` automatically; Nitro reads it at runtime.
|
|
57
|
+
|
|
58
|
+
Need a database? Add one from the Render Dashboard, then connect it via
|
|
59
|
+
environment variables. See https://render.com/docs/databases for options.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Shadcn
|
|
63
|
+
|
|
64
|
+
Add components using the latest version of [Shadcn](https://ui.shadcn.com/).
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm dlx shadcn@latest add button
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Routing
|
|
73
|
+
|
|
74
|
+
This project uses [TanStack Router](https://tanstack.com/router) with file-based routing. Routes are managed as files in `src/routes`.
|
|
75
|
+
|
|
76
|
+
### Adding A Route
|
|
77
|
+
|
|
78
|
+
To add a new route to your application just add a new file in the `./src/routes` directory.
|
|
79
|
+
|
|
80
|
+
TanStack will automatically generate the content of the route file for you.
|
|
81
|
+
|
|
82
|
+
Now that you have two routes you can use a `Link` component to navigate between them.
|
|
83
|
+
|
|
84
|
+
### Adding Links
|
|
85
|
+
|
|
86
|
+
To use SPA (Single Page Application) navigation you will need to import the `Link` component from `@tanstack/react-router`.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { Link } from "@tanstack/react-router";
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Then anywhere in your JSX you can use it like so:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<Link to="/about">About</Link>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This will create a link that will navigate to the `/about` route.
|
|
99
|
+
|
|
100
|
+
More information on the `Link` component can be found in the [Link documentation](https://tanstack.com/router/v1/docs/framework/react/api/router/linkComponent).
|
|
101
|
+
|
|
102
|
+
### Using A Layout
|
|
103
|
+
|
|
104
|
+
In the File Based Routing setup the layout is located in `src/routes/__root.tsx`. Anything you add to the root route will appear in all the routes. The route content will appear in the JSX where you render `{children}` in the `shellComponent`.
|
|
105
|
+
|
|
106
|
+
Here is an example layout that includes a header:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router'
|
|
110
|
+
|
|
111
|
+
export const Route = createRootRoute({
|
|
112
|
+
head: () => ({
|
|
113
|
+
meta: [
|
|
114
|
+
{ charSet: 'utf-8' },
|
|
115
|
+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
|
116
|
+
{ title: 'My App' },
|
|
117
|
+
],
|
|
118
|
+
}),
|
|
119
|
+
shellComponent: ({ children }) => (
|
|
120
|
+
<html lang="en">
|
|
121
|
+
<head>
|
|
122
|
+
<HeadContent />
|
|
123
|
+
</head>
|
|
124
|
+
<body>
|
|
125
|
+
<header>
|
|
126
|
+
<nav>
|
|
127
|
+
<Link to="/">Home</Link>
|
|
128
|
+
<Link to="/about">About</Link>
|
|
129
|
+
</nav>
|
|
130
|
+
</header>
|
|
131
|
+
{children}
|
|
132
|
+
<Scripts />
|
|
133
|
+
</body>
|
|
134
|
+
</html>
|
|
135
|
+
),
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
More information on layouts can be found in the [Layouts documentation](https://tanstack.com/router/latest/docs/framework/react/guide/routing-concepts#layouts).
|
|
140
|
+
|
|
141
|
+
## Server Functions
|
|
142
|
+
|
|
143
|
+
TanStack Start provides server functions that allow you to write server-side code that seamlessly integrates with your client components.
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { createServerFn } from '@tanstack/react-start'
|
|
147
|
+
|
|
148
|
+
const getServerTime = createServerFn({
|
|
149
|
+
method: 'GET',
|
|
150
|
+
}).handler(async () => {
|
|
151
|
+
return new Date().toISOString()
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
// Use in a component
|
|
155
|
+
function MyComponent() {
|
|
156
|
+
const [time, setTime] = useState('')
|
|
157
|
+
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
getServerTime().then(setTime)
|
|
160
|
+
}, [])
|
|
161
|
+
|
|
162
|
+
return <div>Server time: {time}</div>
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## API Routes
|
|
167
|
+
|
|
168
|
+
You can create API routes by using the `server` property in your route definitions:
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
172
|
+
import { json } from '@tanstack/react-start'
|
|
173
|
+
|
|
174
|
+
export const Route = createFileRoute('/api/hello')({
|
|
175
|
+
server: {
|
|
176
|
+
handlers: {
|
|
177
|
+
GET: () => json({ message: 'Hello, World!' }),
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Data Fetching
|
|
184
|
+
|
|
185
|
+
There are multiple ways to fetch data in your application. You can use TanStack Query to fetch data from a server. But you can also use the `loader` functionality built into TanStack Router to load the data for a route before it's rendered.
|
|
186
|
+
|
|
187
|
+
For example:
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
191
|
+
|
|
192
|
+
export const Route = createFileRoute('/people')({
|
|
193
|
+
loader: async () => {
|
|
194
|
+
const response = await fetch('https://swapi.dev/api/people')
|
|
195
|
+
return response.json()
|
|
196
|
+
},
|
|
197
|
+
component: PeopleComponent,
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
function PeopleComponent() {
|
|
201
|
+
const data = Route.useLoaderData()
|
|
202
|
+
return (
|
|
203
|
+
<ul>
|
|
204
|
+
{data.results.map((person) => (
|
|
205
|
+
<li key={person.name}>{person.name}</li>
|
|
206
|
+
))}
|
|
207
|
+
</ul>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Loaders simplify your data fetching logic dramatically. Check out more information in the [Loader documentation](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#loader-parameters).
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
# Demo files
|
|
216
|
+
|
|
217
|
+
Files prefixed with `demo` can be safely deleted. They are there to provide a starting point for you to play around with the features you've installed.
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# Learn More
|
|
221
|
+
|
|
222
|
+
You can learn more about all of the offerings from TanStack in the [TanStack documentation](https://tanstack.com).
|
|
223
|
+
|
|
224
|
+
For TanStack Start specific documentation, visit [TanStack Start](https://tanstack.com/start).
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# ๐ฅ ็่๏ผpoon-choi๏ผ
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | ไธญๆ
|
|
4
|
+
|
|
5
|
+
> ไธไธช่ฝป้ๆฌๅฐๆๅก๏ผๆๅคๅผ ๅพ็ๆผๅๆๅพฎไฟกๅฐ้ขโโๅฐฑๅไธไปฝ**็่**๏ผไธ้ตๅฎน็บณๅค็งไธๅ้ฃๆใ
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/poon-choi)
|
|
8
|
+
[](https://www.npmjs.com/package/poon-choi)
|
|
9
|
+
[](./LICENSE)
|
|
10
|
+
|
|
11
|
+
**poon-choi๏ผ็่๏ผ** ๆฏไธ้็ฒค่๏ผๅค็ง้ฃๆ็ ๅจๅไธไธช็้๏ผ็ฑไธ่ณไธไบซ็จใ่ฟไธชๅทฅๅ
ทไนๆฏๅ็๏ผๆพๅ
ฅ 1โ6 ๅผ ๅพ็๏ผๅฎไผ่ชๅจๆผๅบไธๅผ **2.35:1 ็ๅพฎไฟกๅฐ้ข๏ผ900ร383๏ผ**๏ผๅๆถ็ๆไธๅผ **1:1 ็็ผฉ็ฅๅพ๏ผ383ร383๏ผ**ใ
|
|
12
|
+
|
|
13
|
+
ๆ ้ๆๅปบๆต็จ๏ผไธ็จ้ขๅค้
็ฝฎ๏ผไธๆกๅฝไปคๅณๅฏๅฏๅจๆฌๅฐๆๅกใ
|
|
14
|
+
|
|
15
|
+
## ๅฟซ้ไธๆ
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpx poon-choi
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
ๅทฅๅ
ทไผๅจๆฌๅฐ็ซฏๅฃๅฏๅจ๏ผๅนถ่พๅบ่ฎฟ้ฎ้พๆฅ๏ผไนๅ็ดๆฅๆๅพ็ๆๅ
ฅ้กต้ขๅณๅฏใ
|
|
22
|
+
|
|
23
|
+
### ๆๅฎ็ซฏๅฃ
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpx poon-choi --port 5173
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## ไฝฟ็จๆนๅผ
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
poon-choi [้้กน]
|
|
33
|
+
|
|
34
|
+
้้กน๏ผ
|
|
35
|
+
-p, --port <ๆฐๅญ> ็ๅฌ็ซฏๅฃ๏ผ้ป่ฎค๏ผ3000๏ผ
|
|
36
|
+
-h, --help ๅฑ็คบๅธฎๅฉไฟกๆฏ
|
|
37
|
+
-v, --version ๆฅ็็ๆฌ
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### ไฝฟ็จ็คบไพ
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# ไฝฟ็จ้ป่ฎค็ซฏๅฃ
|
|
44
|
+
pnpx poon-choi
|
|
45
|
+
|
|
46
|
+
# ๆๅฎ่ชๅฎไน็ซฏๅฃ
|
|
47
|
+
pnpx poon-choi --port 5173
|
|
48
|
+
|
|
49
|
+
# ไฝฟ็จ็ญๅๆฐ
|
|
50
|
+
pnpx poon-choi -p 3000
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
็ถๅๅจๆต่งๅจๆๅผ่พๅบ็้พๆฅ๏ผไพๅฆ `[http://localhost:5173](http://localhost:5173)`ใ
|
|
54
|
+
|
|
55
|
+
>
|
|
56
|
+
> ๆณ่ฆๅ
จๅฑๅฎ่ฃ
๏ผ
|
|
57
|
+
>
|
|
58
|
+
>
|
|
59
|
+
> ```bash
|
|
60
|
+
> npm i -g poon-choi
|
|
61
|
+
> poon-choi --port 5173
|
|
62
|
+
> ```
|
|
63
|
+
|
|
64
|
+
## ๅ่ฝ่ฏดๆ
|
|
65
|
+
|
|
66
|
+
- **ๅฏผๅ
ฅ** โ ๆฏๆๆๆฝไธไผ ใ็นๅป้ๆฉๆ่
ๅช่ดดๆฟ็ฒ่ดดใๆๅคไธไผ **6 ๅผ ๅพ็**๏ผ่ถ
ๅบ้จๅไผ้่ฟๅผน็ชๆ็คบๅนถๅฟฝ็ฅ๏ผ้ๅพ็ๆไปถใๆๅๆไปถไผๅ็ฌ่ทณ่ฟใ
|
|
67
|
+
- **ๅธๅฑ** โ ๆ นๆฎๅพ็ๆฐ้่ชๅจๆ็๏ผ
|
|
68
|
+
|
|
69
|
+
| ๅพ็ๆฐ้ | ๅธๅฑๆนๅผ |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| 1 | ๅ
จๅฑ่ฃๅ้บๆปก |
|
|
72
|
+
| 2 | ็ญๅฎฝไธคๅ |
|
|
73
|
+
| 3 | ็ญๅฎฝไธๅ |
|
|
74
|
+
| 4 | 2ร2 ็ฝๆ ผ |
|
|
75
|
+
| 5โ6 | 3ร2 ็ฝๆ ผ๏ผ5 ๅผ ๆถๆๅไธๆ ผ็็ฉบ๏ผ |
|
|
76
|
+
|
|
77
|
+
- **ๅกซๅ
ๆจกๅผ** โ `Cover`๏ผๅฑ
ไธญ่ฃๅ๏ผๅกซๆปกๆ ผๅญ๏ผๆ่
`Contain`๏ผๅฎๆดๅฑ็คบๅพ็๏ผ็็ฝไฝฟ็จ้ด้่ฒๅกซๅ
๏ผ๏ผ้ๆถๅๆขใ
|
|
78
|
+
- **้ด้้ข่ฒ** โ ๆพ่ฒๅจใๅธฆ่ฒๅก็้ข่ฎพ่ฐ่ฒๆฟ๏ผ่ฟๆไธ้ฎ่ฝฎๆข้ข่ฎพ้ข่ฒ็ๆ้ฎใ
|
|
79
|
+
- **ๅ้่พน** โ ๆฏไธชๆ ผๅญๅธฆๆ็ปๅพฎ็ 1 ๅ็ด ๅ
่พน็บฟ๏ผ็ฝๅบๅพ็ๅ ๅ ๅจไธ่ตทๆถไน่ฝๅๆธ
่พน็ใ
|
|
80
|
+
- **่ฐๆด้กบๅบ** โ ๆๆฝ็ผฉ็ฅๅพ่ช็ฑๆๅบ๏ผ็นๅป ร ๅ ้คๅพ็ใ่งฆๅฑ่ฎพๅคไผๆพ็คบๅทฆๅณๅๆขๆ้ฎใ
|
|
81
|
+
- **ๅฏผๅบ**
|
|
82
|
+
- `wechat-cover-900x383.jpg` โ 2.35:1 ๅฐ้ขๅพ
|
|
83
|
+
- `wechat-cover-thumbnail-383x383.jpg` โ ๅฑ
ไธญ่ฃๅ็ 1:1 ็ผฉ็ฅๅพ
|
|
84
|
+
- ่พๅบไธบ JPEG๏ผ็ป่ดจ็บฆ 0.92๏ผ้ข่ง้้
่ฎพๅคๅ็ด ๆฏ๏ผๅฏผๅบๅฐบๅฏธไธฅๆ ผ็ฌฆๅๅ็ด ่งๆ ผใ
|
|
85
|
+
|
|
86
|
+
## ไธบไปไนๅซโ็่โ๏ผ
|
|
87
|
+
|
|
88
|
+
็่ๆฏๆฑ่ไผๅค้ฃๆ็ๅคง็๏ผๅบๅฑๆพ่ๅใ่ๅคดๅธ้ฅฑๆฑคๆฑ๏ผ้ฒ้ฑผใๅคง่พ่ฟ็ฑปๅ่ดต้ฃๆๆๅจ้กถๅฑใ่ฟไธชๅทฅๅ
ทๆไฝ ็ๅพ็่ฃ
่ฟๅไธไธชโ็็ถโๅฐ้ข๏ผๆฏๅผ ๅพ็ๅ่ชไธๆ ผ๏ผๅๅนถๆไธๆดๅผ ๅพใไธ้ต็็พๅณใ
|
|
89
|
+
|
|
90
|
+
## ็ฏๅข่ฆๆฑ
|
|
91
|
+
|
|
92
|
+
- Node.js **22.18.0+**
|
|
93
|
+
- ็ฐไปฃๆต่งๅจ๏ผChromeใEdgeใFirefoxใSafari๏ผ
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## ๅผๅ
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pnpm install
|
|
101
|
+
pnpm dev # ๅฏๅจ็ๅฌๆจกๅผ็ๆฌๅฐๆๅก
|
|
102
|
+
pnpm build # ๆๅ
ๅๅธ็ๆฌ
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## ่ฎธๅฏ่ฏ
|
|
106
|
+
|
|
107
|
+
[MIT](./LICENSE)
|
package/bin/index.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// vite dev --port 3000
|
|
4
|
+
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { parseArgs } from 'node:util';
|
|
7
|
+
|
|
8
|
+
main();
|
|
9
|
+
|
|
10
|
+
function main() {
|
|
11
|
+
const { values } = parseArgs({
|
|
12
|
+
options: {
|
|
13
|
+
port: {
|
|
14
|
+
short: 'p',
|
|
15
|
+
type: 'string',
|
|
16
|
+
default: '3000',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
console.log(values);
|
|
22
|
+
|
|
23
|
+
const port = Number(values.port);
|
|
24
|
+
// validate port in a valid range
|
|
25
|
+
const valid = port >= 1024 && port <= 65535
|
|
26
|
+
if (!valid) {
|
|
27
|
+
console.error(`Invalid port number ${values.port}, should be between 1024 and 65535`);
|
|
28
|
+
process.exitCode =1;
|
|
29
|
+
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
spawn('npx', ['vite', 'dev', `--port=${port}`], {
|
|
34
|
+
stdio: 'inherit',
|
|
35
|
+
shell: true,
|
|
36
|
+
})
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poon-choi",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "poon-choi ๐ฒ is a wechat-cover-studio: a cover mosaic tool to generate wechat (2.35:1) cover image using multiple images",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"imports": {
|
|
8
|
+
"#/*": "./src/*"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"poon-choi": "./bin/index.ts"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin/",
|
|
15
|
+
"src/"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "vite dev --port 3000",
|
|
19
|
+
"generate-routes": "tsr generate",
|
|
20
|
+
"build": "vite build",
|
|
21
|
+
"preview": "vite preview",
|
|
22
|
+
"format": "biome format",
|
|
23
|
+
"lint": "biome lint",
|
|
24
|
+
"check": "biome check",
|
|
25
|
+
"start": "node .output/server/index.mjs",
|
|
26
|
+
"test": "echo no test yet",
|
|
27
|
+
"pub:patch": "npm version patch",
|
|
28
|
+
"pub:minor": "npm version minor",
|
|
29
|
+
"pub:major": "npm version major",
|
|
30
|
+
"preversion": "npm test",
|
|
31
|
+
"postversion": "npm publish && git push && git push --tags"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
35
|
+
"@tanstack/react-devtools": "0.10.13",
|
|
36
|
+
"@tanstack/react-router": "1.170.46",
|
|
37
|
+
"@tanstack/react-router-devtools": "1.167.2",
|
|
38
|
+
"@tanstack/react-start": "1.169.4",
|
|
39
|
+
"class-variance-authority": "^0.7.1",
|
|
40
|
+
"clsx": "^2.1.1",
|
|
41
|
+
"lucide-react": "^0.577.0",
|
|
42
|
+
"nitro": "3.0.260610-beta",
|
|
43
|
+
"react": "^19.2.0",
|
|
44
|
+
"react-dom": "^19.2.0",
|
|
45
|
+
"tailwind-merge": "^3.0.2",
|
|
46
|
+
"tailwindcss": "^4.1.18",
|
|
47
|
+
"tw-animate-css": "^1.3.6"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@biomejs/biome": "2.4.5",
|
|
51
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
52
|
+
"@tanstack/devtools-vite": "0.8.5",
|
|
53
|
+
"@tanstack/router-cli": "^1.132.0",
|
|
54
|
+
"@types/node": "^22.10.2",
|
|
55
|
+
"@types/react": "^19.2.0",
|
|
56
|
+
"@types/react-dom": "^19.2.0",
|
|
57
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
58
|
+
"typescript": "^6.0.2",
|
|
59
|
+
"vite": "^8.0.0"
|
|
60
|
+
},
|
|
61
|
+
"pnpm": {
|
|
62
|
+
"onlyBuiltDependencies": [
|
|
63
|
+
"esbuild",
|
|
64
|
+
"lightningcss"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** biome-ignore-all lint/a11y/noStaticElementInteractions: <explanation> */
|
|
2
|
+
/** biome-ignore-all lint/a11y/useKeyWithClickEvents: <explanation> */
|
|
3
|
+
|
|
4
|
+
import { useRef, useState } from 'react'
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
items: unknown[]
|
|
8
|
+
children: React.ReactNode
|
|
9
|
+
onFiles: (files: FileList) => void // โฌ
๏ธ ๅฏนๅบ addFiles
|
|
10
|
+
id?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function DropStage({ items, children, onFiles }: Props) {
|
|
14
|
+
const dragDepth = useRef(0)
|
|
15
|
+
const [isDragOver, setIsDragOver] = useState(false)
|
|
16
|
+
|
|
17
|
+
const handleDragEnter = (e: React.DragEvent) => {
|
|
18
|
+
if (e.dataTransfer && Array.from(e.dataTransfer.types).includes('Files')) {
|
|
19
|
+
e.preventDefault()
|
|
20
|
+
dragDepth.current += 1
|
|
21
|
+
setIsDragOver(true)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const handleDragover = (e: React.DragEvent) => {
|
|
26
|
+
if (e.dataTransfer && Array.from(e.dataTransfer.types).includes('Files')) {
|
|
27
|
+
e.preventDefault()
|
|
28
|
+
e.dataTransfer.dropEffect = 'copy'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const handleDragLeave = (_e: React.DragEvent) => {
|
|
32
|
+
dragDepth.current = Math.max(0, dragDepth.current - 1)
|
|
33
|
+
if (dragDepth.current === 0) setIsDragOver(false)
|
|
34
|
+
}
|
|
35
|
+
const handleDrop = (e: React.DragEvent) => {
|
|
36
|
+
if (e.dataTransfer && Array.from(e.dataTransfer.types).includes('Files')) {
|
|
37
|
+
e.preventDefault()
|
|
38
|
+
dragDepth.current = 0
|
|
39
|
+
setIsDragOver(false)
|
|
40
|
+
onFiles(e.dataTransfer.files)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const className = [
|
|
45
|
+
'stage',
|
|
46
|
+
items.length > 0 && 'has-image',
|
|
47
|
+
isDragOver && 'dragover',
|
|
48
|
+
]
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.join(' ')
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
className={className}
|
|
55
|
+
id="stage"
|
|
56
|
+
onDragEnter={(event) => handleDragEnter(event)}
|
|
57
|
+
onDragLeave={handleDragLeave}
|
|
58
|
+
onDragOver={handleDragover}
|
|
59
|
+
onDrop={handleDrop}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FitMode } from '#/lib/draw'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ๅๆง็ๆจกๅผๅๆขๆ้ฎใ
|
|
5
|
+
* value: 'cover' | 'contain'
|
|
6
|
+
* onChange: (next: 'cover' | 'contain') => void
|
|
7
|
+
*/
|
|
8
|
+
export function FitModeToggle({
|
|
9
|
+
value,
|
|
10
|
+
onChange,
|
|
11
|
+
className = '',
|
|
12
|
+
}: {
|
|
13
|
+
value: FitMode
|
|
14
|
+
onChange: (next: FitMode) => void
|
|
15
|
+
className?: string
|
|
16
|
+
}) {
|
|
17
|
+
const next = value === 'cover' ? 'contain' : 'cover'
|
|
18
|
+
const label = value === 'cover' ? 'Cover' : 'Contain'
|
|
19
|
+
return (
|
|
20
|
+
<button
|
|
21
|
+
type="button"
|
|
22
|
+
onClick={() => onChange(next)}
|
|
23
|
+
aria-pressed={value === 'contain'}
|
|
24
|
+
className={
|
|
25
|
+
'cursor-pointer ' +
|
|
26
|
+
'px-4 py-2.5 rounded-lg text-sm font-medium bg-white text-slate-700 ' +
|
|
27
|
+
'border border-slate-200 transition hover:bg-slate-50 ' +
|
|
28
|
+
className
|
|
29
|
+
}
|
|
30
|
+
>
|
|
31
|
+
่ฃๅชๆจกๅผ๏ผ{label}
|
|
32
|
+
</button>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default function Footer() {
|
|
2
|
+
const year = new Date().getFullYear()
|
|
3
|
+
|
|
4
|
+
return (
|
|
5
|
+
<footer className="mt-20 border-t border-[var(--line)] px-4 pb-14 pt-10 text-[var(--sea-ink-soft)]">
|
|
6
|
+
<div className="page-wrap flex flex-col items-center justify-between gap-4 text-center sm:flex-row sm:text-left">
|
|
7
|
+
<p className="m-0 text-sm">
|
|
8
|
+
© {year} Your name here. All rights reserved.
|
|
9
|
+
</p>
|
|
10
|
+
<p className="island-kicker m-0">Built with TanStack Start</p>
|
|
11
|
+
</div>
|
|
12
|
+
<div className="mt-4 flex justify-center gap-4">
|
|
13
|
+
<a
|
|
14
|
+
href="https://x.com/tan_stack"
|
|
15
|
+
target="_blank"
|
|
16
|
+
rel="noreferrer"
|
|
17
|
+
className="rounded-xl p-2 text-[var(--sea-ink-soft)] transition hover:bg-[var(--link-bg-hover)] hover:text-[var(--sea-ink)]"
|
|
18
|
+
>
|
|
19
|
+
<span className="sr-only">Follow TanStack on X</span>
|
|
20
|
+
<svg viewBox="0 0 16 16" aria-hidden="true" width="32" height="32">
|
|
21
|
+
<path
|
|
22
|
+
fill="currentColor"
|
|
23
|
+
d="M12.6 1h2.2L10 6.48 15.64 15h-4.41L7.78 9.82 3.23 15H1l5.14-5.84L.72 1h4.52l3.12 4.73L12.6 1zm-.77 12.67h1.22L4.57 2.26H3.26l8.57 11.41z"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
</a>
|
|
27
|
+
<a
|
|
28
|
+
href="https://github.com/TanStack"
|
|
29
|
+
target="_blank"
|
|
30
|
+
rel="noreferrer"
|
|
31
|
+
className="rounded-xl p-2 text-[var(--sea-ink-soft)] transition hover:bg-[var(--link-bg-hover)] hover:text-[var(--sea-ink)]"
|
|
32
|
+
>
|
|
33
|
+
<span className="sr-only">Go to TanStack GitHub</span>
|
|
34
|
+
<svg viewBox="0 0 16 16" aria-hidden="true" width="32" height="32">
|
|
35
|
+
<path
|
|
36
|
+
fill="currentColor"
|
|
37
|
+
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"
|
|
38
|
+
/>
|
|
39
|
+
</svg>
|
|
40
|
+
</a>
|
|
41
|
+
</div>
|
|
42
|
+
</footer>
|
|
43
|
+
)
|
|
44
|
+
}
|