-
Notifications
You must be signed in to change notification settings - Fork 212
W-18672799 Chakra UI v3 header migration #2691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
0b589f5
92e1969
6343715
19655b9
6e98850
1057004
1b415cc
3799844
153f1f7
33e3709
20fd974
807fc9e
6c984c6
99726fb
dc3052e
b9402ec
299f7af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,23 +10,38 @@ import {Link as ChakraLink} from '@chakra-ui/react' | |
| import {Link as SPALink, NavLink as NavSPALink} from 'react-router-dom' | ||
| import useMultiSite from '../../hooks/use-multi-site' | ||
|
|
||
| const Link = React.forwardRef(({href, to, useNavLink = false, ...props}, ref) => { | ||
| const Link = React.forwardRef(({href, to, useNavLink = false, css, children, ...props}, ref) => { | ||
| const _href = to || href | ||
| const {buildUrl} = useMultiSite() | ||
| const updatedHref = buildUrl(_href) | ||
|
|
||
| const isActive = useNavLink | ||
| ? (_, location) => { | ||
| return location.pathname.endsWith(_href) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we have multi-site, so we only need check the last section of the pathname. |
||
| } | ||
| : undefined | ||
|
|
||
| return ( | ||
| <ChakraLink | ||
| as={useNavLink ? NavSPALink : SPALink} | ||
| {...(useNavLink && {exact: true})} | ||
| {...props} | ||
| to={updatedHref} | ||
| ref={ref} | ||
| /> | ||
| <ChakraLink asChild {...props} css={css} ref={ref}> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Chakra V3 advised to not use |
||
| {useNavLink ? ( | ||
| <NavSPALink to={updatedHref} isActive={isActive}> | ||
| {children} | ||
| </NavSPALink> | ||
| ) : ( | ||
| <SPALink to={updatedHref}>{children}</SPALink> | ||
| )} | ||
| </ChakraLink> | ||
| ) | ||
| }) | ||
|
|
||
| Link.displayName = 'Link' | ||
|
|
||
| Link.propTypes = {href: PropTypes.string, to: PropTypes.string, useNavLink: PropTypes.bool} | ||
| Link.propTypes = { | ||
| href: PropTypes.string, | ||
| to: PropTypes.string, | ||
| useNavLink: PropTypes.bool, | ||
| children: PropTypes.node, | ||
| css: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.array, PropTypes.string]) | ||
| } | ||
|
|
||
| export default React.memo(Link) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chakra link no longers at active class by default, we need to do it here and restyling the active class manually for account menu in the header