@@ -8,7 +8,7 @@ import 'brace/theme/textmate';
88import Title from './common/Title' ;
99import Spinner from './common/Spinner' ;
1010import * as actions from '../actions' ;
11- import { downloadSnippet } from '../helpers' ;
11+ import { downloadSnippet , copyToClipboard , parseDate } from '../helpers' ;
1212
1313import '../styles/Snippet.styl' ;
1414
@@ -18,6 +18,9 @@ class Snippet extends React.Component {
1818 this . state = { isShowEmbed : false } ;
1919 this . toggleEmbed = this . toggleEmbed . bind ( this ) ;
2020 this . download = this . download . bind ( this ) ;
21+ this . copyClipboard = ( e ) => {
22+ copyToClipboard ( e , 'embedded' ) ;
23+ } ;
2124 }
2225
2326 componentDidMount ( ) {
@@ -51,31 +54,41 @@ class Snippet extends React.Component {
5154 < div className = "snippet" key = "Snippet" >
5255 < div className = "snippet-header" >
5356 < div className = "snippet-data" >
57+ < span className = "snippet-data-title" > { snippetTitle } </ span >
58+ < div className = "snippet-data-tags" >
59+ { snippet . get ( 'tags' ) . map ( item => < span className = "snippet-data-tag" key = { item } > { item } </ span > ) }
60+ </ div >
61+ < span className = "snippet-data-meta" > { parseDate ( snippet . get ( 'created_at' ) ) } , by Guest</ span >
62+ </ div >
63+ < div className = "snippet-data-actions" >
64+ < span className = "snippet-data-lang" > { syntax } </ span >
5465 < div >
55- < span className = "snippet-data-title" > { snippetTitle } </ span >
56- < span className = "snippet-data-lang" > [ { syntax } ]</ span >
66+ < button className = "snippet-button" > Raw</ button >
67+ < button className = "snippet-button" onClick = { this . download } > Download</ button >
68+ < button
69+ className = { `snippet-button ${ this . state . isShowEmbed } ` }
70+ key = "snippet-details"
71+ onClick = { this . toggleEmbed }
72+ onKeyPress = { this . toggleEmbed }
73+ >
74+ Embed
75+ </ button >
5776 </ div >
58- < span className = "snippet-data-author" > By Guest</ span >
5977 </ div >
60- < button
61- className = "snippet-button"
62- key = "snippet-details"
63- onClick = { this . toggleEmbed }
64- onKeyPress = { this . toggleEmbed }
65- >
66- Embed
67- </ button >
6878 </ div >
6979 < div className = { `snippet-embed ${ this . state . isShowEmbed } ` } >
80+ < span className = "snippet-embed-close" onClick = { this . toggleEmbed } role = "presentation" />
7081 < p className = "snippet-embed-text" >
7182 In order to embed this content into your website or blog,
7283 simply copy and paste code provided below:
7384 </ p >
7485 < input
86+ id = "embedded"
7587 className = "input"
7688 type = "text"
7789 defaultValue = { `<script src='http://xsnippet.org/${ snippet . get ( 'id' ) } /embed/'></script>` }
7890 />
91+ < button className = "snippet-button embed" onClick = { this . copyClipboard } > Copy</ button >
7992 </ div >
8093 < div className = "snippet-code" >
8194 < AceEditor
@@ -94,10 +107,6 @@ class Snippet extends React.Component {
94107 } }
95108 value = { `${ snippet . get ( 'content' ) } ` }
96109 />
97- < div className = "snippet-code-bottom-bar" >
98- < button className = "snippet-button light" > Raw</ button >
99- < button className = "snippet-button light" onClick = { this . download } > Download</ button >
100- </ div >
101110 </ div >
102111 </ div > ,
103112 ]
0 commit comments