Skip to content

Commit 31ca087

Browse files
chinmaychaudharySaraVieira
authored andcommitted
🔨 Refactored 🧠 Overmind Hacktober | /Sandbox/Editor/Header/He… (#2644)
1 parent c69229a commit 31ca087

File tree

2 files changed

+53
-47
lines changed

2 files changed

+53
-47
lines changed
Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { dashboardUrl } from '@codesandbox/common/lib/utils/url-generator';
2-
import { inject, hooksObserver } from 'app/componentConnectors';
2+
import { useOvermind } from 'app/overmind';
33
import React from 'react';
44

55
import { UserMenu } from 'app/pages/common/UserMenu';
@@ -29,50 +29,59 @@ import {
2929
import { Logo } from './Logo';
3030
import { MenuBar } from './MenuBar';
3131
import { SandboxName } from './SandboxName';
32-
import { HeaderProps } from './types';
32+
import { IHeaderProps } from './types';
3333

34-
export const Header = inject('store')(
35-
hooksObserver(({ zenMode, store }: HeaderProps & { store: any }) => {
36-
const vscode = store.preferences.settings.experimentVSCode;
34+
export const Header: React.FC<IHeaderProps> = ({ zenMode }) => {
35+
const {
36+
state: {
37+
preferences: {
38+
settings: { experimentVSCode: vscode },
39+
},
40+
isPatron,
41+
updateStatus,
42+
hasLogIn,
43+
isLoggedIn,
44+
user,
45+
},
46+
} = useOvermind();
3747

38-
return (
39-
<Container zenMode={zenMode}>
40-
<Left>
41-
{store.hasLogIn ? (
42-
<DashboardLink to={dashboardUrl()}>
43-
<DashboardIcon />
44-
</DashboardLink>
45-
) : (
46-
<Logo />
47-
)}
48+
return (
49+
<Container zenMode={zenMode}>
50+
<Left>
51+
{hasLogIn ? (
52+
<DashboardLink to={dashboardUrl()}>
53+
<DashboardIcon />
54+
</DashboardLink>
55+
) : (
56+
<Logo />
57+
)}
4858

49-
{vscode ? <MenuBar /> : <SaveAllButton />}
50-
</Left>
59+
{vscode ? <MenuBar /> : <SaveAllButton />}
60+
</Left>
5161

52-
<Centered>
53-
<SandboxName />
54-
</Centered>
62+
<Centered>
63+
<SandboxName />
64+
</Centered>
5565

56-
<Right>
57-
{store.updateStatus === 'available' && <RefreshButton />}
58-
{!store.isLoggedIn || (!store.isPatron && <PatronButton />)}
59-
{!store.isLoggedIn && <PreferencesButton />}
60-
<NewSandboxButton />
61-
{store.isLoggedIn && <LikeButton />}
62-
{store.user && store.user.curatorAt && <PickButton />}
63-
<ShareButton />
64-
<ForkButton />
65-
<AccountContainer>
66-
{store.isLoggedIn ? (
67-
<UserMenuContainer>
68-
<UserMenu />
69-
</UserMenuContainer>
70-
) : (
71-
<SignInButton />
72-
)}
73-
</AccountContainer>
74-
</Right>
75-
</Container>
76-
);
77-
})
78-
);
66+
<Right>
67+
{updateStatus === 'available' && <RefreshButton />}
68+
{!isLoggedIn || (!isPatron && <PatronButton />)}
69+
{!isLoggedIn && <PreferencesButton />}
70+
<NewSandboxButton />
71+
{isLoggedIn && <LikeButton />}
72+
{user && user.curatorAt && <PickButton />}
73+
<ShareButton />
74+
<ForkButton />
75+
<AccountContainer>
76+
{isLoggedIn ? (
77+
<UserMenuContainer>
78+
<UserMenu />
79+
</UserMenuContainer>
80+
) : (
81+
<SignInButton />
82+
)}
83+
</AccountContainer>
84+
</Right>
85+
</Container>
86+
);
87+
};
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import React from 'react';
2-
3-
export interface HeaderProps extends React.FunctionComponent {
1+
export interface IHeaderProps {
42
zenMode: boolean;
5-
store: any;
63
}

0 commit comments

Comments
 (0)