Skip to content

Commit a5c3153

Browse files
authored
design fixes (codesandbox#3411)
* design fixes * finish danny things * fix some ives stuff * no hardcoding colors
1 parent 1e9aa40 commit a5c3153

File tree

15 files changed

+110
-129
lines changed

15 files changed

+110
-129
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/ConfigurationFiles/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ const getIcon = name => {
3737
};
3838

3939
const Grid = styled(BaseGrid)`
40-
grid-template-columns: 1fr 100px;
40+
grid-template-columns: 1fr 56px;
4141
grid-gap: ${({ theme }) => theme.space[4]}px;
42+
align-items: flex-end;
4243
`;
4344

4445
export const ConfigurationFilesComponent = ({ theme }) => {
@@ -150,7 +151,7 @@ export const ConfigurationFilesComponent = ({ theme }) => {
150151
})
151152
}
152153
>
153-
Create File
154+
Create
154155
</Button>
155156
</Grid>
156157
</Element>

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Dependencies/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const Dependencies: FunctionComponent = () => {
4242
const { dependencies = {} } = parsed;
4343

4444
return (
45-
<Collapsible title="Dependencies">
45+
<Collapsible title="Dependencies" defaultOpen>
4646
<List marginBottom={2}>
4747
{Object.keys(dependencies)
4848
.sort()

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { useOvermind } from 'app/overmind';
44
import { css } from '@styled-system/css';
55
import { Button, Element, Stack } from '@codesandbox/components';
66

7-
import { TemplateConfig } from './TemplateConfig';
8-
97
export const Config = () => {
108
const {
119
actions: {
@@ -51,7 +49,6 @@ export const Config = () => {
5149

5250
return (
5351
<>
54-
{customTemplate && <TemplateConfig />}
5552
{!customTemplate && (
5653
<Element marginX={2} marginY={4}>
5754
<Button

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ const DescriptionTrimmed = styled(Text)`
2929
const Icon = styled(PenIcon)`
3030
cursor: pointer;
3131
opacity: 0;
32+
transition: all;
33+
transition-duration: ${({ theme }) => theme.speeds[4]};
3234
`;
3335

3436
const SandboxDescription = styled(SidebarRow)`
37+
min-height: 0;
3538
:hover {
3639
svg {
3740
opacity: 1;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const Privacy = () => {
4141
<option value={1}>Unlisted (only available by url)</option>
4242
<option value={2}>Private</option>
4343
</Select>
44-
{isPaidUser ? (
44+
{!isPaidUser ? (
4545
<Text variant="muted" size={2}>
4646
You an change privacy of a sandbox as a Pro.{' '}
4747
<Link href="/pro" css={{ textDecoration: 'underline !important' }}>
Lines changed: 46 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import * as templates from '@codesandbox/common/lib/templates';
22
import React, { FunctionComponent, useState } from 'react';
3-
import { SketchPicker } from 'react-color';
3+
44
import { useOvermind } from 'app/overmind';
5-
import {
6-
Collapsible,
7-
List,
8-
ListAction,
9-
Text,
10-
Element,
11-
} from '@codesandbox/components';
5+
import { ListAction, Text, Element } from '@codesandbox/components';
126
import styled, { css } from 'styled-components';
137
import getIcon from '@codesandbox/common/lib/templates/icons';
148
import { ColorIcons as Icons } from '@codesandbox/template-icons';
@@ -21,21 +15,6 @@ const buttonStyles = css`
2115
cursor: pointer;
2216
`;
2317

24-
const PickColor = styled(PopoverDisclosure)`
25-
${({ theme, color }) => css`
26-
width: ${theme.space[5]}px;
27-
height: ${theme.space[4]}px;
28-
border: 1px solid ${color};
29-
background: ${color};
30-
border-radius: ${theme.radii.small}px;
31-
&:focus {
32-
// need to use !important to override styles from
33-
// workbench-theme.css, not proud :/
34-
outline: none !important;
35-
}
36-
`}
37-
`;
38-
3918
export const Button = styled(PopoverDisclosure)<{ color: string }>`
4019
${({ color }) => css`
4120
color: ${color};
@@ -49,6 +28,7 @@ export const IconButton = styled.button`
4928

5029
export const IconWrapper = styled(Popover)`
5130
${({ theme }) => css`
31+
z-index: 12;
5232
padding: ${theme.space[3]}px;
5333
background: ${theme.colors.sideBar.background};
5434
`};
@@ -67,6 +47,14 @@ export const IconList = styled.ul`
6747
}
6848
`;
6949

50+
const OpenPopover = styled(PopoverDisclosure)`
51+
padding: 0;
52+
background: transparent;
53+
border: 0;
54+
color: inherit;
55+
width: 100%;
56+
`;
57+
7058
export const TemplateConfig: FunctionComponent = () => {
7159
const {
7260
actions: {
@@ -81,89 +69,54 @@ export const TemplateConfig: FunctionComponent = () => {
8169
const iconPopover = usePopoverState({
8270
placement: 'top',
8371
});
84-
const colorPopover = usePopoverState({
85-
placement: 'top',
86-
});
8772
const [selectedIcon, setSelectedIcon] = useState(
8873
customTemplate.iconUrl || ''
8974
);
9075

9176
const DefaultIcon = getIcon(template);
92-
const defaultColor =
93-
customTemplate.color || templates.default(template).color();
77+
const defaultColor = templates.default(template).color();
9478

9579
const setIcon = (key: string) => {
9680
setSelectedIcon(key);
9781
iconPopover.hide();
9882
editTemplate({ ...customTemplate, iconUrl: key });
9983
};
10084
const TemplateIcon = Icons[selectedIcon];
101-
const [selectedColor, setSelectedColor] = useState(
102-
() => customTemplate.color || templates.default(template).color()
103-
);
104-
const colors = Object.keys(templates)
105-
.filter(x => x !== 'default')
106-
.map(t => templates[t])
107-
.map(a => ({ color: a.color(), title: a.niceName }));
10885

10986
return (
110-
<Collapsible title="Template" defaultOpen>
111-
<List>
112-
<ListAction justify="space-between" gap={2}>
113-
<Text>Color</Text>
114-
<Element>
115-
<PickColor {...colorPopover} color={selectedColor} />
116-
<Popover
117-
aria-label="Choose a Color"
118-
hideOnClickOutside
119-
hideOnEsc
120-
{...colorPopover}
121-
>
122-
<SketchPicker
123-
color={selectedColor}
124-
disableAlpha
125-
onChangeComplete={({ hex }) => {
126-
colorPopover.hide();
127-
setSelectedColor(hex);
128-
}}
129-
presetColors={[...new Set(colors)]}
130-
/>
131-
</Popover>
132-
</Element>
133-
</ListAction>
134-
<ListAction justify="space-between" gap={2}>
135-
<Text>Icon</Text>
136-
<Element>
137-
<Button {...iconPopover} color={defaultColor}>
138-
{selectedIcon && TemplateIcon ? (
139-
<TemplateIcon width={24} />
140-
) : (
141-
<DefaultIcon width={24} />
142-
)}
143-
</Button>
144-
<IconWrapper
145-
aria-label="Choose an Icon"
146-
hideOnClickOutside
147-
hideOnEsc
148-
{...iconPopover}
149-
>
150-
<IconList>
151-
{Object.keys(Icons).map((i: string) => {
152-
const TemplateIconMap = Icons[i];
153-
return (
154-
// eslint-disable-next-line
155-
<li onClick={() => setIcon(i)} role="button" tabIndex={0}>
156-
<IconButton>
157-
<TemplateIconMap width={24} />
158-
</IconButton>
159-
</li>
160-
);
161-
})}
162-
</IconList>
163-
</IconWrapper>
164-
</Element>
165-
</ListAction>
166-
</List>
167-
</Collapsible>
87+
<OpenPopover {...iconPopover}>
88+
<ListAction justify="space-between" gap={2}>
89+
<Text>Template Icon</Text>
90+
<Element>
91+
<Button {...iconPopover} color={defaultColor}>
92+
{selectedIcon && TemplateIcon ? (
93+
<TemplateIcon width={24} />
94+
) : (
95+
<DefaultIcon width={24} />
96+
)}
97+
</Button>
98+
<IconWrapper
99+
aria-label="Choose an Icon"
100+
hideOnClickOutside
101+
hideOnEsc
102+
{...iconPopover}
103+
>
104+
<IconList>
105+
{Object.keys(Icons).map((i: string) => {
106+
const TemplateIconMap = Icons[i];
107+
return (
108+
// eslint-disable-next-line
109+
<li onClick={() => setIcon(i)} role="button" tabIndex={0}>
110+
<IconButton>
111+
<TemplateIconMap width={24} />
112+
</IconButton>
113+
</li>
114+
);
115+
})}
116+
</IconList>
117+
</IconWrapper>
118+
</Element>
119+
</ListAction>
120+
</OpenPopover>
168121
);
169122
};

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ import { PenIcon } from './icons';
1111

1212
const Icon = styled(PenIcon)`
1313
cursor: pointer;
14-
display: none;
14+
opacity: 0;
15+
transition: all;
16+
transition-duration: ${({ theme }) => theme.speeds[4]};
1517
`;
1618

1719
const SandboxNameWrapper = styled(SidebarRow)`
20+
min-height: 0;
1821
:hover {
1922
svg {
20-
display: block;
23+
opacity: 1;
2124
}
2225
}
2326
`;

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Avatar,
99
Stack,
1010
List,
11+
ListAction,
1112
ListItem,
1213
Switch,
1314
Stats,
@@ -26,6 +27,7 @@ import { Title } from './Title';
2627
import { Description } from './Description';
2728
import { Privacy } from './Privacy';
2829
import { Config } from './Config';
30+
import { TemplateConfig } from './TemplateConfig';
2931

3032
export const ProjectInfo = () => {
3133
const {
@@ -65,11 +67,16 @@ export const ProjectInfo = () => {
6567

6668
return (
6769
<>
68-
<Collapsible title="Sandbox Info" defaultOpen>
70+
<Collapsible
71+
title={customTemplate ? 'Template Info' : 'Sandbox Info'}
72+
defaultOpen
73+
>
6974
<Stack direction="vertical" gap={6}>
7075
<Element as="section" css={css({ paddingX: 2 })}>
7176
<Title editable />
72-
<Description editable />
77+
<Element marginTop={2}>
78+
<Description editable />
79+
</Element>
7380
</Element>
7481

7582
<Element as="section" css={css({ paddingX: 2 })}>
@@ -84,14 +91,15 @@ export const ProjectInfo = () => {
8491
</Element>
8592

8693
<List>
87-
<ListItem justify="space-between">
94+
{customTemplate && <TemplateConfig />}
95+
<ListAction onClick={updateFrozenState} justify="space-between">
8896
<Label htmlFor="frozen">Frozen</Label>
8997
<Switch
9098
id="frozen"
9199
onChange={updateFrozenState}
92100
on={customTemplate ? sessionFrozen : isFrozen}
93101
/>
94-
</ListItem>
102+
</ListAction>
95103
{isForked ? (
96104
<ListItem justify="space-between">
97105
<Text>

packages/components/src/components/Button/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,14 @@ export const Button = styled(Element).attrs({ as: 'button' })<{
102102
justifyContent: 'center',
103103
alignItems: 'center',
104104
cursor: 'pointer',
105+
padding: 0,
105106
height: 6,
106107
width: '100%',
107108
fontSize: 2,
108109
border: 'none',
109110
borderRadius: 'small',
110111
transition: 'all ease-in',
111-
transitionDuration: theme => theme.speeds[1],
112+
transitionDuration: theme => theme.speeds[2],
112113

113114
':focus': {
114115
outline: 'none',

packages/components/src/components/Collapsible/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const Header = styled(SidebarRow).attrs({ gap: 2 })(
2323
backgroundColor: 'sideBar.hoverBackground',
2424
svg: {
2525
// TODO: this should come from somewhere else - text muted maybe?
26-
color: 'grays.300',
26+
color: 'grays.400',
2727
},
2828
},
2929
})
@@ -37,7 +37,7 @@ const Icon = styled.svg<{
3737
transform: props.open ? 'rotate(0)' : 'rotate(-90deg)',
3838
transition: 'transform',
3939
transitionDuration: theme => theme.speeds[1],
40-
color: 'grays.400',
40+
color: 'grays.500',
4141
})
4242
);
4343

0 commit comments

Comments
 (0)