Skip to content

Commit a4ecf5d

Browse files
author
strausr
committed
fix: add copy on click
1 parent d6c68dd commit a4ecf5d

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/src/App.css.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ h2 {
9090
font-size: 0.9rem;
9191
transition: all 0.2s;
9292
user-select: text;
93-
cursor: text;
93+
cursor: pointer;
9494
}
9595

9696
.prompts-list li:hover {

templates/src/App.tsx.template

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ function App() {
2525
alert(`Upload failed: ${error.message}`);
2626
};
2727

28+
const copyPrompt = (e: React.MouseEvent<HTMLLIElement>) => {
29+
const text = e.currentTarget.textContent ?? '';
30+
void navigator.clipboard.writeText(text);
31+
};
32+
2833
// Display uploaded image if available, otherwise show a sample
2934
const imageId = uploadedImageId || 'samples/people/bicycle';
3035

@@ -72,16 +77,16 @@ function App() {
7277
<ul className="prompts-list">
7378
{hasUploadPreset ? (
7479
<>
75-
<li>Create an image gallery with lazy loading and responsive images</li>
76-
<li>Create a video player that plays a Cloudinary video</li>
77-
<li>Add image overlays with text or logos</li>
80+
<li onClick={copyPrompt} title="Click to copy">Create an image gallery with lazy loading and responsive images</li>
81+
<li onClick={copyPrompt} title="Click to copy">Create a video player that plays a Cloudinary video</li>
82+
<li onClick={copyPrompt} title="Click to copy">Add image overlays with text or logos</li>
7883
</>
7984
) : (
8085
<>
81-
<li>Let&apos;s try uploading — help me add an upload preset and upload widget</li>
82-
<li>Create an image gallery with lazy loading and responsive images</li>
83-
<li>Create a video player that plays a Cloudinary video</li>
84-
<li>Add image overlays with text or logos</li>
86+
<li onClick={copyPrompt} title="Click to copy">Let&apos;s try uploading — help me add an upload preset and upload widget</li>
87+
<li onClick={copyPrompt} title="Click to copy">Create an image gallery with lazy loading and responsive images</li>
88+
<li onClick={copyPrompt} title="Click to copy">Create a video player that plays a Cloudinary video</li>
89+
<li onClick={copyPrompt} title="Click to copy">Add image overlays with text or logos</li>
8590
</>
8691
)}
8792
</ul>

0 commit comments

Comments
 (0)