Skip to content

Commit 3b166d0

Browse files
committed
Add visual feedback for copied tasks and improve sticky mode behavior in the home panel
1 parent d59cce6 commit 3b166d0

4 files changed

Lines changed: 60 additions & 30 deletions

File tree

‎packages/ui/src/components/editor/panel/Tasks/Tasks.module.scss‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
background-color: var(--vscode-list-hoverBackground);
2020
}
2121

22+
&--copied {
23+
background-color: var(--vscode-list-inactiveSelectionBackground);
24+
}
25+
2226
&__left {
2327
display: flex;
2428
flex-direction: column;
@@ -40,14 +44,15 @@
4044
display: flex;
4145
justify-content: space-between;
4246
align-items: center;
43-
47+
cursor: grab;
4448
margin-bottom: 2px;
4549
}
4650

4751
&__header-left {
4852
display: flex;
4953
align-items: center;
5054
padding-top: 3px;
55+
5156
}
5257

5358
&__time {

‎packages/ui/src/components/editor/panel/Tasks/Tasks.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ export const Tasks: React.FC<Props> = (props) => {
4242
const [editing_timestamp, set_editing_timestamp] = useState<number | null>(
4343
null
4444
)
45+
const [last_copied_timestamp, set_last_copied_timestamp] = useState<
46+
number | null
47+
>(null)
4548
const prevent_edit_ref = useRef(false)
4649

4750
const tree = useMemo(() => add_ids(props.tasks), [props.tasks])
@@ -61,6 +64,7 @@ export const Tasks: React.FC<Props> = (props) => {
6164
depth: number
6265
) => {
6366
const is_editing = editing_timestamp == task.created_at
67+
const is_copied = last_copied_timestamp == task.created_at
6468
const has_children = task.children && task.children.length > 0
6569

6670
const checked_children_count = has_children
@@ -69,7 +73,9 @@ export const Tasks: React.FC<Props> = (props) => {
6973

7074
return (
7175
<div
72-
className={styles.item}
76+
className={cn(styles.item, {
77+
[styles['item--copied']]: is_copied
78+
})}
7379
style={{ paddingLeft: `${10 + depth * 20}px` }}
7480
>
7581
{[...Array(depth)].map((_, i) => (
@@ -140,8 +146,9 @@ export const Tasks: React.FC<Props> = (props) => {
140146
on_click={(e) => {
141147
e.stopPropagation()
142148
props.on_copy(task.text)
149+
set_last_copied_timestamp(task.created_at)
143150
}}
144-
title="Copy task text"
151+
title="Copy Task"
145152
/>
146153
)}
147154
<IconButton

‎packages/vscode/src/views/panel/frontend/Home/Home.module.scss‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,25 @@
8181
margin: 0;
8282
}
8383

84-
&__mode {
85-
display: flex;
86-
position: relative;
87-
background-color: var(--vscode-sideBar-background);
88-
border-radius: 10px;
89-
border: 1px solid var(--cwc-border-color);
90-
overflow: hidden;
84+
&__mode-wrapper {
9185
margin: 0 12px;
92-
z-index: 10;
86+
z-index: 1;
9387

9488
&--sticky {
9589
position: sticky;
9690
top: 10px;
97-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
98-
animation: stickyFadeIn var(--transition-duration-150) var(--transition-timing-function)
91+
animation: stickyFadeIn var(--transition-duration-150)
92+
var(--transition-timing-function);
9993
}
94+
}
95+
96+
&__mode {
97+
position: relative;
98+
display: flex;
99+
background-color: var(--vscode-sideBar-background);
100+
border-radius: 10px;
101+
border: 1px solid var(--cwc-border-color);
102+
overflow: hidden;
100103

101104
> button {
102105
flex: 1;
@@ -113,6 +116,14 @@
113116
background-color: var(--cwc-border-color-dimmed);
114117
pointer-events: none;
115118
}
119+
120+
&--sticky {
121+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
122+
123+
&::after {
124+
height: 20px;
125+
}
126+
}
116127
}
117128

118129
&__empty {

‎packages/vscode/src/views/panel/frontend/Home/Home.tsx‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type Props = {
4545
export const Home: React.FC<Props> = (props) => {
4646
const { t } = use_translation()
4747
const [is_mode_sticky, set_is_mode_sticky] = useState(false)
48+
const full_mode_height_ref = useRef<number>(0)
4849
const responses_ref = useRef<HTMLDivElement>(null)
4950
const mode_ref = useRef<HTMLDivElement>(null)
5051

@@ -100,8 +101,15 @@ export const Home: React.FC<Props> = (props) => {
100101
<Scrollable
101102
on_scroll={(top) => {
102103
const responses_height = responses_ref.current?.clientHeight || 0
103-
const mode_height = mode_ref.current?.clientHeight || 0
104-
set_is_mode_sticky(top > responses_height + mode_height + 4)
104+
const current_mode_height = mode_ref.current?.offsetHeight || 0
105+
106+
if (!is_mode_sticky && current_mode_height > 0) {
107+
full_mode_height_ref.current = current_mode_height
108+
}
109+
110+
const height_to_use = is_mode_sticky ? full_mode_height_ref.current : current_mode_height
111+
112+
set_is_mode_sticky(top > responses_height + height_to_use + 4)
105113
}}
106114
>
107115
<div className={styles.content}>
@@ -127,23 +135,22 @@ export const Home: React.FC<Props> = (props) => {
127135
)}
128136

129137
<div
130-
className={cn(styles.inner__mode, {
131-
[styles['inner__mode--sticky']]: is_mode_sticky
138+
className={cn(styles['inner__mode-wrapper'], {
139+
[styles['inner__mode-wrapper--sticky']]: is_mode_sticky
132140
})}
133-
ref={mode_ref}
141+
style={{
142+
minHeight: is_mode_sticky ? full_mode_height_ref.current : undefined
143+
}}
134144
>
135-
<ModeButton
136-
pre="Autofill"
137-
label="Chatbots"
138-
on_click={props.on_chatbots_click}
139-
is_compact={is_mode_sticky}
140-
/>
141-
<ModeButton
142-
pre="Make"
143-
label="API calls"
144-
on_click={props.on_api_calls_click}
145-
is_compact={is_mode_sticky}
146-
/>
145+
<div
146+
className={cn(styles.inner__mode, {
147+
[styles['inner__mode--sticky']]: is_mode_sticky
148+
})}
149+
ref={mode_ref}
150+
>
151+
<ModeButton pre="Autofill" label="Chatbots" on_click={props.on_chatbots_click} is_compact={is_mode_sticky} />
152+
<ModeButton pre="Make" label="API calls" on_click={props.on_api_calls_click} is_compact={is_mode_sticky} />
153+
</div>
147154
</div>
148155

149156
<Separator height={8} />

0 commit comments

Comments
 (0)