Skip to content

Commit 04afd27

Browse files
author
Ives van Hoorne
committed
Update views to reflect template
1 parent a7c5c42 commit 04afd27

File tree

7 files changed

+32
-5
lines changed

7 files changed

+32
-5
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { sandboxUrl, githubRepoUrl, profileUrl } from 'app/utils/url-generator';
88
import UserWithAvatar from 'app/components/user/UserWithAvatar';
99
import Stats from 'app/components/sandbox/Stats';
1010
import PrivacyStatus from 'app/components/sandbox/PrivacyStatus';
11+
import getTemplateDefinition from 'common/templates';
1112

1213
import type { User, GitInfo } from 'common/types';
1314
import WorkspaceInputContainer from '../WorkspaceInputContainer';
@@ -117,6 +118,7 @@ export default class Project extends React.PureComponent<
117118
forkCount,
118119
author,
119120
git,
121+
template,
120122
preventTransition,
121123
privacy,
122124
} = this.props;
@@ -192,6 +194,20 @@ export default class Project extends React.PureComponent<
192194
<PrivacyStatus privacy={privacy} />
193195
</PrivacyContainer>
194196
</div>}
197+
198+
<div>
199+
<WorkspaceSubtitle>Template</WorkspaceSubtitle>
200+
<Item>
201+
<a
202+
href={getTemplateDefinition(template).url}
203+
target="_blank"
204+
rel="noreferrer noopener"
205+
style={{ color: getTemplateDefinition(template).color() }}
206+
>
207+
{template}
208+
</a>
209+
</Item>
210+
</div>
195211
<StatsContainer>
196212
<Stats
197213
sandboxId={id}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const Workspace = ({
105105
owned={sandbox.owned}
106106
author={user}
107107
privacy={sandbox.privacy}
108+
template={sandbox.template}
108109
/>
109110
</WorkspaceItem>
110111

src/app/pages/Search/Filters/Filter.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ type Props = {
3434
title: string,
3535
attributeName: string,
3636
operator: string,
37+
noSearch: ?boolean,
3738
};
3839

39-
export default ({ title, attributeName, operator }: Props) =>
40+
export default ({ title, attributeName, operator, noSearch }: Props) =>
4041
<Container>
4142
<Title>
4243
{title}
4344
</Title>
4445
<RefinementList
45-
withSearchBox
46-
showMore
46+
withSearchBox={!noSearch}
47+
showMore={!noSearch}
4748
operator={operator}
4849
attributeName={attributeName}
4950
/>

src/app/pages/Search/Filters/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Filter from './Filter';
44

55
export default () =>
66
<div style={{ flex: 1 }}>
7+
<Filter title="Templates" operator="or" attributeName="template" noSearch />
78
<Filter
89
title="Dependencies"
910
operator="and"

src/app/pages/Search/SandboxCard/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import styled from 'styled-components';
33
import { Link } from 'react-router-dom';
44
import { Highlight } from 'react-instantsearch/dom';
55

6+
import getTemplateDefinition from 'common/templates';
7+
68
import Tags from 'app/components/sandbox/Tags';
79

810
import SandboxInfo from './SandboxInfo';
@@ -22,7 +24,8 @@ const Container = styled.div`
2224
border-radius: 2px;
2325
box-sizing: border-box;
2426
25-
border-left: 2px solid ${props => props.theme.secondary.clearer(0.3)};
27+
border-left: 2px solid
28+
${props => getTemplateDefinition(props.template).color.clearer(0.3)};
2629
2730
cursor: pointer;
2831
@@ -79,12 +82,13 @@ type Props = {
7982
'description': ?string,
8083
'author': ?{ username: string, avatarUrl: string },
8184
'objectID': string,
85+
'template': string,
8286
},
8387
};
8488

8589
export default ({ hit }: Props) =>
8690
<StyledLink to={sandboxUrl({ id: hit.objectID, git: hit.git })}>
87-
<Container>
91+
<Container template={hit.template}>
8892
<Row alignItems="flex-start">
8993
<Title>
9094
{hit.title

src/common/templates/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { decorateSelector } from '../theme';
22

33
export const react = {
44
name: 'create-react-app',
5+
url: 'https://github.com/facebookincubator/create-react-app',
56
color: decorateSelector(() => '#6CAEDD'),
67
};
78

89
export const vue = {
910
name: 'vue-cli',
11+
url: 'https://github.com/vuejs/vue-cli',
1012
color: decorateSelector(() => '#41B883'),
1113
};
1214

src/sandbox/eval/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ export default function getPreset(template: 'create-react-app' | 'vue-cli') {
1010
} else if (template === vue.name) {
1111
return vuePreset;
1212
}
13+
14+
return reactPreset;
1315
}

0 commit comments

Comments
 (0)