fix: make sample controls focusable

This commit is contained in:
Anya Stasiuk 2020-06-03 13:32:45 +03:00 committed by Roman Hotsiy
parent 05fd7543a2
commit 006031c517
3 changed files with 14 additions and 7 deletions

View File

@ -34,14 +34,14 @@ export class CopyButtonWrapper extends React.PureComponent<
renderCopyButton = () => { renderCopyButton = () => {
return ( return (
<span onClick={this.copy}> <button onClick={this.copy}>
<Tooltip <Tooltip
title={ClipboardService.isSupported() ? 'Copied' : 'Not supported in your browser'} title={ClipboardService.isSupported() ? 'Copied' : 'Not supported in your browser'}
open={this.state.tooltipShown} open={this.state.tooltipShown}
> >
Copy Copy
</Tooltip> </Tooltip>
</span> </button>
); );
}; };

View File

@ -6,12 +6,19 @@ export const SampleControls = styled.div`
transition: opacity 0.3s ease; transition: opacity 0.3s ease;
text-align: right; text-align: right;
> span { > button {
display: inline-block; background-color: transparent;
border: 0;
color: inherit;
padding: 2px 10px; padding: 2px 10px;
font-family: ${({ theme }) => theme.typography.fontFamily};
font-size: ${({ theme }) => theme.typography.fontSize};
line-height: ${({ theme }) => theme.typography.lineHeight};
cursor: pointer; cursor: pointer;
outline: 0;
:hover { :hover,
:focus {
background: rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.1);
} }
} }

View File

@ -30,8 +30,8 @@ class Json extends React.PureComponent<JsonProps> {
<JsonViewerWrap> <JsonViewerWrap>
<SampleControls> <SampleControls>
{renderCopyButton()} {renderCopyButton()}
<span onClick={this.expandAll}> Expand all </span> <button onClick={this.expandAll}> Expand all </button>
<span onClick={this.collapseAll}> Collapse all </span> <button onClick={this.collapseAll}> Collapse all </button>
</SampleControls> </SampleControls>
<OptionsContext.Consumer> <OptionsContext.Consumer>
{options => ( {options => (