Accessibility: Make QueryEditorHelp examples keyboard interactive (#59355)

* Cloudwatch: A11y - Make example log keyboard interactive

* Change all cheat sheets to buttons

* Make suggestions block
This commit is contained in:
Ida Štambuk 2022-12-05 16:03:24 +01:00 committed by GitHub
parent 7deaeb0f9e
commit 3544250baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 8 deletions

View File

@ -223,10 +223,10 @@ export default class LogsCheatSheet extends PureComponent<
onClickExample(query: CloudWatchQuery) {
this.props.onClickExample(query);
}
renderExpression(expr: string, keyPrefix: string) {
return (
<div
<button
type="button"
className="cheat-sheet-item__example"
key={expr}
onClick={() =>
@ -241,7 +241,7 @@ export default class LogsCheatSheet extends PureComponent<
}
>
<pre>{renderHighlightedMarkup(expr, keyPrefix)}</pre>
</div>
</button>
);
}

View File

@ -81,9 +81,14 @@ export default class LokiCheatSheet extends PureComponent<QueryEditorHelpProps<L
};
return (
<div className="cheat-sheet-item__example" key={expr} onClick={(e) => onClick({ refId: 'A', expr })}>
<button
type="button"
className="cheat-sheet-item__example"
key={expr}
onClick={(e) => onClick({ refId: 'A', expr })}
>
<code>{expr}</code>
</div>
</button>
);
}

View File

@ -35,12 +35,13 @@ const PromCheatSheet = (props: QueryEditorHelpProps<PromQuery>) => (
<div className="cheat-sheet-item" key={index}>
<div className="cheat-sheet-item__title">{item.title}</div>
{item.expression ? (
<div
<button
type="button"
className="cheat-sheet-item__example"
onClick={(e) => props.onClickExample({ refId: 'A', expr: item.expression })}
>
<code>{item.expression}</code>
</div>
</button>
) : null}
<div className="cheat-sheet-item__label">{item.label}</div>
</div>

View File

@ -139,7 +139,11 @@
.cheat-sheet-item__example {
margin: $space-xs 0;
cursor: pointer;
// element is interactive, clear button styles
text-align: left;
border: none;
background: transparent;
display: block;
}
.query-type-toggle {