-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: new create modals #8182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: new create modals #8182
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
866ea3d
initial commit
alexnm dfea468
feat: Update modals and actions
alexnm 030e215
feat: Add 'Start something new' heading
alexnm 679acd1
Merge branch 'master' of https://github.com/codesandbox/codesandbox-c…
alexnm 2edba32
Update 11 files
alexnm ad929e8
feat: Update CreateBox component
alexnm f2e2e3d
implement search
alexnm 0505d16
feat: Update CreateBox, GenericCreate, ImportRepository, and Editor
alexnm a2de02a
feat: Updated Badge component
alexnm c7cc2fd
cleanup
alexnm d98bb8a
refactor: Change showBetaBadge to showDevboxBadge in SandboxCard.tsx
alexnm 4206fe9
feat: Add Devbox and Sandbox alternatives
alexnm f7b4dfd
style: Update text color and underline style
alexnm b4192bb
feat: Add optional v2 parameter to body object
alexnm d4f4315
feat: Update UI text and functionality
alexnm f538228
Update SyncedSandboxListItem.tsx
alexnm a9c7cb1
Update constants.ts and PermissionSettings.tsx
alexnm d739902
Update 8 files
alexnm 109dc05
Update FromTemplate.tsx and useEssentialTemplates.ts
alexnm f24dc9f
Update CreateBox.tsx and state.ts
alexnm e7ef748
feat: Upgrade Sandbox to Devbox
alexnm f575301
Update 13 files
alexnm f8c306a
fix: ui styles
alexnm c504b91
refactor: Refactor CreateBox and FromTemplate components
alexnm f30f648
Update useFeaturedTemplates.ts
alexnm 4311991
refactor: Remove TemplatesRow component
alexnm 1f2f478
feat: Update getting started video
necoline 0340b79
feat: Removed outdated instruction videos
necoline 850c64e
feat: Updated documentation videos
necoline 248c15a
feat: Add tracking for create actions
alexnm e8fc210
refactor: Update DevboxAlternative component
alexnm 4e9aa82
refactor: Refactor CreateBox, elements, and LargeCTAButton components
alexnm dc955ea
temporarily remove second step
alexnm 071f59a
refactor: Update component styles
alexnm 86c02e8
style: Update LargeCTAButton styles
alexnm d0316ae
feat: Add activeTeam check
alexnm 08e72b7
feat: update URLs
alexnm fd616b5
Update useBetaSandboxEditor.ts
alexnm 3ce7b5d
feat: Update beta sandbox editor hooks
alexnm ed42b57
chore: update tests
alexnm 245a3a5
Merge branch 'master' of https://github.com/codesandbox/codesandbox-c…
alexnm 476998b
update templates
alexnm b7b1809
Update url-generator.ts
alexnm cc78403
feat: Updated CreateBox
alexnm a1e62f1
fix: anonymous access
alexnm 509506b
chore: remove personal space announcement
alexnm ccfcacc
feat: Update button descriptions
alexnm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
176 changes: 176 additions & 0 deletions
176
packages/app/src/app/components/Create/CreateBox/CreateBoxForm.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| import React, { useState } from 'react'; | ||
| import { | ||
| Stack, | ||
| Element, | ||
| Button, | ||
| Text, | ||
| Input, | ||
| Radio, | ||
| Icon, | ||
| } from '@codesandbox/components'; | ||
|
|
||
| import { CreateParams } from '../utils/types'; | ||
|
|
||
| interface CreateBoxFormProps { | ||
| type: 'sandbox' | 'devbox'; | ||
| onCancel: () => void; | ||
| onSubmit: (params: CreateParams) => void; | ||
| } | ||
|
|
||
| export const CreateBoxForm: React.FC<CreateBoxFormProps> = ({ | ||
| type, | ||
| onCancel, | ||
| onSubmit, | ||
| }) => { | ||
| const label = type === 'sandbox' ? 'Sandbox' : 'Devbox'; | ||
|
|
||
| const [name, setName] = useState<string>(); | ||
| // TODO: default privacy in workspace | ||
| const [permission, setPermission] = useState<0 | 1 | 2>(0); | ||
| const [editor, setEditor] = useState<'web' | 'vscode'>('web'); | ||
| const showVMSpecs = type === 'devbox'; | ||
| const disableEditorChange = type === 'sandbox'; | ||
|
|
||
| const defaultSpecs = '4 vCPUs - 8GiB RAM - 16GB disk'; | ||
|
|
||
| return ( | ||
| <Stack | ||
| direction="vertical" | ||
| gap={7} | ||
| css={{ width: '100%', height: '100%', paddingBottom: '24px' }} | ||
| > | ||
| <Element | ||
| as="form" | ||
| css={{ | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| width: '100%', | ||
| height: '100%', | ||
| justifyContent: 'space-between', | ||
| }} | ||
| onSubmit={e => { | ||
| e.preventDefault(); | ||
| onSubmit({ | ||
| name, | ||
| createAs: type, | ||
| permission, | ||
| editor, | ||
| }); | ||
| }} | ||
| > | ||
| <Stack direction="vertical" gap={6}> | ||
| <Text | ||
| as="h2" | ||
| css={{ | ||
| fontSize: '16px', | ||
| fontWeight: 500, | ||
| margin: 0, | ||
| }} | ||
| > | ||
| Create {label} | ||
| </Text> | ||
| <Stack direction="vertical" gap={1}> | ||
| <Text size={3} as="label"> | ||
| Name | ||
| </Text> | ||
| <Text size={3} id="name-desc" variant="muted"> | ||
| Leaving this field empty will generate a random name. | ||
| </Text> | ||
| <Input | ||
| autoFocus | ||
| id="sb-name" | ||
| name="sb-name" | ||
| type="text" | ||
| value={name} | ||
| placeholder={`Let's give this ${label} a name.`} | ||
| onChange={e => setName(e.target.value)} | ||
| aria-describedby="name-desc" | ||
| /> | ||
| </Stack> | ||
|
|
||
| <Stack direction="vertical" gap={2}> | ||
| <Text size={3} as="label"> | ||
| Visibility | ||
| </Text> | ||
| <Stack direction="vertical" gap={1}> | ||
| <Radio | ||
| checked={permission === 0} | ||
| onChange={() => setPermission(0)} | ||
| label="Public" | ||
| /> | ||
| <Radio | ||
| checked={permission === 1} | ||
| onChange={() => setPermission(1)} | ||
| label="Unlisted" | ||
| /> | ||
| <Radio | ||
| checked={permission === 2} | ||
| onChange={() => setPermission(2)} | ||
| label="Private" | ||
| /> | ||
| </Stack> | ||
| </Stack> | ||
|
|
||
| <Stack direction="vertical" gap={2}> | ||
| <Text size={3} as="label"> | ||
| Open in | ||
| </Text> | ||
| <Stack direction="vertical" gap={1}> | ||
| <Radio | ||
| disabled={disableEditorChange} | ||
| checked={editor === 'web'} | ||
| onChange={() => setEditor('web')} | ||
| label="Web editor" | ||
| /> | ||
| <Radio | ||
| disabled={disableEditorChange} | ||
| checked={editor === 'vscode'} | ||
| onChange={() => setEditor('vscode')} | ||
| label="VSCode" | ||
| /> | ||
| </Stack> | ||
| {disableEditorChange && ( | ||
| <Stack gap={1}> | ||
| <Icon color="#999" name="circleBang" /> | ||
| <Text size={3} variant="muted"> | ||
| Sandboxes can only be open in the web editor. | ||
| </Text> | ||
| </Stack> | ||
| )} | ||
| </Stack> | ||
|
|
||
| {showVMSpecs && ( | ||
| <Stack direction="vertical" align="flex-start" gap={2}> | ||
| <Text size={3} as="label"> | ||
| Virtual machine specifications | ||
| </Text> | ||
| <Input value={defaultSpecs} disabled /> | ||
| <Stack gap={1}> | ||
| <Icon color="#999" name="circleBang" /> | ||
| <Text size={3} variant="muted"> | ||
| VM specs are currently tied to your subscription. | ||
| </Text> | ||
| </Stack> | ||
| </Stack> | ||
| )} | ||
| </Stack> | ||
|
|
||
| <Stack css={{ justifyContent: 'flex-end' }}> | ||
| <Stack gap={2}> | ||
| <Button | ||
| type="button" | ||
| variant="secondary" | ||
| onClick={onCancel} | ||
| autoWidth | ||
| > | ||
| Cancel | ||
| </Button> | ||
| <Button type="submit" variant="primary" autoWidth> | ||
| Create {label} | ||
| </Button> | ||
| </Stack> | ||
| </Stack> | ||
| </Element> | ||
| </Stack> | ||
| ); | ||
| }; | ||
41 changes: 41 additions & 0 deletions
41
packages/app/src/app/components/Create/CreateBox/TemplateInfo.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { getTemplateIcon } from '@codesandbox/common/lib/utils/getTemplateIcon'; | ||
| import { Stack, Text } from '@codesandbox/components'; | ||
| import { TemplateFragment } from 'app/graphql/types'; | ||
| import React from 'react'; | ||
|
|
||
| interface TemplateInfoProps { | ||
| template: TemplateFragment; | ||
| } | ||
|
|
||
| export const TemplateInfo = ({ template }: TemplateInfoProps) => { | ||
| const { UserIcon } = getTemplateIcon( | ||
| template.sandbox.title, | ||
| template.iconUrl, | ||
| template.sandbox?.source?.template | ||
| ); | ||
|
|
||
| const title = template.sandbox.title || template.sandbox.alias; | ||
| const author = | ||
| template.sandbox?.team?.name || | ||
| template.sandbox?.author?.username || | ||
| 'CodeSandbox'; | ||
|
|
||
| return ( | ||
| <Stack direction="vertical" gap={4}> | ||
| <UserIcon /> | ||
| <Stack direction="vertical" gap={1}> | ||
| <Text size={3} weight="500"> | ||
| {title} | ||
| </Text> | ||
| {author && ( | ||
| <Text size={2} css={{ color: '#999' }}> | ||
| {author} | ||
| </Text> | ||
| )} | ||
| </Stack> | ||
| <Text size={2} css={{ color: '#999', lineHeight: '1.4' }}> | ||
| {template.sandbox.description} | ||
| </Text> | ||
| </Stack> | ||
| ); | ||
| }; |
133 changes: 133 additions & 0 deletions
133
packages/app/src/app/components/Create/GenericCreate.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| import React, { useEffect } from 'react'; | ||
|
|
||
| import { Stack, Text, IconButton, Element } from '@codesandbox/components'; | ||
| import track from '@codesandbox/common/lib/utils/analytics'; | ||
| import { useActions } from 'app/overmind'; | ||
| import { Container, HeaderInformation } from './elements'; | ||
| import { LargeCTAButton } from '../dashboard/LargeCTAButton'; | ||
| import { | ||
| DEVBOX_BUTTON_DESCRIPTION, | ||
| IMPORT_BUTTON_DESCRIPTION, | ||
| SANDBOX_BUTTON_DESCRIPTION, | ||
| } from './utils/constants'; | ||
|
|
||
| export const GenericCreate: React.FC<{ | ||
| closeModal?: () => void; | ||
| isModal?: boolean; | ||
| }> = ({ closeModal, isModal }) => { | ||
| const actions = useActions(); | ||
|
|
||
| useEffect(() => { | ||
| track('Generic Create - Show', { | ||
| codesandbox: 'V1', | ||
| event_source: 'UI', | ||
| }); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <Container | ||
| css={{ | ||
| height: '260px', | ||
| '@media screen and (max-width: 750px)': { | ||
| height: 'auto', | ||
| }, | ||
| }} | ||
| > | ||
| <Stack | ||
| gap={4} | ||
| align="center" | ||
| css={{ | ||
| width: '100%', | ||
| padding: '24px', | ||
| '@media screen and (max-width: 750px)': { | ||
| padding: '16px', | ||
| }, | ||
| }} | ||
| > | ||
| <HeaderInformation> | ||
| <Text size={4} variant="muted"> | ||
| Create | ||
| </Text> | ||
| </HeaderInformation> | ||
|
|
||
| {/* isModal is undefined on /s/ page */} | ||
| {isModal ? ( | ||
| <IconButton | ||
| name="cross" | ||
| variant="square" | ||
| size={16} | ||
| title="Close modal" | ||
| onClick={() => closeModal()} | ||
| /> | ||
| ) : null} | ||
| </Stack> | ||
|
|
||
| <Element | ||
| paddingBottom={6} | ||
| paddingX={6} | ||
| css={{ | ||
| display: 'grid', | ||
| gridTemplateColumns: '1fr 1fr 1fr', | ||
| gap: '16px', | ||
| '@media screen and (max-width: 750px)': { | ||
| gridTemplateColumns: '1fr', | ||
| }, | ||
| }} | ||
| > | ||
| <LargeCTAButton | ||
| icon="boxRepository" | ||
| title="Import repository" | ||
| subtitle={IMPORT_BUTTON_DESCRIPTION} | ||
| onClick={() => { | ||
| track('Generic Create - Import Repository', { | ||
| codesandbox: 'V1', | ||
| event_source: 'UI', | ||
| }); | ||
| if (closeModal) { | ||
| closeModal(); | ||
| } | ||
| actions.modalOpened({ modal: 'importRepository' }); | ||
| }} | ||
| variant="primary" | ||
| alignment="vertical" | ||
| /> | ||
|
|
||
| <LargeCTAButton | ||
| icon="boxDevbox" | ||
| title="Create a Devbox" | ||
| subtitle={DEVBOX_BUTTON_DESCRIPTION} | ||
| onClick={() => { | ||
| track('Generic Create - Create Devbox', { | ||
| codesandbox: 'V1', | ||
| event_source: 'UI', | ||
| }); | ||
| if (closeModal) { | ||
| closeModal(); | ||
| } | ||
| actions.modalOpened({ modal: 'createDevbox' }); | ||
| }} | ||
| variant="primary" | ||
| alignment="vertical" | ||
| /> | ||
|
|
||
| <LargeCTAButton | ||
| icon="boxSandbox" | ||
| title="Create a Sandbox" | ||
| subtitle={SANDBOX_BUTTON_DESCRIPTION} | ||
| onClick={() => { | ||
| track('Generic Create - Create Sandbox', { | ||
| codesandbox: 'V1', | ||
| event_source: 'UI', | ||
| }); | ||
| if (closeModal) { | ||
| closeModal(); | ||
| } | ||
| actions.modalOpened({ modal: 'createSandbox' }); | ||
| }} | ||
| variant="secondary" | ||
| alignment="vertical" | ||
| /> | ||
| </Element> | ||
| </Container> | ||
| ); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this component is still WIP, skip it