-
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.
Merge pull request #1016 from greenriver/release-147
Release 147
- Loading branch information
Showing
30 changed files
with
433 additions
and
361 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,55 @@ | ||
import { Button } from '@mui/material'; | ||
import { ReactNode } from 'react'; | ||
|
||
type SkipToContentProps = { | ||
focusTargetId: string; | ||
children?: ReactNode; | ||
}; | ||
|
||
const SkipToContent: React.FC<SkipToContentProps> = ({ | ||
focusTargetId, | ||
children, | ||
}) => { | ||
const handleClick = () => { | ||
const container = document.getElementById(focusTargetId); | ||
if (container) { | ||
// First ensure the container is focusable | ||
if (!container.hasAttribute('tabindex')) { | ||
container.setAttribute('tabindex', '-1'); | ||
} | ||
container.focus({ preventScroll: true }); | ||
} | ||
}; | ||
|
||
return ( | ||
<Button | ||
variant='contained' | ||
onClick={handleClick} | ||
sx={{ | ||
// Use `clip` to hide the button when it isn't focused, without preventing focus entirely (which display:none and visibility:hidden would do) | ||
// `clip` is considered deprecated, but more widely supported than the more modern `clipPath` | ||
clip: 'rect(0 0 0 0)', | ||
clipPath: 'inset(50%)', | ||
|
||
// Remove padding, border, and margin | ||
padding: 0, | ||
margin: 0, | ||
border: 'none', | ||
position: 'absolute', // Ensure it doesn't take up any space | ||
|
||
'&:focus': { | ||
// On focus, restore clip and other styles so the button is visible and styled normally | ||
clip: 'auto', | ||
clipPath: 'none', | ||
position: 'relative', | ||
padding: '8px 16px', | ||
border: '1px solid', | ||
}, | ||
}} | ||
> | ||
{children || 'Skip to Content'} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default SkipToContent; |
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
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.