File tree 6 files changed +85
-40
lines changed
6 files changed +85
-40
lines changed Original file line number Diff line number Diff line change 35
35
},
36
36
"peerDependencies" : {
37
37
"react" : " ^16.14.0" ,
38
- "react-dom" : " ^16.14.0"
38
+ "react-dom" : " ^16.14.0" ,
39
+ "react-router-dom" : " ^6.3.0"
39
40
},
40
41
"devDependencies" : {
41
42
"@babel/core" : " ^7.17.5" ,
82
83
"prettier" : " ^2.5.1" ,
83
84
"react" : " ^16.14.0" ,
84
85
"react-dom" : " ^16.14.0" ,
86
+ "react-router-dom" : " ^6.3.0" ,
85
87
"semantic-release" : " ^19.0.2" ,
86
88
"storybook-dark-mode" : " ^1.1.0" ,
87
89
"typescript" : " ^4.6.2" ,
Original file line number Diff line number Diff line change
1
+ import * as R from 'ramda' ;
1
2
import React , { FC } from 'react' ;
2
3
import { Button as RebassButton , ButtonProps } from 'rebass' ;
3
- import * as R from 'ramda' ;
4
4
5
5
// Styles
6
- import styles , { spinnerColor } from './button.styles ' ;
6
+ import { Link } from 'react-router-dom ' ;
7
7
import Spinner from '../spinner' ;
8
+ import styles , { spinnerColor } from './button.styles' ;
8
9
9
- import { GetIcon , IconName } from '../icon' ;
10
10
import { Color } from '../../theme/types' ;
11
+ import { GetIcon , IconName } from '../icon' ;
11
12
12
13
type Intent = 'primary' | 'secondary' | 'ghost' | 'inline' | 'alert' ;
13
14
export interface QuartzButtonProps extends Omit < ButtonProps , 'css' > {
@@ -27,6 +28,7 @@ const Button: FC<QuartzButtonProps> = ({
27
28
disabled,
28
29
isLoading,
29
30
loadingOnly,
31
+ target,
30
32
...props
31
33
} : QuartzButtonProps ) => {
32
34
const test = { ...props } ;
@@ -49,17 +51,16 @@ const Button: FC<QuartzButtonProps> = ({
49
51
50
52
if ( href ) {
51
53
return (
52
- < a
54
+ < Link
53
55
style = { {
54
56
textDecoration : 'none' ,
55
57
} }
56
- onClick = { ( e ) => {
57
- e . preventDefault ( ) ;
58
- } }
59
- href = { href }
58
+ to = { href }
59
+ target = { target }
60
+ { ...( target === '_blank' ? { rel : 'noopener noreferrer' } : { } ) }
60
61
>
61
62
{ component }
62
- </ a >
63
+ </ Link >
63
64
) ;
64
65
}
65
66
Original file line number Diff line number Diff line change 1
1
import React , { FC } from 'react' ;
2
2
import { Button as RebassButton , ButtonProps } from 'rebass' ;
3
+ import { Link } from 'react-router-dom' ;
3
4
4
5
// Components
5
6
import Tooltip , { TooltipProps } from '../tooltip' ;
6
7
7
- // Styles
8
+ import { getIcon , IconName } from '../icon/list' ;
8
9
import styles from './icon-button.styles' ;
9
- import { IconName , getIcon } from '../icon/list' ;
10
10
11
11
export interface IconButtonProps extends Omit < ButtonProps , 'css' > {
12
12
intent ?: 'primary' | 'ghost' | 'ghost-white' ;
@@ -26,6 +26,7 @@ const IconButton: FC<IconButtonProps> = ({
26
26
tooltipProps,
27
27
href,
28
28
onClickIcon,
29
+ target,
29
30
...props
30
31
} : IconButtonProps ) => {
31
32
let component ;
@@ -57,28 +58,20 @@ const IconButton: FC<IconButtonProps> = ({
57
58
58
59
if ( href ) {
59
60
return (
60
- < a
61
+ < Link
61
62
style = { {
62
63
textDecoration : 'none' ,
63
64
} }
64
65
onClick = { onClickIcon }
65
- href = { href }
66
+ to = { href }
67
+ target = { target }
68
+ { ...( target === '_blank' ? { rel : 'noopener noreferrer' } : { } ) }
66
69
>
67
70
{ component }
68
- </ a >
71
+ </ Link >
69
72
) ;
70
73
}
71
- return (
72
- < a
73
- style = { {
74
- textDecoration : 'none' ,
75
- } }
76
- onClick = { onClickIcon }
77
- href = { href }
78
- >
79
- { component }
80
- </ a >
81
- ) ;
74
+ return component ;
82
75
} ;
83
76
84
77
export default IconButton ;
Original file line number Diff line number Diff line change 1
- import { Box } from 'rebass ' ;
1
+ import * as R from 'ramda ' ;
2
2
import React , {
3
3
FC ,
4
4
memo ,
@@ -8,16 +8,17 @@ import React, {
8
8
useEffect ,
9
9
useMemo ,
10
10
} from 'react' ;
11
- import * as R from 'ramda' ;
11
+ import { Box } from 'rebass' ;
12
+ import { Link } from 'react-router-dom' ;
12
13
import { useTheme } from '../../../theme/theme' ;
13
14
14
15
// Context
15
16
import NavigationContext from '../context/navigation.context' ;
16
17
import { NavigationItemProps } from '../types' ;
17
18
// Styles
18
- import styles from './navigation-item.styles' ;
19
19
import Tooltip from '../../tooltip' ;
20
20
import TooltipPositions from '../../tooltip/positions' ;
21
+ import styles from './navigation-item.styles' ;
21
22
22
23
const getVariant = ( isDisabled = false , isActive = false ) : string => {
23
24
if ( isDisabled ) {
@@ -127,17 +128,15 @@ const NavigationItem: FC<NavigationItemProps> = (
127
128
} }
128
129
>
129
130
{ href ? (
130
- < a
131
+ < Link
131
132
style = { {
132
133
textDecoration : 'none' ,
133
134
} }
134
- onClick = { ( e ) => {
135
- e . preventDefault ( ) ;
136
- } }
137
- href = { href }
135
+ onClick = { ( e ) => e . stopPropagation ( ) }
136
+ to = { href }
138
137
>
139
138
{ component }
140
- </ a >
139
+ </ Link >
141
140
) : (
142
141
component
143
142
) }
Original file line number Diff line number Diff line change 1
1
import React , { FC } from 'react' ;
2
- import { Text , TextProps , Link , LinkProps } from 'rebass' ;
2
+ import { Link } from 'react-router-dom' ;
3
+ import { Text , TextProps , LinkProps , Link as RebassLink } from 'rebass' ;
3
4
4
5
export interface HoverableTextProps extends Omit < TextProps , 'css' > { }
5
6
export interface HoverableLinkProps extends Omit < LinkProps , 'css' > { }
@@ -20,10 +21,24 @@ export const HoverableText: FC<HoverableTextProps> = (
20
21
return < Text { ...props } variant = "title" sx = { sx } /> ;
21
22
} ;
22
23
23
- export const HoverableLink : FC < HoverableLinkProps > = (
24
- props : HoverableLinkProps ,
25
- ) => {
24
+ export const HoverableLink : FC < HoverableLinkProps > = ( {
25
+ href,
26
+ target,
27
+ ...props
28
+ } : HoverableLinkProps ) => {
26
29
let { sx } = { ...props } ;
27
30
sx = { ...sx , ...styles } ;
28
- return < Link { ...props } variant = "title" sx = { sx } /> ;
31
+
32
+ return (
33
+ < RebassLink
34
+ as = { Link }
35
+ { ...props }
36
+ // @ts -ignore
37
+ to = { href }
38
+ variant = "title"
39
+ sx = { sx }
40
+ target = { target }
41
+ { ...( target === '_blank' ? { rel : 'noopener noreferrer' } : { } ) }
42
+ />
43
+ ) ;
29
44
} ;
Original file line number Diff line number Diff line change @@ -2683,6 +2683,7 @@ __metadata:
2683
2683
react-codemirror2: ^7.2.1
2684
2684
react-datepicker: ^3.3.0
2685
2685
react-dom: ^16.14.0
2686
+ react-router-dom: ^6.3.0
2686
2687
react-spring: ^8.0.27
2687
2688
react-syntax-highlighter: ^15.4.3
2688
2689
rebass: ^4.0.7
@@ -2694,6 +2695,7 @@ __metadata:
2694
2695
peerDependencies:
2695
2696
react: ^16.14.0
2696
2697
react-dom: ^16.14.0
2698
+ react-router-dom: ^6.3.0
2697
2699
languageName: unknown
2698
2700
linkType: soft
2699
2701
@@ -12061,6 +12063,15 @@ __metadata:
12061
12063
languageName: node
12062
12064
linkType: hard
12063
12065
12066
+ "history@npm:^5.2.0":
12067
+ version: 5.3.0
12068
+ resolution: "history@npm:5.3.0"
12069
+ dependencies:
12070
+ "@babel/runtime": ^7.7.6
12071
+ checksum: d73c35df49d19ac172f9547d30a21a26793e83f16a78386d99583b5bf1429cc980799fcf1827eb215d31816a6600684fba9686ce78104e23bd89ec239e7c726f
12072
+ languageName: node
12073
+ linkType: hard
12074
+
12064
12075
"hmac-drbg@npm:^1.0.1":
12065
12076
version: 1.0.1
12066
12077
resolution: "hmac-drbg@npm:1.0.1"
@@ -18751,6 +18762,30 @@ __metadata:
18751
18762
languageName: node
18752
18763
linkType: hard
18753
18764
18765
+ "react-router-dom@npm:^6.3.0":
18766
+ version: 6.3.0
18767
+ resolution: "react-router-dom@npm:6.3.0"
18768
+ dependencies:
18769
+ history: ^5.2.0
18770
+ react-router: 6.3.0
18771
+ peerDependencies:
18772
+ react: ">=16.8"
18773
+ react-dom: ">=16.8"
18774
+ checksum: 77603a654f8a8dc7f65535a2e5917a65f8d9ffcb06546d28dd297e52adcc4b8a84377e0115f48dca330b080af2da3e78f29d590c89307094d36927d2b1751ec3
18775
+ languageName: node
18776
+ linkType: hard
18777
+
18778
+ "react-router@npm:6.3.0":
18779
+ version: 6.3.0
18780
+ resolution: "react-router@npm:6.3.0"
18781
+ dependencies:
18782
+ history: ^5.2.0
18783
+ peerDependencies:
18784
+ react: ">=16.8"
18785
+ checksum: 7be673f5e72104be01e6ab274516bdb932efd93305243170690f6560e3bd1035dd1df3d3c9ce1e0f452638a2529f43a1e77dcf0934fc8031c4783da657be13ca
18786
+ languageName: node
18787
+ linkType: hard
18788
+
18754
18789
"react-spring@npm:^8.0.27":
18755
18790
version: 8.0.27
18756
18791
resolution: "react-spring@npm:8.0.27"
You can’t perform that action at this time.
0 commit comments