Skip to content

Commit b801a3d

Browse files
🔨 Switch Profile/Navigation to use useOvermind (codesandbox#3408)
1 parent 6f1aed4 commit b801a3d

File tree

5 files changed

+71
-75
lines changed

5 files changed

+71
-75
lines changed

‎packages/app/src/app/pages/Profile/Navigation/elements.js‎

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Row from '@codesandbox/common/lib/components/flex/Row';
2+
import delayEffect from '@codesandbox/common/lib/utils/animation/delay-effect';
3+
import { NavLink } from 'react-router-dom';
4+
import styled, { css } from 'styled-components';
5+
6+
export const NavigationLink = styled(NavLink).attrs({
7+
activeStyle: {
8+
color: 'white',
9+
},
10+
})<{ isLast?: boolean }>`
11+
${({ isLast = false }) => css`
12+
transition: 0.3s ease all;
13+
14+
display: block;
15+
color: white;
16+
padding: 0 4rem;
17+
margin: 1.5rem 0;
18+
font-size: 1.25rem;
19+
font-weight: 300;
20+
text-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
21+
color: rgba(255, 255, 255, 0.5);
22+
text-decoration: none;
23+
24+
${!isLast &&
25+
css`
26+
border-right: 1px solid rgba(255, 255, 255, 0.2);
27+
`};
28+
29+
${delayEffect(0.2)};
30+
&:hover {
31+
color: white;
32+
}
33+
`};
34+
`;
35+
36+
export const CenteredRow = styled(Row)`
37+
width: 100%;
38+
`;

‎packages/app/src/app/pages/Profile/Navigation/index.js‎

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { FunctionComponent } from 'react';
2+
3+
import { useOvermind } from 'app/overmind';
4+
5+
import { NavigationLink, CenteredRow } from './elements';
6+
7+
export const Navigation: FunctionComponent = () => {
8+
const {
9+
state: {
10+
profile: {
11+
current: { givenLikeCount, sandboxCount, username },
12+
},
13+
},
14+
} = useOvermind();
15+
16+
return (
17+
<CenteredRow alignItems="center" justifyContent="center">
18+
<NavigationLink exact to={`/u/${username}`}>
19+
SHOWCASE
20+
</NavigationLink>
21+
22+
<NavigationLink to={`/u/${username}/sandboxes`}>
23+
SANDBOXES ({sandboxCount})
24+
</NavigationLink>
25+
26+
<NavigationLink isLast to={`/u/${username}/likes`}>
27+
LIKES ({givenLikeCount})
28+
</NavigationLink>
29+
</CenteredRow>
30+
);
31+
};

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { NotFound } from 'app/pages/common/NotFound';
1212

1313
import { Container, Content, Margin } from './elements';
1414
import Header from './Header';
15-
import Navigation from './Navigation';
15+
import { Navigation } from './Navigation';
1616
import { Sandboxes } from './Sandboxes';
1717
import { Showcase } from './Showcase';
1818

@@ -54,11 +54,7 @@ export const Profile: FunctionComponent<Props> = ({
5454

5555
<Content>
5656
<MaxWidth>
57-
<Navigation
58-
likeCount={user.givenLikeCount}
59-
sandboxCount={user.sandboxCount}
60-
username={user.username}
61-
/>
57+
<Navigation />
6258
</MaxWidth>
6359
</Content>
6460

0 commit comments

Comments
 (0)