-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [CGC-34] Change to DHIS2 UI (#58)
- Loading branch information
Showing
13 changed files
with
846 additions
and
180 deletions.
There are no files selected for viewing
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
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
69 changes: 50 additions & 19 deletions
69
src/components/GrowthChart/ChartSettingsButton/EllipsisButton/EllipsisButton.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 |
---|---|---|
@@ -1,22 +1,53 @@ | ||
import React from 'react'; | ||
import { Ellipsis } from '../../../../UI/Icons'; | ||
import React, { useState, useRef, ReactNode } from 'react'; | ||
import { Button, Layer, Popper, FlyoutMenu, IconMore16 } from '@dhis2/ui'; | ||
|
||
type EllipsisButtonProps = { | ||
onClick: () => void; | ||
isVisible: boolean; | ||
setReferenceElement: (element: HTMLButtonElement | null) => void; | ||
type Props = { | ||
primary?: boolean; | ||
secondary?: boolean; | ||
dataTest?: string; | ||
small?: boolean; | ||
large?: boolean; | ||
children: ReactNode; | ||
}; | ||
|
||
export const EllipsisButton = ({ onClick, isVisible, setReferenceElement }: EllipsisButtonProps): JSX.Element => ( | ||
<button | ||
type='button' | ||
aria-label='Chart settings' | ||
onClick={onClick} | ||
ref={setReferenceElement} | ||
className='flex items-center absolute right-[55px] justify-center w-7 h-7 rounded border | ||
text-gray-600 hover:bg-gray-300 hover:text-gray-700' | ||
style={isVisible ? { border: '1px solid black' } : {}} | ||
> | ||
<Ellipsis /> | ||
</button> | ||
); | ||
export const EllipsisButton = ({ | ||
primary, | ||
secondary, | ||
small, | ||
large, | ||
dataTest, | ||
children, | ||
}: Props) => { | ||
const anchorRef = useRef(null); | ||
const [actionsIsOpen, setActionsIsOpen] = useState(false); | ||
|
||
const toggle = () => { | ||
setActionsIsOpen((prev) => !prev); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div ref={anchorRef}> | ||
{/* @ts-ignore */} | ||
<Button | ||
primary={primary} | ||
secondary={secondary} | ||
dataTest={dataTest} | ||
small={small} | ||
large={large} | ||
onClick={toggle} | ||
icon={<IconMore16 />} | ||
/> | ||
</div> | ||
{actionsIsOpen && ( | ||
<Layer onBackdropClick={toggle}> | ||
<Popper reference={anchorRef} placement='bottom-end'> | ||
<FlyoutMenu dense> | ||
{children} | ||
</FlyoutMenu> | ||
</Popper> | ||
</Layer> | ||
)} | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.