Skip to content

Commit 9c6f262

Browse files
authored
Feat: Add copy-all button to reduce copy steps on search page (#106)
1 parent d5c758f commit 9c6f262

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/components/SearchResult.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ const SearchResult = (props: SearchResultProps): JSX.Element => {
126126
const bucketUrl = metadata.repositoryOfficial ? '' : `${metadata.repository}`;
127127
const bucketCommandLine = `${bucketName} ${bucketUrl}`.trim();
128128

129+
const bucketCommand = `scoop bucket add ${bucketCommandLine}`;
130+
const appCommand = `scoop install ${installBucketName ? bucketName + '/' : ''}${name}`;
131+
const fullCommand = `${bucketCommand}\n${appCommand}`;
132+
129133
return (
130134
<Card key={id} className="mb-2" ref={cardRef}>
131135
<Card.Header>
@@ -196,13 +200,22 @@ const SearchResult = (props: SearchResultProps): JSX.Element => {
196200
</Col>
197201
<Col lg={6} className="mt-4 mt-lg-0">
198202
<Row>
199-
<CopyToClipboardComponent value={`scoop bucket add ${bucketCommandLine}`} id="bucket-command" />
200-
</Row>
201-
<Row className="mt-2">
202-
<CopyToClipboardComponent
203-
value={`scoop install ${installBucketName ? bucketName + '/' : ''}${name}`}
204-
id="app-command"
205-
/>
203+
<Col className="pe-1">
204+
<Row>
205+
<CopyToClipboardComponent value={`${bucketCommand}`} id="bucket-command" />
206+
</Row>
207+
<Row className="mt-2">
208+
<CopyToClipboardComponent value={`${appCommand}`} id="app-command" />
209+
</Row>
210+
</Col>
211+
<Col xs="auto" className="copy-command-group ps-1 d-flex">
212+
<CopyToClipboardButton
213+
className="copy-command-button"
214+
title="Copy all to clipboard"
215+
variant="outline-secondary"
216+
onClick={() => handleCopyToClipboard(`${fullCommand}`)}
217+
/>
218+
</Col>
206219
</Row>
207220
</Col>
208221
</Row>

0 commit comments

Comments
 (0)