Skip to content

Commit 6c6b744

Browse files
authored
* add avatr * fix my merge, sorry :( * should always be white; wwow that sounds racist * fix avatar color * fixed pr comments
1 parent 8cbbe54 commit 6c6b744

File tree

5 files changed

+140
-3
lines changed

5 files changed

+140
-3
lines changed

packages/components/.storybook/config.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ const GlobalStyle = createGlobalStyle`
3333
${global};
3434
html body {
3535
font-family: 'Inter', sans-serif;
36-
background-color: ${theme.colors.sideBar.background};
37-
color: ${theme.colors.sideBar.foreground};
36+
37+
background-color: ${props =>
38+
// @ts-ignore
39+
props.theme.colors.sideBar.background} !important;
40+
color: ${props =>
41+
// @ts-ignore
42+
props.theme.colors.sideBar.foreground} !important;
3843
margin: 0;
39-
padding: 20px;
4044
4145
* {
4246
box-sizing: border-box;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import { Avatar } from '.';
3+
import { sid, sara } from './stubs';
4+
5+
export default {
6+
title: 'components/Avatar',
7+
component: Avatar,
8+
};
9+
10+
export const Sid = () => <Avatar user={sid} />;
11+
export const Sara = () => <Avatar user={sara} />;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
import css from '@styled-system/css';
3+
import { User } from '@codesandbox/common/lib/types';
4+
import styled from 'styled-components';
5+
import { Element } from '../Element';
6+
import { Text } from '../Text';
7+
8+
interface IAvatarProps {
9+
user: User;
10+
}
11+
12+
export const AvatarImage = styled.img(
13+
css({
14+
width: 8,
15+
height: 8,
16+
borderRadius: 'small',
17+
border: '1px solid',
18+
borderColor: 'avatar.border',
19+
backgroundColor: 'avatar.border', // fallback for loading image
20+
})
21+
);
22+
23+
export const Pro = styled(Text).attrs({ size: 1, weight: 'bold' })(
24+
css({
25+
backgroundColor: 'blues.700',
26+
color: 'white',
27+
borderRadius: 'small',
28+
paddingX: 2,
29+
paddingY: '2px', // no 2 in spaces
30+
border: '1px solid',
31+
borderColor: 'avatar.border',
32+
transform: 'translateX(-50%) translateY(-100%);',
33+
position: 'absolute',
34+
top: '100%',
35+
})
36+
);
37+
38+
export const Avatar = ({ user }: IAvatarProps) => (
39+
<Element style={{ position: 'relative' }}>
40+
<AvatarImage src={user.avatarUrl} alt={user.username} />
41+
{user.subscriptionSince ? <Pro>Pro</Pro> : null}
42+
</Element>
43+
);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
export const sid = {
2+
avatarUrl: 'https://avatars0.githubusercontent.com/u/1863771?v=4',
3+
badges: [],
4+
bio: null,
5+
curatorAt: '2018-12-19T14:09:51Z',
6+
featuredSandboxes: [],
7+
forkedCount: 334,
8+
givenLikeCount: 15,
9+
id: '740dca51-993d-4b0e-b8cb-0e46acada86b',
10+
insertedAt: '2017-07-23T17:28:22',
11+
name: 'Siddharth Kshetrapal',
12+
profileEmail: null,
13+
receivedLikeCount: 35,
14+
sandboxCount: 215,
15+
sandboxCountPerTemplate: {
16+
apollo: 1,
17+
'create-react-app': 166,
18+
gatsby: 3,
19+
node: 14,
20+
nuxt: 1,
21+
parcel: 24,
22+
'preact-cli': 1,
23+
static: 5,
24+
},
25+
showcasedSandboxShortid: 'ppsij',
26+
subscriptionSince: null,
27+
sandboxes: [],
28+
likedSandboxes: [],
29+
topSandboxes: [],
30+
twitter: null,
31+
username: 'siddharthkp',
32+
viewCount: 31128,
33+
};
34+
35+
export const sara = {
36+
avatarUrl: 'https://avatars0.githubusercontent.com/u/1051509?v=4',
37+
badges: [{ id: 'patron_2', name: 'Patron II', visible: true }],
38+
bio: 'I am sara',
39+
curatorAt: '2018-11-25T18:51:34Z',
40+
featuredSandboxes: [],
41+
forkedCount: 1556,
42+
givenLikeCount: 33,
43+
id: '8d35d7c1-eecb-4aad-87b0-c22d30d12081',
44+
insertedAt: '2017-07-18T23:49:53',
45+
name: 'Sara Vieira',
46+
profileEmail: '[email protected]',
47+
receivedLikeCount: 86,
48+
sandboxCount: 611,
49+
sandboxCountPerTemplate: {
50+
'@dojo/cli-create-app': 1,
51+
'angular-cli': 3,
52+
apollo: 7,
53+
'create-react-app': 356,
54+
'create-react-app-typescript': 6,
55+
cxjs: 3,
56+
gatsby: 13,
57+
'mdx-deck': 2,
58+
next: 1,
59+
node: 44,
60+
nuxt: 1,
61+
parcel: 77,
62+
'preact-cli': 8,
63+
sapper: 1,
64+
static: 28,
65+
svelte: 11,
66+
'vue-cli': 49,
67+
},
68+
showcasedSandboxShortid: '3p5b4',
69+
subscriptionSince: '2018-03-01T16:00:18Z',
70+
sandboxes: [],
71+
likedSandboxes: [],
72+
topSandboxes: [],
73+
twitter: 'NikkitaFTW',
74+
username: 'SaraVieira',
75+
viewCount: 84435,
76+
};

packages/components/src/utils/polyfill-theme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const polyfillTheme = vsCodeTheme =>
1818
sideBar: {
1919
hoverBackground: vsCodeTheme.sideBar.border,
2020
},
21+
avatar: {
22+
border: vsCodeTheme.sideBar.border,
23+
},
2124
});
2225

2326
export default polyfillTheme;

0 commit comments

Comments
 (0)