78
return (
79
<>
80
<button
81
+ type="button"
82
onClick={() => setIsOpen(true)}
82
- className="inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground hover:text-fd-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring"
83
- aria-label="Share feedback"
83
+ className="inline-flex items-center gap-1.5 px-3 py-2 sm:px-2.5 sm:py-1.5 text-xs font-medium
84
+ text-fd-muted-foreground hover:text-fd-foreground
85
+ bg-fd-secondary/50 hover:bg-fd-secondary
86
+ rounded-md
87
+ transition-all duration-150 ease-out
88
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring focus-visible:ring-offset-2 focus-visible:ring-offset-fd-background
89
+ active:scale-[0.98]
90
+ touch-manipulation
91
+ motion-reduce:transition-none motion-reduce:active:scale-100"
92
+ aria-label="Share feedback about this page"
93
>
85
- <MessageSquare className="w-4 h-4" aria-hidden="true" />
86
- Share feedback
94
+ <MessageSquare className="size-3.5" aria-hidden="true" />
95
+ <span>Feedback</span>
96
</button>
97
98
{isOpen && (
99
<div
91
- className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"
100
+ className="fixed inset-0 z-50 flex items-end sm:items-center justify-center
101
+ bg-black/60 backdrop-blur-sm
102
+ animate-in fade-in duration-150
103
+ motion-reduce:animate-none
104
+ p-0 sm:p-4"
105
onClick={handleClose}
106
+ role="dialog"
107
+ aria-modal="true"
108
+ aria-labelledby="feedback-title"
109
>
110
<div
95
- className="bg-fd-background border border-fd-border rounded-lg shadow-lg w-full max-w-md mx-4 p-6"
111
+ className="bg-fd-background border border-fd-border shadow-2xl
112
+ w-full max-w-md p-5 sm:p-6
113
+ pb-[calc(1.25rem+env(safe-area-inset-bottom))] sm:pb-6
114
+ rounded-t-xl sm:rounded-xl
115
+ animate-in slide-in-from-bottom duration-200 sm:zoom-in-95
116
+ motion-reduce:animate-none
117
+ overscroll-contain
118
+ max-h-[90vh] overflow-y-auto"
119
onClick={(e) => e.stopPropagation()}
120
>
121
<div className="flex items-center justify-between mb-4">
99
- <h2 className="text-lg font-semibold">Share feedback</h2>
122
+ <h2 id="feedback-title" className="text-lg font-semibold text-fd-foreground">
123
+ Share feedback
124
+ </h2>
125
<button
126
+ type="button"
127
onClick={handleClose}
102
- className="text-fd-muted-foreground hover:text-fd-foreground transition-colors"
103
- aria-label="Close"
128
+ className="p-1.5 -m-1.5 rounded-md
129
+ text-fd-muted-foreground hover:text-fd-foreground hover:bg-fd-secondary
130
+ transition-all duration-150 ease-out
131
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring
132
+ active:scale-95
133
+ motion-reduce:transition-none motion-reduce:active:scale-100"
134
+ aria-label="Close feedback dialog"
135
>
105
- <X className="w-5 h-5" />
136
+ <X className="size-5" aria-hidden="true" />
137
</button>
138
</div>
139
140
{state === 'success' ? (
110
- <p className="text-green-600 text-center py-8">
111
- Thank you for your feedback!
112
- </p>
141
+ <div
142
+ className="text-center py-8 animate-in fade-in zoom-in-95 duration-200 motion-reduce:animate-none"
143
+ role="status"
144
+ aria-live="polite"
145
+ >
146
+ <div className="inline-flex items-center justify-center size-12 mb-3 rounded-full bg-emerald-100 dark:bg-emerald-900/30">
147
+ <svg
148
+ className="size-6 text-emerald-600 dark:text-emerald-400"
149
+ fill="none"
150
+ viewBox="0 0 24 24"
151
+ stroke="currentColor"
152
+ strokeWidth={2}
153
+ aria-hidden="true"
154
+ >
155
+ <path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
156
+ </svg>
157
+ </div>
158
+ <p className="text-fd-foreground font-medium">Thank you!</p>
159
+ <p className="text-sm text-fd-muted-foreground mt-1">Your feedback helps us improve.</p>
160
+ </div>
161
) : (
162
<form onSubmit={handleSubmit}>
163
<p className="text-sm text-fd-muted-foreground mb-4">
164
Help us improve our documentation by sharing your thoughts.
165
</p>
166
119
- <div className="flex gap-2 mb-4">
120
- {[
121
- { value: 'positive', emoji: '😊', label: 'Positive' },
122
- { value: 'neutral', emoji: '😐', label: 'Neutral' },
123
- { value: 'negative', emoji: '😞', label: 'Negative' },
124
- ].map((option) => (
125
- <button
126
- key={option.value}
127
- type="button"
128
- onClick={() => setSentiment(option.value as Sentiment)}
129
- className={`flex-1 py-2 px-3 rounded-md border text-xl transition-colors ${
130
- sentiment === option.value
131
- ? 'border-fd-primary bg-fd-primary/10'
132
- : 'border-fd-border hover:border-fd-muted-foreground'
133
- }`}
134
- aria-label={option.label}
135
- >
136
- {option.emoji}
137
- </button>
138
- ))}
139
- </div>
167
+ <fieldset className="mb-4">
168
+ <legend className="sr-only">How would you rate this page?</legend>
169
+ <div className="flex gap-2" role="radiogroup" aria-label="Sentiment">
170
+ {[
171
+ { value: 'positive', emoji: '😊', label: 'Positive' },
172
+ { value: 'neutral', emoji: '😐', label: 'Neutral' },
173
+ { value: 'negative', emoji: '😞', label: 'Negative' },
174
+ ].map((option) => (
175
+ <button
176
+ key={option.value}
177
+ type="button"
178
+ onClick={() => setSentiment(option.value as Sentiment)}
179
+ className={`flex-1 py-3 sm:py-2.5 px-3 rounded-lg border text-xl
180
+ transition-all duration-150 ease-out
181
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring focus-visible:ring-offset-2 focus-visible:ring-offset-fd-background
182
+ active:scale-[0.98]
183
+ touch-manipulation
184
+ motion-reduce:transition-none motion-reduce:active:scale-100
185
+ ${
186
+ sentiment === option.value
187
+ ? 'border-fd-primary bg-fd-primary/10 shadow-sm ring-1 ring-fd-primary/20'
188
+ : 'border-fd-border hover:border-fd-muted-foreground hover:bg-fd-secondary/50'
189
+ }`}
190
+ role="radio"
191
+ aria-checked={sentiment === option.value}
192
+ aria-label={option.label}
193
+ >
194
+ <span className="block transform transition-transform duration-150 hover:scale-110 motion-reduce:hover:scale-100">
195
+ {option.emoji}
196
+ </span>
197
+ </button>
198
+ ))}
199
+ </div>
200
+ </fieldset>
201
202
<label className="block mb-4">
142
- <span className="text-sm font-medium">
143
- Your feedback <span className="text-red-500">*</span>
203
+ <span className="text-sm font-medium text-fd-foreground">
204
+ Your feedback <span className="text-red-500 dark:text-red-400">*</span>
205
</span>
206
<textarea
207
value={message}
209
placeholder="Tell us what you think…"
210
required
211
rows={4}
151
- className="mt-1 w-full px-3 py-2 border border-fd-border rounded-md bg-fd-background text-fd-foreground placeholder:text-fd-muted-foreground focus:outline-none focus:ring-2 focus:ring-fd-ring resize-none"
212
+ className="mt-1.5 w-full px-3 py-3 sm:py-2.5 border border-fd-border rounded-lg
213
+ bg-fd-background text-fd-foreground text-base sm:text-sm
214
+ placeholder:text-fd-muted-foreground
215
+ transition-colors duration-150
216
+ focus:outline-none focus:ring-2 focus:ring-fd-ring focus:border-transparent
217
+ resize-none"
218
/>
219
</label>
220
221
<label className="block mb-6">
156
- <span className="text-sm font-medium">Email (optional)</span>
222
+ <span className="text-sm font-medium text-fd-foreground">
223
+ Email <span className="text-fd-muted-foreground font-normal">(optional)</span>
224
+ </span>
225
<input
226
type="email"
227
value={email}
228
onChange={(e) => setEmail(e.target.value)}
161
- placeholder="your@email.com"
229
+ placeholder="you@example.com"
230
autoComplete="email"
163
- className="mt-1 w-full px-3 py-2 border border-fd-border rounded-md bg-fd-background text-fd-foreground placeholder:text-fd-muted-foreground focus:outline-none focus:ring-2 focus:ring-fd-ring"
231
+ className="mt-1.5 w-full px-3 py-3 sm:py-2.5 border border-fd-border rounded-lg
232
+ bg-fd-background text-fd-foreground text-base sm:text-sm
233
+ placeholder:text-fd-muted-foreground
234
+ transition-colors duration-150
235
+ focus:outline-none focus:ring-2 focus:ring-fd-ring focus:border-transparent"
236
/>
237
</label>
238
167
- <div className="flex gap-3 justify-end">
239
+ <div className="flex flex-col-reverse sm:flex-row gap-2 sm:gap-3 sm:justify-end pt-4 border-t border-fd-border/50">
240
<button
241
type="button"
242
onClick={handleClose}
171
- className="px-4 py-2 text-sm font-medium text-fd-muted-foreground hover:text-fd-foreground transition-colors"
243
+ className="w-full sm:w-auto px-4 py-2.5 sm:py-2 text-sm font-medium rounded-lg
244
+ text-fd-muted-foreground hover:text-fd-foreground hover:bg-fd-secondary
245
+ transition-all duration-150 ease-out
246
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring
247
+ active:scale-[0.98]
248
+ touch-manipulation
249
+ motion-reduce:transition-none motion-reduce:active:scale-100"
250
>
251
Cancel
252
</button>
253
<button
254
type="submit"
255
disabled={!message.trim() || state === 'loading'}
178
- className="px-4 py-2 text-sm font-medium bg-fd-primary text-fd-primary-foreground rounded-md hover:bg-fd-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors inline-flex items-center gap-2"
256
+ className="w-full sm:w-auto px-4 py-2.5 sm:py-2 text-sm font-medium rounded-lg
257
+ bg-fd-primary text-fd-primary-foreground
258
+ hover:bg-fd-primary/90
259
+ disabled:opacity-50 disabled:pointer-events-none
260
+ transition-all duration-150 ease-out
261
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring focus-visible:ring-offset-2 focus-visible:ring-offset-fd-background
262
+ active:scale-[0.98]
263
+ touch-manipulation
264
+ motion-reduce:transition-none motion-reduce:active:scale-100
265
+ inline-flex items-center justify-center gap-2"
266
+ aria-live="polite"
267
>
180
- {state === 'loading' && <Loader2 className="w-4 h-4 animate-spin" />}
181
- {state === 'error' ? 'Try again' : 'Submit feedback'}
268
+ {state === 'loading' && (
269
+ <Loader2 className="size-4 animate-spin motion-reduce:animate-none" aria-hidden="true" />
270
+ )}
271
+ <span>{state === 'loading' ? 'Sending…' : state === 'error' ? 'Try again' : 'Submit'}</span>
272
</button>
273
</div>
274
</form>