|
1 | 1 | import React from "react"
|
2 | 2 | import { graphql } from "gatsby"
|
3 | 3 | import EditIcon from "react-icons/lib/md/create"
|
4 |
| -import CheckIcon from "react-icons/lib/md/thumb-up" |
5 |
| -import CrossIcon from "react-icons/lib/md/thumb-down" |
6 |
| -import { GraphQLClient } from "graphql-request" |
7 | 4 |
|
8 | 5 | import { rhythm, scale } from "../utils/typography"
|
9 | 6 | import { colors } from "../utils/presets"
|
10 | 7 |
|
11 |
| -const client = new GraphQLClient( |
12 |
| - `https://api.graph.cool/relay/v1/cj8xuo77f0a3a0164y7jketkr` |
13 |
| -) |
14 |
| - |
15 |
| -function sendReview(thumbsUp, relativePath) { |
16 |
| - return client.request(` |
17 |
| - mutation { |
18 |
| - createReview(input: {thumbsUp: ${thumbsUp}, relativePath: "${relativePath}", clientMutationId: "1"}) { |
19 |
| - review { |
20 |
| - id |
21 |
| - } |
22 |
| - } |
23 |
| - } |
24 |
| - `) |
25 |
| -} |
26 |
| - |
27 | 8 | export default class MarkdownPageFooter extends React.Component {
|
28 | 9 | constructor() {
|
29 | 10 | super()
|
30 | 11 | this.state = { feedbackSubmitted: false }
|
31 | 12 | }
|
32 | 13 | render() {
|
33 |
| - return [ |
34 |
| - <hr css={{ marginTop: rhythm(2) }} key="hr" />, |
35 |
| - <div |
36 |
| - css={{ |
37 |
| - marginBottom: rhythm(1), |
38 |
| - }} |
39 |
| - key="div" |
40 |
| - > |
41 |
| - {this.state.feedbackSubmitted ? ( |
42 |
| - <span css={{ lineHeight: rhythm(2) }}>Thank you!</span> |
43 |
| - ) : ( |
44 |
| - <span css={{ lineHeight: rhythm(2) }}> |
45 |
| - Was this helpful? |
46 |
| - {` `} |
47 |
| - <CheckIcon |
48 |
| - onClick={() => { |
49 |
| - sendReview(true, this.props.page.parent.relativePath) |
50 |
| - this.setState({ feedbackSubmitted: true }) |
51 |
| - }} |
52 |
| - css={{ |
53 |
| - color: colors.success, |
54 |
| - fontSize: rhythm(1.3), |
55 |
| - padding: rhythm(0.2), |
56 |
| - position: `relative`, |
57 |
| - top: -3, |
58 |
| - marginLeft: rhythm(1 / 4), |
59 |
| - cursor: `pointer`, |
60 |
| - }} |
61 |
| - /> |
| 14 | + return ( |
| 15 | + <> |
| 16 | + <hr css={{ marginTop: rhythm(2) }} /> |
| 17 | + |
| 18 | + {this.props.page && ( |
| 19 | + <a |
| 20 | + css={{ |
| 21 | + "&&": { |
| 22 | + display: `block`, |
| 23 | + color: colors.gray.calm, |
| 24 | + fontSize: scale(-1 / 5).fontSize, |
| 25 | + fontWeight: `normal`, |
| 26 | + border: `none`, |
| 27 | + boxShadow: `none`, |
| 28 | + padding: rhythm(1 / 2), |
| 29 | + "&:hover": { |
| 30 | + background: `transparent`, |
| 31 | + color: colors.gatsby, |
| 32 | + }, |
| 33 | + }, |
| 34 | + }} |
| 35 | + href={`https://github.com/gatsbyjs/gatsby/blob/master/${ |
| 36 | + this.props.packagePage ? `packages` : `docs` |
| 37 | + }/${this.props.page ? this.props.page.parent.relativePath : ``}`} |
| 38 | + > |
| 39 | + <EditIcon css={{ fontSize: 20, position: `relative`, top: -2 }} /> |
62 | 40 | {` `}
|
63 |
| - <CrossIcon |
64 |
| - onClick={() => { |
65 |
| - sendReview(false, this.props.page.parent.relativePath) |
66 |
| - this.setState({ feedbackSubmitted: true }) |
67 |
| - }} |
68 |
| - css={{ |
69 |
| - color: colors.warning, |
70 |
| - fontSize: rhythm(1.3), |
71 |
| - padding: rhythm(0.2), |
72 |
| - cursor: `pointer`, |
73 |
| - }} |
74 |
| - /> |
75 |
| - </span> |
| 41 | + edit this page on GitHub |
| 42 | + </a> |
76 | 43 | )}
|
77 |
| - <a |
78 |
| - css={{ |
79 |
| - "&&": { |
80 |
| - float: `right`, |
81 |
| - display: `block`, |
82 |
| - color: colors.gray.calm, |
83 |
| - fontSize: scale(-1 / 5).fontSize, |
84 |
| - fontWeight: `normal`, |
85 |
| - border: `none`, |
86 |
| - boxShadow: `none`, |
87 |
| - padding: rhythm(1 / 2), |
88 |
| - "&:hover": { |
89 |
| - background: `transparent`, |
90 |
| - color: colors.gatsby, |
91 |
| - }, |
92 |
| - }, |
93 |
| - }} |
94 |
| - href={`https://github.com/gatsbyjs/gatsby/blob/master/${ |
95 |
| - this.props.packagePage ? `packages` : `docs` |
96 |
| - }/${this.props.page ? this.props.page.parent.relativePath : ``}`} |
97 |
| - > |
98 |
| - <EditIcon css={{ fontSize: 20, position: `relative`, top: -2 }} /> |
99 |
| - {` `} |
100 |
| - edit this page on GitHub |
101 |
| - </a> |
102 |
| - </div>, |
103 |
| - ] |
| 44 | + </> |
| 45 | + ) |
104 | 46 | }
|
105 | 47 | }
|
106 | 48 |
|
|
0 commit comments