@devries-cameron20 / composio Mirror · read-only / commits / 18c7d4229
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 12:00 UTC

docs: enhance page actions with better UX and mobile support

- Add pill-style buttons with subtle backgrounds and micro-interactions - Add error state handling for copy failures - Improve accessibility with proper ARIA attributes and roles - Add motion-reduce support for users who prefer reduced motion - Mobile optimizations: - Bottom sheet modal on mobile, centered on desktop - Safe area padding for notched devices - Larger touch targets (44px+) - Full-width stacked buttons in modal - 16px font on inputs to prevent iOS zoom - Wrap support for action buttons - Enhanced feedback modal with success animation and better form UX Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 28, 2026 at 14:27 UTC 18c7d42298ecd1481e541ff5302b58ffddaf6491
2 files changed +223 -67
docs/components/feedback.tsx
+135 -45
@@ -78,69 +78,130 @@ export function Feedback({ page }: FeedbackProps) {
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}
@@ -148,37 +209,66 @@ export function Feedback({ page }: FeedbackProps) {
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>
docs/components/page-actions.tsx
+88 -22
@@ -1,6 +1,6 @@
1 'use client';
2
3 -import { useState } from 'react';
3 +import { useState, useCallback } from 'react';
4 import { Copy, Check, Loader2, ExternalLink } from 'lucide-react';
5 import { Feedback } from './feedback';
6
@@ -13,9 +13,10 @@ interface PageActionsProps {
13 * Provides AI-friendly access to documentation content.
14 */
15 export function PageActions({ path }: PageActionsProps) {
16 - const [copyState, setCopyState] = useState<'idle' | 'loading' | 'copied'>('idle');
16 + const [copyState, setCopyState] = useState<'idle' | 'loading' | 'copied' | 'error'>('idle');
17
18 - const handleCopy = async () => {
18 + const handleCopy = useCallback(async () => {
19 + if (copyState === 'loading') return;
20 setCopyState('loading');
21
22 try {
@@ -28,46 +29,111 @@ export function PageActions({ path }: PageActionsProps) {
29 setCopyState('copied');
30 setTimeout(() => setCopyState('idle'), 2000);
31 } catch {
31 - setCopyState('idle');
32 + setCopyState('error');
33 + setTimeout(() => setCopyState('idle'), 2000);
34 + }
35 + }, [path, copyState]);
36 +
37 + const getCopyIcon = () => {
38 + switch (copyState) {
39 + case 'loading':
40 + return (
41 + <Loader2
42 + className="size-3.5 animate-spin motion-reduce:animate-none"
43 + aria-hidden="true"
44 + />
45 + );
46 + case 'copied':
47 + return (
48 + <Check
49 + className="size-3.5 text-emerald-500 dark:text-emerald-400"
50 + aria-hidden="true"
51 + />
52 + );
53 + case 'error':
54 + return (
55 + <Copy
56 + className="size-3.5 text-red-500 dark:text-red-400"
57 + aria-hidden="true"
58 + />
59 + );
60 + default:
61 + return <Copy className="size-3.5" aria-hidden="true" />;
62 }
63 };
64
35 - const handleOpen = () => {
36 - window.open(`${path}.md`, '_blank');
65 + const getCopyLabel = () => {
66 + switch (copyState) {
67 + case 'loading':
68 + return 'Copying…';
69 + case 'copied':
70 + return 'Copied!';
71 + case 'error':
72 + return 'Failed';
73 + default:
74 + return 'Copy page';
75 + }
76 };
77
78 return (
40 - <div className="flex items-center gap-4 mt-2 mb-6">
79 + <div
80 + className="flex flex-wrap items-center gap-1.5 sm:gap-1 mt-2 mb-6"
81 + role="group"
82 + aria-label="Page actions"
83 + >
84 + {/* Copy Button */}
85 <button
86 + type="button"
87 onClick={handleCopy}
88 disabled={copyState === 'loading'}
44 - 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 disabled:opacity-50"
89 + className="inline-flex items-center gap-1.5 px-3 py-2 sm:px-2.5 sm:py-1.5 text-xs font-medium
90 + text-fd-muted-foreground hover:text-fd-foreground
91 + bg-fd-secondary/50 hover:bg-fd-secondary
92 + rounded-md
93 + transition-all duration-150 ease-out
94 + focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring focus-visible:ring-offset-2 focus-visible:ring-offset-fd-background
95 + disabled:pointer-events-none
96 + active:scale-[0.98]
97 + touch-manipulation
98 + motion-reduce:transition-none motion-reduce:active:scale-100"
99 aria-label="Copy page as markdown"
100 + aria-live="polite"
101 >
47 - {copyState === 'loading' ? (
48 - <Loader2 className="w-4 h-4 animate-spin" aria-hidden="true" />
49 - ) : copyState === 'copied' ? (
50 - <Check className="w-4 h-4 text-green-500" aria-hidden="true" />
51 - ) : (
52 - <Copy className="w-4 h-4" aria-hidden="true" />
53 - )}
54 - {copyState === 'copied' ? 'Copied!' : 'Copy page'}
102 + <span className="transition-transform duration-150 ease-out">
103 + {getCopyIcon()}
104 + </span>
105 + <span>{getCopyLabel()}</span>
106 </button>
107
57 - <span className="text-fd-muted-foreground/50" aria-hidden="true">·</span>
58 -
108 + {/* View Markdown Link */}
109 <a
110 href={`${path}.md`}
111 target="_blank"
112 rel="noopener noreferrer"
63 - 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"
113 + className="inline-flex items-center gap-1.5 px-3 py-2 sm:px-2.5 sm:py-1.5 text-xs font-medium
114 + text-fd-muted-foreground hover:text-fd-foreground
115 + bg-fd-secondary/50 hover:bg-fd-secondary
116 + rounded-md
117 + transition-all duration-150 ease-out
118 + focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring focus-visible:ring-offset-2 focus-visible:ring-offset-fd-background
119 + active:scale-[0.98]
120 + touch-manipulation
121 + motion-reduce:transition-none motion-reduce:active:scale-100"
122 + aria-label="View page as markdown (opens in new tab)"
123 >
65 - <ExternalLink className="w-4 h-4" aria-hidden="true" />
66 - View as markdown
124 + <ExternalLink className="size-3.5" aria-hidden="true" />
125 + <span className="hidden xs:inline">View </span>
126 + <span>Markdown</span>
127 </a>
128
69 - <span className="text-fd-muted-foreground/50" aria-hidden="true">·</span>
129 + {/* Divider - hidden on mobile when wrapped */}
130 + <span
131 + className="hidden sm:block mx-1 h-4 w-px bg-fd-border/60"
132 + role="separator"
133 + aria-orientation="vertical"
134 + />
135
136 + {/* Feedback */}
137 <Feedback page={path} />
138 </div>
139 );