From cfef2cbd84af8abf187fb064f40ee03e37049f62 Mon Sep 17 00:00:00 2001 From: Sara Vieira Date: Tue, 21 Apr 2020 00:49:24 +0200 Subject: [PATCH] add skeleton --- .../Components/SandboxCard/index.tsx | 11 +++ .../app/pages/NewDashboard/Content/index.tsx | 54 ++++++----- .../Content/routes/StartSandboxes/index.tsx | 95 +++++++++++++++++++ .../Content/routes/Templates/index.tsx | 48 ++++++++++ .../app/pages/NewDashboard/Sidebar/index.tsx | 38 +++++++- .../app/src/app/pages/NewDashboard/index.tsx | 37 +++----- .../app/src/app/pages/NewDashboard/queries.ts | 2 +- .../app/src/app/pages/NewSandbox/index.tsx | 2 +- .../components/src/components/Link/index.tsx | 5 +- 9 files changed, 240 insertions(+), 52 deletions(-) create mode 100644 packages/app/src/app/pages/NewDashboard/Components/SandboxCard/index.tsx create mode 100644 packages/app/src/app/pages/NewDashboard/Content/routes/StartSandboxes/index.tsx create mode 100644 packages/app/src/app/pages/NewDashboard/Content/routes/Templates/index.tsx diff --git a/packages/app/src/app/pages/NewDashboard/Components/SandboxCard/index.tsx b/packages/app/src/app/pages/NewDashboard/Components/SandboxCard/index.tsx new file mode 100644 index 00000000000..641ed8444dd --- /dev/null +++ b/packages/app/src/app/pages/NewDashboard/Components/SandboxCard/index.tsx @@ -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 }) => ( + + + {sandbox.title || sandbox.alias || sandbox.id} + + +); diff --git a/packages/app/src/app/pages/NewDashboard/Content/index.tsx b/packages/app/src/app/pages/NewDashboard/Content/index.tsx index 2c366328204..2407ad8fe24 100644 --- a/packages/app/src/app/pages/NewDashboard/Content/index.tsx +++ b/packages/app/src/app/pages/NewDashboard/Content/index.tsx @@ -1,5 +1,5 @@ -// import React from 'react'; -// import { Route, Switch, Redirect, withRouter } from 'react-router-dom'; +import React from 'react'; +import { Route, Switch, Redirect, withRouter } from 'react-router-dom'; // 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 = () => ( -// -// -// -// -// -// -// -// -// -// -// -// -// ); +const ContentComponent = () => ( + + + + + {/* + + + + + + + */} + + + +); -// export default withRouter(Content); +export const Content = withRouter(ContentComponent); diff --git a/packages/app/src/app/pages/NewDashboard/Content/routes/StartSandboxes/index.tsx b/packages/app/src/app/pages/NewDashboard/Content/routes/StartSandboxes/index.tsx new file mode 100644 index 00000000000..6120bff1838 --- /dev/null +++ b/packages/app/src/app/pages/NewDashboard/Content/routes/StartSandboxes/index.tsx @@ -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( + LIST_PERSONAL_TEMPLATES, + { + variables: {}, + fetchPolicy: 'cache-and-network', + } + ); + + if (error || templatesError) { + return Error; + } + + if (loading || templatesLoading) { + return loading; + } + + const sandboxes = data && data.me && data.me.sandboxes; + const templates = + templatesData && + templatesData.me && + templatesData.me.recentlyUsedTemplates.slice(0, 4); + + return ( + + + Recently used Templates + + + {templates.map(({ sandbox }) => ( + + ))} + + + + Your Recent Sandboxes + + + + {sandboxes.map(sandbox => ( + + ))} + + + ); +}; diff --git a/packages/app/src/app/pages/NewDashboard/Content/routes/Templates/index.tsx b/packages/app/src/app/pages/NewDashboard/Content/routes/Templates/index.tsx new file mode 100644 index 00000000000..6e03073a6cc --- /dev/null +++ b/packages/app/src/app/pages/NewDashboard/Content/routes/Templates/index.tsx @@ -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 Error; + } + + if (loading) { + return loading; + } + + const templates = data && data.me && data.me.templates; + + return ( + + + Templates + + + {templates.map(({ sandbox }) => ( + + ))} + + + ); +}; diff --git a/packages/app/src/app/pages/NewDashboard/Sidebar/index.tsx b/packages/app/src/app/pages/NewDashboard/Sidebar/index.tsx index 66f81c9d139..ca47842d484 100644 --- a/packages/app/src/app/pages/NewDashboard/Sidebar/index.tsx +++ b/packages/app/src/app/pages/NewDashboard/Sidebar/index.tsx @@ -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 = () => I AM A SIDEBAR; +export const Sidebar = () => ( + + + + Start + + + + + Drafts + + + + + Recent + + + + + All Sandboxes + + + + + Templates + + + + + Recently Deleted + + + +); diff --git a/packages/app/src/app/pages/NewDashboard/index.tsx b/packages/app/src/app/pages/NewDashboard/index.tsx index 8886d8baa85..671e97f43bd 100644 --- a/packages/app/src/app/pages/NewDashboard/index.tsx +++ b/packages/app/src/app/pages/NewDashboard/index.tsx @@ -1,30 +1,13 @@ import { signInPageUrl } from '@codesandbox/common/lib/utils/url-generator'; +import css from '@styled-system/css'; import React, { useEffect, FunctionComponent } from 'react'; import { Redirect } from 'react-router-dom'; -import { createGlobalStyle } from 'styled-components'; import { client } from 'app/graphql/client'; import { useOvermind } from 'app/overmind'; import codesandboxBlack from '@codesandbox/components/lib/themes/codesandbox-black'; -import { Element, ThemeProvider, Stack } from '@codesandbox/components'; +import { ThemeProvider, Stack } from '@codesandbox/components'; import { Sidebar } from './Sidebar'; - -type Theme = { - colors: any; - name: string; -}; - -const GlobalStyle = createGlobalStyle` - html body { - font-family: 'Inter', sans-serif; - background: ${({ theme }: { theme: Theme }) => - theme.colors.sideBar.background} !important; - color: ${({ theme }: { theme: Theme }) => theme.colors.sideBar.foreground}; - - * { - box-sizing: border-box; - } - } -`; +import { Content } from './Content'; export const Dashboard: FunctionComponent = () => { const { @@ -47,10 +30,18 @@ export const Dashboard: FunctionComponent = () => { return ( - - + - I AM THE CONTENT + ); diff --git a/packages/app/src/app/pages/NewDashboard/queries.ts b/packages/app/src/app/pages/NewDashboard/queries.ts index efd1cfc38c6..aee291562a3 100644 --- a/packages/app/src/app/pages/NewDashboard/queries.ts +++ b/packages/app/src/app/pages/NewDashboard/queries.ts @@ -222,7 +222,7 @@ export const RECENT_SANDBOXES_CONTENT_QUERY = gql` query RecentSandboxes($orderField: String!, $orderDirection: Direction!) { me { sandboxes( - limit: 20 + limit: 7 orderBy: { field: $orderField, direction: $orderDirection } ) { ...Sandbox diff --git a/packages/app/src/app/pages/NewSandbox/index.tsx b/packages/app/src/app/pages/NewSandbox/index.tsx index 6627e10ad89..b0692bb0e38 100644 --- a/packages/app/src/app/pages/NewSandbox/index.tsx +++ b/packages/app/src/app/pages/NewSandbox/index.tsx @@ -10,7 +10,7 @@ import { import { useOvermind } from 'app/overmind'; import { Navigation } from 'app/pages/common/Navigation'; -import {MaxWidth} from './elements' +import { MaxWidth } from './elements'; export const NewSandbox: FunctionComponent = () => { const { diff --git a/packages/components/src/components/Link/index.tsx b/packages/components/src/components/Link/index.tsx index 237b3622922..381147107a9 100644 --- a/packages/components/src/components/Link/index.tsx +++ b/packages/components/src/components/Link/index.tsx @@ -5,7 +5,10 @@ import { Text, ITextProps } from '../Text'; type LinkProps = React.AnchorHTMLAttributes & React.AnchorHTMLAttributes & - ITextProps; + ITextProps & { + as?: any; + to?: string; + }; const LinkElement = styled(Text).attrs({ as: 'a' })( css({