-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Embed redesign 2/n: Sidebar sections + Sandbox info #2731
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
334cc93
create new vscode theme for new redesign
siddharthkp 0677eb6
remove dead code
siddharthkp 51acf26
tiny polish for missing tab styles
siddharthkp d97a78b
copy sidebar border
siddharthkp 9dc8dde
Merge branch 'master' into embed-black
siddharthkp 3a92822
Merge branch 'master' into embed-black
siddharthkp 9341460
Fix bad merge
siddharthkp 9892b60
Get tokens + styled-system going
siddharthkp 6b92dd6
get sidebar sections in [skip ci]
siddharthkp 6d65b50
add stats to sandbox info
siddharthkp 849dd9a
linter oh linter
siddharthkp 87e1874
drone is confused, i need a commit
siddharthkp d61cbd8
get the border right
siddharthkp b29c672
who knew dot object mutates object!
siddharthkp f039a43
sync the sidebar border color
siddharthkp 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
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
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
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
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
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
27 changes: 27 additions & 0 deletions
27
packages/app/src/embed/components/Sidebar/AvatarBlock/elements.js
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,27 @@ | ||
| import styled from 'styled-components'; | ||
| import css from '@styled-system/css'; | ||
|
|
||
| export const Container = styled.div( | ||
| css({ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| marginBottom: 4, | ||
| }) | ||
| ); | ||
|
|
||
| export const Avatar = styled.img( | ||
| css({ | ||
| size: '24px', | ||
| borderRadius: '2px', | ||
| border: '1px solid', | ||
| borderColor: 'grays.400', | ||
| }) | ||
| ); | ||
|
|
||
| export const Name = styled.span( | ||
| css({ | ||
| display: 'inline-block', | ||
| fontSize: 2, | ||
| marginLeft: 2, | ||
| }) | ||
| ); |
11 changes: 11 additions & 0 deletions
11
packages/app/src/embed/components/Sidebar/AvatarBlock/index.js
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,11 @@ | ||
| import React from 'react'; | ||
| import { Container, Avatar, Name } from './elements'; | ||
|
|
||
| const AvatarBlock = ({ url, name }) => ( | ||
| <Container> | ||
| <Avatar src={url} /> | ||
| <Name>{name}</Name> | ||
| </Container> | ||
| ); | ||
|
|
||
| export default AvatarBlock; |
42 changes: 42 additions & 0 deletions
42
packages/app/src/embed/components/Sidebar/SandboxInfo/elements.js
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,42 @@ | ||
| import styled from 'styled-components'; | ||
| import css from '@styled-system/css'; | ||
| import CommonStats from '@codesandbox/common/lib/components/Stats'; | ||
| import { CenteredText } from '@codesandbox/common/lib/components/Stats/Stat/elements'; | ||
|
|
||
| export const Container = styled.div( | ||
| css({ | ||
| padding: 4, | ||
| }) | ||
| ); | ||
|
|
||
| export const Title = styled.h2( | ||
| css({ | ||
| fontSize: 3, | ||
| fontWeight: 'medium', | ||
| margin: 0, | ||
| marginBottom: 1, | ||
| }) | ||
| ); | ||
|
|
||
| export const Description = styled.div( | ||
| css({ | ||
| fontSize: 2, | ||
| color: 'grays.300', | ||
| marginBottom: 4, | ||
| }) | ||
| ); | ||
|
|
||
| export const Stats = styled(CommonStats)( | ||
| css({ | ||
| fontSize: 1, | ||
| // ouch ouch ouch, modifying a child of | ||
| // a common element is just pure evil | ||
| // this will definitely break on the | ||
| // slightest touch to the Stats component | ||
| // TODO: Refactor stats component to accept | ||
| // justify as an input | ||
| [CenteredText]: { | ||
| justifyContent: 'start', | ||
| }, | ||
| }) | ||
| ); |
23 changes: 23 additions & 0 deletions
23
packages/app/src/embed/components/Sidebar/SandboxInfo/index.js
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,23 @@ | ||
| import React from 'react'; | ||
| import { Container, Title, Description, Stats } from './elements'; | ||
| import AvatarBlock from '../AvatarBlock'; | ||
|
|
||
| const SandboxInfo = ({ sandbox }) => { | ||
| const title = sandbox.title || sandbox.id; | ||
|
|
||
| return ( | ||
| <Container> | ||
| <Title title={title}>{title}</Title> | ||
| {sandbox.description && <Description>{sandbox.description}</Description>} | ||
| {sandbox.author && ( | ||
| <AvatarBlock | ||
| url={sandbox.author.avatarUrl} | ||
| name={sandbox.author.username} | ||
| /> | ||
| )} | ||
| <Stats {...sandbox} /> | ||
| </Container> | ||
| ); | ||
| }; | ||
|
|
||
| export default SandboxInfo; |
40 changes: 40 additions & 0 deletions
40
packages/app/src/embed/components/Sidebar/Section/elements.js
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,40 @@ | ||
| import styled from 'styled-components'; | ||
| import css from '@styled-system/css'; | ||
|
|
||
| export const Body = styled.div( | ||
| css({ | ||
| borderBottom: '1px solid', | ||
| borderColor: 'sideBar.border', | ||
| }) | ||
| ); | ||
|
|
||
| export const Header = styled.div( | ||
| css({ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| height: '32px', | ||
| paddingX: 3, | ||
| borderBottom: '1px solid', | ||
| borderColor: 'sideBar.border', | ||
| cursor: 'pointer', | ||
| ':hover': { | ||
| backgroundColor: 'sideBar.border', | ||
| }, | ||
| ':focus': { | ||
| backgroundColor: 'sideBar.border', | ||
| }, | ||
| }) | ||
| ); | ||
|
|
||
| export const Title = styled.div( | ||
| css({ | ||
| fontSize: 3, | ||
| }) | ||
| ); | ||
|
|
||
| export const Icon = styled.svg(props => | ||
| css({ | ||
| marginRight: 1, | ||
| transform: props.open ? 'rotate(0)' : 'rotate(-90deg)', | ||
| }) | ||
| ); |
36 changes: 36 additions & 0 deletions
36
packages/app/src/embed/components/Sidebar/Section/index.js
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,36 @@ | ||
| import React from 'react'; | ||
| import { Header, Icon, Title, Body } from './elements'; | ||
|
|
||
| function Section(props) { | ||
| const [open, setOpen] = React.useState(props.defaultOpen || false); | ||
| const toggle = () => setOpen(!open); | ||
|
|
||
| return ( | ||
| <section> | ||
| <Header onClick={toggle}> | ||
| <ToggleIcon open={open} /> | ||
| <Title>{props.title}</Title> | ||
| </Header> | ||
| {open ? <Body>{props.children}</Body> : null} | ||
| </section> | ||
| ); | ||
| } | ||
|
|
||
| function ToggleIcon(props) { | ||
| return ( | ||
| <Icon | ||
| width="9" | ||
| height="6" | ||
| viewBox="0 0 9 6" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| {...props} | ||
| > | ||
| <path | ||
| d="M4.50009 6L-5.24537e-07 1.26364e-06L9 4.76837e-07L4.50009 6Z" | ||
| fill="#757575" | ||
| /> | ||
| </Icon> | ||
| ); | ||
| } | ||
|
|
||
| export default Section; |
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
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
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
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
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,20 @@ | ||
| import dot from 'dot-object'; | ||
| import applicationTheme from '@codesandbox/common/lib/theme'; | ||
| import codesandboxBlack from '@codesandbox/common/lib/themes/codesandbox-nu.json'; | ||
| import tokens from './tokens'; | ||
|
|
||
| // merge vscode colors into tokens | ||
| Object.assign(tokens.colors, dot.object({ ...codesandboxBlack.colors })); | ||
|
|
||
| const theme = { | ||
| // hope to remove this bit | ||
| ...applicationTheme, | ||
| // used for parts imported from outside embed | ||
| ...codesandboxBlack.colors, | ||
| // used for syntax highlighting | ||
| vscodeTheme: codesandboxBlack, | ||
| // used for embed styles | ||
| ...tokens, | ||
| }; | ||
|
|
||
| export default theme; |
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.
Nice that we're using themes here already!