Skip to content

Commit 69be02a

Browse files
authored
update styles for comments (codesandbox#3821)
* update styles for comments * make api file
1 parent 9ab4f59 commit 69be02a

File tree

7 files changed

+140
-108
lines changed

7 files changed

+140
-108
lines changed

packages/app/src/app/overmind/effects/vscode/icons.css

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

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './icons.css';
2-
31
import DEFAULT_PRETTIER_CONFIG from '@codesandbox/common/lib/prettify-default-config';
42
import { resolveModule } from '@codesandbox/common/lib/sandbox/modules';
53
import getTemplate from '@codesandbox/common/lib/templates';

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import { NotOwnedSandboxInfo } from './items/NotOwnedSandboxInfo';
3030
import { ProjectInfo } from './items/ProjectInfo';
3131
import { Server } from './items/Server';
3232
import { Comments } from './screens/Comments';
33-
import { MultiComment } from './screens/Comments/components/MultiComment';
34-
import { CommentDialog } from './screens/Comments/Dialog';
3533
import { ConfigurationFiles as ConfigurationFilesNew } from './screens/ConfigurationFiles';
3634
import { Deployment as DeploymentNew } from './screens/Deployment/index';
3735
import { Explorer } from './screens/Explorer';
@@ -114,11 +112,6 @@ export const WorkspaceComponent = ({ theme }) => {
114112
{NEW_SIDEBAR &&
115113
!(isPatron || (currentSandbox && currentSandbox.owned)) &&
116114
!(isLive && roomInfo.chatEnabled) && <Advertisement />}
117-
118-
{state.comments.currentCommentId && <CommentDialog />}
119-
{state.comments.multiCommentsSelector && (
120-
<MultiComment {...state.comments.multiCommentsSelector} />
121-
)}
122115
</>
123116
</WorkspaceWrapper>
124117

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This file imports the necessary files that allow for the comments to be used in the outside world as a plug API
2+
import React from 'react';
3+
import { useOvermind } from 'app/overmind';
4+
import { CommentsGlobalStyles } from './components/GlobalStyles';
5+
import { MultiComment } from './components/MultiComment';
6+
import { CommentDialog } from './Dialog';
7+
8+
export const CommentsAPI = () => {
9+
const {
10+
state: { comments },
11+
} = useOvermind();
12+
13+
return (
14+
<>
15+
<CommentsGlobalStyles />
16+
{comments.currentCommentId && <CommentDialog />}
17+
{comments.multiCommentsSelector && (
18+
<MultiComment {...comments.multiCommentsSelector} />
19+
)}
20+
</>
21+
);
22+
};
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { createGlobalStyle, css } from 'styled-components';
2+
3+
const POSITION = css`
4+
top: 0px;
5+
left: ${props => props.theme.space[2] + 1}px;
6+
`;
7+
8+
const primary = (theme: any) =>
9+
'%23' + theme.colors.button.background.split('#')[1];
10+
11+
const makeColor = (color: string) => '%23' + color.split('#')[1];
12+
13+
export const CommentsGlobalStyles = createGlobalStyle`
14+
${({ theme }: any) => css`
15+
.editor-comments-glyph {
16+
position: relative;
17+
background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M0 5C0 2.23858 2.23858 0 5 0C7.76142 0 10 2.23858 10 5C10 7.76142 7.76142 10 5 10H0V5Z' fill='black'/%3E%3C/svg%3E");
18+
background-size: ${theme.space[3] + 1}px ${theme.space[3] + 1}px;
19+
background-repeat: no-repeat;
20+
background-position: center center;
21+
opacity: 0.3;
22+
transition: all ${theme.speeds[4]}ms ease;
23+
position: relative;
24+
cursor: pointer;
25+
26+
&:hover {
27+
opacity: 1;
28+
}
29+
}
30+
31+
.vs-dark {
32+
.editor-comments-glyph {
33+
background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M0 5C0 2.23858 2.23858 0 5 0C7.76142 0 10 2.23858 10 5C10 7.76142 7.76142 10 5 10H0V5Z' fill='${makeColor(
34+
theme.colors.white
35+
)}'/%3E%3C/svg%3E");
36+
}
37+
.editor-comments-multi:before {
38+
color: ${theme.colors.grays[600]};
39+
}
40+
}
41+
42+
.editor-comments-glyph.active-comment.editor-comments-multi:before {
43+
color: ${theme.colors.white};
44+
}
45+
46+
.editor-comments-multi:before {
47+
content: '...';
48+
color: ${theme.colors.white};
49+
position: absolute;
50+
top: -2px;
51+
left: ${theme.space[2] - 1}px;
52+
z-index: 10;
53+
font-size: 8px;
54+
font-weight: bold;
55+
height: ${theme.space[3] + 1}px;
56+
font-family: 'Inter', sans-serif;
57+
}
58+
59+
.editor-comments-multi-2:before {
60+
content: '2';
61+
${POSITION}
62+
}
63+
64+
.editor-comments-multi-3:before {
65+
content: '3';
66+
${POSITION}
67+
}
68+
.editor-comments-multi-4:before {
69+
content: '4';
70+
${POSITION}
71+
}
72+
.editor-comments-multi-5:before {
73+
content: '5';
74+
${POSITION}
75+
}
76+
.editor-comments-multi-6:before {
77+
content: '6';
78+
${POSITION}
79+
}
80+
.editor-comments-multi-7:before {
81+
content: '7';
82+
${POSITION}
83+
}
84+
.editor-comments-multi-8:before {
85+
content: '8';
86+
${POSITION}
87+
}
88+
.editor-comments-multi-9:before {
89+
content: '9';
90+
${POSITION}
91+
}
92+
93+
.editor-comments-glyph.editor-comments-active {
94+
opacity: 1;
95+
background-image: url('${`data:image/svg+xml,%3Csvg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M0 5C0 7.76142 2.23858 10 5 10C7.76142 10 10 7.76142 10 5C10 2.23858 7.76142 0 5 0C2.23858 0 0 2.23858 0 5Z" fill="${primary(
96+
theme
97+
)}"/%3E%3Cpath d="M5 5H0V10H5V5Z" fill="${primary(
98+
theme
99+
)}"/%3E%3C/svg%3E%0A`}');
100+
101+
&::before {
102+
content: '';
103+
}
104+
}
105+
106+
.editor-comments-add:before {
107+
content: '+';
108+
font-size: 10px;
109+
font-weight: bold;
110+
top: 0;
111+
left: ${theme.space[2]}px;
112+
}
113+
`}
114+
`;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import { css } from '@styled-system/css';
1111
import { useOvermind } from 'app/overmind';
1212
import React from 'react';
13-
1413
import { AddComment } from './AddComment';
1514
import { Comment } from './Comment';
1615

packages/app/src/app/pages/Sandbox/Editor/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Navigation as NavigationOld } from './NavigationOld';
1919
import { ContentSkeleton } from './Skeleton';
2020
import getVSCodeTheme from './utils/get-vscode-theme';
2121
import { Workspace } from './Workspace';
22+
import { CommentsAPI } from './Workspace/screens/Comments/API';
2223

2324
const STATUS_BAR_SIZE = 22;
2425

@@ -203,6 +204,9 @@ const ContentSplit = () => {
203204

204205
<ForkFrozenSandboxModal />
205206
</Container>
207+
<NewThemeProvider theme={localState.theme.vscodeTheme}>
208+
<CommentsAPI />
209+
</NewThemeProvider>
206210
</ThemeProvider>
207211
);
208212
};

0 commit comments

Comments
 (0)