-
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.
Update Project Household Enrollments table with new designs (#989)
* Update Project Enrollment tables * fix a11y * More accessibility fixes * Simplify and resolve todos * Add storybook story * Remove errant comment * Add comments * Update api of TableRowActions * Fix issue with fulColSpan * Right-align table row actions Co-authored-by: Gig <[email protected]> * Remove comment * Replace overrideTableBody with more understandable API * Implement PR suggestion of moving table row to column def * Cleanup and add comments * Port over relevant changes from other PR * Refactor to use renderCellContents * Revert out-of-scope change * Add todo * Remove circular dependency * Clean up * Centralize action column base attrs * PR feedback * Fix typescript problems * Implement Table Actions pattern and default columns (#998) * Implement Table Actions pattern and default columns * Add random comment * Add storybook for table actions and fix cde story * Implement PR suggestion of moving table row to column def * add todo * Finish refactor to use column def instead of getTableAction * Fix bulk services loading * Provide a visually hidden header when header isnt provided * Keep existing behavior of individual/household assessment viewing * Fix typescript * Add accessible text for RelativeDateDisplay * implement one possible approach for client ID typescript * Remove unnecessary cast --------- Co-authored-by: Gig Ashton <[email protected]>
- Loading branch information
Showing
47 changed files
with
1,687 additions
and
1,068 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
Box, | ||
Tooltip, | ||
TooltipProps, | ||
Typography, | ||
TypographyProps, | ||
} from '@mui/material'; | ||
import { visuallyHidden } from '@mui/utils'; | ||
import { useMemo } from 'react'; | ||
|
||
import { getFormattedDates } from './RelativeDateDisplay'; | ||
|
||
export interface DateWithRelativeTooltipProps { | ||
dateString: string; | ||
preciseTime?: boolean; | ||
TooltipProps?: Omit<TooltipProps, 'title' | 'children'>; | ||
TypographyProps?: TypographyProps; | ||
} | ||
|
||
/** | ||
* Date with relative date as tooltip | ||
*/ | ||
const DateWithRelativeTooltip = ({ | ||
dateString, | ||
preciseTime = false, | ||
TooltipProps = {}, | ||
TypographyProps = {}, | ||
}: DateWithRelativeTooltipProps) => { | ||
const [formattedDate, formattedDateRelative] = useMemo( | ||
() => getFormattedDates(dateString, preciseTime), | ||
[dateString, preciseTime] | ||
); | ||
|
||
if (!dateString || !formattedDate || !formattedDateRelative) return null; | ||
|
||
return ( | ||
<Tooltip | ||
title={ | ||
<Typography component='span' variant='inherit'> | ||
{formattedDateRelative} | ||
</Typography> | ||
} | ||
arrow | ||
{...TooltipProps} | ||
> | ||
<Typography | ||
component='span' | ||
variant='inherit' | ||
{...TypographyProps} | ||
sx={{ | ||
cursor: 'pointer', | ||
...TypographyProps.sx, | ||
}} | ||
> | ||
{formattedDate} | ||
{/* Include the tooltip text as visually hidden for accessibility */} | ||
<Box sx={visuallyHidden}>, {formattedDateRelative}</Box> | ||
</Typography> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export default DateWithRelativeTooltip; |
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.