-
Notifications
You must be signed in to change notification settings - Fork 2.4k
add skeleton to templates and start #3952
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||
| import React from 'react'; | ||||||
| import { sandboxUrl } from '@codesandbox/common/lib/utils/url-generator'; | ||||||
| import { Element, Link } from '@codesandbox/components'; | ||||||
|
|
||||||
| export const SandboxCard = ({ sandbox }) => ( | ||||||
| <Element> | ||||||
| <Link href={sandboxUrl({ id: sandbox.id, alias: sandbox.alias })}> | ||||||
| {sandbox.title || sandbox.alias || sandbox.id} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use
Suggested change
|
||||||
| </Link> | ||||||
| </Element> | ||||||
| ); | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||
| // import React from 'react'; | ||||||
| // import { Route, Switch, Redirect, withRouter } from 'react-router-dom'; | ||||||
| import React from 'react'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| import { Route, Switch, Redirect, withRouter } from 'react-router-dom'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| // import { RecentSandboxes } from './routes/RecentSandboxes'; | ||||||
| // import PathedSandboxes from './routes/PathedSandboxes'; | ||||||
|
|
@@ -8,27 +8,33 @@ | |||||
| // import SearchSandboxes from './routes/SearchSandboxes'; | ||||||
| // import CreateTeam from './routes/CreateTeam'; | ||||||
| // import TeamView from './routes/TeamView'; | ||||||
| import { Element } from '@codesandbox/components'; | ||||||
| import { StartSandboxes } from './routes/StartSandboxes'; | ||||||
| import { Templates } from './routes/Templates'; | ||||||
|
|
||||||
| // const Content = () => ( | ||||||
| // <Switch> | ||||||
| // <Route path="/dashboard/recent" component={RecentSandboxes} /> | ||||||
| // <Route path="/dashboard/trash" component={DeletedSandboxes} /> | ||||||
| // <Route path="/dashboard/templates" exact component={Templates} /> | ||||||
| // <Route path="/dashboard/sandboxes/:path*" component={PathedSandboxes} /> | ||||||
| // <Route path="/dashboard/search" component={SearchSandboxes} /> | ||||||
| // <Route path="/dashboard/teams/new" component={CreateTeam} /> | ||||||
| // <Route exact path="/dashboard/teams/:teamId" component={TeamView} /> | ||||||
| // <Route | ||||||
| // path="/dashboard/teams/:teamId/sandboxes/:path*" | ||||||
| // component={PathedSandboxes} | ||||||
| // /> | ||||||
| // <Route | ||||||
| // path="/dashboard/teams/:teamId/templates" | ||||||
| // component={Templates} | ||||||
| // exact | ||||||
| // /> | ||||||
| // <Redirect to="/dashboard/recent" /> | ||||||
| // </Switch> | ||||||
| // ); | ||||||
| const ContentComponent = () => ( | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| <Element style={{ width: 960, margin: '40px auto' }}> | ||||||
| <Switch> | ||||||
| <Route path="/new-dashboard/start" component={StartSandboxes} /> | ||||||
| <Route path="/new-dashboard/templates" component={Templates} /> | ||||||
| {/* <Route path="/dashboard/trash" component={DeletedSandboxes} /> | ||||||
| <Route path="/dashboard/templates" exact component={Templates} /> | ||||||
| <Route path="/dashboard/sandboxes/:path*" component={PathedSandboxes} /> | ||||||
| <Route path="/dashboard/search" component={SearchSandboxes} /> | ||||||
| <Route path="/dashboard/teams/new" component={CreateTeam} /> | ||||||
| <Route exact path="/dashboard/teams/:teamId" component={TeamView} /> | ||||||
| <Route | ||||||
| path="/dashboard/teams/:teamId/sandboxes/:path*" | ||||||
| component={PathedSandboxes} | ||||||
| /> | ||||||
| <Route | ||||||
| path="/dashboard/teams/:teamId/templates" | ||||||
| component={Templates} | ||||||
| exact | ||||||
| /> */} | ||||||
| <Redirect to="/new-dashboard/start" /> | ||||||
| </Switch> | ||||||
| </Element> | ||||||
| ); | ||||||
|
|
||||||
| // export default withRouter(Content); | ||||||
| export const Content = withRouter(ContentComponent); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for
Suggested change
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,95 @@ | ||||||||||||
| import React from 'react'; | ||||||||||||
| import css from '@styled-system/css'; | ||||||||||||
| import { Element, Text, Button } from '@codesandbox/components'; | ||||||||||||
| import { useQuery } from '@apollo/react-hooks'; | ||||||||||||
| import { useOvermind } from 'app/overmind'; | ||||||||||||
| import { | ||||||||||||
| RecentSandboxesQuery, | ||||||||||||
| RecentSandboxesQueryVariables, | ||||||||||||
| ListPersonalTemplatesQuery, | ||||||||||||
| ListPersonalTemplatesQueryVariables, | ||||||||||||
| } from 'app/graphql/types'; | ||||||||||||
| import { LIST_PERSONAL_TEMPLATES } from 'app/components/CreateNewSandbox/queries'; | ||||||||||||
| import { RECENT_SANDBOXES_CONTENT_QUERY } from '../../../queries'; | ||||||||||||
| import { SandboxCard } from '../../../Components/SandboxCard'; | ||||||||||||
|
|
||||||||||||
| export const StartSandboxes = () => { | ||||||||||||
| const { | ||||||||||||
| state, | ||||||||||||
| actions: { modalOpened }, | ||||||||||||
| } = useOvermind(); | ||||||||||||
| const { loading, error, data } = useQuery< | ||||||||||||
| RecentSandboxesQuery, | ||||||||||||
| RecentSandboxesQueryVariables | ||||||||||||
| >(RECENT_SANDBOXES_CONTENT_QUERY, { | ||||||||||||
| variables: { | ||||||||||||
| orderField: state.dashboard.orderBy.field, | ||||||||||||
| // @ts-ignore | ||||||||||||
| orderDirection: state.dashboard.orderBy.order.toUpperCase(), | ||||||||||||
| }, | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| const { | ||||||||||||
| data: templatesData, | ||||||||||||
| error: templatesError, | ||||||||||||
| loading: templatesLoading, | ||||||||||||
| } = useQuery<ListPersonalTemplatesQuery, ListPersonalTemplatesQueryVariables>( | ||||||||||||
| LIST_PERSONAL_TEMPLATES, | ||||||||||||
| { | ||||||||||||
| variables: {}, | ||||||||||||
| fetchPolicy: 'cache-and-network', | ||||||||||||
| } | ||||||||||||
| ); | ||||||||||||
|
|
||||||||||||
| if (error || templatesError) { | ||||||||||||
| return <Text>Error</Text>; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (loading || templatesLoading) { | ||||||||||||
| return <Text>loading</Text>; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const sandboxes = data && data.me && data.me.sandboxes; | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we know for sure there's no error or loading state, we know
Suggested change
|
||||||||||||
| const templates = | ||||||||||||
| templatesData && | ||||||||||||
| templatesData.me && | ||||||||||||
| templatesData.me.recentlyUsedTemplates.slice(0, 4); | ||||||||||||
|
Comment on lines
+53
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we know for sure there's no error or loading state, we know
Suggested change
|
||||||||||||
|
|
||||||||||||
| return ( | ||||||||||||
| <Element> | ||||||||||||
| <Text marginBottom={4} block> | ||||||||||||
| Recently used Templates | ||||||||||||
| </Text> | ||||||||||||
| <Element | ||||||||||||
| css={css({ | ||||||||||||
| display: 'grid', | ||||||||||||
| gridTemplateColumns: 'repeat(4,1fr)', | ||||||||||||
| gridGap: 6, | ||||||||||||
| })} | ||||||||||||
| marginBottom={8} | ||||||||||||
| > | ||||||||||||
| {templates.map(({ sandbox }) => ( | ||||||||||||
| <SandboxCard sandbox={sandbox} key={sandbox.id} /> | ||||||||||||
| ))} | ||||||||||||
| </Element> | ||||||||||||
|
|
||||||||||||
| <Text marginBottom={4} block> | ||||||||||||
| Your Recent Sandboxes | ||||||||||||
| </Text> | ||||||||||||
| <Element | ||||||||||||
| css={css({ | ||||||||||||
| display: 'grid', | ||||||||||||
| gridTemplateColumns: 'repeat(4,1fr)', | ||||||||||||
| gridGap: 6, | ||||||||||||
| })} | ||||||||||||
| > | ||||||||||||
| <Button onClick={() => modalOpened({ modal: 'newSandbox' })}> | ||||||||||||
| New Sandbox | ||||||||||||
| </Button> | ||||||||||||
| {sandboxes.map(sandbox => ( | ||||||||||||
| <SandboxCard sandbox={sandbox} key={sandbox.id} /> | ||||||||||||
| ))} | ||||||||||||
| </Element> | ||||||||||||
| </Element> | ||||||||||||
| ); | ||||||||||||
| }; | ||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||
| import React from 'react'; | ||||||
| import css from '@styled-system/css'; | ||||||
| import { Element, Text } from '@codesandbox/components'; | ||||||
| import { useQuery } from '@apollo/react-hooks'; | ||||||
| import { | ||||||
| ListTemplatesQuery, | ||||||
| ListTemplatesQueryVariables, | ||||||
| } from 'app/graphql/types'; | ||||||
| import { LIST_OWNED_TEMPLATES } from 'app/components/CreateNewSandbox/queries'; | ||||||
| import { SandboxCard } from '../../../Components/SandboxCard'; | ||||||
|
|
||||||
| export const Templates = () => { | ||||||
| const { loading, error, data } = useQuery< | ||||||
| ListTemplatesQuery, | ||||||
| ListTemplatesQueryVariables | ||||||
| >(LIST_OWNED_TEMPLATES, { | ||||||
| variables: { showAll: false }, | ||||||
| }); | ||||||
|
|
||||||
| if (error) { | ||||||
| return <Text>Error</Text>; | ||||||
| } | ||||||
|
|
||||||
| if (loading) { | ||||||
| return <Text>loading</Text>; | ||||||
| } | ||||||
|
|
||||||
| const templates = data && data.me && data.me.templates; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we know for sure there's no error or loading state, we know
Suggested change
|
||||||
|
|
||||||
| return ( | ||||||
| <Element> | ||||||
| <Text marginBottom={4} block> | ||||||
| Templates | ||||||
| </Text> | ||||||
| <Element | ||||||
| css={css({ | ||||||
| display: 'grid', | ||||||
| gridTemplateColumns: 'repeat(4,1fr)', | ||||||
| gridGap: 6, | ||||||
| })} | ||||||
| > | ||||||
| {templates.map(({ sandbox }) => ( | ||||||
| <SandboxCard sandbox={sandbox} key={sandbox.id} /> | ||||||
| ))} | ||||||
| </Element> | ||||||
| </Element> | ||||||
| ); | ||||||
| }; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,38 @@ | ||
| import React from 'react'; | ||
| import { Element } from '@codesandbox/components'; | ||
| import { List, Link, ListAction } from '@codesandbox/components'; | ||
| import { Link as BaseLink } from 'react-router-dom'; | ||
|
|
||
| export const Sidebar = () => <Element>I AM A SIDEBAR</Element>; | ||
| export const Sidebar = () => ( | ||
| <List> | ||
| <ListAction> | ||
| <Link to="start" as={BaseLink}> | ||
| Start | ||
| </Link> | ||
| </ListAction> | ||
| <ListAction> | ||
| <Link to="drafts" as={BaseLink}> | ||
| Drafts | ||
| </Link> | ||
| </ListAction> | ||
| <ListAction> | ||
| <Link to="recent" as={BaseLink}> | ||
| Recent | ||
| </Link> | ||
| </ListAction> | ||
| <ListAction> | ||
| <Link to="all" as={BaseLink}> | ||
| All Sandboxes | ||
| </Link> | ||
| </ListAction> | ||
| <ListAction> | ||
| <Link to="templates" as={BaseLink}> | ||
| Templates | ||
| </Link> | ||
| </ListAction> | ||
| <ListAction> | ||
| <Link to="deleted" as={BaseLink}> | ||
| Recently Deleted | ||
| </Link> | ||
| </ListAction> | ||
| </List> | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,10 @@ import { Text, ITextProps } from '../Text'; | |
|
|
||
| type LinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & | ||
| React.AnchorHTMLAttributes<HTMLSpanElement> & | ||
| ITextProps; | ||
| ITextProps & { | ||
| as?: any; | ||
| to?: string; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if this is the best way to do it, but we'll find out 🤷 |
||
| }; | ||
|
|
||
| const LinkElement = styled(Text).attrs({ as: 'a' })<LinkProps>( | ||
| css({ | ||
|
|
||
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.