Skip to content

Commit df8b2b9

Browse files
committed
fixes
1 parent d278307 commit df8b2b9

File tree

4 files changed

+86
-4
lines changed

4 files changed

+86
-4
lines changed

packages/graphql-playground-electron/src/ElectronApp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export default class ElectronApp extends React.Component<{}, State> {
327327
})
328328
.then(res => res.json())
329329
.then(res => {
330-
const shareUrl = `https://graphql-bin.com/${res.data.addSession.id}`
330+
const shareUrl = `https://graphqlbin.com/${res.data.addSession.id}`
331331
// const shareUrl = `${location.origin}/${res.data.addSession.id}`
332332
this.setState({ shareUrl })
333333
})
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import * as React from 'react'
2+
import { $v } from 'graphcool-styles'
3+
import * as CopyToClipboard from 'react-copy-to-clipboard'
4+
5+
interface Props {
6+
text: string
7+
color?: string
8+
}
9+
10+
interface State {
11+
copied: boolean
12+
}
13+
14+
export default class Copy extends React.Component<Props, State> {
15+
private copyTimer: any
16+
17+
constructor(props) {
18+
super(props)
19+
20+
this.state = {
21+
copied: false,
22+
}
23+
}
24+
25+
componentWillUnmount() {
26+
clearTimeout(this.copyTimer)
27+
}
28+
29+
render() {
30+
const { text } = this.props
31+
let { color } = this.props
32+
33+
color = color || $v.blue
34+
35+
return (
36+
<CopyToClipboard text={text} onCopy={this.onCopy}>
37+
<div className="copy">
38+
<style jsx={true}>{`
39+
.copy {
40+
@p: .relative;
41+
}
42+
@keyframes copying {
43+
0% {
44+
opacity: 0;
45+
transform: translate(-50%, 0);
46+
}
47+
48+
50% {
49+
opacity: 1;
50+
}
51+
52+
100% {
53+
opacity: 0;
54+
transform: translate(-50%, -50px);
55+
}
56+
}
57+
.indicator {
58+
@p: .absolute;
59+
top: -20px;
60+
left: 50%;
61+
transform: translate(-50%, 0);
62+
animation: copying 700ms linear;
63+
}
64+
`}</style>
65+
{this.state.copied &&
66+
<div className="indicator" style={{ color }}>
67+
Copied
68+
</div>}
69+
{this.props.children}
70+
</div>
71+
</CopyToClipboard>
72+
)
73+
}
74+
75+
private onCopy = () => {
76+
this.setState({ copied: true } as State)
77+
this.copyTimer = window.setTimeout(
78+
() => this.setState({ copied: false } as State),
79+
500,
80+
)
81+
}
82+
}

packages/graphql-playground/src/components/Playground/DocExplorer/TypeLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class TypeLink extends React.PureComponent<
143143
transition: $duration background-color;
144144
}
145145
.doc-category-item.clickable:hover {
146-
@p: .pointer, .white;
146+
@p: .pointer, .white, .bgBlue;
147147
}
148148
.doc-category-item.clickable:hover :global(.brace) {
149149
@p: .white;

packages/graphql-playground/src/components/Share.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Tooltip from './Tooltip'
66
import { Theme } from './Playground'
77
import * as cn from 'classnames'
88
import { Button } from './Button'
9-
import * as Copy from 'react-copy-to-clipboard'
9+
import Copy from './Copy'
1010

1111
interface Props {
1212
theme: Theme
@@ -173,7 +173,7 @@ export default class Share extends React.Component<Props, State> {
173173
<div className="row">
174174
<div />
175175
<Button hideArrow={true} onClick={onShare}>
176-
{reshare || shareUrl ? 'Reshare' : 'Share'}
176+
{reshare && shareUrl ? 'Reshare' : 'Share'}
177177
</Button>
178178
</div>
179179
</div>

0 commit comments

Comments
 (0)