Skip to content

Commit 1564be2

Browse files
SaraVieiraCompuIves
authored andcommitted
Profile page (codesandbox#1571)
* start * pºrogress * i needed to, sorry * things * get liked anmdboxes0 * add more things * add badges * add slider * more things * add 404 * add menu * fix more link * add responsive * add close account modal * Fix lib paths * Update common paths * Update paths to theme * Fix return type for template icons * Update paths * lodash * Move some lodash back * Revert README of codesandbox-api * Temporary fix for lodash * Styling tweaks * Fix my color mistake * remove slider yay * remove unsudes deps * much clean * add ediing * fix routing * move delete when edit * revert io * re add mobile * make link 100% * only show badge if there are some * onlu show see all liked if more than 5 * le tweaks * remove unecessary files * PR fixes
1 parent a5a70b7 commit 1564be2

File tree

84 files changed

+3120
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3120
-166
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
"build:embed": "lerna run build:embed --scope app --stream && gulp",
1010
"build:clean": "lerna run build:clean --scope app --scope homepage && rimraf www",
1111
"build:deps": "lerna run build:dev --scope codesandbox-api --scope codesandbox-browserfs --scope node-services --scope common && lerna run build:dev --scope sse-hooks",
12+
"build:dynamic": "lerna run build --scope dynamic-pages --stream",
1213
"start": "yarn build:deps && lerna run start --scope app --stream",
1314
"start:fast": "lerna run start --scope app --stream",
1415
"start:vscode": "VSCODE=1 yarn start:fast & cd standalone-packages/monaco-editor && yarn simpleserver & cd standalone-packages/vscode && yarn watch",
16+
"start:dynamic": "lerna run dev --scope dynamic-pages --stream",
1517
"start:home": "lerna run start --scope homepage --stream",
1618
"start:test": "lerna run start:test --scope app --stream",
1719
"start:dev_api": "lerna run start --parallel --scope codesandbox-api & lerna run start:dev_api --scope app --stream",

packages/app/src/app/components/Preview/DevTools/Terminal/Shell/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { listen, dispatch } from 'codesandbox-api';
44
import { withTheme } from 'styled-components';
55
import { Terminal } from 'xterm';
6-
import { debounce } from 'lodash';
6+
import { debounce } from 'lodash-es';
77
import * as fit from 'xterm/lib/addons/fit/fit';
88

99
import getTerminalTheme from '../terminal-theme';

packages/app/src/app/components/UserWithAvatar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import ContributorHelm from '../ContributorsBadge';
3+
import ContributorHelm from 'common/lib/components/ContributorsBadge';
44
import PatronStar from '../PatronStar';
55
import { CenteredText, AuthorName, Image, Names, Username } from './elements';
66

packages/app/src/app/pages/Profile/Header/UserInfo/Stats/Badges/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ import { Link } from 'react-router-dom';
33

44
import Margin from 'common/lib/components/spacing/Margin';
55
import Badge from 'common/lib/utils/badges/Badge';
6-
import ContributorsBadge from 'app/components/ContributorsBadge';
6+
import ContributorsBadge from 'common/lib/components/ContributorsBadge';
77

88
import { patronUrl } from 'common/lib/utils/url-generator';
99

1010
function Badges({ badges, username }) {
1111
return (
1212
<Margin style={{ display: 'flex', alignItems: 'center' }} right={2}>
1313
<Link to={patronUrl()}>
14-
{badges.map(badge => (
15-
<Badge key={badge.id} badge={badge} size={64} />
16-
))}
14+
{badges.map(badge => <Badge key={badge.id} badge={badge} size={64} />)}
1715
</Link>
1816

1917
<ContributorsBadge

packages/app/src/app/pages/common/Modals/DeploymentModal/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ function DeploymentModal({ store, signals }) {
4949
<DeployText>Deploying sandbox...</DeployText>
5050
<DeployAnimationContainer deploying={store.deployment.deploying}>
5151
<StyledLogo width={70} height={70} />
52-
{[0, 1, 2, 3].map(i => (
53-
<StyledCube key={i} i={i} size={20} />
54-
))}
52+
{[0, 1, 2, 3].map(i => <StyledCube key={i} i={i} size={20} />)}
5553
<StyledNowLogo backgroundColor="#24282A" />
5654
</DeployAnimationContainer>
5755
</Margin>

packages/app/src/embed/components/App/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ export default class App extends React.PureComponent<
8888
runOnClick,
8989
verticalMode = window.innerWidth < window.innerHeight,
9090
tabs,
91-
} = props.embedOptions || getSandboxOptions(document.location.href);
91+
} =
92+
props.embedOptions || getSandboxOptions(document.location.href);
9293

9394
this.state = {
9495
notFound: false,

packages/app/src/sandbox/version-resolving/merge-dependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { uniq } from 'lodash';
1+
import { uniq } from 'lodash-es';
22
import * as semver from 'semver';
33

44
interface ILambdaResponse {
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import styled, { css } from 'styled-components';
2+
import Link from 'react-router-dom/Link';
3+
import theme from '../../theme';
4+
5+
export type OptionProps = {
6+
theme: any;
7+
disabled?: boolean;
8+
red?: boolean;
9+
secondary?: boolean;
10+
danger?: boolean;
11+
};
12+
13+
const getBackgroundColor = ({
14+
theme: internalTheme,
15+
disabled,
16+
red,
17+
secondary,
18+
danger,
19+
}: OptionProps) => {
20+
if (disabled) return `background-color: ${theme.background2.darken(0.1)()}`;
21+
if (internalTheme && internalTheme['button.background']) {
22+
return `background-color: ${internalTheme['button.background']}`;
23+
}
24+
if (danger) return `background-color: ${theme.dangerBackground()}`;
25+
if (secondary) return `background-color: transparent`;
26+
if (red) return `background-color: ${theme.red.darken(0.2)()}`;
27+
28+
return `background-color: #40A9F3;`;
29+
};
30+
31+
const getBackgroundHoverColor = ({
32+
theme: internalTheme,
33+
disabled,
34+
red,
35+
secondary,
36+
danger,
37+
}: OptionProps) => {
38+
if (disabled) return `background-color: ${theme.background2.darken(0.1)()}`;
39+
if (internalTheme && internalTheme['button.hoverBackground']) {
40+
return `background-color: ${internalTheme['button.hoverBackground']}`;
41+
}
42+
if (danger) return `background-color: #E25D6A`;
43+
if (secondary) return `background-color: #66b9f4`;
44+
if (red) return `background-color: #F27777`;
45+
46+
return `background-color: #66b9f4;`;
47+
};
48+
49+
const getColor = ({ disabled, secondary }: OptionProps) => {
50+
if (disabled) return theme.background2.lighten(1.5)();
51+
if (secondary) return `#66b9f4`;
52+
53+
return 'white';
54+
};
55+
56+
const getHoverColor = ({ secondary }: OptionProps) => {
57+
if (secondary) return 'color: white';
58+
59+
return '';
60+
};
61+
62+
const getBorder = ({
63+
theme: internalTheme,
64+
secondary,
65+
danger,
66+
red,
67+
disabled,
68+
}: OptionProps) => {
69+
if (disabled) return '2px solid #161A1C';
70+
if (internalTheme && internalTheme['button.hoverBackground']) {
71+
return `2px solid ${internalTheme['button.hoverBackground']}`;
72+
}
73+
if (secondary) return `2px solid #66B9F4`;
74+
if (red) return '2px solid #F27777';
75+
if (danger) return '2px solid #E25D6A';
76+
77+
return '2px solid #66B9F4';
78+
};
79+
80+
const styles = css<{
81+
disabled?: boolean;
82+
secondary?: boolean;
83+
danger?: boolean;
84+
red?: boolean;
85+
block?: boolean;
86+
small?: boolean;
87+
}>`
88+
transition: 0.3s ease all;
89+
90+
border: none;
91+
outline: none;
92+
${props => getBackgroundColor(props)};
93+
background-size: 720%;
94+
95+
border: ${props => getBorder(props)};
96+
border-radius: 4px;
97+
98+
box-sizing: border-box;
99+
font-size: 1.125em;
100+
text-align: center;
101+
color: ${props => getColor(props)};
102+
font-weight: 400;
103+
width: ${props => (props.block ? '100%' : 'inherit')};
104+
105+
user-select: none;
106+
text-decoration: none;
107+
font-weight: 600;
108+
109+
${props =>
110+
props.small
111+
? css`
112+
padding: 0.5em 0.7em;
113+
font-size: 0.875em;
114+
`
115+
: css`
116+
padding: 0.65em 2.25em;
117+
`};
118+
119+
svg {
120+
font-size: 1.125em;
121+
}
122+
123+
${props =>
124+
!props.disabled &&
125+
`
126+
cursor: pointer;
127+
`};
128+
129+
&:hover {
130+
${props => getBackgroundHoverColor(props)};
131+
${props => getHoverColor(props)};
132+
}
133+
`;
134+
135+
export const LinkButton = styled(Link)`
136+
${styles};
137+
`;
138+
export const AButton = styled.a`
139+
${styles};
140+
`;
141+
export const Button = styled.button`
142+
${styles};
143+
`;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { LinkButton, AButton, Button } from './elements';
3+
4+
type Props = {
5+
[key: string]: any;
6+
to?: string;
7+
href?: string;
8+
small?: boolean;
9+
style?: any;
10+
};
11+
12+
function ButtonComponent({ style = {}, ...props }: Props) {
13+
// Link
14+
if (props.to) {
15+
return <LinkButton style={style} {...props} />;
16+
}
17+
18+
if (props.href) {
19+
return <AButton style={style} {...props} />;
20+
}
21+
22+
return <Button style={style} {...props} />;
23+
}
24+
25+
export default ButtonComponent;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import React from 'react';
2+
import IconBase from 'react-icons/lib/IconBase';
3+
import Tooltip from '../Tooltip';
4+
import getIcon from '../../templates/icons';
5+
import getDefinition from '../../templates/';
6+
import Color from 'color';
7+
import styled from 'styled-components';
8+
9+
const IconContainer = styled.div`
10+
max-width: 30%;
11+
left: 50%;
12+
position: absolute;
13+
top: 6px;
14+
transform: translateX(-50%);
15+
16+
svg,
17+
img {
18+
max-width: 100%;
19+
filter: grayscale(0.4);
20+
height: auto;
21+
}
22+
`;
23+
24+
export default ({ style, sandboxesNumber, template }) => {
25+
const templateInfo = getDefinition(template);
26+
const color = templateInfo.color();
27+
const lighter = Color(color)
28+
.lighten(0.2)
29+
.rgb();
30+
31+
const Icon = getIcon(template);
32+
33+
return sandboxesNumber >= 50 ? (
34+
<Tooltip
35+
style={{ display: 'flex', position: 'relative' }}
36+
title={`${sandboxesNumber < 100 ? 'Silver' : 'Gold'} medal for ${
37+
templateInfo.niceName
38+
}`}
39+
>
40+
<IconBase
41+
style={style}
42+
width="1em"
43+
height="0.67em"
44+
viewBox="0 0 204 320"
45+
fill="none"
46+
>
47+
<path d="M162.478 320V182H102v104.895L162.478 320z" fill={color} />
48+
<path
49+
d="M41.522 319.628V182H102v105.639l-60.478 31.989z"
50+
fill={`rgb(${lighter.r},${lighter.g},${lighter.b})`}
51+
/>
52+
<circle
53+
cx={102}
54+
cy="102.355"
55+
r={102}
56+
transform="rotate(180 102 102.355)"
57+
fill={sandboxesNumber < 100 ? '#EBEBEB' : '#EAC17A'}
58+
/>
59+
<circle
60+
cx={102}
61+
cy="102.355"
62+
r="92.7273"
63+
transform="rotate(180 102 102.355)"
64+
fill={sandboxesNumber < 100 ? '#C8C8C8' : '#CFAE72'}
65+
/>
66+
</IconBase>
67+
<IconContainer>
68+
<Icon />
69+
</IconContainer>
70+
</Tooltip>
71+
) : null;
72+
};

0 commit comments

Comments
 (0)