Skip to content

Commit aee7b72

Browse files
Update preview header (codesandbox#3209)
* add icons * add icons * swap colors * update design * border fix * move to ts * make naming better * fork of sara's PR (codesandbox#3215) Co-authored-by: Siddharth Kshetrapal <[email protected]>
1 parent 77ccbf9 commit aee7b72

File tree

18 files changed

+286
-177
lines changed

18 files changed

+286
-177
lines changed

packages/app/src/app/components/Preview/DevTools/Tabs/Tab/elements.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export const Tab = styled.div<{ active: boolean; isOver: boolean }>`
3434
props.active
3535
? css`
3636
background-color: ${props.theme['tab.activeBackground'] ||
37-
props.theme['editor.background'] ||
38-
'transparent'};
37+
props.theme.background4};
38+
3939
color: ${props.theme['tab.activeForeground'] ||
4040
(props.theme.light ? '#000000' : '#FFFFFF')};
4141
`

packages/app/src/app/components/Preview/DevTools/elements.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
import styled, { css } from 'styled-components';
2+
import Color from 'color';
3+
4+
const getColor = (light, color) =>
5+
light
6+
? Color(color)
7+
.darken(0.2)
8+
.hexString()
9+
: Color(color)
10+
.lighten(0.2)
11+
.hexString();
212

313
const getCursor = ({ primary, open }) => {
414
if (primary) {
@@ -24,9 +34,12 @@ export const Header = styled.div<{ primary: boolean; open: boolean }>`
2434
font-size: 0.75rem;
2535
flex: 0 0 ${props => (props.primary ? 35 : 28)}px;
2636
background-color: ${props =>
27-
props.theme['editorGroupHeader.tabsBackground'] ||
28-
props.theme['editor.background'] ||
29-
props.theme.background4};
37+
getColor(
38+
props.theme.light,
39+
props.theme['editor.background'] ||
40+
props.theme['input.background'] ||
41+
props.theme.background4
42+
)};
3043
3144
${props =>
3245
!props.primary &&
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
import styled from 'styled-components';
2+
import Color from 'color';
3+
import { darker } from '../Navigator/elements';
4+
5+
const getColor = (light: boolean, color: string) =>
6+
light
7+
? Color(color)
8+
.darken(0.2)
9+
.hexString()
10+
: Color(color)
11+
.lighten(0.2)
12+
.hexString();
213

314
export const Container = styled.div`
415
position: relative;
@@ -9,17 +20,29 @@ export const Container = styled.div`
920

1021
export const InputContainer = styled.div`
1122
input {
12-
border-radius: 4px;
23+
border-radius: 2px;
1324
outline: none;
14-
/* border: 1px solid #ccc; */
1525
border: 0px solid transparent;
1626
padding: 0.2rem 0.5rem;
1727
color: black;
1828
width: 100%;
29+
height: 26px;
30+
font-size: 13px;
1931
color: ${props =>
2032
props.theme['input.foreground'] || 'rgba(255, 255, 255, 0.8)'};
2133
box-sizing: border-box;
34+
border: 1px solid
35+
${props =>
36+
darker(
37+
props.theme.light,
38+
props.theme['editor.background'] || props.theme.background()
39+
)};
2240
background-color: ${props =>
23-
props.theme['input.background'] || props.theme.background4};
41+
getColor(
42+
props.theme.light,
43+
props.theme['input.background'] ||
44+
props.theme['editor.background'] ||
45+
props.theme.background4
46+
)};
2447
}
2548
`;

packages/common/src/components/Preview/Navigator/ExternalOpen.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/common/src/components/Preview/Navigator/HorizontalAlign.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/common/src/components/Preview/Navigator/VerticalAlign.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/common/src/components/Preview/Navigator/elements.js

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import styled, { css } from 'styled-components';
2+
import Color from 'color';
3+
4+
export const darker = (light: boolean, color: string) =>
5+
Color(color)
6+
.darken(light ? 0.3 : 0.7)
7+
.hexString();
8+
9+
export const Container = styled.div`
10+
display: flex;
11+
background-color: ${props =>
12+
props.theme['tab.activeBackground'] || props.theme.background4};
13+
padding: 0.25rem;
14+
align-items: center;
15+
line-height: 1;
16+
/* box-shadow: 0 1px 3px #ddd; */
17+
height: 35px;
18+
min-height: 35px;
19+
box-sizing: border-box;
20+
z-index: 2;
21+
`;
22+
23+
export const Icons = styled.div`
24+
display: flex;
25+
`;
26+
27+
export const Icon = styled.button<{ moduleView?: boolean }>`
28+
display: inline-block;
29+
border: none;
30+
background-color: transparent;
31+
font-size: 1.5rem;
32+
line-height: 0.5;
33+
margin: 0 0.25rem;
34+
vertical-align: middle;
35+
text-align: center;
36+
padding: 0;
37+
outline: none;
38+
cursor: pointer;
39+
40+
${({ moduleView, theme }) =>
41+
!moduleView &&
42+
css`
43+
&:hover svg path,
44+
&:hover svg rect {
45+
fill: ${theme.light ? 'black' : 'white'};
46+
}
47+
`}
48+
49+
/* // TODO: Replace with new theme */
50+
${({ moduleView, theme }) =>
51+
moduleView &&
52+
css`
53+
${theme.light
54+
? css`
55+
svg rect[fill='#E6E6E6'] {
56+
fill: #343434;
57+
}
58+
svg rect[fill='#343434'] {
59+
fill: #e6e6e6;
60+
}
61+
&:hover svg rect {
62+
fill: black;
63+
}
64+
`
65+
: css`
66+
&:hover svg rect:not([fill='#E6E6E6']) {
67+
fill: #757575;
68+
}
69+
`}
70+
`}
71+
`;
72+
73+
export const IconWithBackground = styled(Icon)`
74+
border-radius: 2px;
75+
background-color: ${({ theme }) =>
76+
theme['editor.background'] || theme.background()};
77+
border: 1px solid
78+
${({ theme }) =>
79+
darker(theme.light, theme['editor.background'] || theme.background())};
80+
`;
81+
82+
export const AddressBarContainer = styled.div`
83+
width: 100%;
84+
box-sizing: border-box;
85+
margin: 0 0.25rem;
86+
`;

packages/common/src/components/Preview/Navigator/external-open.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/common/src/components/Preview/Navigator/horizontal-align.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)