diff --git a/packages/app/src/app/pages/Profile/Showcase/LoadingSandbox.tsx b/packages/app/src/app/pages/Profile/Showcase/LoadingSandbox.tsx new file mode 100644 index 00000000000..a0792b98448 --- /dev/null +++ b/packages/app/src/app/pages/Profile/Showcase/LoadingSandbox.tsx @@ -0,0 +1,13 @@ +import Centered from '@codesandbox/common/lib/components/flex/Centered'; +import Margin from '@codesandbox/common/lib/components/spacing/Margin'; +import React, { FunctionComponent } from 'react'; + +import { ErrorTitle } from './elements'; + +export const LoadingSandbox: FunctionComponent = () => ( + + + Loading showcased sandbox... + + +); diff --git a/packages/app/src/app/pages/Profile/Showcase/NoSandboxAvailable.tsx b/packages/app/src/app/pages/Profile/Showcase/NoSandboxAvailable.tsx new file mode 100644 index 00000000000..2982dd45e46 --- /dev/null +++ b/packages/app/src/app/pages/Profile/Showcase/NoSandboxAvailable.tsx @@ -0,0 +1,27 @@ +import React, { FunctionComponent } from 'react'; +import Centered from '@codesandbox/common/lib/components/flex/Centered'; +import Margin from '@codesandbox/common/lib/components/spacing/Margin'; + +import { useOvermind } from 'app/overmind'; + +import { ErrorTitle } from './elements'; + +export const NoSandboxAvailable: FunctionComponent = () => { + const { + state: { + profile: { isProfileCurrentUser }, + }, + } = useOvermind(); + + return ( + + + + {`${ + isProfileCurrentUser ? `You don't` : `This user doesn't` + } have any sandboxes yet`} + + + + ); +}; diff --git a/packages/app/src/app/pages/Profile/Showcase/SandboxInfo/elements.ts b/packages/app/src/app/pages/Profile/Showcase/SandboxInfo/elements.ts index e3f710694a1..5d35c6f763b 100644 --- a/packages/app/src/app/pages/Profile/Showcase/SandboxInfo/elements.ts +++ b/packages/app/src/app/pages/Profile/Showcase/SandboxInfo/elements.ts @@ -39,6 +39,10 @@ export const Description = styled.p` color: rgba(255, 255, 255, 0.8); `; +export const DescriptionContainer = styled.div` + flex: 6; +`; + export const Stats = styled.div` position: relative; display: flex; diff --git a/packages/app/src/app/pages/Profile/Showcase/SandboxInfo/index.tsx b/packages/app/src/app/pages/Profile/Showcase/SandboxInfo/index.tsx index d1163c3490b..480dd8b9fcb 100644 --- a/packages/app/src/app/pages/Profile/Showcase/SandboxInfo/index.tsx +++ b/packages/app/src/app/pages/Profile/Showcase/SandboxInfo/index.tsx @@ -1,5 +1,4 @@ import Row from '@codesandbox/common/lib/components/flex/Row'; -import { Sandbox } from '@codesandbox/common/lib/types'; import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name'; import { sandboxUrl } from '@codesandbox/common/lib/utils/url-generator'; import React, { FunctionComponent } from 'react'; @@ -10,6 +9,7 @@ import { useOvermind } from 'app/overmind'; import { Container, Description, + DescriptionContainer, Like, PlayButtonContainer, Stats, @@ -17,40 +17,48 @@ import { } from './elements'; import SvgButton from './play-button.svg'; -type Props = { - sandbox: Sandbox; -}; -export const SandboxInfo: FunctionComponent = ({ sandbox }) => { +export const SandboxInfo: FunctionComponent = () => { const { - state: { isLoggedIn }, + state: { + profile: { + showcasedSandbox, + showcasedSandbox: { + alias, + description, + forkCount, + id, + likeCount, + viewCount, + }, + }, + isLoggedIn, + }, } = useOvermind(); return ( - {getSandboxName(sandbox)} {''} - {isLoggedIn ? : null} + {getSandboxName(showcasedSandbox)} {''} + {isLoggedIn ? : null} - - {sandbox.description} - + + {description} + - + - + - + - + diff --git a/packages/app/src/app/pages/Profile/Showcase/elements.js b/packages/app/src/app/pages/Profile/Showcase/elements.js deleted file mode 100644 index 7448eac8259..00000000000 --- a/packages/app/src/app/pages/Profile/Showcase/elements.js +++ /dev/null @@ -1,7 +0,0 @@ -import styled from 'styled-components'; - -export const ErrorTitle = styled.div` - font-size: 1.25rem; - color: ${props => - props.theme.light ? 'rgba(0, 0, 0, 0.7)' : 'rgba(255, 255, 255, 0.7)'}; -`; diff --git a/packages/app/src/app/pages/Profile/Showcase/elements.ts b/packages/app/src/app/pages/Profile/Showcase/elements.ts new file mode 100644 index 00000000000..8f528108f49 --- /dev/null +++ b/packages/app/src/app/pages/Profile/Showcase/elements.ts @@ -0,0 +1,16 @@ +import styled, { css } from 'styled-components'; + +export const ErrorTitle = styled.div` + ${({ theme }) => css` + font-size: 1.25rem; + color: ${theme.light ? 'rgba(0, 0, 0, 0.7)' : 'rgba(255, 255, 255, 0.7)'}; + `}; +`; + +export const SandboxInfoContainer = styled.div` + flex: 1; +`; + +export const ShowcasePreviewContainer = styled.div` + flex: 2; +`; diff --git a/packages/app/src/app/pages/Profile/Showcase/index.tsx b/packages/app/src/app/pages/Profile/Showcase/index.tsx index 416c1e21a31..be8164a224b 100644 --- a/packages/app/src/app/pages/Profile/Showcase/index.tsx +++ b/packages/app/src/app/pages/Profile/Showcase/index.tsx @@ -1,62 +1,41 @@ import React, { FunctionComponent } from 'react'; -import { useOvermind } from 'app/overmind'; - import Column from '@codesandbox/common/lib/components/flex/Column'; -import Centered from '@codesandbox/common/lib/components/flex/Centered'; import Margin from '@codesandbox/common/lib/components/spacing/Margin'; import { Button } from '@codesandbox/common/lib/components/Button'; -import { SandboxInfo } from './SandboxInfo'; +import { useOvermind } from 'app/overmind'; + import ShowcasePreview from '../../common/ShowcasePreview'; -import { ErrorTitle } from './elements'; +import { SandboxInfoContainer, ShowcasePreviewContainer } from './elements'; +import { LoadingSandbox } from './LoadingSandbox'; +import { NoSandboxAvailable } from './NoSandboxAvailable'; +import { SandboxInfo } from './SandboxInfo'; export const Showcase: FunctionComponent = () => { const { - state: { - profile, - profile: { isLoadingProfile }, - preferences: { settings }, - }, actions: { profile: { selectSandboxClicked }, }, + state: { + preferences: { settings }, + profile: { isLoadingProfile, isProfileCurrentUser, showcasedSandbox }, + }, } = useOvermind(); - const sandbox = profile.showcasedSandbox; - const isCurrentUser = profile.isProfileCurrentUser; - - const openModal = () => { - selectSandboxClicked(); - }; if (isLoadingProfile) { - return ( - - - Loading showcased sandbox... - - - ); + return ; } - if (!sandbox) { - return ( - - - - {isCurrentUser ? "You don't" : "This user doesn't"} have any - sandboxes yet - - - - ); + if (!showcasedSandbox) { + return ; } return ( - {isCurrentUser && ( - + {isProfileCurrentUser && ( + selectSandboxClicked()} small> Change Sandbox )} @@ -64,13 +43,13 @@ export const Showcase: FunctionComponent = () => { - - - + + + - - - + + +