File tree 3 files changed +104
-0
lines changed
components/OpenGithubIssueButton
3 files changed +104
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import styles from './styles.module.css' ;
3
+
4
+ const OpenGithubIssueButton = ( ) => {
5
+ const handleOpenGitHubIssue = ( ) => {
6
+ const selectedText = window . getSelection ( ) ?. toString ( ) || '' ;
7
+ const formattedText = selectedText . split ( '\n' ) . map ( line => `> ${ line } ` ) . join ( '\n' ) ;
8
+ const pageTitle = document . title . replace ( ' | Dice Rolling Game' , '' ) ;
9
+ const title = encodeURIComponent ( `Docs: sugestão em \"${ pageTitle } \"` ) ;
10
+ const body = encodeURIComponent ( `URL: ${ window . location . href } \n\nTexto selecionado:\n${ formattedText } ` ) ;
11
+ const issueUrl = `https://github.com/Space-Wizard-Studios/sw-game-dice-rolling/issues/new?title=${ title } &body=${ body } ` ;
12
+ window . open ( issueUrl , '_blank' ) ;
13
+ } ;
14
+
15
+ return (
16
+ < div className = { styles . openGithubIssueButton } >
17
+ < div className = { styles . content } >
18
+ < div className = { styles . icon } >
19
+ < svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 32 32" >
20
+ < path fill = "currentColor" d = "M16 .396c-8.839 0-16 7.167-16 16c0 7.073 4.584 13.068 10.937 15.183c.803.151 1.093-.344 1.093-.772c0-.38-.009-1.385-.015-2.719c-4.453.964-5.391-2.151-5.391-2.151c-.729-1.844-1.781-2.339-1.781-2.339c-1.448-.989.115-.968.115-.968c1.604.109 2.448 1.645 2.448 1.645c1.427 2.448 3.744 1.74 4.661 1.328c.14-1.031.557-1.74 1.011-2.135c-3.552-.401-7.287-1.776-7.287-7.907c0-1.751.62-3.177 1.645-4.297c-.177-.401-.719-2.031.141-4.235c0 0 1.339-.427 4.4 1.641a15.4 15.4 0 0 1 4-.541c1.36.009 2.719.187 4 .541c3.043-2.068 4.381-1.641 4.381-1.641c.859 2.204.317 3.833.161 4.235c1.015 1.12 1.635 2.547 1.635 4.297c0 6.145-3.74 7.5-7.296 7.891c.556.479 1.077 1.464 1.077 2.959c0 2.14-.02 3.864-.02 4.385c0 .416.28.916 1.104.755c6.4-2.093 10.979-8.093 10.979-15.156c0-8.833-7.161-16-16-16z" />
21
+ </ svg >
22
+ </ div >
23
+ < p > Tem uma sugestão?</ p >
24
+ < button onClick = { handleOpenGitHubIssue } > Criar issue</ button >
25
+ </ div >
26
+ </ div >
27
+ ) ;
28
+ } ;
29
+
30
+ export default OpenGithubIssueButton ;
Original file line number Diff line number Diff line change
1
+ .openGithubIssueButton {
2
+ position : fixed;
3
+ display : flex;
4
+ right : 10rem ;
5
+ bottom : -50px ;
6
+ width : 200px ;
7
+ z-index : 1000 ;
8
+ font-size : 14px ;
9
+ transition : bottom 0.5s ;
10
+ }
11
+
12
+ .openGithubIssueButton : hover {
13
+ bottom : 0px ;
14
+ }
15
+
16
+ .openGithubIssueButton .content {
17
+ display : flex;
18
+ flex-direction : column;
19
+ justify-content : center;
20
+ align-items : center;
21
+ flex-grow : 1 ;
22
+ gap : 0.5rem ;
23
+ background-color : rgb (33 , 33 , 33 );
24
+ border : 1px solid # ddd ;
25
+ border-radius : 8px ;
26
+ padding : 10px ;
27
+ }
28
+
29
+ .openGithubIssueButton .icon {
30
+ position : absolute;
31
+ display : flex;
32
+ justify-content : center;
33
+ align-items : center;
34
+ top : -1rem ;
35
+ width : 2rem ;
36
+ height : 2rem ;
37
+ background-color : rgb (33 , 33 , 33 );
38
+ border : 1px solid # ddd ;
39
+ border-radius : 100% ;
40
+ }
41
+
42
+ .openGithubIssueButton .icon svg {
43
+ width : 1rem ;
44
+ height : 1rem ;
45
+ }
46
+
47
+ .openGithubIssueButton p {
48
+ margin : 0 ;
49
+ }
50
+
51
+ .openGithubIssueButton button {
52
+ background-color : # 4caf50 ;
53
+ color : white;
54
+ border : none;
55
+ padding : 10px 20px ;
56
+ border-radius : 4px ;
57
+ cursor : pointer;
58
+ }
59
+
60
+ .openGithubIssueButton button : hover {
61
+ background-color : # 45a049 ;
62
+ }
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import Layout from '@theme-original/Layout' ;
3
+ import OpenGithubIssueButton from '@site/src/components/OpenGithubIssueButton' ;
4
+
5
+ export default function LayoutWrapper ( props ) {
6
+ return (
7
+ < >
8
+ < Layout { ...props } />
9
+ < OpenGithubIssueButton />
10
+ </ >
11
+ ) ;
12
+ }
You can’t perform that action at this time.
0 commit comments