Skip to content

Commit bade600

Browse files
strausreportis-cloudinary
authored andcommitted
fix: simplified questions into arrays
1 parent 9ad35b2 commit bade600

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

templates/src/App.tsx.template

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,20 @@ import './App.css';
1212

1313
const hasUploadPreset = Boolean(uploadPreset);
1414

15+
const PROMPTS_WITH_UPLOAD = [
16+
'Create an image gallery with lazy loading and responsive images',
17+
'Create a video player that plays a Cloudinary video',
18+
'Add image overlays with text or logos',
19+
];
20+
21+
const PROMPTS_WITHOUT_UPLOAD = [
22+
"Let's try uploading — help me add an upload preset and upload widget",
23+
...PROMPTS_WITH_UPLOAD,
24+
];
25+
1526
function App() {
1627
const [uploadedImageId, setUploadedImageId] = useState<string | null>(null);
17-
const [clickedIds, setClickedIds] = useState(new Set());
28+
const [clickedIds, setClickedIds] = useState(new Set<number>());
1829

1930
const handleUploadSuccess = (result: CloudinaryUploadResult) => {
2031
console.log('Upload successful:', result);
@@ -26,8 +37,7 @@ function App() {
2637
alert(`Upload failed: ${error.message}`);
2738
};
2839

29-
const copyPrompt = (e: React.MouseEvent<HTMLLIElement>, id: number) => {
30-
const text = e.currentTarget.textContent ?? '';
40+
const copyPrompt = (text: string, id: number) => {
3141
void navigator.clipboard.writeText(text).then(() => {
3242
setClickedIds((prev) => new Set(prev).add(id));
3343
setTimeout(() => setClickedIds( (prev) => {
@@ -83,20 +93,16 @@ function App() {
8393
<strong>Copy and paste</strong> one of these prompts into your AI assistant:
8494
</p>
8595
<ul className="prompts-list">
86-
{hasUploadPreset ? (
87-
<>
88-
<li key={0} onClick={(e) => copyPrompt(e, 0)} title="Click to copy" className={ clickedIds.has(0) ? "clicked" : '' }>Create an image gallery with lazy loading and responsive images</li>
89-
<li key={1} onClick={(e) => copyPrompt(e, 1)} title="Click to copy" className={ clickedIds.has(1) ? "clicked" : '' }>Create a video player that plays a Cloudinary video</li>
90-
<li key={2} onClick={(e) => copyPrompt(e, 2)} title="Click to copy" className={ clickedIds.has(2) ? "clicked" : '' }>Add image overlays with text or logos</li>
91-
</>
92-
) : (
93-
<>
94-
<li key={0} onClick={(e) => copyPrompt(e, 0)} title="Click to copy" className={ clickedIds.has(0) ? "clicked" : '' }>Let&apos;s try uploading — help me add an upload preset and upload widget</li>
95-
<li key={1} onClick={(e) => copyPrompt(e, 1)} title="Click to copy" className={ clickedIds.has(1) ? "clicked" : '' }>Create an image gallery with lazy loading and responsive images</li>
96-
<li key={2} onClick={(e) => copyPrompt(e, 2)} title="Click to copy" className={ clickedIds.has(2) ? "clicked" : '' }>Create a video player that plays a Cloudinary video</li>
97-
<li key={3} onClick={(e) => copyPrompt(e, 3)} title="Click to copy" className={ clickedIds.has(3) ? "clicked" : '' }>Add image overlays with text or logos</li>
98-
</>
99-
)}
96+
{(hasUploadPreset ? PROMPTS_WITH_UPLOAD : PROMPTS_WITHOUT_UPLOAD).map((text, i) => (
97+
<li
98+
key={i}
99+
onClick={() => copyPrompt(text, i)}
100+
title="Click to copy"
101+
className={clickedIds.has(i) ? 'clicked' : ''}
102+
>
103+
{text}
104+
</li>
105+
))}
100106
</ul>
101107
</div>
102108
</main>

0 commit comments

Comments
 (0)