Skip to content

Commit 8f6d977

Browse files
authored
feat: experimental standalone page (#8180)
* feat: show personal free workspaces as teams * feat: Update workspace settings titles and references Update titles and references in the workspace settings pages and components * refactor: Update delete workspace functionality Removed condition to show notification and added modal * refactor: Update workspace settings and navigation Updated workspace settings in Dashboard and navigation in Settings * feat: Add personal space announcement modal Added new modal component for announcing personal workspace features and benefits * feat: Edit workspace and team titles Changed titles in multiple files from 'Edit team' to 'Edit workspace'. * change subtitle * feat: add account settings in preferences * feat: Add user check Add user check before executing code in preferences actions.ts * initial commit * Update index.tsx * feat: sandbox and preference modal exposed on standalone page * fix typing
1 parent c94a2c7 commit 8f6d977

File tree

6 files changed

+81
-26
lines changed

6 files changed

+81
-26
lines changed

packages/app/src/app/overmind/namespaces/preferences/state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type State = {
1515
settings: Settings;
1616
isLoadingPaymentDetails: boolean;
1717
hideNavigation: boolean;
18-
itemId: string;
18+
itemId: string | null;
1919
showEditor: boolean;
2020
showModal: boolean;
2121
showPreview: boolean;
@@ -84,7 +84,7 @@ export const state: State = {
8484
isLoadingPaymentDetails: true,
8585
paymentDetailError: null,
8686
paymentDetails: null,
87-
itemId: 'appearance',
87+
itemId: null,
8888
showEditor: true,
8989
showPreview: true,
9090
showDevtools: false,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React, { useEffect } from 'react';
2+
import { createGlobalStyle, withTheme } from 'styled-components';
3+
import { ThemeProvider, Element } from '@codesandbox/components';
4+
import { useActions } from 'app/overmind';
5+
import { useParams } from 'react-router-dom';
6+
import { CreateSandbox } from 'app/components/CreateSandbox';
7+
import { Preferences } from '../common/Modals/PreferencesModal';
8+
import { NotFound } from '../common/NotFound';
9+
10+
const COMPONENT_MAP = {
11+
preferences: Preferences,
12+
create: CreateSandbox,
13+
};
14+
15+
export const StandalonePage = withTheme(({ theme }) => {
16+
const { genericPageMounted } = useActions();
17+
const params: { componentId?: string } = useParams();
18+
const searchParams = new URLSearchParams(window.location.search);
19+
20+
useEffect(() => {
21+
genericPageMounted();
22+
}, [genericPageMounted]);
23+
24+
const Content = COMPONENT_MAP[params.componentId];
25+
const contentProps = Object.fromEntries(searchParams.entries());
26+
27+
if (!Content) {
28+
return <NotFound />;
29+
}
30+
31+
const GlobalStyles = createGlobalStyle({
32+
body: {
33+
overflow: 'hidden',
34+
color: '#f5f5f5',
35+
background: '#151515 !important',
36+
},
37+
});
38+
39+
return (
40+
<ThemeProvider theme={theme.vsCode}>
41+
<GlobalStyles />
42+
<Element css={{ background: '#151515', width: '100%', height: '100%' }}>
43+
<Content isStandalone {...contentProps} />
44+
</Element>
45+
</ThemeProvider>
46+
);
47+
});

packages/app/src/app/pages/common/Modals/PreferencesModal/SideNavigation.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { Element, Stack, Text } from '@codesandbox/components';
22
import css from '@styled-system/css';
33
import React, { ComponentType, FunctionComponent } from 'react';
44

5-
import { useAppState, useActions } from 'app/overmind';
5+
import { useActions } from 'app/overmind';
6+
67
import { useIsEditorPage } from 'app/hooks/useIsEditorPage';
78

89
type MenuItem = {
@@ -12,9 +13,12 @@ type MenuItem = {
1213
};
1314
type Props = {
1415
menuItems: MenuItem[];
16+
selectedTab: string;
1517
};
16-
export const SideNavigation: FunctionComponent<Props> = ({ menuItems }) => {
17-
const { itemId = 'appearance' } = useAppState().preferences;
18+
export const SideNavigation: FunctionComponent<Props> = ({
19+
menuItems,
20+
selectedTab,
21+
}) => {
1822
const { itemIdChanged } = useActions().preferences;
1923
const isEditorPage = useIsEditorPage();
2024

@@ -55,7 +59,7 @@ export const SideNavigation: FunctionComponent<Props> = ({ menuItems }) => {
5559
lineHeight: 1,
5660
border: '1px solid transparent',
5761
color:
58-
itemId === id
62+
selectedTab === id
5963
? 'list.hoverForeground'
6064
: 'sideBarSectionHeader.foreground',
6165
'&:hover': {

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

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { Stack } from '@codesandbox/components';
2-
import css from '@styled-system/css';
3-
import React, { ComponentProps, ComponentType, FunctionComponent } from 'react';
1+
import { Stack, Element } from '@codesandbox/components';
2+
import React, { ComponentProps, ComponentType } from 'react';
43

54
import AccountIcon from 'react-icons/lib/fa/user';
65
import CodeIcon from 'react-icons/lib/fa/code';
@@ -15,8 +14,6 @@ import { useAppState } from 'app/overmind';
1514
import { useIsEditorPage } from 'app/hooks/useIsEditorPage';
1615
import { CurrentUser } from '@codesandbox/common/lib/types';
1716

18-
import { Alert } from '../Common/Alert';
19-
2017
import { Account } from './Account';
2118
import { Appearance } from './Appearance';
2219
import { CodeFormatting } from './CodeFormatting';
@@ -99,35 +96,40 @@ const getItems = (
9996
},
10097
].filter(Boolean);
10198

102-
export const PreferencesModal: FunctionComponent = () => {
99+
export const Preferences: React.FC<{
100+
tab?: string;
101+
isStandalone?: boolean;
102+
}> = ({ tab, isStandalone }) => {
103103
const {
104104
isLoggedIn,
105105
user,
106-
preferences: { itemId = 'account' },
106+
preferences: { itemId },
107107
environment,
108108
} = useAppState();
109109

110110
const isEditorPage = useIsEditorPage();
111111
const items = getItems(isLoggedIn, user, environment.isOnPrem, isEditorPage);
112112

113-
const tabToShow = items.find(({ id }) => id === itemId) || items[0];
113+
const tabId = itemId || tab || 'account';
114+
115+
const tabToShow = items.find(({ id }) => id === tabId) || items[0];
114116
const { Content } = tabToShow;
115117

116118
return (
117-
<Stack css={css({ fontFamily: "'Inter', sans-serif" })}>
118-
<SideNavigation menuItems={items} />
119+
<Stack>
120+
<SideNavigation menuItems={items} selectedTab={tabId} />
119121

120-
<Alert
121-
css={css({
122-
height: 482,
122+
<Element
123+
css={{
124+
height: isStandalone ? 'auto' : '482px',
123125
width: '100%',
124-
padding: 6,
125-
marginTop: 52,
126-
'*': { boxSizing: 'border-box' },
127-
})}
126+
padding: '24px',
127+
marginTop: '52px',
128+
overflow: 'auto',
129+
}}
128130
>
129131
<Content />
130-
</Alert>
132+
</Element>
131133
</Stack>
132134
);
133135
};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { LiveSessionRestricted } from './LiveSessionRestricted';
2626
import { LiveVersionMismatch } from './LiveSessionVersionMismatch';
2727
import { NetlifyLogs } from './NetlifyLogs';
2828
import { PickSandboxModal } from './PickSandboxModal';
29-
import { PreferencesModal } from './PreferencesModal';
29+
import { Preferences } from './PreferencesModal';
3030
import { RecoverFilesModal } from './RecoverFilesModal';
3131
import { LegacyPaymentModal } from './LegacyPaymentModal';
3232
import { SandboxPickerModal } from './SandboxPickerModal';
@@ -54,7 +54,7 @@ import { PersonalSpaceAnnouncement } from './PersonalSpaceAnnouncement';
5454

5555
const modals = {
5656
preferences: {
57-
Component: PreferencesModal,
57+
Component: Preferences,
5858
width: 900,
5959
},
6060
legacyPayment: {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Debug } from 'app/components/Debug';
1212
import { ErrorBoundary } from './common/ErrorBoundary';
1313
import { Modals } from './common/Modals';
1414
import { DevAuthPage } from './DevAuth';
15+
import { StandalonePage } from './Standalone';
1516
import { Container, Content } from './elements';
1617
import { Dashboard } from './Dashboard';
1718
import { Sandbox } from './Sandbox';
@@ -217,6 +218,7 @@ const RoutesComponent: React.FC = () => {
217218
<Route path="/auth/dev" component={DevAuthPage} />
218219
)}
219220
<Route path="/codesadbox" component={CodeSadbox} />
221+
<Route path="/standalone/:componentId" component={StandalonePage} />
220222
<Redirect from="/patron" to="/pro" />
221223
<Route component={NotFound} />
222224
</Switch>

0 commit comments

Comments
 (0)