Skip to content

Commit ff50980

Browse files
authored
Make grid at least have 4 elements + shadow instead of scale (codesandbox#4056)
1 parent d05ead5 commit ff50980

File tree

2 files changed

+23
-13
lines changed
  • packages/app/src/app/pages/NewDashboard/Components

2 files changed

+23
-13
lines changed

packages/app/src/app/pages/NewDashboard/Components/SandboxCard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const SandboxCard = ({ sandbox, isTemplate = false, ...props }) => {
7777
transitionDuration: theme => theme.speeds[4],
7878
':hover, :focus, :focus-within': {
7979
cursor: edit ? 'normal' : 'pointer',
80-
transform: 'scale(0.98)',
80+
boxShadow: theme => '0 4px 16px 0 ' + theme.colors.grays[900],
8181
},
8282
})}
8383
{...props}

packages/app/src/app/pages/NewDashboard/Components/SandboxGrid/index.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@ import React from 'react';
22
import { Grid } from '@codesandbox/components';
33
import css from '@styled-system/css';
44

5-
export const SandboxGrid = props => (
6-
<Grid
7-
rowGap={6}
8-
columnGap={6}
9-
marginBottom={8}
10-
css={css({
11-
gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
12-
})}
13-
>
14-
{props.children}
15-
</Grid>
16-
);
5+
export const SandboxGrid = props => {
6+
const numberOfItems = React.Children.toArray(props.children).filter(
7+
React.isValidElement
8+
).length;
9+
10+
return (
11+
<Grid
12+
rowGap={6}
13+
columnGap={6}
14+
marginBottom={8}
15+
css={css({
16+
gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
17+
})}
18+
>
19+
{props.children}
20+
{numberOfItems < 4
21+
? // fill with empty divs to always maintain 4 elements in a group
22+
Array.from(Array(4 - numberOfItems).keys()).map(n => <div key={n} />)
23+
: null}
24+
</Grid>
25+
);
26+
};

0 commit comments

Comments
 (0)