mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-27 23:52:46 +03:00
fix: make properties focusable
This commit is contained in:
parent
442014c06d
commit
05fd7543a2
|
@ -62,7 +62,7 @@ export const PropertyNameCell = styled(PropertyCell)`
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
font-size: 0.929em;
|
font-size: 13px;
|
||||||
font-family: ${props => props.theme.typography.code.fontFamily};
|
font-family: ${props => props.theme.typography.code.fontFamily};
|
||||||
|
|
||||||
&.deprecated {
|
&.deprecated {
|
||||||
|
|
|
@ -5,8 +5,19 @@ import { PropertyNameCell } from './fields-layout';
|
||||||
import { ShelfIcon } from './shelfs';
|
import { ShelfIcon } from './shelfs';
|
||||||
|
|
||||||
export const ClickablePropertyNameCell = styled(PropertyNameCell)`
|
export const ClickablePropertyNameCell = styled(PropertyNameCell)`
|
||||||
|
button {
|
||||||
|
background-color: transparent;
|
||||||
|
border: 0;
|
||||||
|
outline: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: ${props => props.theme.typography.code.fontFamily};
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
padding: 0;
|
||||||
|
color: ${props => props.theme.colors.text.primary};
|
||||||
|
&:focus {
|
||||||
|
font-weight: ${({ theme }) => theme.typography.fontWeightBold};
|
||||||
|
}
|
||||||
|
}
|
||||||
${ShelfIcon} {
|
${ShelfIcon} {
|
||||||
height: ${({ theme }) => theme.schema.arrow.size};
|
height: ${({ theme }) => theme.schema.arrow.size};
|
||||||
width: ${({ theme }) => theme.schema.arrow.size};
|
width: ${({ theme }) => theme.schema.arrow.size};
|
||||||
|
|
|
@ -37,6 +37,14 @@ export class Field extends React.Component<FieldProps> {
|
||||||
this.props.field.toggle();
|
this.props.field.toggle();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleKeyPress = e => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
e.preventDefault();
|
||||||
|
this.toggle();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className, field, isLast, expandByDefault } = this.props;
|
const { className, field, isLast, expandByDefault } = this.props;
|
||||||
const { name, deprecated, required, kind } = field;
|
const { name, deprecated, required, kind } = field;
|
||||||
|
@ -46,14 +54,19 @@ export class Field extends React.Component<FieldProps> {
|
||||||
|
|
||||||
const paramName = withSubSchema ? (
|
const paramName = withSubSchema ? (
|
||||||
<ClickablePropertyNameCell
|
<ClickablePropertyNameCell
|
||||||
onClick={this.toggle}
|
|
||||||
className={deprecated ? 'deprecated' : ''}
|
className={deprecated ? 'deprecated' : ''}
|
||||||
kind={kind}
|
kind={kind}
|
||||||
title={name}
|
title={name}
|
||||||
>
|
>
|
||||||
<PropertyBullet />
|
<PropertyBullet />
|
||||||
|
<button
|
||||||
|
onClick={this.toggle}
|
||||||
|
onKeyPress={this.handleKeyPress}
|
||||||
|
aria-label="expand properties"
|
||||||
|
>
|
||||||
{name}
|
{name}
|
||||||
<ShelfIcon direction={expanded ? 'down' : 'right'} />
|
<ShelfIcon direction={expanded ? 'down' : 'right'} />
|
||||||
|
</button>
|
||||||
{required && <RequiredLabel> required </RequiredLabel>}
|
{required && <RequiredLabel> required </RequiredLabel>}
|
||||||
</ClickablePropertyNameCell>
|
</ClickablePropertyNameCell>
|
||||||
) : (
|
) : (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user