Приложение для заметок, с целями и с ии чатом · VibeGit
Приложение для заметок, с целями и с ии чатом Это приложение для заметок с ии(свои ключи), есть поддерживание целей, их отслеживание по %
prilozhenie-dlya-zametok-s-tselyami-i-s-ii-chato / src / components / ui.tsx 362 строк · изменён 5 нояб., 15:46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
"use client" ;
import Image from "next/image" ;
import { useEffect, useId, useRef, useState, type ReactNode } from "react" ;
import { createPortal } from "react-dom" ;
import { Check , Trash2 , X } from "lucide-react" ;
import { cn } from "@/lib/utils" ;
import { pushOverlay, removeOverlay } from "@/lib/overlay-stack" ;
export
value
size
className
value
size
className
h size size
checked
onChange
label
className
checked
label
className
onDelete
children
label
children
label
dx setDx
startX
dragging
moved
children
open
onClose
label
children
open
label
children
overlayId
open
e
e
onKey
id overlayId close onClose
onKey
overlayId
open onClose overlayId
open
children
open
onClose
title
children
open
title
children
panelRef
overlayId
open
e
e
e
onKey capture
id overlayId close onClose
onKey capture
overlayId
open onClose overlayId
open
title children
image
title
hint
action
image
title
hint
action
title hint action
options
value
onChange
ariaLabel
options value label
value
v
ariaLabel
options opt
active opt value
active
opt
children
onRemove
icon
children
onRemove
icon
icon children onRemove
function
ProgressBar
(
{
,
=
"md"
,
,
}
:
{
:
number
;
?
:
"sm"
|
"md"
|
"lg"
;
?
:
string
;
}
)
{
const
=
===
"sm"
?
"h-1"
:
===
"lg"
?
"h-2.5"
:
"h-1.5"
;
return
(
< div
role = " progressbar"
aria-valuenow = { Math . round ( value * 100 ) }
aria-valuemin = { 0 }
aria-valuemax = { 100 }
className = { cn ( "w-full overflow-hidden rounded-full bg-card-2" , h, className) }
>
< div
className = " h-full rounded-full bg-accent transition-[width] duration-500 ease-out"
style = { { width: ` ${ Math. round ( value * 100 ) } % ` } }
/>
</ div>
)
;
}
export
function
Checkbox
(
{
,
,
,
,
}
:
{
:
boolean
;
onChange
:
(
)
=>
void
;
:
string
;
?
:
string
;
}
)
{
return
(
< button
type = " button"
role = " checkbox"
aria-checked = { checked}
aria-label = { label}
onClick = { onChange}
className = { cn (
"group flex h-6 w-6 shrink-0 items-center justify-center rounded-lg border transition-all duration-150" ,
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent" ,
"active:scale-90" ,
checked
? "border-accent bg-accent"
: "border-line bg-card hover:border-accent" ,
className
) }
>
< Check
className = { cn (
"h-4 w-4 text-white transition-all duration-150" ,
checked ? "scale-100 opacity-100" : "scale-50 opacity-0"
) }
strokeWidth = { 3 }
/>
</ button>
)
;
}
export
function
SwipeToDelete
(
{
,
,
,
}
:
{
onDelete
:
(
)
=>
void
;
:
ReactNode
;
:
string
;
}
)
{
const
[
,
]
=
useState
(
0
)
;
const
=
useRef
(
0
)
;
const
=
useRef
(
false
)
;
const
=
useRef
(
false
)
;
return
(
< div className = " relative overflow-hidden rounded-2xl select-none touch-pan-y" >
< div className = " absolute inset-y-0 right-0 flex w-24 items-center justify-end pr-4" >
< button
onClick = { onDelete}
aria-label = { ` Удалить « ${ label} » ` }
className = " flex h-11 w-11 items-center justify-center rounded-full bg-danger text-white transition-transform active:scale-90"
>
< Trash2 className = " h-5 w-5" />
</ button>
</ div>
< div
className = " relative"
style = { {
transform: ` translateX( ${ dx} px) ` ,
transition: dragging. current ? "none" : "transform 0.2s ease-out" ,
} }
onPointerDown = { ( e) => {
dragging. current = true ;
moved. current = false ;
startX. current = e. clientX ;
} }
onPointerMove = { ( e) => {
if ( ! dragging. current ) return ;
const delta = Math . min ( 0 , Math . max ( - 96 , e. clientX - startX. current ) ) ;
if ( Math . abs ( delta) > 8 ) moved. current = true ;
setDx ( delta) ;
onPointerUp = { ( ) => {
dragging. current = false ;
setDx ( ( v) => ( v < - 56 ? - 96 : 0 ) ) ;
} }
onPointerCancel = { ( ) => {
dragging. current = false ;
setDx ( 0 ) ;
} }
onClickCapture = { ( e) => {
if ( moved. current ) {
e. preventDefault ( ) ;
e. stopPropagation ( ) ;
moved. current = false ;
}
} }
>
{
}
</ div>
</ div>
)
;
}
export
function
FullPage
(
{
,
,
,
,
}
:
{
:
boolean
;
onClose
:
(
)
=>
void
;
:
string
;
:
ReactNode
;
}
)
{
const
=
useId
(
)
;
useEffect
(
(
)
=>
{
if
(
!
)
return
;
const
onKey
=
(
:
KeyboardEvent
)
=>
{
if
(
.
key
===
"Escape"
)
onClose
(
)
;
}
;
window
.
addEventListener
(
"keydown"
,
)
;
pushOverlay
(
{
:
,
:
}
)
;
return
(
)
=>
{
window
.
removeEventListener
(
"keydown"
,
)
;
removeOverlay
(
)
;
}
;
}
,
[
,
,
]
)
;
if
(
!
)
return
null
;
return
createPortal
(
< div
role = " dialog"
aria-modal = " true"
aria-label = { label}
className = " fixed inset-0 z-50 animate-sheet bg-canvas"
>
< div className = " mx-auto flex h-full w-full max-w-md flex-col" >
{
}
</ div>
</ div>
,
document
.
body
)
;
}
export
function
Sheet
(
{
,
,
,
,
}
:
{
:
boolean
;
onClose
:
(
)
=>
void
;
:
string
;
:
ReactNode
;
}
)
{
const
=
useRef < HTMLDivElement>
(
null
)
;
const
=
useId
(
)
;
useEffect
(
(
)
=>
{
if
(
!
)
return
;
const
onKey
=
(
:
KeyboardEvent
)
=>
{
if
(
.
key
===
"Escape"
)
{
.
stopPropagation
(
)
;
onClose
(
)
;
}
}
;
window
.
addEventListener
(
"keydown"
,
,
{
:
true
}
)
;
pushOverlay
(
{
:
,
:
}
)
;
return
(
)
=>
{
window
.
removeEventListener
(
"keydown"
,
,
{
:
true
}
)
;
removeOverlay
(
)
;
}
;
}
,
[
,
,
]
)
;
if
(
!
)
return
null
;
return
createPortal
(
< div
className = " fixed inset-0 z-50 flex items-end justify-center"
role = " dialog"
aria-modal = " true"
aria-label = { title}
>
< button
aria-label = " Закрыть"
onClick = { onClose}
className = " absolute inset-0 animate-fade bg-black/40 backdrop-blur-[2px]"
/>
< div
ref = { panelRef}
className = " relative z-10 max-h-[88dvh] w-full max-w-md animate-sheet overflow-y-auto rounded-t-3xl border border-line bg-card p-5 pb-8 shadow-2xl"
>
< div className = " mb-4 flex items-center justify-between" >
< div className = " mx-auto absolute left-1/2 top-2 h-1 w-10 -translate-x-1/2 rounded-full bg-line" />
< h2 className = " pt-2 text-lg font-bold text-body" >
{
}
</ h2>
< button
onClick = { onClose}
aria-label = " Закрыть панель"
className = " mt-2 flex h-9 w-9 items-center justify-center rounded-full bg-card-2 text-faint transition-all hover:text-body active:scale-90"
>
< X className = " h-4.5 w-4.5" />
</ button>
</ div>
{
}
</ div>
</ div>
,
document
.
body
)
;
}
export
function
EmptyState
(
{
,
,
,
,
}
:
{
:
"empty-notes"
|
"empty-calendar"
|
"empty-goals"
;
:
string
;
:
string
;
?
:
ReactNode
;
}
)
{
return
(
< div className = " flex flex-col items-center gap-4 py-10 text-center animate-rise" >
< div className = " overflow-hidden rounded-3xl border border-line bg-white shadow-sm" >
< Image
src = { ` /assets/ ${ image} .webp ` }
alt = " "
width = { 180 }
height = { 180 }
className = " h-40 w-40 object-cover"
/>
</ div>
< div>
< p className = " font-bold text-body" >
{
}
</ p>
< p className = " mt-1 max-w-[26ch] text-sm leading-relaxed text-faint" >
{
}
</ p>
</ div>
{
}
</ div>
)
;
}
export
function
Segmented
<
T
extends
string
>
(
{
,
,
,
,
}
:
{
:
{
:
T
;
:
string
}
[
]
;
:
T
;
onChange
:
(
:
T
)
=>
void
;
:
string
;
}
)
{
return
(
< div
role = " tablist"
aria-label = { ariaLabel}
className = " relative flex rounded-full bg-card-2 p-1"
>
{
.
map
(
(
)
=>
{
const
=
.
value
===
;
return
(
< button
key = { opt. value }
role = " tab"
aria-selected = { active}
onClick = { ( ) => onChange ( opt. value ) }
className = { cn (
"relative z-10 flex-1 rounded-full px-4 py-1.5 text-sm font-semibold transition-colors duration-200" ,
"focus-visible:outline-2 focus-visible:outline-accent" ,
active ? "text-body" : "text-faint hover:text-body"
) }
>
{
&&
(
< span
aria-hidden
className = " absolute inset-0 -z-10 animate-pop rounded-full bg-card shadow-sm"
/>
)
}
{
.
label
}
</ button>
)
;
}
)
}
</ div>
)
;
}
export
function
Chip
(
{
,
,
,
}
:
{
:
ReactNode
;
?
:
(
)
=>
void
;
?
:
ReactNode
;
}
)
{
return
(
< span className = " inline-flex items-center gap-1.5 rounded-full border border-accent/40 bg-accent-soft px-2.5 py-1 text-xs font-semibold text-accent-strong animate-pop" >
{
}
< span className = " max-w-[16ch] truncate" >
{
}
</ span>
{
&&
(
< button
onClick = { onRemove}
aria-label = " Убрать контекст"
className = " flex h-4 w-4 items-center justify-center rounded-full transition-colors hover:bg-accent/20 active:scale-90"
>
< X className = " h-3 w-3" />
</ button>
)
}
</ span>
)
;
}
}
}