forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloatingMenuLink.js
More file actions
37 lines (34 loc) · 847 Bytes
/
FloatingMenuLink.js
File metadata and controls
37 lines (34 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react'
import { Link, Text } from '@chakra-ui/react'
import { Link as RouteLink } from 'react-router-dom'
import { bool, string } from 'prop-types'
export const FloatingMenuLink = ({ to, text, isExternal, ...props }) => {
// isExternal will change the type of element required (external vs react-router link)
let linkType
if (isExternal) {
linkType = Link
} else {
linkType = RouteLink
}
return (
<Link
as={linkType}
to={to}
href={to}
ml="auto"
isExternal={isExternal}
_active={{ bg: 'accent' }}
_focus={{ outline: 'none' }}
{...props}
>
<Text fontWeight="bold" color="white" fontSize="lg">
{text}
</Text>
</Link>
)
}
FloatingMenuLink.propTypes = {
to: string.isRequired,
text: string.isRequired,
isExternal: bool,
}