Skip to content

Commit 1fbb685

Browse files
authored
Add new sidebar experiment toggle (codesandbox#3475)
* add expeeriment toggle * update cvopy * update cvopy
1 parent f7e17a6 commit 1fbb685

File tree

4 files changed

+53
-26
lines changed

4 files changed

+53
-26
lines changed

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,18 @@ import { Server } from './items/Server';
3636
import { SSEDownNotice } from './SSEDownNotice';
3737
import { WorkspaceItem } from './WorkspaceItem';
3838

39-
const WorkspaceWrapper = REDESIGNED_SIDEBAR ? ThemeProvider : React.Fragment;
39+
const NEW_SIDEBAR = REDESIGNED_SIDEBAR === 'true';
40+
const WorkspaceWrapper = NEW_SIDEBAR ? ThemeProvider : React.Fragment;
4041

4142
const workspaceTabs = {
42-
project: REDESIGNED_SIDEBAR ? ProjectInfoNew : ProjectInfo,
43-
'project-summary': REDESIGNED_SIDEBAR
44-
? NotOwnedSandboxInfoNew
45-
: NotOwnedSandboxInfo,
46-
github: REDESIGNED_SIDEBAR ? GitHubNew : GitHub,
47-
files: REDESIGNED_SIDEBAR ? Explorer : FilesItem,
48-
deploy: REDESIGNED_SIDEBAR ? DeploymentNew : Deployment,
49-
config: REDESIGNED_SIDEBAR ? ConfigurationFilesNew : ConfigurationFiles,
50-
live: REDESIGNED_SIDEBAR ? LiveNew : Live,
51-
server: REDESIGNED_SIDEBAR ? ServerNew : Server,
43+
project: NEW_SIDEBAR ? ProjectInfoNew : ProjectInfo,
44+
'project-summary': NEW_SIDEBAR ? NotOwnedSandboxInfoNew : NotOwnedSandboxInfo,
45+
github: NEW_SIDEBAR ? GitHubNew : GitHub,
46+
files: NEW_SIDEBAR ? Explorer : FilesItem,
47+
deploy: NEW_SIDEBAR ? DeploymentNew : Deployment,
48+
config: NEW_SIDEBAR ? ConfigurationFilesNew : ConfigurationFiles,
49+
live: NEW_SIDEBAR ? LiveNew : Live,
50+
server: NEW_SIDEBAR ? ServerNew : Server,
5251
more: More,
5352
};
5453

@@ -76,8 +75,8 @@ export const WorkspaceComponent = ({ theme }) => {
7675
getDisabledItems(state).find(({ id }) => id === activeTab);
7776

7877
return (
79-
<Container REDESIGNED_SIDEBAR={REDESIGNED_SIDEBAR}>
80-
{item && !item.hasCustomHeader && !REDESIGNED_SIDEBAR && (
78+
<Container REDESIGNED_SIDEBAR={NEW_SIDEBAR}>
79+
{item && !item.hasCustomHeader && !NEW_SIDEBAR && (
8180
<ItemTitle>{item.name}</ItemTitle>
8281
)}
8382

@@ -93,13 +92,13 @@ export const WorkspaceComponent = ({ theme }) => {
9392
</WorkspaceWrapper>
9493
</div>
9594

96-
{isLive && roomInfo.chatEnabled && !REDESIGNED_SIDEBAR && (
95+
{isLive && roomInfo.chatEnabled && !NEW_SIDEBAR && (
9796
<WorkspaceItem defaultOpen title="Chat">
9897
<Chat />
9998
</WorkspaceItem>
10099
)}
101100

102-
{!zenMode && !REDESIGNED_SIDEBAR && (
101+
{!zenMode && !NEW_SIDEBAR && (
103102
<>
104103
{!(isPatron || owned) && <Advertisement />}
105104

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const ContentSplit = ({ theme }) => {
8787

8888
<Fullscreen style={{ width: 'initial' }}>
8989
{!hideNavigation &&
90-
(REDESIGNED_SIDEBAR ? (
90+
(REDESIGNED_SIDEBAR === 'true' ? (
9191
<NewThemeProvider theme={theme.vscodeTheme}>
9292
<Navigation topOffset={topOffset} bottomOffset={bottomOffset} />
9393
</NewThemeProvider>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { useState, useEffect } from 'react';
2+
3+
import { SubDescription, PaddedPreference } from '../elements';
4+
5+
export const NewSidebar: React.FunctionComponent = () => {
6+
const [newSidebar, setNewSidebar] = useState(false);
7+
useEffect(() => {
8+
const value = window.localStorage.getItem('REDESIGNED_SIDEBAR');
9+
10+
if (value === 'true') {
11+
return setNewSidebar(true);
12+
}
13+
return setNewSidebar(false);
14+
}, []);
15+
16+
const setValue = (val: boolean) => {
17+
setNewSidebar(val);
18+
window.localStorage.setItem('REDESIGNED_SIDEBAR', val.toString());
19+
location.reload();
20+
};
21+
22+
return (
23+
<>
24+
<PaddedPreference
25+
title="Sidebar Redesign"
26+
type="boolean"
27+
value={newSidebar}
28+
setValue={setValue}
29+
/>
30+
<SubDescription>
31+
This will refresh the page, make sure to save your changes.
32+
</SubDescription>
33+
</>
34+
);
35+
};

packages/app/src/app/pages/common/Modals/PreferencesModal/Experiments/index.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
import React from 'react';
22

3-
import {
4-
Title,
5-
SubContainer,
6-
SubDescription,
7-
PreferenceContainer,
8-
} from '../elements';
3+
import { Title, SubContainer, PreferenceContainer } from '../elements';
4+
import { NewSidebar } from './NewSidebar';
95

106
export const Experiments: React.FunctionComponent = () => (
117
<div>
128
<Title>Experiments</Title>
139

1410
<SubContainer>
1511
<PreferenceContainer>
16-
<SubDescription>
17-
There are no experiments running at the moment. Stay tuned for new
18-
experiments!
19-
</SubDescription>
12+
<NewSidebar />
2013
</PreferenceContainer>
2114
</SubContainer>
2215
</div>

0 commit comments

Comments
 (0)