Skip to content

Commit 57ccfd1

Browse files
feat: Add username to sandbox/devbox cards/listitems (#8540)
* Add username to sandbox/devbox cards/listitems * new version * update icon * update types --------- Co-authored-by: Danilo Woznica <[email protected]>
1 parent e4b7f8d commit 57ccfd1

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

packages/app/src/app/pages/Dashboard/Components/Sandbox/SandboxBadge.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@ export const SandboxBadge: React.FC<SandboxBadgeProps> = ({
1515
const isRestricted = restricted;
1616
const isTemplate = !!sandbox.customTemplate;
1717

18-
const boxIcon = isDevbox ? 'boxDevbox' : 'boxSandbox';
19-
let boxTypeColor = isDevbox ? '#FFFFFF' : '#A6A6A6';
18+
const boxIcon = isDevbox ? 'server' : 'boxDevbox';
2019
let boxTypeLabel = isDevbox ? 'Devbox' : 'Sandbox';
2120

2221
if (isTemplate) {
2322
boxTypeLabel = 'Template';
2423
}
2524

2625
if (isRestricted) {
27-
boxTypeColor = '#F7CC66';
2826
boxTypeLabel += ' (Restricted)';
2927
}
3028

3129
return (
3230
<Stack align="center" gap={1}>
33-
<Icon name={boxIcon} color={boxTypeColor} />
34-
<Text size={2} color={boxTypeColor}>
31+
<Icon name={boxIcon} color="#A6A6A6" />
32+
<Text size={2} color="#A6A6A6">
3533
{boxTypeLabel}
3634
</Text>
3735
</Stack>

packages/app/src/app/pages/Dashboard/Components/Sandbox/SandboxCard.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const SandboxCard = ({
184184
// drag preview
185185
thumbnailRef,
186186
isDragging,
187-
187+
username,
188188
'data-selection-id': dataSelectionId,
189189
...props
190190
}: SandboxItemComponentProps) => {
@@ -193,11 +193,14 @@ export const SandboxCard = ({
193193
});
194194

195195
let textColor = '#EBEBEB'; // default
196+
let userNameTextColor = '#A6A6A6';
196197

197198
if (restricted) {
198199
textColor = thumbnail.isCustom ? textColor : '#999999';
200+
userNameTextColor = textColor;
199201
} else if (thumbnail?.brightness && thumbnail.isCustom) {
200202
textColor = thumbnail.brightness === 'light' ? '#0E0E0E' : '#FFFFFF';
203+
userNameTextColor = textColor;
201204
}
202205

203206
return (
@@ -279,7 +282,16 @@ export const SandboxCard = ({
279282
) : null}
280283

281284
<CardContent selected={selected}>
282-
<SandboxTitle brightness={thumbnail.brightness} {...props} />
285+
<Stack direction="vertical" gap={0}>
286+
<SandboxTitle brightness={thumbnail.brightness} {...props} />
287+
<Text
288+
size={12}
289+
truncate
290+
css={{ marginLeft: 28, color: userNameTextColor }}
291+
>
292+
Created by {username}
293+
</Text>
294+
</Stack>
283295
<SandboxStats
284296
noDrag={noDrag}
285297
timeAgo={timeAgo}

packages/app/src/app/pages/Dashboard/Components/Sandbox/SandboxListItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const SandboxListItem = ({
1919
sandbox,
2020
sandboxTitle,
2121
sandboxLocation,
22+
username,
2223
timeAgo,
2324
viewCount,
2425
TemplateIcon,
@@ -174,7 +175,7 @@ export const SandboxListItem = ({
174175
variant={selected ? 'body' : 'muted'}
175176
maxWidth="100%"
176177
>
177-
{timeAgo}
178+
{timeAgo} by {username}
178179
</Text>
179180
)}
180181
</Column>

packages/app/src/app/pages/Dashboard/Components/Sandbox/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import track, {
1313
import { Icon } from '@codesandbox/components';
1414
import { formatNumber } from '@codesandbox/components/lib/components/Stats';
1515
import { useBetaSandboxEditor } from 'app/hooks/useBetaSandboxEditor';
16+
1617
import { SandboxCard } from './SandboxCard';
1718
import { SandboxListItem } from './SandboxListItem';
1819
import { getTemplateIcon } from './TemplateIcon';
@@ -67,7 +68,7 @@ function getFolderName(item: GenericSandboxProps['item']): string | undefined {
6768
}
6869

6970
const GenericSandbox = ({ isScrolling, item, page }: GenericSandboxProps) => {
70-
const { dashboard, activeWorkspaceAuthorization } = useAppState();
71+
const { user, dashboard, activeWorkspaceAuthorization } = useAppState();
7172
const [hasBetaEditorExperiment] = useBetaSandboxEditor();
7273
const actions = useActions();
7374

@@ -306,6 +307,11 @@ const GenericSandbox = ({ isScrolling, item, page }: GenericSandboxProps) => {
306307
{...sandboxProps}
307308
{...interactionProps}
308309
isScrolling={isScrolling}
310+
username={
311+
sandboxProps.sandbox.author.username === user.username
312+
? 'you'
313+
: sandboxProps.sandbox.author.username
314+
}
309315
/>
310316
</div>
311317
);

packages/app/src/app/pages/Dashboard/Components/Sandbox/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface SandboxItemComponentProps {
1515
PrivacyIcon: React.FC;
1616
screenshotUrl: string | null;
1717
restricted: boolean;
18-
18+
username: string;
1919
interaction: 'button' | 'link';
2020
isScrolling: boolean;
2121
selected: boolean;

0 commit comments

Comments
 (0)