Skip to content

Commit b4a292f

Browse files
committed
fix copy path above code intel
1 parent f1cd946 commit b4a292f

5 files changed

Lines changed: 111 additions & 160 deletions

File tree

public/output.css

Lines changed: 21 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
--color-amber-900: oklch(41.4% 0.112 45.904);
2222
--color-yellow-500: oklch(79.5% 0.184 86.047);
2323
--color-green-200: oklch(92.5% 0.084 155.995);
24-
--color-green-500: oklch(72.3% 0.219 149.579);
2524
--color-green-900: oklch(39.3% 0.095 152.535);
2625
--color-emerald-100: oklch(95% 0.052 163.051);
2726
--color-emerald-200: oklch(90.5% 0.093 164.15);
@@ -1011,21 +1010,6 @@
10111010
}
10121011
}
10131012
}
1014-
.indicator {
1015-
position: relative;
1016-
display: inline-flex;
1017-
width: max-content;
1018-
:where(.indicator-item) {
1019-
z-index: 1;
1020-
position: absolute;
1021-
white-space: nowrap;
1022-
top: var(--indicator-t, 0);
1023-
bottom: var(--indicator-b, auto);
1024-
left: var(--indicator-s, auto);
1025-
right: var(--indicator-e, 0);
1026-
translate: var(--indicator-x, 50%) var(--indicator-y, -50%);
1027-
}
1028-
}
10291013
.range {
10301014
appearance: none;
10311015
webkit-appearance: none;
@@ -1443,18 +1427,12 @@
14431427
.top-0 {
14441428
top: calc(var(--spacing) * 0);
14451429
}
1446-
.top-1\/2 {
1447-
top: calc(1/2 * 100%);
1448-
}
14491430
.top-20 {
14501431
top: calc(var(--spacing) * 20);
14511432
}
14521433
.right-0 {
14531434
right: calc(var(--spacing) * 0);
14541435
}
1455-
.right-12 {
1456-
right: calc(var(--spacing) * 12);
1457-
}
14581436
.left-0 {
14591437
left: calc(var(--spacing) * 0);
14601438
}
@@ -2374,6 +2352,9 @@
23742352
.w-80 {
23752353
width: calc(var(--spacing) * 80);
23762354
}
2355+
.w-fit {
2356+
width: fit-content;
2357+
}
23772358
.w-full {
23782359
width: 100%;
23792360
}
@@ -2419,19 +2400,12 @@
24192400
.flex-grow {
24202401
flex-grow: 1;
24212402
}
2422-
.-translate-y-1\/2 {
2423-
--tw-translate-y: calc(calc(1/2 * 100%) * -1);
2424-
translate: var(--tw-translate-x) var(--tw-translate-y);
2425-
}
24262403
.scale-95 {
24272404
--tw-scale-x: 95%;
24282405
--tw-scale-y: 95%;
24292406
--tw-scale-z: 95%;
24302407
scale: var(--tw-scale-x) var(--tw-scale-y);
24312408
}
2432-
.transform {
2433-
transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
2434-
}
24352409
.skeleton {
24362410
border-radius: var(--radius-box);
24372411
background-color: var(--color-base-300);
@@ -2907,9 +2881,6 @@
29072881
.whitespace-nowrap {
29082882
white-space: nowrap;
29092883
}
2910-
.whitespace-pre {
2911-
white-space: pre;
2912-
}
29132884
.text-amber-900 {
29142885
color: var(--color-amber-900);
29152886
}
@@ -2946,9 +2917,6 @@
29462917
.text-gray-900 {
29472918
color: var(--color-gray-900);
29482919
}
2949-
.text-green-500 {
2950-
color: var(--color-green-500);
2951-
}
29522920
.text-inherit {
29532921
color: inherit;
29542922
}
@@ -4151,21 +4119,6 @@
41514119
--noise: 1;
41524120
}
41534121
}
4154-
@property --tw-translate-x {
4155-
syntax: "*";
4156-
inherits: false;
4157-
initial-value: 0;
4158-
}
4159-
@property --tw-translate-y {
4160-
syntax: "*";
4161-
inherits: false;
4162-
initial-value: 0;
4163-
}
4164-
@property --tw-translate-z {
4165-
syntax: "*";
4166-
inherits: false;
4167-
initial-value: 0;
4168-
}
41694122
@property --tw-scale-x {
41704123
syntax: "*";
41714124
inherits: false;
@@ -4181,26 +4134,6 @@
41814134
inherits: false;
41824135
initial-value: 1;
41834136
}
4184-
@property --tw-rotate-x {
4185-
syntax: "*";
4186-
inherits: false;
4187-
}
4188-
@property --tw-rotate-y {
4189-
syntax: "*";
4190-
inherits: false;
4191-
}
4192-
@property --tw-rotate-z {
4193-
syntax: "*";
4194-
inherits: false;
4195-
}
4196-
@property --tw-skew-x {
4197-
syntax: "*";
4198-
inherits: false;
4199-
}
4200-
@property --tw-skew-y {
4201-
syntax: "*";
4202-
inherits: false;
4203-
}
42044137
@property --tw-space-y-reverse {
42054138
syntax: "*";
42064139
inherits: false;
@@ -4382,6 +4315,21 @@
43824315
syntax: "*";
43834316
inherits: false;
43844317
}
4318+
@property --tw-translate-x {
4319+
syntax: "*";
4320+
inherits: false;
4321+
initial-value: 0;
4322+
}
4323+
@property --tw-translate-y {
4324+
syntax: "*";
4325+
inherits: false;
4326+
initial-value: 0;
4327+
}
4328+
@property --tw-translate-z {
4329+
syntax: "*";
4330+
inherits: false;
4331+
initial-value: 0;
4332+
}
43854333
@property --tw-outline-style {
43864334
syntax: "*";
43874335
inherits: false;
@@ -4395,17 +4343,9 @@
43954343
@layer properties {
43964344
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
43974345
*, ::before, ::after, ::backdrop {
4398-
--tw-translate-x: 0;
4399-
--tw-translate-y: 0;
4400-
--tw-translate-z: 0;
44014346
--tw-scale-x: 1;
44024347
--tw-scale-y: 1;
44034348
--tw-scale-z: 1;
4404-
--tw-rotate-x: initial;
4405-
--tw-rotate-y: initial;
4406-
--tw-rotate-z: initial;
4407-
--tw-skew-x: initial;
4408-
--tw-skew-y: initial;
44094349
--tw-space-y-reverse: 0;
44104350
--tw-divide-y-reverse: 0;
44114351
--tw-border-style: solid;
@@ -4448,6 +4388,9 @@
44484388
--tw-backdrop-saturate: initial;
44494389
--tw-backdrop-sepia: initial;
44504390
--tw-duration: initial;
4391+
--tw-translate-x: 0;
4392+
--tw-translate-y: 0;
4393+
--tw-translate-z: 0;
44514394
--tw-outline-style: solid;
44524395
}
44534396
}

src/components/breadcrumbs.rs

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,79 @@ use leptos::either::Either;
22
use leptos::prelude::*;
33
use leptos_router::components::A;
44

5+
#[component]
6+
pub fn CopyPathButton(path: Signal<String>) -> impl IntoView {
7+
let trimmed_path = Memo::new(move |_| path.get().trim_matches('/').to_string());
8+
let copy_feedback = RwSignal::new(None::<String>);
9+
let copy_path = {
10+
let trimmed_path = trimmed_path.clone();
11+
let copy_feedback = copy_feedback.clone();
12+
move |_event: leptos::ev::MouseEvent| {
13+
let path_value = trimmed_path.get_untracked();
14+
if path_value.is_empty() {
15+
return;
16+
}
17+
18+
if let Some(window) = web_sys::window() {
19+
let clipboard = window.navigator().clipboard();
20+
_ = clipboard.write_text(&path_value);
21+
copy_feedback.set(Some(path_value.clone()));
22+
let signal = copy_feedback.clone();
23+
set_timeout(
24+
move || {
25+
signal.set(None);
26+
},
27+
std::time::Duration::from_secs(2),
28+
);
29+
}
30+
}
31+
};
32+
33+
view! {
34+
<Show when=move || !trimmed_path.get().is_empty() fallback=|| ()>
35+
<div class="flex flex-col gap-2 w-fit">
36+
<button
37+
class="inline-flex items-center gap-2 text-xs font-semibold border border-slate-300 dark:border-slate-600 rounded-md px-3 py-1.5 bg-white/80 dark:bg-slate-900/50 text-slate-700 dark:text-slate-100 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors"
38+
type="button"
39+
on:click=copy_path
40+
title="Copy file path"
41+
>
42+
<svg
43+
xmlns="http://www.w3.org/2000/svg"
44+
viewBox="0 0 24 24"
45+
fill="none"
46+
stroke="currentColor"
47+
stroke-width="1.5"
48+
class="h-3.5 w-3.5"
49+
>
50+
<path
51+
stroke-linecap="round"
52+
stroke-linejoin="round"
53+
d="M8 8h8a2 2 0 012 2v8a2 2 0 01-2 2H8a2 2 0 01-2-2v-8a2 2 0 012-2z"
54+
></path>
55+
<path
56+
stroke-linecap="round"
57+
stroke-linejoin="round"
58+
d="M16 4h-8a2 2 0 00-2 2v2h2V6h8v8h-2v2h2a2 2 0 002-2v-8a2 2 0 00-2-2z"
59+
></path>
60+
</svg>
61+
<span>"Copy path"</span>
62+
</button>
63+
<Show when=move || copy_feedback.get().is_some() fallback=|| ()>
64+
<span class="badge badge-outline text-xs font-mono border-slate-300 dark:border-slate-600 text-slate-700 dark:text-slate-100 bg-white/80 dark:bg-slate-900/40">
65+
{move || {
66+
copy_feedback
67+
.get()
68+
.map(|value| format!("Copied {value}"))
69+
.unwrap_or_default()
70+
}}
71+
</span>
72+
</Show>
73+
</div>
74+
</Show>
75+
}
76+
}
77+
578
#[component]
679
pub fn Breadcrumbs(
780
repo: Signal<String>,
@@ -31,37 +104,6 @@ pub fn Breadcrumbs(
31104
segs
32105
});
33106

34-
let copy_feedback = RwSignal::new(None::<String>);
35-
let copy_segments = {
36-
let segments = segments.clone();
37-
let copy_feedback = copy_feedback.clone();
38-
move |_event: leptos::ev::MouseEvent| {
39-
let parts: Vec<String> = segments
40-
.get_untracked()
41-
.into_iter()
42-
.map(|(name, _, _)| name)
43-
.collect();
44-
45-
if parts.is_empty() {
46-
return;
47-
}
48-
49-
let joined = parts.join("/");
50-
if let Some(window) = web_sys::window() {
51-
let clipboard = window.navigator().clipboard();
52-
_ = clipboard.write_text(&joined);
53-
copy_feedback.set(Some(joined.clone()));
54-
let signal = copy_feedback.clone();
55-
set_timeout(
56-
move || {
57-
signal.set(None);
58-
},
59-
std::time::Duration::from_secs(2),
60-
);
61-
}
62-
}
63-
};
64-
65107
view! {
66108
<div class="flex flex-wrap items-center gap-3 mb-6 text-slate-700 dark:text-slate-300">
67109
<div class="text-sm breadcrumbs flex-1 min-w-0 text-inherit">
@@ -120,45 +162,6 @@ pub fn Breadcrumbs(
120162
/>
121163
</ul>
122164
</div>
123-
<Show when=move || !segments.get().is_empty() fallback=|| ()>
124-
<button
125-
class="inline-flex items-center gap-2 text-xs font-semibold border border-slate-300 dark:border-slate-600 rounded-md px-3 py-1.5 bg-white/80 dark:bg-slate-900/50 text-slate-700 dark:text-slate-100 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors"
126-
type="button"
127-
on:click=copy_segments
128-
title="Copy file path"
129-
>
130-
<svg
131-
xmlns="http://www.w3.org/2000/svg"
132-
viewBox="0 0 24 24"
133-
fill="none"
134-
stroke="currentColor"
135-
stroke-width="1.5"
136-
class="h-3.5 w-3.5"
137-
>
138-
<path
139-
stroke-linecap="round"
140-
stroke-linejoin="round"
141-
d="M8 8h8a2 2 0 012 2v8a2 2 0 01-2 2H8a2 2 0 01-2-2v-8a2 2 0 012-2z"
142-
></path>
143-
<path
144-
stroke-linecap="round"
145-
stroke-linejoin="round"
146-
d="M16 4h-8a2 2 0 00-2 2v2h2V6h8v8h-2v2h2a2 2 0 002-2v-8a2 2 0 00-2-2z"
147-
></path>
148-
</svg>
149-
<span>"Copy path"</span>
150-
</button>
151-
</Show>
152-
<Show when=move || copy_feedback.get().is_some() fallback=|| ()>
153-
<span class="badge badge-outline text-xs font-mono border-slate-300 dark:border-slate-600 text-slate-700 dark:text-slate-100 bg-white/80 dark:bg-slate-900/40">
154-
{move || {
155-
copy_feedback
156-
.get()
157-
.map(|value| format!("Copied {value}"))
158-
.unwrap_or_default()
159-
}}
160-
</span>
161-
</Show>
162165
</div>
163166
}
164167
}

src/components/code_intel_panel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub fn CodeIntelPanel(
111111
let insights_scroll_container = NodeRef::<Div>::new();
112112

113113
view! {
114-
<aside class="w-80 flex-shrink-0 flex flex-col max-h-[calc(100vh-6rem)] bg-white/95 dark:bg-slate-950/70 text-slate-900 dark:text-slate-100 rounded-lg shadow border border-slate-200 dark:border-slate-800 p-4 sticky top-20 backdrop-blur">
114+
<aside class="w-80 flex-shrink-0 flex flex-col max-h-[calc(100vh-6rem)] bg-white/95 dark:bg-slate-950/70 text-slate-900 dark:text-slate-100 rounded-lg shadow border border-slate-200 dark:border-slate-800 p-4 backdrop-blur">
115115
<h2 class="text-xl font-semibold mb-4 text-slate-900 dark:text-white">
116116
"Code Intelligence"
117117
</h2>

src/components/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod quick_navigator;
88
pub mod repo_list;
99
pub mod search_bar;
1010

11-
pub use breadcrumbs::Breadcrumbs;
11+
pub use breadcrumbs::{Breadcrumbs, CopyPathButton};
1212
pub use code_intel_panel::{
1313
CodeIntelPanel, SymbolInsightsResponse, SymbolMatch, SymbolReferenceWithSnippet,
1414
};

0 commit comments

Comments
 (0)