@@ -11,6 +11,7 @@ import { FeaturedLink } from '../../patterns/blocks/FeaturedLink';
11
11
import { LinkWithIcon } from '../LinkWithIcon' ;
12
12
import PropTypes from 'prop-types' ;
13
13
import React from 'react' ;
14
+ import { smoothScrolling } from '@carbon/ibmdotcom-utilities' ;
14
15
15
16
/**
16
17
* CTA component
@@ -28,26 +29,14 @@ const CTA = ({ style, type, ...cta }) => {
28
29
< CardLink
29
30
{ ...cta }
30
31
icon = { iconSelector ( type ) }
31
- onClick = {
32
- type === 'jump'
33
- ? e => {
34
- smoothScrolling ( e , cta . id ) ;
35
- }
36
- : null
37
- }
32
+ onClick = { type === 'jump' ? smoothScrolling : null }
38
33
/>
39
34
) ;
40
35
case 'button' :
41
36
return (
42
37
< ButtonGroup
43
38
buttons = { renderButtons ( cta ) }
44
- onClick = {
45
- type === 'jump'
46
- ? e => {
47
- smoothScrolling ( e , cta . id ) ;
48
- }
49
- : null
50
- }
39
+ onClick = { type === 'jump' ? smoothScrolling : null }
51
40
/>
52
41
) ;
53
42
case 'feature' :
@@ -57,33 +46,14 @@ const CTA = ({ style, type, ...cta }) => {
57
46
< LinkWithIcon
58
47
href = { cta . href }
59
48
target = { type === 'external' ? '_blank' : null }
60
- onClick = {
61
- type === 'jump'
62
- ? e => {
63
- smoothScrolling ( e , cta . id ) ;
64
- }
65
- : null
66
- } >
49
+ onClick = { type === 'jump' ? smoothScrolling : null } >
67
50
{ cta . copy }
68
51
{ iconSelector ( type ) }
69
52
</ LinkWithIcon >
70
53
) ;
71
54
}
72
55
} ;
73
56
74
- /**
75
- * Handle OnClick
76
- *
77
- * @param {* } e event object
78
- * @param {* } id element id
79
- */
80
- const smoothScrolling = ( e , id ) => {
81
- e . preventDefault ( ) ;
82
- document . querySelector ( `[id="${ id } "]` ) . scrollIntoView ( {
83
- behavior : 'smooth' ,
84
- block : 'start' ,
85
- } ) ;
86
- } ;
87
57
/**
88
58
* TEMPORARY sets icon based on link type
89
59
*
0 commit comments