mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-11-21 08:47:20 +00:00
* use html5 details element instead of javascript Reduces reliance on JS for content. I found when the JS didn't full load (flaky connection), I couldn't open these detail blocks. * fix: remove the unused click handler --------- Co-authored-by: Franck Nijhof <git@frenck.dev>
30 lines
891 B
JavaScript
30 lines
891 B
JavaScript
import React from 'react';
|
|
|
|
// Styles for this element is defined in src/css/custom.css
|
|
|
|
export default class ApiEndpoint extends React.Component {
|
|
render() {
|
|
return (
|
|
<details className="api-endpoint">
|
|
<summary className="api-endpoint-header">
|
|
<div className={`api-endpoint-method ${this.props.method}`}>
|
|
{this.props.method}
|
|
</div>
|
|
<code>{this.props.path}</code>
|
|
<div
|
|
className="api-endpoint-protection"
|
|
title={
|
|
this.props.unprotected
|
|
? 'Authentication is not required for this endpoint'
|
|
: 'Authentication is required for this endpoint'
|
|
}>
|
|
{this.props.unprotected ? '🔓' : '🔒'}
|
|
</div>
|
|
</summary>
|
|
|
|
<div className="api-endpoint-content">{this.props.children}</div>
|
|
</details>
|
|
);
|
|
}
|
|
}
|