Skip to content

Commit 65d2ab2

Browse files
ganes1410CompuIves
authored andcommitted
Refactor /app/pages/Profile/Showcase/index.js to /app/pages/Profile/Showcase/index.tsx 🔨 Refactor 🧠 Overmind Hacktoberfest (codesandbox#2766)
* Refactor `/app/pages/Profile/Showcase/index.js` to `/app/pages/Profile/Showcase/index.tsx` * Fix import
1 parent 3e4ceaa commit 65d2ab2

File tree

5 files changed

+84
-82
lines changed

5 files changed

+84
-82
lines changed

packages/app/src/app/components/CodeEditor/Monaco/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,7 @@ class MonacoEditor extends React.Component<Props, State> implements Editor {
946946
),
947947
options: {
948948
inlineClassName: classification.type
949-
? `${classification.kind} ${classification.type}-of-${
950-
classification.parentKind
951-
}`
949+
? `${classification.kind} ${classification.type}-of-${classification.parentKind}`
952950
: classification.kind,
953951
},
954952
}));

packages/app/src/app/pages/Profile/Showcase/index.js

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React from 'react';
2+
import { useOvermind } from 'app/overmind';
3+
4+
import Column from '@codesandbox/common/lib/components/flex/Column';
5+
import Centered from '@codesandbox/common/lib/components/flex/Centered';
6+
import Margin from '@codesandbox/common/lib/components/spacing/Margin';
7+
import { Button } from '@codesandbox/common/lib/components/Button';
8+
9+
import SandboxInfo from './SandboxInfo';
10+
import ShowcasePreview from '../../common/ShowcasePreview';
11+
12+
import { ErrorTitle } from './elements';
13+
14+
export const Showcase: React.FC<{}> = () => {
15+
const {
16+
state: {
17+
profile,
18+
profile: { isLoadingProfile },
19+
preferences: { settings },
20+
isLoggedIn,
21+
},
22+
actions: {
23+
profile: { selectSandboxClicked },
24+
},
25+
} = useOvermind();
26+
const sandbox = profile.showcasedSandbox;
27+
const isCurrentUser = profile.isProfileCurrentUser;
28+
29+
const openModal = () => {
30+
selectSandboxClicked();
31+
};
32+
33+
if (isLoadingProfile) {
34+
return (
35+
<Centered vertical horizontal>
36+
<Margin top={4}>
37+
<ErrorTitle>Loading showcased sandbox...</ErrorTitle>
38+
</Margin>
39+
</Centered>
40+
);
41+
}
42+
43+
if (!sandbox) {
44+
return (
45+
<Centered vertical horizontal>
46+
<Margin top={4}>
47+
<ErrorTitle>
48+
{isCurrentUser ? "You don't" : "This user doesn't"} have any
49+
sandboxes yet
50+
</ErrorTitle>
51+
</Margin>
52+
</Centered>
53+
);
54+
}
55+
56+
return (
57+
<Column alignItems="center">
58+
<Margin top={1}>
59+
{isCurrentUser && (
60+
<Button small onClick={openModal}>
61+
Change Sandbox
62+
</Button>
63+
)}
64+
</Margin>
65+
<Margin top={2} style={{ width: '100%' }}>
66+
<Column alignItems="initial">
67+
<div style={{ flex: 2 }}>
68+
<ShowcasePreview sandbox={sandbox} settings={settings} />
69+
</div>
70+
<div style={{ flex: 1 }}>
71+
<SandboxInfo sandbox={sandbox} isLoggedIn={isLoggedIn} />
72+
</div>
73+
</Column>
74+
</Margin>
75+
</Column>
76+
);
77+
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { NotFound } from 'app/pages/common/NotFound';
1111
import { useOvermind } from 'app/overmind';
1212
import Header from './Header';
1313
import Navigation from './Navigation';
14-
import Showcase from './Showcase';
14+
import { Showcase } from './Showcase';
1515
import Sandboxes from './Sandboxes';
1616
import { Container, Content } from './elements';
1717

packages/common/src/components/flex/Column.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import styled from 'styled-components';
22

33
export default styled.div<{
44
flex?: boolean;
5-
justifyContent: string;
6-
alignItems: string;
5+
justifyContent?: string;
6+
alignItems?: string;
77
}>`
88
display: flex;
99
flex-direction: column;
1010
1111
${props => props.flex && `flex: ${props.flex}`};
1212
13-
justify-content: ${props => props.justifyContent};
14-
align-items: ${props => props.alignItems};
13+
${props =>
14+
props.justifyContent && `justify-content: ${props.justifyContent}`};
15+
${props => props.alignItems && `align-items: ${props.alignItems}`};
1516
`;

0 commit comments

Comments
 (0)