Skip to content

Commit 749d2ff

Browse files
authored
WIP: Redesign header (codesandbox#3517)
* duplicate header * get all the pieces ther * move Actions into a file * delete dead code * move usermenu container styles to usermenu * make avatar wrap not take extra spac * align avatar with buttons * vertical align menubar * redesign menu + sandbox name * get the right logos top left * adjust alignment * remove debug line * fixed margin issues * add aria-label to link buttons * fix toggle position
1 parent fdc2f07 commit 749d2ff

File tree

49 files changed

+1311
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1311
-235
lines changed

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ export class VSCodeEffect {
735735

736736
this.elements.menubar.style.alignItems = 'center';
737737
this.elements.menubar.style.height = '38px';
738-
this.elements.menubar.style.fontSize = '0.875rem';
738+
this.elements.menubar.style.fontSize = '0.8125rem';
739739
this.elements.menubar.className = 'menubar';
740740

741741
this.elements.statusbar.className = 'part statusbar';
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import React from 'react';
2+
import { useOvermind } from 'app/overmind';
3+
4+
import { UserMenu } from 'app/pages/common/UserMenu';
5+
import Tooltip from '@codesandbox/common/lib/components/Tooltip';
6+
7+
import { Stack, Avatar, Button } from '@codesandbox/components';
8+
import css from '@styled-system/css';
9+
import {
10+
ReloadIcon,
11+
PreferenceIcon,
12+
LikeIcon,
13+
EmbedIcon,
14+
ForkIcon,
15+
} from './icons';
16+
17+
const TooltipButton = ({ tooltip, ...props }) => (
18+
<Tooltip content={tooltip}>
19+
<Button {...props} />
20+
</Tooltip>
21+
);
22+
23+
export const Actions = () => {
24+
const {
25+
actions: {
26+
modalOpened,
27+
editor: { likeSandboxToggled, forkSandboxClicked },
28+
explore: { pickSandboxModal },
29+
},
30+
state: {
31+
hasLogIn,
32+
updateStatus,
33+
user,
34+
editor: {
35+
currentSandbox: { id, owned, title, description, likeCount, userLiked },
36+
},
37+
},
38+
39+
actions: { signInClicked },
40+
} = useOvermind();
41+
42+
const handleSignIn = async () => {
43+
await signInClicked({ useExtraScopes: false });
44+
};
45+
46+
let primaryAction;
47+
if (!hasLogIn) primaryAction = 'Sign in';
48+
else primaryAction = owned ? 'Embed' : 'Fork';
49+
50+
return (
51+
<Stack align="center" gap={1} css={{ button: { width: 'auto' } }}>
52+
{updateStatus === 'available' && (
53+
<TooltipButton
54+
tooltip="Update Available! Click to Refresh."
55+
variant="link"
56+
onClick={() => document.location.reload()}
57+
>
58+
<ReloadIcon css={css({ height: 3 })} />
59+
</TooltipButton>
60+
)}
61+
62+
{!hasLogIn && (
63+
<TooltipButton
64+
tooltip="Open preferences"
65+
variant="link"
66+
onClick={() => modalOpened({ modal: 'preferences' })}
67+
>
68+
<PreferenceIcon css={css({ height: 3 })} />
69+
</TooltipButton>
70+
)}
71+
72+
{hasLogIn ? (
73+
<TooltipButton
74+
tooltip={userLiked ? 'Undo like sandbox' : 'Like sandbox'}
75+
variant="link"
76+
onClick={() => likeSandboxToggled(id)}
77+
>
78+
<LikeIcon
79+
css={css({
80+
height: 3,
81+
marginRight: 1,
82+
color: userLiked ? 'reds.500' : 'inherit',
83+
})}
84+
/>{' '}
85+
<span>{likeCount}</span>
86+
</TooltipButton>
87+
) : (
88+
<Stack gap={1} paddingX={2} align="center">
89+
<LikeIcon css={css({ height: 3 })} />
90+
<span>{likeCount}</span>
91+
</Stack>
92+
)}
93+
94+
{user?.curatorAt && (
95+
<Button
96+
variant="secondary"
97+
onClick={() => pickSandboxModal({ description, id, title })}
98+
>
99+
Pick
100+
</Button>
101+
)}
102+
<Button
103+
variant={primaryAction === 'Embed' ? 'primary' : 'secondary'}
104+
onClick={() => modalOpened({ modal: 'share' })}
105+
>
106+
<EmbedIcon css={css({ height: 3, marginRight: 1 })} /> Embed
107+
</Button>
108+
<Button
109+
variant={primaryAction === 'Fork' ? 'primary' : 'secondary'}
110+
onClick={forkSandboxClicked}
111+
>
112+
<ForkIcon css={css({ height: 3, marginRight: 1 })} /> Fork
113+
</Button>
114+
<Button
115+
variant="secondary"
116+
onClick={() => modalOpened({ modal: 'newSandbox' })}
117+
>
118+
Create Sandbox
119+
</Button>
120+
{hasLogIn ? (
121+
<UserMenu>
122+
<Avatar
123+
user={{ ...user, subscriptionSince: null }}
124+
css={css({ size: 6 })}
125+
/>
126+
</UserMenu>
127+
) : (
128+
<Button variant="primary" onClick={handleSignIn}>
129+
Sign in
130+
</Button>
131+
)}
132+
</Stack>
133+
);
134+
};

packages/app/src/app/pages/Sandbox/Editor/Header/MenuBar/elements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from 'styled-components';
33
export const Child = styled.div`
44
align-items: center;
55
height: 38px;
6-
font-size: 0.875rem;
6+
font-size: 0.8125rem;
77
`;
88

99
export const Container = styled.div`

packages/app/src/app/pages/Sandbox/Editor/Header/MenuBar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const MenuBar: FunctionComponent = () => {
2222
className="part titlebar"
2323
onClick={() => track('Editor - Click Menubar')}
2424
>
25-
<Child className="menubar" ref={menuBarEl} />
25+
<Child ref={menuBarEl} />
2626
</Container>
2727
);
2828
};

packages/app/src/app/pages/Sandbox/Editor/Header/MenuBar/titlebar.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
-webkit-app-region: no-drag;
175175
overflow: hidden;
176176
flex-wrap: wrap;
177-
font-size: 14px;
177+
font-size: 13px;
178178
}
179179

180180
.monaco-workbench.fullscreen .menubar {
@@ -201,8 +201,7 @@
201201
}
202202

203203
.monaco-workbench .menubar .menubar-menu-items-holder.monaco-menu-container {
204-
font-family: Roboto, -apple-system, BlinkMacSystemFont, 'Segoe WPC',
205-
'Segoe UI', 'HelveticaNeue-Light', 'Ubuntu', 'Droid Sans', sans-serif;
204+
font-family: Inter, sans-serif;
206205
outline: 0;
207206
border: none;
208207
font-size: 0.75rem;

packages/app/src/app/pages/Sandbox/Editor/Header/SandboxName/elements.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,14 @@
11
import AutosizeInput from 'react-input-autosize';
22
import styled, { css } from 'styled-components';
33

4-
export const Container = styled.div`
5-
display: flex;
6-
position: relative;
7-
font-size: 0.875rem;
8-
align-items: center;
9-
white-space: nowrap;
10-
text-align: center;
11-
`;
12-
134
export const Folder = styled.div`
14-
overflow: hidden;
155
display: none;
166
177
@media screen and (min-width: 950px) {
188
display: block;
199
}
2010
`;
2111

22-
export const FolderName = styled.button`
23-
display: inline-block;
24-
cursor: pointer;
25-
transition: 0.3s ease color;
26-
padding: 0;
27-
margin: 0 0.25rem 0 0;
28-
outline: 0;
29-
border: 0;
30-
background-color: transparent;
31-
color: inherit;
32-
33-
&:hover {
34-
color: white;
35-
}
36-
`;
37-
3812
export const Form = styled.form`
3913
position: absolute;
4014
left: 0;
@@ -57,20 +31,6 @@ export const NameInput = styled(AutosizeInput)`
5731
}
5832
`;
5933

60-
export const Name = styled.span<{ owned?: boolean }>`
61-
${({ theme, owned }) => css`
62-
color: ${theme.light ? 'black' : 'white'};
63-
margin-left: 0.25rem;
64-
margin-right: ${owned ? 0 : '0.5rem'};
65-
cursor: ${owned ? 'pointer' : 'initial'};
66-
text-overflow: ellipsis;
67-
appearance: ${owned ? 'none' : 'initial'};
68-
background: none;
69-
border: 0;
70-
outline: 0;
71-
`}
72-
`;
73-
7434
export const Main = styled.div`
7535
display: none;
7636

0 commit comments

Comments
 (0)