@@ -6,6 +6,8 @@ import ModeIcons from 'app/components/sandbox/ModeIcons';
66import {
77 optionsToParameterizedUrl ,
88 protocolAndHost ,
9+ sandboxUrl ,
10+ embedUrl ,
911} from 'app/utils/url-generator' ;
1012
1113import type { Sandbox } from 'common/types' ;
@@ -15,7 +17,6 @@ import Action from './Action';
1517import {
1618 isMainModule ,
1719} from '../../../../../store/entities/sandboxes/modules/selectors' ;
18- import { sandboxUrl , embedUrl } from '../../../../../utils/url-generator' ;
1920
2021const Container = styled . div `
2122 position: relative;
@@ -26,7 +27,7 @@ const Container = styled.div`
2627const ShareOptions = styled . div `
2728 position: absolute;
2829 top: calc(100% + 0.25rem);
29- left: -150px ;
30+ left: -250px ;
3031 box-sizing: border-box;
3132 z-index: 2;
3233 border-radius: 4px;
@@ -35,10 +36,10 @@ const ShareOptions = styled.div`
3536 color: rgba(255, 255, 255, 0.8);
3637 padding: 1rem;
3738
38- box-shadow: 1px 1px 1px rgba(0,0,0,0.2 );
39- background-color: ${ props => props . theme . background2 . darken ( 0.1 ) } ;
39+ box-shadow: - 1px 4px 5px rgba(0,0,0,0.5 );
40+ background-color: ${ props => props . theme . background2 } ;
4041
41- width: 700px ;
42+ width: 900px ;
4243
4344
4445 h3 {
@@ -55,21 +56,23 @@ const Inputs = styled.div`
5556 border: none;
5657 outline: none;
5758 width: 100%;
58- background-color: ${ props => props . theme . background } ;
59+ background-color: rgba(255, 255, 255, 0.1) ;
5960 color: white;
6061 padding: 0.2rem;
6162 margin: 0.5rem 0;
63+ border-radius: 4px;
6264 }
6365
6466 textarea {
6567 border: none;
6668 outline: none;
6769 width: 100%;
68- background-color: ${ props => props . theme . background } ;
70+ background-color: rgba(255, 255, 255, 0.1) ;
6971 color: white;
7072 padding: 0.2rem;
7173 margin: 0.5rem 0;
72- height: 120px;
74+ height: 100px;
75+ border-radius: 4px;
7376 }
7477` ;
7578
@@ -88,22 +91,34 @@ const Divider = styled.div`
8891const Column = styled . div `
8992 display: flex;
9093 flex-direction: column;
91- flex: 50 %;
94+ flex: 100 %;
9295
9396 color: rgba(255, 255, 255, 0.8);
94- margin: 0 .5rem ;
97+ margin: 0 .75rem ;
9598
9699 h4 {
97100 margin: 1rem 0;
98101 font-weight: 400;
99102 }
100103` ;
101104
105+ const ButtonContainer = styled . div `
106+ margin-top: 0.25rem;
107+ ` ;
108+
109+ const ButtonName = styled . div `
110+ margin: 0.5rem 0;
111+ font-weight: 500;
112+ margin-bottom: 0;
113+ ` ;
114+
102115type Props = {
103116 sandbox : Sandbox ,
104117 sendMessage : ( message : string ) => void ,
105118} ;
106119
120+ const BUTTON_URL = 'https://codesandbox.io/static/img/play-codesandbox.svg' ;
121+
107122export default class ShareView extends React . PureComponent {
108123 props : Props ;
109124 state = {
@@ -166,12 +181,27 @@ export default class ShareView extends React.PureComponent {
166181 event . target . select ( ) ;
167182 } ;
168183
184+ // eslint-disable-next-line
185+ getButtonMarkdown = ( ) => {
186+ const { sandbox } = this . props ;
187+ return `[](${ this . getEditorUrl ( ) } )` ;
188+ } ;
189+
190+ // eslint-disable-next-line
191+ getButtonHTML = ( ) => {
192+ const { sandbox } = this . props ;
193+ return `<a href="${ this . getEditorUrl ( ) } ">
194+ <img alt="Edit ${ sandbox . title || sandbox . id } " src="${ BUTTON_URL } ">
195+ </a>
196+ ` ;
197+ } ;
198+
169199 render ( ) {
170200 const { sandbox } = this . props ;
171201 const { showEditor, showPreview } = this . state ;
172202
173- const defaultModule = this . state . defaultModule ||
174- sandbox . modules . find ( isMainModule ) . id ;
203+ const defaultModule =
204+ this . state . defaultModule || sandbox . modules . find ( isMainModule ) . id ;
175205
176206 return (
177207 < Container >
@@ -187,6 +217,7 @@ export default class ShareView extends React.PureComponent {
187217 < h3 > Share options</ h3 >
188218 < Divider >
189219 < Column >
220+ < ButtonName > URL Options</ ButtonName >
190221 < div >
191222 < h4 > Default view</ h4 >
192223 < div
@@ -219,6 +250,7 @@ export default class ShareView extends React.PureComponent {
219250 </ div >
220251 </ Column >
221252 < Column >
253+ < ButtonName > Links</ ButtonName >
222254 < Inputs >
223255 < LinkName > Editor url</ LinkName >
224256 < input onFocus = { this . select } value = { this . getEditorUrl ( ) } />
@@ -233,6 +265,30 @@ export default class ShareView extends React.PureComponent {
233265 />
234266 </ Inputs >
235267 </ Column >
268+ < Column >
269+ < ButtonName > Button</ ButtonName >
270+ < Inputs >
271+ < ButtonContainer >
272+ < a href = { sandboxUrl ( sandbox ) } >
273+ < img
274+ alt = { sandbox . title || 'Untitled' }
275+ src = { BUTTON_URL }
276+ />
277+ </ a >
278+ </ ButtonContainer >
279+ < LinkName > Markdown</ LinkName >
280+ < textarea
281+ onFocus = { this . select }
282+ value = { this . getButtonMarkdown ( ) }
283+ />
284+
285+ < LinkName > HTML</ LinkName >
286+ < textarea
287+ onFocus = { this . select }
288+ value = { this . getButtonHTML ( ) }
289+ />
290+ </ Inputs >
291+ </ Column >
236292 </ Divider >
237293 </ ShareOptions >
238294 ) }
0 commit comments