Skip to content

Commit ebc2ef7

Browse files
committed
add copy btn
1 parent 3acac5b commit ebc2ef7

3 files changed

Lines changed: 57 additions & 2 deletions

File tree

public/src/app/app.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,20 @@ <h3 i18n="@@installation.step1.title">Install the CLI</h3>
181181
<p i18n="@@installation.step1.desc">Download and install the CLI on your computer</p>
182182

183183
<h4 i18n="@@installation.linux">Linux / macOS</h4>
184-
<pre><code>curl -fsSL https://raw.githubusercontent.com/softwarity/aipilot-cli/main/install.sh | bash</code></pre>
184+
<div class="code-block">
185+
<pre><code>curl -fsSL https://raw.githubusercontent.com/softwarity/aipilot-cli/main/install.sh | bash</code></pre>
186+
<button class="copy-btn" (click)="copyToClipboard('curl -fsSL https://raw.githubusercontent.com/softwarity/aipilot-cli/main/install.sh | bash', $event)">
187+
<span class="material-icons">content_copy</span>
188+
</button>
189+
</div>
185190

186191
<h4 i18n="@@installation.windows">Windows (PowerShell)</h4>
187-
<pre><code>irm https://raw.githubusercontent.com/softwarity/aipilot-cli/main/install.ps1 | iex</code></pre>
192+
<div class="code-block">
193+
<pre><code>irm https://raw.githubusercontent.com/softwarity/aipilot-cli/main/install.ps1 | iex</code></pre>
194+
<button class="copy-btn" (click)="copyToClipboard('irm https://raw.githubusercontent.com/softwarity/aipilot-cli/main/install.ps1 | iex', $event)">
195+
<span class="material-icons">content_copy</span>
196+
</button>
197+
</div>
188198
<p i18n="@@installation.windowsAlt">Or download directly from <a href="https://github.com/softwarity/aipilot-cli/releases" target="_blank">GitHub Releases</a></p>
189199
</div>
190200
</div>

public/src/app/app.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,16 @@ export class App {
3737
// Chemin relatif: depuis /aipilot-cli/fr/ vers /aipilot-cli/en/
3838
return `../${lang.code}/`;
3939
}
40+
41+
copyToClipboard(text: string, event: Event): void {
42+
if (!isPlatformBrowser(this.platformId)) return;
43+
const btn = (event.currentTarget as HTMLElement);
44+
const icon = btn.querySelector('.material-icons');
45+
navigator.clipboard.writeText(text).then(() => {
46+
if (icon) {
47+
icon.textContent = 'check';
48+
setTimeout(() => icon.textContent = 'content_copy', 1500);
49+
}
50+
});
51+
}
4052
}

public/src/styles.scss

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,39 @@ pre {
6565
}
6666
}
6767

68+
.code-block {
69+
position: relative;
70+
71+
.copy-btn {
72+
position: absolute;
73+
top: 8px;
74+
right: 8px;
75+
background: var(--bg-primary);
76+
border: 1px solid var(--border-color);
77+
border-radius: 4px;
78+
padding: 4px;
79+
cursor: pointer;
80+
opacity: 0;
81+
transition: opacity 0.2s;
82+
display: flex;
83+
align-items: center;
84+
justify-content: center;
85+
86+
.material-icons {
87+
font-size: 16px;
88+
color: var(--text-muted);
89+
}
90+
91+
&:hover {
92+
border-color: var(--accent-blue);
93+
94+
.material-icons { color: var(--accent-blue); }
95+
}
96+
}
97+
98+
&:hover .copy-btn { opacity: 1; }
99+
}
100+
68101
h2 {
69102
font-size: 1.3rem;
70103
font-weight: 600;

0 commit comments

Comments
 (0)