Skip to content

Commit 1db69a8

Browse files
committed
fix a bunch of tiny issues
1 parent 7d126f4 commit 1db69a8

File tree

6 files changed

+77
-68
lines changed

6 files changed

+77
-68
lines changed

packages/app/src/app/components/TeamAvatar/TeamAvatar.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const backgrounds = [
1010
'orange',
1111
'blues.300',
1212
'blues.600',
13-
'blues.700',
13+
'blues.700'
1414
];
1515

1616
interface TeamAvatarProps {
@@ -24,15 +24,15 @@ interface TeamAvatarProps {
2424
const textSizes = {
2525
small: 2,
2626
big: 3,
27-
bigger: 6,
27+
bigger: 6
2828
};
2929

3030
export const TeamAvatar = ({
3131
name,
3232
size = 'big',
3333
className,
3434
avatar,
35-
style,
35+
style
3636
}: TeamAvatarProps) => {
3737
if (!name) return null;
3838

@@ -45,13 +45,14 @@ export const TeamAvatar = ({
4545
<>
4646
<img
4747
css={css({
48-
maxWidth: avatarSize,
49-
maxHeight: avatarSize,
48+
width: avatarSize,
49+
height: avatarSize,
50+
objectFit: 'cover',
5051
borderRadius: 'small',
5152
borderColor: 'sideBar.border',
5253
borderStyle: 'solid',
5354
borderWidth: 1,
54-
boxSizing: 'border-box',
55+
boxSizing: 'border-box'
5556
})}
5657
style={style}
5758
src={avatar}
@@ -72,7 +73,7 @@ export const TeamAvatar = ({
7273
backgroundColor,
7374
color: 'white',
7475
fontWeight: 600,
75-
fontFamily: 'Inter',
76+
fontFamily: 'Inter'
7677
})}
7778
className={className}
7879
>

packages/app/src/app/pages/Profile2/LikedSandboxes.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import { SANDBOXES_PER_PAGE } from './constants';
88
export const LikedSandboxes = ({ menuControls }) => {
99
const {
1010
actions: {
11-
profile: { likedSandboxesPageChanged },
11+
profile: { likedSandboxesPageChanged }
1212
},
1313
state: {
1414
profile: {
1515
current: { username },
1616
isLoadingSandboxes,
1717
currentLikedSandboxesPage,
18-
likedSandboxes,
19-
},
20-
},
18+
likedSandboxes
19+
}
20+
}
2121
} = useOvermind();
2222

2323
// explicitly call it on first page render
@@ -45,7 +45,7 @@ export const LikedSandboxes = ({ menuControls }) => {
4545
rowGap={6}
4646
columnGap={6}
4747
css={{
48-
gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))',
48+
gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))'
4949
}}
5050
>
5151
{isLoadingSandboxes
@@ -62,6 +62,8 @@ export const LikedSandboxes = ({ menuControls }) => {
6262
<SandboxCard sandbox={sandbox} menuControls={menuControls} />
6363
</Column>
6464
))}
65+
<div />
66+
<div />
6567
</Grid>
6668
<Pagination />
6769
</Stack>
@@ -71,14 +73,14 @@ export const LikedSandboxes = ({ menuControls }) => {
7173
const Pagination = () => {
7274
const {
7375
actions: {
74-
profile: { likedSandboxesPageChanged },
76+
profile: { likedSandboxesPageChanged }
7577
},
7678
state: {
7779
profile: {
7880
currentLikedSandboxesPage,
79-
current: { givenLikeCount },
80-
},
81-
},
81+
current: { givenLikeCount }
82+
}
83+
}
8284
} = useOvermind();
8385

8486
const numberOfPages = Math.ceil(givenLikeCount / SANDBOXES_PER_PAGE);

packages/app/src/app/pages/Profile2/ProfileCard.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { motion } from 'framer-motion';
33
import { useOvermind } from 'app/overmind';
44
import { Link as RouterLink } from 'react-router-dom';
55
import {
6+
Grid,
67
Stack,
78
Avatar,
89
Text,
@@ -11,20 +12,20 @@ import {
1112
Button,
1213
Textarea,
1314
Input,
14-
Tooltip,
15+
Tooltip
1516
} from '@codesandbox/components';
1617
import { TeamAvatar } from 'app/components/TeamAvatar';
1718
import css from '@styled-system/css';
1819

1920
export const ProfileCard = ({ defaultEditing = false }) => {
2021
const {
2122
actions: {
22-
profile: { updateUserProfile },
23+
profile: { updateUserProfile }
2324
},
2425
state: {
2526
user: loggedInUser,
26-
profile: { current: user },
27-
},
27+
profile: { current: user }
28+
}
2829
} = useOvermind();
2930

3031
const [editing, setEditing] = React.useState(defaultEditing);
@@ -61,7 +62,7 @@ export const ProfileCard = ({ defaultEditing = false }) => {
6162
borderColor: 'grays.600',
6263
paddingTop: 2,
6364
paddingBottom: 6,
64-
marginBottom: 8,
65+
marginBottom: 8
6566
})}
6667
>
6768
<Stack direction="vertical">
@@ -72,7 +73,7 @@ export const ProfileCard = ({ defaultEditing = false }) => {
7273
paddingX: 6,
7374
paddingY: 6,
7475
// fix height to avoid jumping
75-
height: myProfile ? 230 : 'auto',
76+
height: myProfile ? 230 : 'auto'
7677
})}
7778
>
7879
<Stack gap={4} align="center">
@@ -81,7 +82,7 @@ export const ProfileCard = ({ defaultEditing = false }) => {
8182
css={css({
8283
size: 64,
8384
img: { borderRadius: 'medium' },
84-
span: { fontSize: 3, height: 4, lineHeight: '16px' },
85+
span: { fontSize: 3, height: 4, lineHeight: '16px' }
8586
})}
8687
/>
8788
<Stack direction="vertical">
@@ -121,15 +122,17 @@ export const ProfileCard = ({ defaultEditing = false }) => {
121122
paddingX: 6,
122123
paddingY: 4,
123124
borderTop: '1px solid',
124-
borderColor: 'grays.600',
125+
borderColor: 'grays.600'
125126
})}
126127
>
127128
<Text size={2} weight="bold">
128-
Team
129+
Teams
129130
</Text>
130-
<Stack gap={3}>
131+
<Grid
132+
css={{ gridTemplateColumns: 'repeat(auto-fill, 26px)', gap: 12 }}
133+
>
131134
{user.teams
132-
.slice()
135+
.slice(1) // first one is always personal workspace
133136
.sort((team1, team2) =>
134137
team1.avatarUrl && !team2.avatarUrl ? -1 : 1
135138
)
@@ -140,7 +143,7 @@ export const ProfileCard = ({ defaultEditing = false }) => {
140143
</span>
141144
</Tooltip>
142145
))}
143-
</Stack>
146+
</Grid>
144147
</Stack>
145148
) : null}
146149
<Stack
@@ -149,7 +152,7 @@ export const ProfileCard = ({ defaultEditing = false }) => {
149152
paddingY: 4,
150153
marginBottom: 4,
151154
borderTop: '1px solid',
152-
borderColor: 'grays.600',
155+
borderColor: 'grays.600'
153156
})}
154157
>
155158
<Stack direction="vertical" gap={4} css={{ width: '100%' }}>
@@ -250,7 +253,7 @@ const SocialLinks = ({ username, socialLinks, editing, setSocialLinks }) => (
250253
css={css({
251254
fontWeight: 'normal',
252255
justifyContent: 'start',
253-
paddingX: 0,
256+
paddingX: 0
254257
})}
255258
onClick={() => setSocialLinks([...socialLinks, 'https://'])}
256259
>

packages/app/src/app/pages/Profile2/SandboxCard.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Stats,
88
IconButton,
99
SkeletonText,
10-
isMenuClicked,
10+
isMenuClicked
1111
} from '@codesandbox/components';
1212
import css from '@styled-system/css';
1313
import { ENTER } from '@codesandbox/common/lib/utils/keycodes';
@@ -20,14 +20,14 @@ export const SandboxCard = ({
2020
type = SandboxTypes.DEFAULT_SANDBOX,
2121
sandbox,
2222
menuControls: { onKeyDown, onContextMenu },
23-
index = null,
23+
index = null
2424
}) => {
2525
const {
2626
state: {
2727
user: loggedInUser,
2828
profile: {
29-
current: { username, featuredSandboxes },
30-
},
29+
current: { username, featuredSandboxes }
30+
}
3131
},
3232
actions: {
3333
profile: {
@@ -36,9 +36,9 @@ export const SandboxCard = ({
3636
reorderFeaturedSandboxesInState,
3737
saveFeaturedSandboxesOrder,
3838
removeFeaturedSandboxesInState,
39-
newSandboxShowcaseSelected,
40-
},
41-
},
39+
newSandboxShowcaseSelected
40+
}
41+
}
4242
} = useOvermind();
4343

4444
const ref = React.useRef(null);
@@ -49,7 +49,7 @@ export const SandboxCard = ({
4949
collect: monitor => {
5050
const dragItem = monitor.getItem();
5151
return {
52-
isDragging: dragItem?.sandboxId === sandbox.id,
52+
isDragging: dragItem?.sandboxId === sandbox.id
5353
};
5454
},
5555

@@ -67,7 +67,7 @@ export const SandboxCard = ({
6767
// Rollback any reordering
6868
reorderFeaturedSandboxesInState({
6969
startPosition: index,
70-
endPosition: previousPosition,
70+
endPosition: previousPosition
7171
});
7272
} else {
7373
// remove newly added from featured in state
@@ -86,7 +86,7 @@ export const SandboxCard = ({
8686
} else if (dropResult.name === DropTargets.SHOWCASED_SANDBOX) {
8787
newSandboxShowcaseSelected(item.sandboxId);
8888
}
89-
},
89+
}
9090
});
9191

9292
const [, drop] = useDrop({
@@ -140,12 +140,12 @@ export const SandboxCard = ({
140140

141141
reorderFeaturedSandboxesInState({
142142
startPosition: dragIndex,
143-
endPosition: hoverIndex,
143+
endPosition: hoverIndex
144144
});
145145
// We're mutating the monitor item here to avoid expensive index searches!
146146
item.index = hoverIndex;
147147
},
148-
drop: () => ({ name: DropTargets.PINNED_SANDBOXES }),
148+
drop: () => ({ name: DropTargets.PINNED_SANDBOXES })
149149
});
150150

151151
const myProfile = loggedInUser?.username === username;
@@ -161,11 +161,13 @@ export const SandboxCard = ({
161161
direction="vertical"
162162
gap={4}
163163
onContextMenu={event => onContextMenu(event, sandbox.id)}
164-
onClick={() => {
164+
onClick={(event: React.MouseEvent<HTMLDivElement>) => {
165165
// we use on click instead of anchor tag so that safari renders
166166
// the html5 drag thumbnail instead of text
167167
if (isMenuClicked(event)) return;
168-
window.location.href = sandboxUrl({ id: sandbox.id });
168+
const url = sandboxUrl({ id: sandbox.id });
169+
if (event.ctrlKey || event.metaKey) window.open(url, '_blank');
170+
else window.open(url);
169171
}}
170172
tabIndex={0}
171173
onKeyDown={event => {
@@ -180,7 +182,7 @@ export const SandboxCard = ({
180182
// we transition the thumbnail out so that
181183
// the dragged thumbnail is 100% opacity
182184
transition: 'opacity 75ms',
183-
transitionDelay: '16ms',
185+
transitionDelay: '16ms'
184186
}}
185187
css={css({
186188
backgroundColor: 'grays.700',
@@ -190,12 +192,12 @@ export const SandboxCard = ({
190192
cursor: 'pointer',
191193
overflow: 'hidden',
192194
':hover, :focus, :focus-within': {
193-
boxShadow: theme => '0 4px 16px 0 ' + theme.colors.grays[900],
195+
boxShadow: theme => '0 4px 16px 0 ' + theme.colors.grays[900]
194196
},
195197
':focus, :focus-within': {
196198
outline: 'none',
197-
borderColor: 'blues.600',
198-
},
199+
borderColor: 'blues.600'
200+
}
199201
})}
200202
>
201203
<div
@@ -209,11 +211,11 @@ export const SandboxCard = ({
209211
backgroundSize: 'cover',
210212
backgroundPosition: 'top center',
211213
backgroundRepeat: 'no-repeat',
212-
borderColor: 'grays.600',
214+
borderColor: 'grays.600'
213215
})}
214216
style={{
215217
backgroundImage: `url(${sandbox.screenshotUrl ||
216-
`/api/v1/sandboxes/${sandbox.id}/screenshot.png`})`,
218+
`/api/v1/sandboxes/${sandbox.id}/screenshot.png`})`
217219
}}
218220
/>
219221
<Stack justify="space-between">
@@ -244,15 +246,15 @@ export const SkeletonCard = () => (
244246
backgroundColor: 'grays.700',
245247
border: '1px solid',
246248
borderColor: 'grays.600',
247-
borderRadius: 'medium',
249+
borderRadius: 'medium'
248250
})}
249251
>
250252
<SkeletonText
251253
css={css({
252254
width: '100%',
253255
height: 160 + 1,
254256
borderBottom: '1px solid',
255-
borderColor: 'grays.600',
257+
borderColor: 'grays.600'
256258
})}
257259
/>
258260
<Stack direction="vertical" gap={2} marginX={4} marginBottom={5}>

0 commit comments

Comments
 (0)