import React, { Children, Fragment } from "react"; import { useTranslation } from "react-i18next"; import { Grid, GridItem, GridProps, JumpLinks, JumpLinksItem, PageSection, } from "@patternfly/react-core"; import { mainPageContentId } from "../../App"; import { ScrollPanel } from "./ScrollPanel"; import { FormPanel } from "./FormPanel"; import "./scroll-form.css"; type ScrollFormProps = GridProps & { sections: string[]; borders?: boolean; children: React.ReactNode; }; const spacesToHyphens = (string: string): string => { return string.replace(/\s+/g, "-"); }; export const ScrollForm = ({ sections, borders = false, children, ...rest }: ScrollFormProps) => { const { t } = useTranslation("common"); const nodes = Children.toArray(children); return ( {sections.map((cat, index) => ( {!borders && ( {nodes[index]} )} {borders && ( {nodes[index]} )} ))} {sections.map((cat) => ( // note that JumpLinks currently does not work with spaces in the href {cat} ))} ); };