Skip to content

Commit c9bf824

Browse files
committed
Integrate gripper directly into TargetButton component
- gripper icon should be shown by `packages/ui/src/components/editor/prompt-view/TargetButton/TargetButton.tsx`, inside of it (2px from the left edge) - grabber icon is not visible on hover
1 parent 8f3af6a commit c9bf824

6 files changed

Lines changed: 47 additions & 52 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Home/Home.module.scss‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,10 @@
120120
display: flex;
121121
flex-direction: column;
122122

123-
&__target {
123+
&__targets {
124124
display: flex;
125125
flex-direction: column;
126126
gap: 6px;
127-
margin-right: 12px;
128-
overflow: hidden;
129-
border-radius: 10px;
130-
position: relative;
131-
132-
@include modern-ui {
133-
margin-right: 10px;
134-
}
135127

136128
> button {
137129
flex: 1;

‎apps/editor/src/views/prompt/frontend/Home/Home.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export const Home: React.FC<Props> = (props) => {
244244
) : null
245245

246246
const targets_section = (
247-
<div className={styles.inner__target} ref={target_ref}>
247+
<div className={styles.inner__targets} ref={target_ref}>
248248
<UiTargetButtons
249249
items={ordered_target_items}
250250
on_reorder={props.on_targets_reorder}

‎packages/ui/src/components/editor/prompt-view/TargetButton/TargetButton.module.scss‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
position: relative;
2323
cursor: pointer;
2424
gap: 12px;
25+
margin: 0 12px;
26+
27+
@include modern-ui {
28+
margin: 0 10px;
29+
}
2530

2631
&--compact {
2732
justify-content: center;
@@ -70,6 +75,10 @@
7075
&:not(:disabled):hover {
7176
background: var(--vscode-toolbar-hoverBackground);
7277

78+
.button__grabber {
79+
opacity: 0.4;
80+
}
81+
7382
.button__label-char {
7483
animation: wave 0.5s ease-in-out;
7584
}
@@ -82,6 +91,7 @@
8291
background: var(--cwc-blue-background);
8392
color: var(--cwc-blue-foreground);
8493

94+
.button__grabber,
8595
.button__label,
8696
.button__description {
8797
color: var(--cwc-blue-foreground);
@@ -92,6 +102,7 @@
92102
background: var(--cwc-purple-background);
93103
color: var(--cwc-purple-foreground);
94104

105+
.button__grabber,
95106
.button__label,
96107
.button__description {
97108
color: var(--cwc-purple-foreground);
@@ -108,6 +119,25 @@
108119
cursor: default;
109120
}
110121

122+
&__grabber {
123+
position: absolute;
124+
left: 0;
125+
top: 50%;
126+
transform: translateY(-50%) rotate(90deg);
127+
display: flex;
128+
align-items: center;
129+
justify-content: center;
130+
width: 12px;
131+
opacity: 0;
132+
color: var(--cwc-text-color-dimmed);
133+
cursor: grab;
134+
z-index: 1;
135+
136+
&:active {
137+
cursor: grabbing;
138+
}
139+
}
140+
111141
&__label {
112142
@include accent-font;
113143
font-size: 24px;

‎packages/ui/src/components/editor/prompt-view/TargetButton/TargetButton.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Props = {
1111
disabled?: boolean
1212
hover_color?: 'blue' | 'purple'
1313
keycap_char?: string
14+
has_gripper?: boolean
1415
}
1516

1617
export const TargetButton: React.FC<Props> = (props) => {
@@ -29,6 +30,11 @@ export const TargetButton: React.FC<Props> = (props) => {
2930
disabled={!!props.disabled}
3031
>
3132
<AsciiArtEffect />
33+
{props.has_gripper && (
34+
<div className={styles['button__grabber']}>
35+
<span className="codicon codicon-grabber" />
36+
</div>
37+
)}
3238
<KeycapWrapper
3339
char={props.keycap_char}
3440
className={styles['button__keycap-wrapper']}

‎packages/ui/src/components/editor/prompt-view/TargetButtons/TargetButtons.module.scss‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,3 @@
33
flex-direction: column;
44
gap: 6px;
55
}
6-
7-
.item {
8-
display: flex;
9-
align-items: center;
10-
width: 100%;
11-
12-
&:hover .gripper {
13-
opacity: var(--dimmed-opacity);
14-
}
15-
}
16-
17-
.gripper {
18-
display: flex;
19-
align-items: center;
20-
justify-content: center;
21-
flex-shrink: 0;
22-
width: 12px;
23-
opacity: 0;
24-
color: var(--cwc-text-color-dimmed);
25-
cursor: grab;
26-
27-
@include modern-ui {
28-
width: 10px;
29-
transform: translateX(-1px);
30-
}
31-
32-
&:active {
33-
cursor: grabbing;
34-
}
35-
}

‎packages/ui/src/components/editor/prompt-view/TargetButtons/TargetButtons.tsx‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,15 @@ export const TargetButtons = <T extends string>(
3838
animation={150}
3939
>
4040
{props.items.map((item) => (
41-
<div key={item.id} className={styles.item}>
42-
<div className={styles.gripper}>
43-
<span className="codicon codicon-gripper" />
44-
</div>
45-
<TargetButton
46-
label={item.label}
47-
description={item.description}
48-
on_click={item.on_click}
49-
hover_color={item.hover_color}
50-
keycap_char={item.keycap_char}
51-
/>
52-
</div>
41+
<TargetButton
42+
key={item.id}
43+
label={item.label}
44+
description={item.description}
45+
on_click={item.on_click}
46+
hover_color={item.hover_color}
47+
keycap_char={item.keycap_char}
48+
has_gripper
49+
/>
5350
))}
5451
</ReactSortable>
5552
)

0 commit comments

Comments
 (0)