-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Updated faults searching logic and added expandable nav link
Signed-off-by: Hrishav <[email protected]>
- Loading branch information
1 parent
a2bfe74
commit c92c4b3
Showing
9 changed files
with
138 additions
and
26 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
chaoscenter/web/src/components/NavExpandable/NavExpandable.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.main { | ||
z-index: 1; | ||
} | ||
|
||
.text { | ||
margin: var(--spacing-small) var(--spacing-small) var(--spacing-xsmall) var(--spacing-medium) !important; | ||
padding: var(--spacing-small) var(--spacing-medium) !important; | ||
color: var(--white) !important; | ||
opacity: 0.7; | ||
text-transform: uppercase; | ||
letter-spacing: 1px !important; | ||
cursor: pointer; | ||
|
||
span[class*='bp3-icon'] { | ||
color: inherit !important; | ||
} | ||
|
||
&:hover { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.border { | ||
margin: var(--spacing-small) var(--spacing-xlarge) var(--spacing-xsmall) var(--spacing-xxlarge) !important; | ||
border-top: 1px solid rgba(255, 255, 255, 0.1); | ||
} |
11 changes: 11 additions & 0 deletions
11
chaoscenter/web/src/components/NavExpandable/NavExpandable.module.scss.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
declare namespace NavExpandableModuleScssNamespace { | ||
export interface INavExpandableModuleScss { | ||
border: string; | ||
main: string; | ||
text: string; | ||
} | ||
} | ||
|
||
declare const NavExpandableModuleScssModule: NavExpandableModuleScssNamespace.INavExpandableModuleScss; | ||
|
||
export = NavExpandableModuleScssModule; |
66 changes: 66 additions & 0 deletions
66
chaoscenter/web/src/components/NavExpandable/NavExpandable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { useState } from 'react'; | ||
import cx from 'classnames'; | ||
import { useLocation, matchPath } from 'react-router-dom'; | ||
import { Layout, Text } from '@harnessio/uicore'; | ||
import type { IconName } from '@harnessio/icons'; | ||
import css from './NavExpandable.module.scss'; | ||
|
||
interface NavExpandableProps { | ||
title: string; | ||
route: string; | ||
className?: string; | ||
withoutBorder?: boolean; | ||
defaultExpanded?: boolean; | ||
} | ||
|
||
const NavExpandable: React.FC<React.PropsWithChildren<NavExpandableProps>> = ({ | ||
title, | ||
route, | ||
children, | ||
className, | ||
withoutBorder = false, | ||
defaultExpanded = false | ||
}) => { | ||
const [isExpanded, setIsExpanded] = useState<boolean>(defaultExpanded); | ||
const { pathname } = useLocation(); | ||
const isSelected = matchPath(pathname, route); | ||
const timerRef = React.useRef<number | null>(null); | ||
|
||
const handleMouseEvent = (val: boolean): void => { | ||
if (defaultExpanded) { | ||
return; | ||
} | ||
if (timerRef.current) window.clearTimeout(timerRef.current); | ||
timerRef.current = window.setTimeout(() => { | ||
setIsExpanded(val); | ||
}, 300); | ||
}; | ||
|
||
let rightIcon: IconName | undefined; | ||
if (!defaultExpanded) { | ||
rightIcon = isSelected || isExpanded ? 'chevron-up' : 'chevron-down'; | ||
} | ||
|
||
return ( | ||
<div> | ||
{!withoutBorder && <div className={css.border} />} | ||
<Layout.Vertical | ||
className={cx(className, css.main)} | ||
onMouseEnter={() => handleMouseEvent(true)} | ||
onMouseLeave={() => handleMouseEvent(false)} | ||
> | ||
<Text | ||
rightIcon={rightIcon} | ||
className={css.text} | ||
font="xsmall" | ||
flex={{ alignItems: 'flex-start', justifyContent: 'space-between' }} | ||
> | ||
{title} | ||
</Text> | ||
{isSelected || isExpanded ? children : null} | ||
</Layout.Vertical> | ||
</div> | ||
); | ||
}; | ||
|
||
export default NavExpandable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import NavExpandable from './NavExpandable'; | ||
|
||
export default NavExpandable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
chaoscenter/web/src/components/YAMLBuilder/YAMLBuilderConstants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters