Skip to content

Commit bfc377e

Browse files
committed
Move generate code, prettify. Closes #251
1 parent 78fea19 commit bfc377e

File tree

1 file changed

+12
-36
lines changed

1 file changed

+12
-36
lines changed

packages/graphql-playground/src/components/Playground/GraphQLEditor.tsx

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
Viewer,
2626
} from '../../types'
2727
import { download } from './util/index'
28-
import QueryHeader from './QueryHeader'
2928
import ResultHeader from './ResultHeader'
3029
import { Response } from '../Playground'
3130
import HttpHeaders, { Header } from './HttpHeaders'
@@ -37,9 +36,7 @@ import { getVariableNamesFromQuery, putVariablesToQuery } from './ast'
3736
import { flatMap, groupBy } from 'lodash'
3837
import Results from './Results'
3938
import ReponseTracing from './ResponseTracing'
40-
41-
// tslint:disable-next-line
42-
const CSSTransitionGroup = require('react-transition-group/CSSTransitionGroup')
39+
import GenerateCodeButton from './GenerateCodeButton'
4340

4441
/**
4542
* The top-level React component for GraphQLEditor, intended to encompass the entire
@@ -401,13 +398,12 @@ export class GraphQLEditor extends React.PureComponent<Props, State> {
401398
padding: 5px 9px 6px 9px;
402399
letter-spacing: 0.53px;
403400
}
404-
.graphiql-button.generate-code {
401+
.graphiql-button.prettify {
405402
@p: .absolute;
406403
top: -57px;
407-
right: 25px;
404+
right: 38px;
408405
z-index: 2;
409406
}
410-
411407
.download-button {
412408
@p: .white50, .bgDarkBlue, .ttu, .f14, .fw6, .br2, .pointer,
413409
.absolute;
@@ -475,27 +471,6 @@ export class GraphQLEditor extends React.PureComponent<Props, State> {
475471
onMouseDown={this.handleResizeStart}
476472
>
477473
<div className="queryWrap" style={queryWrapStyle}>
478-
{this.props.disableAnimation ? (
479-
<QueryHeader
480-
onPrettify={this.handlePrettifyQuery}
481-
showEndpoints={this.props.showEndpoints}
482-
showQueryTitle={this.props.showQueryTitle}
483-
/>
484-
) : (
485-
<CSSTransitionGroup
486-
transitionName="query-header"
487-
transitionEnterTimeout={500}
488-
transitionLeaveTimeout={300}
489-
>
490-
{!this.props.disableQueryHeader && (
491-
<QueryHeader
492-
onPrettify={this.handlePrettifyQuery}
493-
showEndpoints={this.props.showEndpoints}
494-
showQueryTitle={this.props.showQueryTitle}
495-
/>
496-
)}
497-
</CSSTransitionGroup>
498-
)}
499474
<QueryEditor
500475
ref={this.setQueryEditorComponent}
501476
schema={this.state.schema}
@@ -514,14 +489,15 @@ export class GraphQLEditor extends React.PureComponent<Props, State> {
514489
headers={this.props.headers}
515490
onChange={this.props.onChangeHeaders}
516491
/>
517-
{this.props.showCodeGeneration && (
518-
<div
519-
className="graphiql-button generate-code"
520-
onClick={this.props.onClickCodeGeneration}
521-
>
522-
Generate Code
523-
</div>
524-
)}
492+
<div
493+
className="graphiql-button prettify"
494+
onClick={this.handlePrettifyQuery}
495+
>
496+
Prettify
497+
</div>
498+
<GenerateCodeButton
499+
onOpenCodeGeneration={this.props.onClickCodeGeneration}
500+
/>
525501
<div
526502
className="variable-editor-title"
527503
style={{ cursor: variableOpen ? 'row-resize' : 'n-resize' }}

0 commit comments

Comments
 (0)