Skip to content

Commit 897fb4c

Browse files
committed
Make a spinning icon when expanding takes longer
1 parent 69c9ba1 commit 897fb4c

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

src/vs/workbench/contrib/positronConnections/browser/components/schemaNavigation.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
justify-content: center;
6363
}
6464

65+
.connections-item .expand-collapse-area .animate-spin {
66+
animation: spin 1s linear infinite;
67+
}
68+
6569
.connections-item.selected {
6670
color: var(--vscode-positronVariables-activeSelectionForeground);
6771
background: var(--vscode-positronVariables-activeSelectionBackground);

src/vs/workbench/contrib/positronConnections/browser/components/schemaNavigation.tsx

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,13 @@ const PositronConnectionsItem = (props: React.PropsWithChildren<PositronConnecti
177177

178178
// If the connection is not expandable, we add some more padding.
179179
const padding = props.item.level * 10 + (props.item.expanded === undefined ? 26 : 0);
180+
const [expanding, setExpanding] = useState<boolean>(false);
181+
180182
const handleExpand = () => {
181183
props.onToggleExpand(props.item.id);
184+
setTimeout(() => {
185+
setExpanding(true);
186+
}, 100);
182187
};
183188

184189
const iconClass = (kind?: string) => {
@@ -270,6 +275,25 @@ const PositronConnectionsItem = (props: React.PropsWithChildren<PositronConnecti
270275
}
271276
};
272277

278+
const expandIcon = (() => {
279+
if (props.item.expanded === undefined) {
280+
return <></>;
281+
}
282+
283+
const className = expanding ?
284+
`codicon codicon-loading animate-spin` :
285+
`codicon codicon-chevron-${props.item.expanded ? 'down' : 'right'}`;
286+
287+
return (
288+
<div
289+
className='expand-collapse-area'
290+
onClick={handleExpand}
291+
>
292+
<div className={className} />
293+
</div>
294+
)
295+
})();
296+
273297
return (
274298
<div
275299
className={positronClassNames(
@@ -279,19 +303,7 @@ const PositronConnectionsItem = (props: React.PropsWithChildren<PositronConnecti
279303
style={props.style}
280304
>
281305
<div className='nesting' style={{ width: `${padding}px` }}></div>
282-
{
283-
props.item.expanded === undefined ?
284-
<></> :
285-
<div
286-
className='expand-collapse-area'
287-
onClick={handleExpand}
288-
>
289-
<div
290-
className={`codicon codicon-chevron-${props.item.expanded ? 'down' : 'right'}`}
291-
>
292-
</div>
293-
</div>
294-
}
306+
{expandIcon}
295307
<div
296308
className='connections-details'
297309
onMouseDown={rowMouseDownHandler}

0 commit comments

Comments
 (0)