Skip to content

Commit c0059e5

Browse files
committed
feat: hide close button for inactive tabs (Fixes #289)
1 parent 19ec283 commit c0059e5

File tree

1 file changed

+16
-2
lines changed
  • packages/graphql-playground/src/components/Playground

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export default class Tab extends React.PureComponent<Props, State> {
6868
.tab:hover {
6969
@p: .bgDarkBlue;
7070
}
71+
.tab:hover :global(.close) {
72+
opacity: 1;
73+
}
7174
.light.tab:hover {
7275
background-color: #eeeff0;
7376
}
@@ -120,12 +123,19 @@ export default class Tab extends React.PureComponent<Props, State> {
120123
}
121124
122125
.close {
123-
@p: .ml10, .o50, .relative;
126+
@p: .ml10, .relative;
124127
top: 1px;
125128
height: 13px;
126129
width: 13px;
130+
opacity: 0;
131+
127132
&.active {
128133
@p: .o100;
134+
opacity: 1;
135+
}
136+
137+
&.hasCircle {
138+
opacity: 1;
129139
}
130140
}
131141
@@ -196,7 +206,11 @@ export default class Tab extends React.PureComponent<Props, State> {
196206
'New Tab'}
197207
</div>
198208
<div
199-
className={`close ${index === selectedSessionIndex && 'active'}`}
209+
className={`close${index === selectedSessionIndex ? ' active' : ''}${
210+
session.isFile && session.hasChanged && !this.state.overCross
211+
? ' hasCircle'
212+
: ''
213+
}`}
200214
onClick={this.handleCloseSession}
201215
onMouseEnter={this.handleMouseOverCross}
202216
onMouseLeave={this.handleMouseOutCross}

0 commit comments

Comments
 (0)