Skip to content

Commit dc3934e

Browse files
christianalfoniSaraVieira
authored andcommitted
SandboxCard: refactor and remove observing (codesandbox#3181)
1 parent bd62d0a commit dc3934e

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

packages/app/src/app/pages/Curator/SandboxCard/index.js renamed to packages/app/src/app/pages/Curator/SandboxCard/index.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
import getTemplate from '@codesandbox/common/lib/templates';
2+
import { GitInfo, User } from '@codesandbox/common/lib/types';
23
import {
3-
sandboxUrl,
44
profileUrl,
5+
sandboxUrl,
56
} from '@codesandbox/common/lib/utils/url-generator';
6-
import { observer } from 'app/componentConnectors';
77
import React, { useCallback, useEffect, useRef, useState } from 'react';
88
import EyeIcon from 'react-icons/lib/fa/eye';
99
import GithubIcon from 'react-icons/lib/fa/github';
1010

1111
import {
12-
Container,
13-
SandboxImageContainer,
14-
SandboxImage,
15-
SandboxInfo,
16-
ImageMessage,
17-
SandboxTitle,
1812
Avatar,
13+
Container,
1914
Details,
2015
FlexCenter,
16+
ImageMessage,
2117
Pick,
18+
SandboxImage,
19+
SandboxImageContainer,
20+
SandboxInfo,
21+
SandboxTitle,
2222
} from './elements';
2323

24-
type Props = {
25-
author: object,
26-
description: string,
27-
git: object,
28-
id: string,
29-
title: string,
30-
viewCount: number,
31-
};
32-
33-
const SandboxCard = ({
24+
interface Props {
25+
author: User;
26+
description: string;
27+
git: GitInfo;
28+
id: string;
29+
title: string;
30+
viewCount: number;
31+
picks: any[];
32+
pickSandbox: (id: string, title: string, description: string) => void;
33+
screenshotUrl: string;
34+
template: any;
35+
}
36+
37+
export const SandboxCard: React.FC<Props> = ({
3438
author,
3539
description,
3640
git,
@@ -41,7 +45,7 @@ const SandboxCard = ({
4145
template,
4246
title,
4347
viewCount,
44-
}: Props) => {
48+
}) => {
4549
const [screenShotURL, setScreenShotURL] = useState(screenshotUrl);
4650
const screenShotTimeout = useRef(null);
4751

@@ -67,7 +71,7 @@ const SandboxCard = ({
6771
}, [checkScreenShot]);
6872

6973
const openSandbox = useCallback(() => {
70-
const url = sandboxUrl({ id });
74+
const url = sandboxUrl({ id, alias: null });
7175

7276
window.open(url, '_blank');
7377
}, [id]);
@@ -168,5 +172,3 @@ const SandboxCard = ({
168172
</div>
169173
);
170174
};
171-
172-
export default observer(SandboxCard);

packages/app/src/app/pages/Curator/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import 'react-day-picker/lib/style.css';
2+
13
import { Button } from '@codesandbox/common/lib/components/Button';
24
import MaxWidth from '@codesandbox/common/lib/components/flex/MaxWidth';
35
import Margin from '@codesandbox/common/lib/components/spacing/Margin';
6+
import { SubTitle } from 'app/components/SubTitle';
7+
import { useOvermind } from 'app/overmind';
8+
import { Navigation } from 'app/pages/common/Navigation';
49
import { format, getTime, subMonths, subWeeks } from 'date-fns';
510
import React, {
611
FunctionComponent,
@@ -9,20 +14,15 @@ import React, {
914
useState,
1015
} from 'react';
1116
import DayPicker from 'react-day-picker';
12-
import 'react-day-picker/lib/style.css';
13-
14-
import { useOvermind } from 'app/overmind';
15-
import { SubTitle } from 'app/components/SubTitle';
16-
import { Navigation } from 'app/pages/common/Navigation';
1717

1818
import {
19-
Container,
2019
Buttons,
20+
Container,
2121
DelayedAnimation,
2222
Heading,
2323
PickerWrapper,
2424
} from './elements';
25-
import SandboxCard from './SandboxCard';
25+
import { SandboxCard } from './SandboxCard';
2626

2727
export const Curator: FunctionComponent = () => {
2828
const {

packages/common/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ export type MiniSandbox = {
255255
description: string;
256256
git: GitInfo;
257257
author: User;
258+
screenshotUrl: string;
258259
};
259260

260261
export type GitCommit = {

0 commit comments

Comments
 (0)