diff --git a/src/components/Configuration/components.jsx b/src/components/Configuration/components.jsx index e395168b3b1a..db2abb0fb188 100644 --- a/src/components/Configuration/components.jsx +++ b/src/components/Configuration/components.jsx @@ -1,5 +1,5 @@ import PropTypes from "prop-types"; -import { Component, isValidElement } from "react"; +import { isValidElement, useState } from "react"; import Popover from "react-tiny-popover"; const DEFAULT_CHILDREN_SIZE = 4; @@ -20,8 +20,8 @@ const addLink = (child, i, url) => const Card = ({ body }) => ( // Applied .shadow > .markdown styles: max-height and overflow
{body}
@@ -33,71 +33,53 @@ Card.propTypes = {
body: PropTypes.node,
};
-export class Details extends Component {
- static propTypes = {
- url: PropTypes.string,
- myChilds: PropTypes.arrayOf(PropTypes.node),
- };
-
- constructor(props) {
- super(props);
- this.state = {
- open: false,
- };
- }
-
- clickOutsideHandler = () => {
- this.setState({ open: false });
- };
-
- toggleVisibility = () => {
- this.setState({ open: !this.state.open });
- };
-
- render() {
- const { myChilds, url } = this.props;
-
- // Find the index of
- const closeDefaultTagIndex = myChilds.findIndex((child) => {
- if (isValidElement(child)) {
- return (
- child.props.className.includes("tag") &&
- child.props.children.length === DEFAULT_CHILDREN_SIZE
- );
- }
-
- return false;
- });
-
- const content = [...myChilds];
-
- // Summary is the part of the snippet that would be shown in the code snippet,
- // to get it we need to cut the enclosing tags
- const summary = content
- .splice(2, closeDefaultTagIndex - 3)
- .map(removeSpaces)
- .map((child, i) => addLink(child, i, url));
-
- content.splice(0, DEFAULT_CHILDREN_SIZE); // Remove information
-
- const { open } = this.state;
- return (
- }
+export function Details({ url, myChilds }) {
+ const [open, setOpen] = useState(false);
+
+ // Find the index of
+ const closeDefaultTagIndex = myChilds.findIndex((child) => {
+ if (isValidElement(child)) {
+ return (
+ child.props.className.includes("tag") &&
+ child.props.children.length === DEFAULT_CHILDREN_SIZE
+ );
+ }
+
+ return false;
+ });
+
+ const content = [...myChilds];
+
+ // Summary is the part of the snippet that would be shown in the code snippet,
+ // to get it we need to cut the enclosing tags
+ const summary = content
+ .splice(2, closeDefaultTagIndex - 3)
+ .map(removeSpaces)
+ .map((child, i) => addLink(child, i, url));
+
+ content.splice(0, DEFAULT_CHILDREN_SIZE); // Remove information
+
+ return (
+ setOpen(false)}
+ // Replaced .shadow with Tailwind equivalents, including the custom rgba box-shadow
+ containerClassName="overflow-visible rounded shadow-[-1px_1px_10px_0_rgba(255,255,255,0.44)]"
+ content={ }
+ >
+ setOpen((prev) => !prev)}
>
-
- {summary}
-
-
- );
- }
+ {summary}
+
+
+ );
}
+
+Details.propTypes = {
+ url: PropTypes.string,
+ myChilds: PropTypes.arrayOf(PropTypes.node),
+};