Skip to content

Commit 9236106

Browse files
authored
Sidebar feedback 999 (codesandbox#3585)
* different selection color for editor * remove max height from animation of collapsible * dont make input jump
1 parent 4aa1909 commit 9236106

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Files/DirectoryEntry/Entry/FileInput.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import React, {
66
} from 'react';
77

88
import { ESC, ENTER } from '@codesandbox/common/lib/utils/keycodes';
9-
import { FormField, Input, Stack } from '@codesandbox/components';
9+
import { FormField, Input } from '@codesandbox/components';
1010

1111
function select(el) {
1212
if (el) {
@@ -30,6 +30,7 @@ export const FileInput: FunctionComponent<Props> = ({
3030
onChange,
3131
error,
3232
id,
33+
...props
3334
}) => {
3435
const [currentValue, setCurrentValue] = useState(title);
3536

@@ -50,25 +51,24 @@ export const FileInput: FunctionComponent<Props> = ({
5051
};
5152

5253
return (
53-
<Stack direction="vertical" gap={1}>
54-
<FormField
55-
label={title ? `rename ${title}` : 'set name new file'}
56-
hideLabel
57-
css={{ height: '100%', padding: 0 }}
58-
id={`input-${id}`}
59-
>
60-
<Input
61-
onChange={handleChange}
62-
onBlur={() => onCommit(currentValue, true)}
63-
onKeyUp={handleKeyUp}
64-
ref={select}
65-
value={currentValue}
66-
autoComplete="off"
67-
spellCheck="false"
68-
aria-invalid={Boolean(error)}
69-
aria-errormessage={`error-${id}`}
70-
/>
71-
</FormField>
72-
</Stack>
54+
<FormField
55+
label={title ? `rename ${title}` : 'set name new file'}
56+
hideLabel
57+
css={{ height: '100%', padding: 0 }}
58+
id={`input-${id}`}
59+
>
60+
<Input
61+
onChange={handleChange}
62+
onBlur={() => onCommit(currentValue, true)}
63+
onKeyUp={handleKeyUp}
64+
ref={select}
65+
value={currentValue}
66+
autoComplete="off"
67+
spellCheck="false"
68+
aria-invalid={Boolean(error)}
69+
aria-errormessage={`error-${id}`}
70+
{...props}
71+
/>
72+
</FormField>
7373
);
7474
};

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Files/DirectoryEntry/Entry/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ const Entry: React.FC<IEntryProps> = ({
201201
onCancel={resetState}
202202
onCommit={handleRename}
203203
error={error}
204+
css={css({
205+
// i know how this looks, but to make the input feel like
206+
// it's editing in place, we move it back half the space
207+
// 0.5 * gap of 2 = 1 and then another 1px for the border
208+
// :upside-down:smile:
209+
marginLeft: '-5px',
210+
paddingLeft: 1,
211+
})}
204212
/>
205213
) : (
206214
<Text maxWidth={150}>{title}</Text>

packages/common/src/themes/codesandbox-black.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const colors = {
4040
lineHighlightBackground: tokens.grays[600],
4141
lineHighlightBorder: tokens.grays[600],
4242
rangeHighlightBackground: tokens.grays[600],
43-
selectionBackground: tokens.grays[600],
43+
selectionBackground: tokens.blues[500] + '33', // 20% opacity
4444
selectionHighlightBackground: tokens.grays[600],
4545
wordHighlightStrongBackground: tokens.grays[600],
4646
wordHighlightBackground: tokens.grays[600],
@@ -201,7 +201,7 @@ const colors = {
201201
hoverBackground: null,
202202
},
203203
selection: {
204-
background: tokens.blues[700],
204+
background: tokens.blues[500] + '40', // 25% opacity
205205
},
206206
separator: {
207207
background: tokens.grays[900],

packages/components/src/components/Collapsible/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export const Body = styled(Element)<{
4747
css({
4848
borderBottom: props.open ? '1px solid' : 'none',
4949
borderColor: 'sideBar.border',
50-
maxHeight: props.open ? '1000px' : 0,
5150
overflow: props.open ? 'auto' : 'hidden',
5251
paddingTop: props.open ? 4 : 0,
5352
paddingBottom: props.open ? 8 : 0,

0 commit comments

Comments
 (0)