Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* * Copyright 2021 Harness Inc. All rights reserved. * Use of this source code is governed by the PolyForm Shield 1.0.0 license * that can be found in the licenses directory at the root of this repository, also available at * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. */ import React, { useState } from 'react' import { Button, Container, Layout } from '@wings-software/uicore' interface VerticalNavSubComponents { Option: React.FC<{ id: any; name: string; component: React.FC<any> }> } const Option: React.FC<{ id: any; name: string; component: React.FC<any> }> = () => <></> const VerticalNav: React.FC<{ initialTab: string; sharedProps?: any }> & VerticalNavSubComponents = ({ initialTab, children: rawChildren, sharedProps = {} }) => { const [selected, setSelected] = useState<string>(initialTab) const children = React.Children.toArray(rawChildren) const selectedChild = children.find((c: any) => c.props.id === selected) as JSX.Element const Comp = selectedChild.props.component return ( <Layout.Horizontal height="100%" width="100%"> <Layout.Vertical height="100%" spacing="medium" padding={{ top: 'xxxlarge', bottom: 'xxxlarge', left: 'xlarge', right: 'xlarge' }} style={{ backgroundColor: 'rgba(196,196,196,0.1)' }} > {children.map((child: any) => { const { id, name } = child.props return ( <Button large style={{ display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', color: `var(--${selected === id ? 'white' : 'black'})`, backgroundColor: `var(--${selected === id ? 'black-100' : 'transparent'})`, border: 'none' }} key={id} onClick={() => setSelected(id)} text={name} /> ) })} </Layout.Vertical> <Container width="100%"> <Comp {...sharedProps} /> </Container> </Layout.Horizontal> ) } VerticalNav.Option = Option export default VerticalNav |