Skip to content

Commit 746d013

Browse files
committed
docs: refine package manager selector
1 parent 4185013 commit 746d013

1 file changed

Lines changed: 43 additions & 14 deletions

File tree

docs/src/components/PackageManagerCode.astro

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
1818
<button class="pm-tab" data-pm="yarn">yarn</button>
1919
<button class="pm-tab" data-pm="bun">bun</button>
2020
</div>
21+
</div>
22+
<div class="pm-content">
23+
<pre class="pm-pre" data-pm="npm"><code>{npm}</code></pre>
24+
<pre class="pm-pre" data-pm="pnpm" hidden><code>{pnpm}</code></pre>
25+
<pre class="pm-pre" data-pm="yarn" hidden><code>{yarn}</code></pre>
26+
<pre class="pm-pre" data-pm="bun" hidden><code>{bun}</code></pre>
2127
<button class="pm-copy" aria-label="Copy to clipboard">
2228
<span class="pm-copied">Copied!</span>
2329
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
@@ -26,12 +32,6 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
2632
</svg>
2733
</button>
2834
</div>
29-
<div class="pm-content">
30-
<pre class="pm-pre" data-pm="npm"><code>{npm}</code></pre>
31-
<pre class="pm-pre" data-pm="pnpm" hidden><code>{pnpm}</code></pre>
32-
<pre class="pm-pre" data-pm="yarn" hidden><code>{yarn}</code></pre>
33-
<pre class="pm-pre" data-pm="bun" hidden><code>{bun}</code></pre>
34-
</div>
3535
</div>
3636

3737
<style>
@@ -40,36 +40,49 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
4040
overflow: hidden;
4141
margin: 1rem 0;
4242
background: rgba(255, 255, 255, 0.04);
43-
padding: 0 0.5rem 0.5rem;
43+
padding: 0.5rem;
4444
}
4545

4646
.pm-header {
4747
display: flex;
4848
align-items: center;
49-
justify-content: space-between;
50-
padding: 0 0.5rem;
49+
padding: 0;
50+
margin: 0 0 0.5rem !important;
5151
}
5252

5353
.pm-tabs {
5454
display: inline-flex;
55+
flex: 0 1 auto;
56+
align-items: center;
5557
gap: 0.15rem;
58+
max-width: 100%;
59+
min-width: 0;
60+
overflow-x: auto;
5661
border-radius: 8px;
5762
background: rgba(255, 255, 255, 0.045);
5863
padding: 0.18rem;
5964
}
6065

6166
.pm-tab {
67+
display: flex;
68+
align-items: center;
69+
justify-content: center;
70+
flex: 0 0 auto;
71+
min-height: 1.9rem;
72+
margin: 0 !important;
6273
padding: 0.34rem 0.72rem;
6374
font-size: 0.82rem;
6475
font-weight: 500;
76+
line-height: 1;
6577
color: var(--ve-text-tertiary, rgba(255, 255, 255, 0.4));
6678
background: none;
6779
border: none;
6880
border-radius: 6px;
81+
box-shadow: none;
6982
cursor: pointer;
7083
transition: background 120ms ease, color 120ms ease;
7184
font-family: inherit;
72-
line-height: 1.25;
85+
white-space: nowrap;
7386
}
7487

7588
.pm-tab:hover {
@@ -87,11 +100,17 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
87100
position: relative;
88101
display: flex;
89102
align-items: center;
103+
justify-content: center;
104+
flex: 0 0 auto;
105+
width: 2rem;
106+
height: 2rem;
107+
margin: 0 !important;
90108
background: none;
91109
border: none;
110+
border-radius: 6px;
92111
color: rgba(255, 255, 255, 0.4);
93112
cursor: pointer;
94-
padding: 0.5rem;
113+
padding: 0;
95114
transition: color 0.15s ease;
96115
}
97116

@@ -103,13 +122,11 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
103122
color: rgba(255, 255, 255, 0.8);
104123
outline: 2px solid rgb(var(--sl-color-accent-rgb) / 0.5);
105124
outline-offset: 2px;
106-
border-radius: 4px;
107125
}
108126

109127
.pm-copied {
110128
position: absolute;
111-
right: 100%;
112-
margin-right: 0.5rem;
129+
right: calc(100% + 0.5rem);
113130
font-size: 0.75rem;
114131
color: #22c55e;
115132
opacity: 0;
@@ -124,12 +141,20 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
124141
}
125142

126143
.pm-content {
144+
display: flex;
145+
align-items: center;
146+
gap: 0.75rem;
147+
min-width: 0;
148+
margin: 0 !important;
127149
padding: 0.75rem 1rem;
128150
background: var(--ve-code-bg, #141419);
129151
border-radius: 8px;
130152
}
131153

132154
.pm-pre {
155+
flex: 1 1 auto;
156+
min-width: 0;
157+
overflow-x: auto;
133158
margin: 0 !important;
134159
padding: 0 !important;
135160
background: transparent !important;
@@ -140,6 +165,10 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
140165
.pm-pre code {
141166
border: none !important;
142167
background: transparent !important;
168+
border-radius: 0 !important;
169+
display: block;
170+
padding: 0 !important;
171+
white-space: pre;
143172
}
144173

145174
.pm-pre {

0 commit comments

Comments
 (0)