Skip to content

Commit b6ef6e1

Browse files
author
Ives van Hoorne
committed
Tweaks to editor and add file icons
1 parent 491173d commit b6ef6e1

File tree

12 files changed

+252
-84
lines changed

12 files changed

+252
-84
lines changed

src/app/components/user/PatronStar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default ({
1616
subscriptionSince: string,
1717
}) =>
1818
<Container
19-
title={`Patron since ${moment(subscriptionSince).format('MMM YY')}!`}
19+
title={`Patron since ${moment(subscriptionSince).format('MMM Y')}`}
2020
>
2121
<StarIcon {...props} />
2222
</Container>;

src/app/pages/Sandbox/Editor/Content/Header/FeedbackView.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ const MessageView = styled.div`
2323
color: rgba(255, 255, 255, 0.8);
2424
padding: 1rem;
2525
26-
box-shadow: 1px 1px 1px rgba(0,0,0,0.2);
26+
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
2727
background-color: ${props => props.theme.background2};
2828
2929
width: 400px;
3030
31-
3231
h3 {
3332
margin: 0;
3433
margin-bottom: 0.5rem;
@@ -73,10 +72,10 @@ export default class FeedbackView extends React.PureComponent {
7372
HeaderComponent={Action}
7473
headerProps={{
7574
Icon: FeedbackIcon,
76-
moreInfo: true,
75+
tooltip: 'Give feedback',
7776
}}
7877
>
79-
{toggle => (
78+
{toggle =>
8079
<MessageView>
8180
<h3>Send feedback</h3>
8281
<textarea
@@ -86,8 +85,7 @@ export default class FeedbackView extends React.PureComponent {
8685
onChange={this.handleChange}
8786
/>
8887
<Button onClick={this.handleSend(toggle)}>Send</Button>
89-
</MessageView>
90-
)}
88+
</MessageView>}
9189
</HoverMenu>
9290
</Container>
9391
);

src/app/pages/Sandbox/Editor/Content/Header/index.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from 'app/utils/url-generator';
2424
import ModeIcons from 'app/components/sandbox/ModeIcons';
2525

26+
import Margin from 'app/components/spacing/Margin';
2627
import UserMenu from 'app/containers/UserMenu';
2728

2829
import Action from './Action';
@@ -199,7 +200,7 @@ export default class Header extends React.PureComponent {
199200
<Action
200201
href="https://twitter.com/CompuIves"
201202
a
202-
tooltip="Message me"
203+
tooltip="Contact"
203204
Icon={TwitterIcon}
204205
/>
205206
<FeedbackView
@@ -211,23 +212,25 @@ export default class Header extends React.PureComponent {
211212
tooltip="Import from GitHub"
212213
Icon={GithubIcon}
213214
/>
214-
<Action href={searchUrl()} tooltip="Search" Icon={SearchIcon} />
215+
<Action href={searchUrl()} Icon={SearchIcon} tooltip="Search" />
215216
<Action
216217
href={newSandboxUrl()}
217218
tooltip="New Sandbox"
218219
Icon={PlusIcon}
219220
/>
220-
{user.jwt
221-
? <div style={{ fontSize: '.875rem', margin: '6px 0.5rem' }}>
222-
<UserMenu small />
223-
</div>
224-
: <Action
225-
onClick={userActions.signIn}
226-
title="Sign in with Github"
227-
Icon={GithubIcon}
228-
highlight
229-
unresponsive
230-
/>}
221+
<Margin left={1}>
222+
{user.jwt
223+
? <div style={{ fontSize: '.875rem', margin: '6px 0.5rem' }}>
224+
<UserMenu small />
225+
</div>
226+
: <Action
227+
onClick={userActions.signIn}
228+
title="Sign in with Github"
229+
Icon={GithubIcon}
230+
highlight
231+
unresponsive
232+
/>}
233+
</Margin>
231234
</Right>
232235
</Container>
233236
);

src/app/pages/Sandbox/Editor/Content/index.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const FullSize = styled.div`
5757
height: 100%;
5858
width: 100%;
5959
pointer-events: ${props => (props.inactive ? 'none' : 'all')};
60-
${fadeIn(0)}
60+
${fadeIn(0)};
6161
`;
6262

6363
const mapStateToProps = createSelector(
@@ -134,10 +134,14 @@ class EditorPreview extends React.PureComponent {
134134

135135
const mainModule = findMainModule(modules);
136136
if (!mainModule) throw new Error('Cannot find main module');
137-
137+
138138
const { currentModule: currentModuleId } = sandbox;
139-
140-
const currentModule = findCurrentModule(modules, currentModuleId, mainModule);
139+
140+
const currentModule = findCurrentModule(
141+
modules,
142+
currentModuleId,
143+
mainModule,
144+
);
141145
const modulePath = getModulePath(modules, directories, currentModule.id);
142146

143147
if (currentModule == null) return null;
@@ -206,22 +210,21 @@ class EditorPreview extends React.PureComponent {
206210
minSize={360}
207211
paneStyle={{ height: '100%' }}
208212
resizerStyle={{
209-
visibility: (!sandbox.showPreview && sandbox.showEditor) ||
213+
visibility:
214+
(!sandbox.showPreview && sandbox.showEditor) ||
210215
(sandbox.showPreview && !sandbox.showEditor)
211-
? 'hidden'
212-
: 'visible',
216+
? 'hidden'
217+
: 'visible',
213218
}}
214219
pane1Style={{
215220
display: sandbox.showEditor ? 'block' : 'none',
216-
minWidth: !sandbox.showPreview && sandbox.showEditor
217-
? '100%'
218-
: 'inherit',
221+
minWidth:
222+
!sandbox.showPreview && sandbox.showEditor ? '100%' : 'inherit',
219223
}}
220224
pane2Style={{
221225
display: sandbox.showPreview ? 'block' : 'none',
222-
minWidth: sandbox.showPreview && !sandbox.showEditor
223-
? '100%'
224-
: 'inherit',
226+
minWidth:
227+
sandbox.showPreview && !sandbox.showEditor ? '100%' : 'inherit',
225228
}}
226229
>
227230
{sandbox.showEditor && EditorPane}

src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/DirectoryChildren.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Module, Directory, ModuleError } from 'common/types';
55

66
import { validateTitle } from 'app/store/entities/sandboxes/modules/validator';
77
import { isMainModule } from 'app/store/entities/sandboxes/modules/selectors';
8+
import getType from 'app/store/entities/sandboxes/modules/utils/get-type';
89

910
import Entry from './Entry';
1011
import DirectoryEntry from './';
@@ -53,7 +54,7 @@ export default class DirectoryChildren extends React.PureComponent {
5354
<div>
5455
{directories
5556
.filter(x => x.directoryShortid === parentShortid)
56-
.map(dir => (
57+
.map(dir =>
5758
<DirectoryEntry
5859
key={dir.id}
5960
siblings={[...directories, ...modules]}
@@ -67,11 +68,12 @@ export default class DirectoryChildren extends React.PureComponent {
6768
currentModuleId={currentModuleId}
6869
isInProjectView={isInProjectView}
6970
errors={errors}
70-
/>
71-
))}
71+
/>,
72+
)}
7273
{modules.filter(x => x.directoryShortid === parentShortid).map(m => {
7374
const isActive = m.id === currentModuleId;
7475
const mainModule = isMainModule(m);
76+
const type = getType(m);
7577

7678
const hasError = !!errors.find(
7779
e => e.severity === 'error' && e.moduleId === m.id,
@@ -85,7 +87,7 @@ export default class DirectoryChildren extends React.PureComponent {
8587
title={m.title}
8688
depth={depth + 1}
8789
active={isActive}
88-
type="function"
90+
type={type || 'function'}
8991
rename={mainModule ? undefined : renameModule}
9092
openMenu={openMenu}
9193
deleteEntry={mainModule ? undefined : deleteEntry}

src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/EntryIcons.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import FunctionIcon from 'react-icons/lib/fa/code';
66
import FolderIcon from 'react-icons/lib/md/keyboard-arrow-down';
77
import DirectoryIcon from 'react-icons/lib/go/file-directory';
88
import NotSyncedIcon from 'react-icons/lib/go/primitive-dot';
9+
import CSSIcon from 'react-icons/lib/fa/css3';
10+
import HTMLIcon from 'react-icons/lib/fa/html5';
911
import ErrorIcon from 'react-icons/lib/md/error';
1012
import ReactIcon from 'app/components/ReactIcon';
1113

@@ -15,9 +17,7 @@ const NotSyncedIconWithMargin = styled(NotSyncedIcon)`
1517
color: ${props => props.theme.secondary};
1618
`;
1719

18-
const RedIcon = styled.span`
19-
color: ${props => props.theme.red};
20-
`;
20+
const RedIcon = styled.span`color: ${props => props.theme.red};`;
2121

2222
const StyledFolderIcon = styled.span`
2323
svg {
@@ -34,18 +34,27 @@ const getIcon = (type, error, root) => {
3434
return <ProjectIcon />;
3535
}
3636
if (error) {
37-
return <RedIcon><ErrorIcon /></RedIcon>;
38-
}
39-
if (type === 'react') {
40-
return <ReactIcon />;
37+
return (
38+
<RedIcon>
39+
<ErrorIcon />
40+
</RedIcon>
41+
);
4142
}
42-
if (type === 'function') {
43-
return <FunctionIcon />;
44-
}
45-
if (type === 'directory') {
46-
return <DirectoryIcon />;
43+
44+
switch (type) {
45+
case 'react':
46+
return <ReactIcon />;
47+
case 'function':
48+
return <FunctionIcon />;
49+
case 'directory':
50+
return <DirectoryIcon />;
51+
case 'css':
52+
return <CSSIcon />;
53+
case 'html':
54+
return <HTMLIcon />;
55+
default:
56+
return <FunctionIcon />;
4757
}
48-
return <FunctionIcon />;
4958
};
5059

5160
type Props = {
@@ -65,7 +74,7 @@ export default ({
6574
isNotSynced,
6675
isOpen,
6776
onOpen,
68-
}: Props) => (
77+
}: Props) =>
6978
<div style={{ display: 'inline-block', verticalAlign: 'middle' }}>
7079
{isNotSynced && <NotSyncedIconWithMargin />}
7180
{type === 'directory' &&
@@ -74,5 +83,4 @@ export default ({
7483
<FolderIcon />
7584
</StyledFolderIcon>}
7685
{getIcon(type, error, root)}
77-
</div>
78-
);
86+
</div>;

src/app/pages/Sandbox/Editor/Workspace/Logo/index.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
import React from 'react';
33
import styled, { injectGlobal } from 'styled-components';
44

5+
import GithubIcon from 'react-icons/lib/go/mark-github';
6+
7+
import Relative from 'app/components/Relative';
58
import LogoIcon from 'app/components/Logo';
9+
import Tooltip from 'app/components/Tooltip';
610
import theme from 'common/theme';
711

812
const Container = styled.a`
@@ -27,6 +31,17 @@ const Title = styled.h1`
2731
color: white;
2832
`;
2933

34+
const GithubContainer = styled.a`
35+
position: absolute;
36+
right: 1rem;
37+
top: 0;
38+
line-height: 3rem;
39+
vertical-align: middle;
40+
font-size: 1rem;
41+
color: rgba(255, 255, 255, 0.8);
42+
text-decoration: none;
43+
`;
44+
3045
export default class Logo extends React.PureComponent {
3146
setupHeadway = el => {
3247
if (el && window.Headway) {
@@ -50,12 +65,24 @@ export default class Logo extends React.PureComponent {
5065

5166
render() {
5267
return (
53-
<Container id="release" ref={this.setupHeadway} href="/">
54-
<div style={{ position: 'relative', display: 'flex' }}>
55-
<LogoIcon width={30} height={30} />
56-
</div>
57-
<Title>CodeSandbox</Title>
58-
</Container>
68+
<Relative>
69+
<Container id="release" ref={this.setupHeadway} href="/">
70+
<div style={{ position: 'relative', display: 'flex' }}>
71+
<LogoIcon width={30} height={30} />
72+
</div>
73+
<Title>CodeSandbox</Title>
74+
</Container>
75+
76+
<GithubContainer
77+
href="https://github.com/CompuIves/codesandbox-client"
78+
target="_blank"
79+
rel="noreferrer noopener"
80+
>
81+
<Tooltip title="View source">
82+
<GithubIcon />
83+
</Tooltip>
84+
</GithubContainer>
85+
</Relative>
5986
);
6087
}
6188
}

src/app/pages/Sandbox/Editor/index.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React from 'react';
33
import SplitPane from 'react-split-pane';
44
import type { Sandbox } from 'common/types';
55

6+
import Fullscreen from 'app/components/flex/Fullscreen';
7+
68
import Workspace from './Workspace';
79

810
import Content from './Content';
@@ -29,27 +31,29 @@ export default class ContentSplit extends React.PureComponent {
2931
const { sandbox, match } = this.props;
3032
const { resizing, workspaceHidden } = this.state;
3133
return (
32-
<SplitPane
33-
split="vertical"
34-
defaultSize={16 * 16}
35-
style={{ top: 0 }}
36-
onDragStarted={this.startResizing}
37-
onDragFinished={this.stopResizing}
38-
resizerStyle={{ visibility: workspaceHidden ? 'hidden' : 'visible' }}
39-
pane1Style={{
40-
visibility: workspaceHidden ? 'hidden' : 'visible',
41-
maxWidth: workspaceHidden ? 0 : 'inherit',
42-
}}
43-
>
44-
{!workspaceHidden && <Workspace sandbox={sandbox} />}
45-
<Content
46-
workspaceHidden={workspaceHidden}
47-
toggleWorkspace={this.toggleWorkspace}
48-
sandbox={sandbox}
49-
resizing={resizing}
50-
match={match}
51-
/>
52-
</SplitPane>
34+
<Fullscreen style={{ position: 'relative' }}>
35+
<SplitPane
36+
split="vertical"
37+
defaultSize={16 * 16}
38+
style={{ top: 0 }}
39+
onDragStarted={this.startResizing}
40+
onDragFinished={this.stopResizing}
41+
resizerStyle={{ visibility: workspaceHidden ? 'hidden' : 'visible' }}
42+
pane1Style={{
43+
visibility: workspaceHidden ? 'hidden' : 'visible',
44+
maxWidth: workspaceHidden ? 0 : 'inherit',
45+
}}
46+
>
47+
{!workspaceHidden && <Workspace sandbox={sandbox} />}
48+
<Content
49+
workspaceHidden={workspaceHidden}
50+
toggleWorkspace={this.toggleWorkspace}
51+
sandbox={sandbox}
52+
resizing={resizing}
53+
match={match}
54+
/>
55+
</SplitPane>
56+
</Fullscreen>
5357
);
5458
}
5559
}

0 commit comments

Comments
 (0)