Skip to content

Commit a23bc2b

Browse files
authored
New tags (codesandbox#3426)
* update zeit * add new tags * add open folder icon * fix comment * use grud for dfesign
1 parent d42086b commit a23bc2b

File tree

12 files changed

+210
-22
lines changed

12 files changed

+210
-22
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Deployment/Zeit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const Zeit = () => {
2626
const { deploySandboxClicked, setDeploymentToDelete } = deployment;
2727

2828
return (
29-
<Integration icon={ZeitIcon} title="ZEIT">
29+
<Integration icon={ZeitIcon} title="ZEIT Now">
3030
{integrations.zeit ? (
3131
<>
3232
<Element marginX={2} marginBottom={sandboxDeploys.length ? 6 : 0}>

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Files/DirectoryEntry/Entry/EntryIcons/GetIconURL.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import imageSvg from '@codesandbox/common/lib/icons/image.svg';
33
import codesandboxSvg from '@codesandbox/common/lib/icons/codesandbox.svg';
44
import nowSvg from '@codesandbox/common/lib/icons/now.svg';
55
import folderSvg from './folder.svg';
6+
import folderOpenSvg from './folderOpen.svg';
67

78
function imageExists(url) {
89
return new Promise((resolve, reject) => {
@@ -37,7 +38,7 @@ async function getIconURL(type) {
3738
break;
3839

3940
case 'directory-open':
40-
url = folderSvg;
41+
url = folderOpenSvg;
4142
break;
4243

4344
default:
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import css from '@styled-system/css';
2+
import React from 'react';
3+
import TagsInput from 'react-tagsinput';
4+
import { Tag, Stack, Element, Input } from '@codesandbox/components';
5+
6+
const TagComponent = props => (
7+
<Element marginY={1}>
8+
<Tag {...props} onRemove={() => props.onRemove(props.key)} />
9+
</Element>
10+
);
11+
12+
const InputComponent = ({ className, ...other }) => (
13+
<Input
14+
{...other}
15+
placeholder="Add Tag"
16+
css={css({
17+
maxWidth: 11,
18+
fontSize: 1,
19+
paddingX: 1,
20+
height: 5,
21+
'::-webkit-input-placeholder': { fontSize: 1 },
22+
'::-ms-input-placeholder': { fontSize: 1 },
23+
'::placeholder': { fontSize: 1 },
24+
})}
25+
/>
26+
);
27+
28+
export const EditableTags = (props: any) => (
29+
<TagsInput
30+
{...props}
31+
renderTag={TagComponent}
32+
renderInput={InputComponent}
33+
renderLayout={(tagComponents, inputComponent) => (
34+
<Stack align="center" gap={1}>
35+
{tagComponents}
36+
{props.value.length !== 5 ? inputComponent : null}
37+
</Stack>
38+
)}
39+
/>
40+
);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React, { FunctionComponent } from 'react';
2+
import getTemplateDefinition from '@codesandbox/common/lib/templates';
3+
import { useOvermind } from 'app/overmind';
4+
import { json } from 'overmind';
5+
import { Tags } from '@codesandbox/components';
6+
import { EditableTags } from './EditableTags';
7+
8+
type Props = {
9+
editable?: boolean;
10+
};
11+
12+
export const Keywords: FunctionComponent<Props> = ({ editable }) => {
13+
const {
14+
actions: {
15+
workspace: { tagChanged, tagsChanged },
16+
},
17+
state: {
18+
editor: {
19+
currentSandbox: { template, tags },
20+
},
21+
workspace: {
22+
tags: { tagName },
23+
},
24+
},
25+
} = useOvermind();
26+
27+
if (tags.length === 0 && !editable) {
28+
return null;
29+
}
30+
31+
const changeTags = (newTags: string[], removedTags: string[]) =>
32+
tagsChanged({ newTags, removedTags });
33+
34+
return (
35+
<div>
36+
{editable ? (
37+
<EditableTags
38+
inputValue={tagName}
39+
maxTags={5}
40+
onChange={changeTags}
41+
onChangeInput={tagChanged}
42+
onlyUnique
43+
template={getTemplateDefinition(template)}
44+
value={json(tags)}
45+
/>
46+
) : (
47+
<Tags tags={tags} />
48+
)}
49+
</div>
50+
);
51+
};

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/ProjectInfo/Summary.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { css } from '@styled-system/css';
2929
import { Title } from './Title';
3030
import { Description } from './Description';
3131
import { TemplateConfig } from './TemplateConfig';
32+
import { Keywords } from './Keywords';
3233

3334
export const Summary = () => {
3435
const {
@@ -88,7 +89,12 @@ export const Summary = () => {
8889
<Title editable={owned} />
8990
</>
9091
)}
91-
<Description editable={owned} />
92+
<Element marginTop={2}>
93+
<Description editable={owned} />
94+
</Element>
95+
<Element marginTop={2}>
96+
<Keywords editable={owned} />
97+
</Element>
9298
</Element>
9399

94100
<Element as="section" css={css({ paddingX: 2 })}>
@@ -104,6 +110,7 @@ export const Summary = () => {
104110

105111
<List>
106112
{customTemplate && <TemplateConfig />}
113+
107114
{owned && (
108115
<ListAction justify="space-between">
109116
<Label htmlFor="frozen">Frozen</Label>

packages/common/src/design-language/theme.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ const theme = {
1212
// 2 - 8
1313
// 3 - 12
1414
// 4 - 16
15-
// 5 - 24
16-
// 6 - 28
17-
// 7 - 32
18-
// 8 - 36
19-
// 9 - 40
20-
space: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40],
21-
sizes: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40],
15+
// 5 - 20
16+
// 6 - 24
17+
// 7 - 28
18+
// 8 - 32
19+
// 9 - 36
20+
// 10 - 40
21+
// 11 - 44
22+
space: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44],
23+
sizes: [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44],
2224

2325
// transition speeds in ms
2426
speeds: [0, '75ms', '100ms', '150ms', '200ms', '300ms', '500ms'],

packages/common/src/design-language/typography.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
export const fontSizes = [
2-
0,
3-
9, // not used yet.
4-
11,
5-
13,
6-
16,
7-
19,
8-
24,
9-
28,
10-
33,
11-
40,
12-
];
1+
export const fontSizes = [0, 9, 11, 13, 16, 19, 24, 28, 33, 40];
132

143
export const fontWeights = {
154
// matches Inter weights
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import css from '@styled-system/css';
4+
import CrossIcon from 'react-icons/lib/md/clear';
5+
import { Stack } from '../Stack';
6+
import { Element } from '../Element';
7+
import { Text } from '../Text';
8+
9+
export type Props = {
10+
tag: string;
11+
onRemove?: (tag: string) => void;
12+
};
13+
14+
export const DeleteIcon = styled(CrossIcon)(
15+
css({
16+
transition: 'all ease',
17+
transitionDuration: theme => theme.speeds[3],
18+
cursor: 'pointer',
19+
color: 'tab.inactiveForeground',
20+
width: '6px',
21+
display: 'flex',
22+
height: '6px',
23+
24+
':hover': {
25+
color: 'sideBarTitle.foreground',
26+
},
27+
})
28+
);
29+
30+
export const TagElement = styled.div(
31+
css({
32+
backgroundColor: 'sideBar.border',
33+
paddingX: 1,
34+
paddingY: 1,
35+
borderRadius: 'small',
36+
})
37+
);
38+
39+
export function Tag({ tag, onRemove }: Props) {
40+
return (
41+
<TagElement key={tag}>
42+
<Stack align="center" justify="space-between">
43+
<Text size={1}>{tag}</Text>
44+
{onRemove && (
45+
<Element marginLeft={2}>
46+
<DeleteIcon onClick={() => onRemove(tag)} />
47+
</Element>
48+
)}
49+
</Stack>
50+
</TagElement>
51+
);
52+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { Tags } from '.';
3+
4+
export default {
5+
title: 'components/Tags',
6+
component: Tags,
7+
};
8+
9+
export const Basic = () => <Tags tags={['one']} />;
10+
export const ManyTags = () => (
11+
<Tags tags={['one', 'two', 'three', 'four', 'five']} />
12+
);
13+
export const Removable = () => (
14+
<Tags removeTag={() => {}} tags={['one', 'two', 'three', 'four', 'five']} />
15+
);

0 commit comments

Comments
 (0)