Skip to content

Sandbox Search #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 21, 2017
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"react-dnd-html5-backend": "^2.4.1",
"react-dom": "^15.6.1",
"react-icons": "^2.2.5",
"react-instantsearch": "^4.0.6",
"react-loadable": "^3.3.1",
"react-modal": "^2.2.1",
"react-motion": "^0.5.0",
Expand Down
File renamed without changes.
16 changes: 7 additions & 9 deletions src/app/components/sandbox/DeleteSandboxButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import styled from 'styled-components';
import DeleteIcon from 'react-icons/lib/md/delete';
import Tooltip from 'app/components/Tooltip';

const DeleteSandboxButton = styled((props) => (
const DeleteSandboxButton = styled(props =>
<Tooltip title="Delete Sandbox">
<button {...props}>
<DeleteIcon />
</button>
</Tooltip>
))`
</Tooltip>,
)`
font-size: 1.2em;
background-color: inherit;
border: none;
Expand All @@ -23,20 +23,18 @@ const DeleteSandboxButton = styled((props) => (
`;

type Props = {
onDelete: Function;
id: string;
onDelete: Function,
id: string,
};

export default class DeleteSandboxButtonContainer extends React.PureComponent {
props: Props;

deleteSandbox = () => {
this.props.onDelete(this.props.id);
}
};

render() {
return (
<DeleteSandboxButton {...this.props} onClick={this.deleteSandbox} />
)
return <DeleteSandboxButton {...this.props} onClick={this.deleteSandbox} />;
}
}
57 changes: 38 additions & 19 deletions src/app/components/sandbox/SandboxList.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,39 +66,58 @@ const SandboxRow = styled.tr`
`;

type Props = {
isCurrentUser: boolean;
sandboxes: Array<SmallSandbox>;
onDelete: Function;
isCurrentUser: boolean,
sandboxes: Array<SmallSandbox>,
onDelete: Function,
};

export default ({ sandboxes, isCurrentUser, onDelete }: Props) => (
export default ({ sandboxes, isCurrentUser, onDelete }: Props) =>
<Table>
<thead>
<tr style={{ height: '3rem' }}>
<HeaderTitle>Title</HeaderTitle>
<HeaderTitle>Created</HeaderTitle>
<HeaderTitle>Updated</HeaderTitle>
<StatTitle><FullHeartIcon /></StatTitle>
<StatTitle><EyeIcon /></StatTitle>
<StatTitle><ForkIcon /></StatTitle>
<StatTitle>
<FullHeartIcon />
</StatTitle>
<StatTitle>
<EyeIcon />
</StatTitle>
<StatTitle>
<ForkIcon />
</StatTitle>
{isCurrentUser && <HeaderTitle />}
</tr>
</thead>
<Body>
{sandboxes.map((s, i) => (
{sandboxes.map((s, i) =>
<SandboxRow index={i} key={s.id}>
<td><Link to={sandboxUrl(s)}>{s.title || s.id}</Link></td>
<td>{moment(s.insertedAt).format('ll')}</td>
<td>{moment(s.updatedAt).format('ll')}</td>
<StatBody>{s.likeCount}</StatBody>
<StatBody>{s.viewCount}</StatBody>
<StatBody>{s.forkCount}</StatBody>
<td>
<Link to={sandboxUrl(s)}>
{s.title || s.id}
</Link>
</td>
<td>
{moment(s.insertedAt).format('ll')}
</td>
<td>
{moment(s.updatedAt).format('ll')}
</td>
<StatBody>
{s.likeCount}
</StatBody>
<StatBody>
{s.viewCount}
</StatBody>
<StatBody>
{s.forkCount}
</StatBody>
{isCurrentUser &&
<StatBody style={{padding: '0.55rem 0.5rem', cursor: 'pointer'}}>
<StatBody style={{ padding: '0.55rem 0.5rem', cursor: 'pointer' }}>
<DeleteSandboxButton id={s.id} onDelete={onDelete} />
</StatBody>}
</SandboxRow>
))}
</SandboxRow>,
)}
</Body>
</Table>
);
</Table>;
4 changes: 2 additions & 2 deletions src/app/components/user/UserWithAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type Props = {
username: string,
};

export default ({ avatarUrl, username }: Props) =>
<CenteredText>
export default ({ avatarUrl, username, ...props }: Props) =>
<CenteredText {...props}>
<Image src={avatarUrl} alt={username} />
<AuthorName>
{username}
Expand Down
38 changes: 31 additions & 7 deletions src/app/containers/Navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { CurrentUser } from 'common/types';
import { Link } from 'react-router-dom';

import GithubIcon from 'react-icons/lib/go/mark-github';
import SearchIcon from 'react-icons/lib/md/search';

import Button from 'app/components/buttons/Button';
import Logo from 'app/components/Logo';
Expand All @@ -16,7 +17,7 @@ import userActionCreators from 'app/store/user/actions';
import Tooltip from 'app/components/Tooltip';

import User from './User';
import { newSandboxUrl } from '../../utils/url-generator';
import { newSandboxUrl, searchUrl } from '../../utils/url-generator';

const LogoWithBorder = styled(Logo)`
padding-right: 1rem;
Expand All @@ -36,9 +37,16 @@ const Title = styled.h1`
font-weight: 300;
`;

const Actions = styled.div`
display: flex;
justify-content: center;
align-items: center;
margin: 0 1rem;
`;

const Action = styled.div`
transition: 0.3s ease all;
margin: 0 2rem;
margin: 0 1rem;
cursor: pointer;
color: white;

Expand All @@ -47,6 +55,13 @@ const Action = styled.div`
}
`;

const Icon = styled(Link)`
color: inherit;
text-decoration: none;
font-size: 1.25rem;
font-weight: 300;
`;

const PlusIcon = styled(Link)`
color: inherit;
text-decoration: none;
Expand Down Expand Up @@ -85,11 +100,20 @@ class Navigation extends React.PureComponent {
</Title>
</Row>
<Row>
<Action>
<Tooltip title="New Sandbox">
<PlusIcon to={newSandboxUrl()}>+</PlusIcon>
</Tooltip>
</Action>
<Actions>
<Action>
<Tooltip title="Search">
<Icon to={searchUrl()}>
<SearchIcon />
</Icon>
</Tooltip>
</Action>
<Action>
<Tooltip title="New Sandbox">
<PlusIcon to={newSandboxUrl()}>+</PlusIcon>
</Tooltip>
</Action>
</Actions>
{hasLogin
? <User signOut={userActions.signOut} user={user} />
: <Button small onClick={userActions.signIn}>
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/Profile/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import styled from 'styled-components';
import Navigation from 'app/containers/Navigation';
import Padding from 'app/components/spacing/Padding';
import Margin from 'app/components/spacing/Margin';
import MaxWidth from 'app/components/flex/MaxWidth';

import type { User } from 'common/types';

import UserInfo from './UserInfo';
import MaxWidth from '../MaxWidth';

const Top = styled.div`
display: flex;
background-image: linear-gradient(-180deg, #121415 0%, #1F2224 100%);
box-shadow: inset 0 -3px 4px 0 rgba(0,0,0,0.50);
background-image: linear-gradient(-180deg, #121415 0%, #1f2224 100%);
box-shadow: inset 0 -3px 4px 0 rgba(0, 0, 0, 0.50);

width: 100%;
justify-content: center;
Expand Down
7 changes: 2 additions & 5 deletions src/app/pages/Profile/Sandboxes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Props = {
fetchSandboxes: Function,
sandboxes: PaginatedSandboxes,
sandboxActions: typeof sandboxActionCreators,
isCurrentUser: boolean;
isCurrentUser: boolean,
};

class Sandboxes extends React.PureComponent {
Expand Down Expand Up @@ -110,7 +110,4 @@ const mapDispatchToProps = dispatch => ({
sandboxActions: bindActionCreators(sandboxActionCreators, dispatch),
});

export default connect(
mapStateToProps,
mapDispatchToProps
)(Sandboxes);
export default connect(mapStateToProps, mapDispatchToProps)(Sandboxes);
2 changes: 1 addition & 1 deletion src/app/pages/Profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { bindActionCreators } from 'redux';
import { createSelector } from 'reselect';
import styled from 'styled-components';

import MaxWidth from 'app/components/flex/MaxWidth';
import Fullscreen from 'app/components/flex/Fullscreen';
import userActionCreators from 'app/store/entities/users/actions';
import { currentUserSelector } from 'app/store/user/selectors';
Expand All @@ -16,7 +17,6 @@ import { profileSandboxesUrl, profileLikesUrl } from 'app/utils/url-generator';

import NotFound from 'app/pages/NotFound';

import MaxWidth from './MaxWidth';
import Header from './Header';
import Navigation from './Navigation';
import Showcase from './Showcase';
Expand Down
8 changes: 7 additions & 1 deletion src/app/pages/Sandbox/Editor/Content/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import ChevronLeft from 'react-icons/lib/md/chevron-left';
import HeartIcon from 'react-icons/lib/fa/heart-o';
import FullHeartIcon from 'react-icons/lib/fa/heart';
import TwitterIcon from 'react-icons/lib/fa/twitter';
import SearchIcon from 'react-icons/lib/go/search';
import { Tooltip } from 'react-tippy';

import type { Sandbox, CurrentUser } from 'common/types';
import sandboxActionCreators from 'app/store/entities/sandboxes/actions';
import userActionCreators from 'app/store/user/actions';
import { newSandboxUrl, importFromGitHubUrl } from 'app/utils/url-generator';
import {
searchUrl,
newSandboxUrl,
importFromGitHubUrl,
} from 'app/utils/url-generator';
import ModeIcons from 'app/components/sandbox/ModeIcons';

import User from 'app/containers/Navigation/User';
Expand Down Expand Up @@ -206,6 +211,7 @@ export default class Header extends React.PureComponent {
tooltip="Import from GitHub"
Icon={GithubIcon}
/>
<Action href={searchUrl()} tooltip="Search" Icon={SearchIcon} />
<Action
href={newSandboxUrl()}
tooltip="New Sandbox"
Expand Down
53 changes: 53 additions & 0 deletions src/app/pages/Sandbox/Editor/Workspace/Tags/Tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import styled, { css } from 'styled-components';

import CrossIcon from 'react-icons/lib/md/clear';

const Container = styled.span`
position: relative;
color: white;
font-size: .875rem;
background-color: ${props => props.theme.secondary};
padding: .3em .5em;
border-radius: 4px;
font-weight: 400;

${props => props.canRemove && css`padding-right: 1.5rem;`};
`;

const DeleteIcon = styled(CrossIcon)`
transition: 0.3s ease all;
position: absolute;
right: .3rem;
top: 0;
bottom: 0;

margin: auto;
cursor: pointer;
color: rgba(255, 255, 255, 0.5);

&:hover {
color: white;
}
`;

export default class Tag extends React.PureComponent {
props: {
tag: string,
removeTag: (tag: string) => void,
};

removeTag = () => {
this.props.removeTag(this.props.tag);
};

render() {
const { tag, removeTag } = this.props;
return (
<Container canRemove={removeTag}>
{tag}
{removeTag && <DeleteIcon onClick={this.removeTag} />}
</Container>
);
}
}
Loading