Skip to content

Commit f7e17a6

Browse files
authored
Sidebar - fix dependencies overlap (codesandbox#3476)
* add maxWidth to text component * fix width of version + select padding
1 parent 78f8464 commit f7e17a6

File tree

4 files changed

+30
-15
lines changed
  • packages

4 files changed

+30
-15
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Dependencies/Dependency/index.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export class Dependency extends React.PureComponent<Props, State> {
149149
>
150150
<Text
151151
variant="muted"
152+
maxWidth={75}
152153
css={{ display: hovering ? 'none' : 'block' }}
153154
>
154155
{formatVersion(dependencies[dependency])}{' '}
@@ -164,7 +165,7 @@ export class Dependency extends React.PureComponent<Props, State> {
164165
css={css({
165166
position: 'absolute',
166167
right: 0,
167-
width: '160px',
168+
width: '150px', // overlay on text
168169
})}
169170
>
170171
{hovering && (
@@ -192,7 +193,11 @@ export class Dependency extends React.PureComponent<Props, State> {
192193
style={{ outline: 'none' }}
193194
singleton={singleton}
194195
>
195-
<Button variant="link" onClick={this.handleOpen}>
196+
<Button
197+
variant="link"
198+
onClick={this.handleOpen}
199+
css={css({ minWidth: 5 })}
200+
>
196201
{open ? <ArrowDropUp /> : <ArrowDropDown />}
197202
</Button>
198203
</Tooltip>
@@ -201,7 +206,11 @@ export class Dependency extends React.PureComponent<Props, State> {
201206
style={{ outline: 'none' }}
202207
singleton={singleton}
203208
>
204-
<Button variant="link" onClick={this.handleRefresh}>
209+
<Button
210+
variant="link"
211+
onClick={this.handleRefresh}
212+
css={css({ minWidth: 5 })}
213+
>
205214
<RefreshIcon />
206215
</Button>
207216
</Tooltip>
@@ -210,7 +219,11 @@ export class Dependency extends React.PureComponent<Props, State> {
210219
style={{ outline: 'none' }}
211220
singleton={singleton}
212221
>
213-
<Button variant="link" onClick={this.handleRemove}>
222+
<Button
223+
variant="link"
224+
onClick={this.handleRemove}
225+
css={css({ minWidth: 5 })}
226+
>
214227
<CrossIcon />
215228
</Button>
216229
</Tooltip>

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,7 @@ const Entry: React.FC<IEntryProps> = ({
202202
error={error}
203203
/>
204204
) : (
205-
<Text
206-
css={{
207-
maxWidth: 150,
208-
overflow: 'hidden',
209-
textOverflow: 'ellipsis',
210-
whiteSpace: 'nowrap',
211-
}}
212-
>
213-
{title}
214-
</Text>
205+
<Text maxWidth={150}>{title}</Text>
215206
)}
216207
{isNotSynced && !state && (
217208
<NotSyncedIcon css={css({ color: 'blues.300' })} />

packages/components/src/components/Select/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const SelectComponent = styled(Input).attrs({ as: 'select' })(
1919
transition: 'all ease',
2020
transitionDuration: theme => theme.speeds[2],
2121

22+
paddingRight: 5, // select has a caret icon on the right
23+
2224
backgroundImage: theme =>
2325
theme && `url(${svg(theme.colors.input.placeholderForeground)})`,
2426
backgroundPosition: 'calc(100% - 8px) center',

packages/components/src/components/Text/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,27 @@ const variants = {
88
danger: 'errorForeground',
99
};
1010

11+
const overflowStyles = {
12+
overflow: 'hidden',
13+
textOverflow: 'ellipsis',
14+
whiteSpace: 'nowrap',
15+
};
16+
1117
export const Text = styled(Element).attrs({ as: 'span' })<{
1218
size?: number;
1319
align?: string;
1420
weight?: string;
1521
block?: boolean;
1622
variant?: 'body' | 'muted' | 'danger';
17-
}>(({ size, align, weight, block, variant = 'body', ...props }) =>
23+
maxWidth?: number;
24+
}>(({ size, align, weight, block, variant = 'body', maxWidth, ...props }) =>
1825
css({
1926
fontSize: size || 'inherit', // from theme.fontSizes
2027
textAlign: align || 'left',
2128
fontWeight: weight || null, // from theme.fontWeights
2229
display: block ? 'block' : 'inline',
2330
color: variants[variant],
31+
maxWidth,
32+
...(maxWidth ? overflowStyles : {}),
2433
})
2534
);

0 commit comments

Comments
 (0)