@@ -4,6 +4,8 @@ import {omit} from 'ramda';
4
4
5
5
import RBCarousel from 'react-bootstrap/Carousel' ;
6
6
7
+ import Link from '../../private/Link' ;
8
+
7
9
/**
8
10
* Component for creating Bootstrap carousel. This component is a slideshow
9
11
* for cycling through a series of content.
@@ -28,12 +30,15 @@ const Carousel = props => {
28
30
? item . imgClassName
29
31
: 'd-block w-100' ;
30
32
31
- const additionalProps = item . href ? { href : item . href } : { } ;
33
+ const useLink = item . href && true ;
34
+ const additionalProps = useLink
35
+ ? { href : item . href , external_link : item . external_link }
36
+ : { } ;
32
37
33
38
return (
34
39
< RBCarousel . Item
35
40
key = { item . key }
36
- as = { item . href ? 'a' : 'div' }
41
+ as = { item . href ? Link : 'div' }
37
42
{ ...additionalProps }
38
43
>
39
44
< img
@@ -156,9 +161,21 @@ Carousel.propTypes = {
156
161
*/
157
162
captionClassName : PropTypes . string ,
158
163
/**
159
- * Optional hyperlink to add to the item.
164
+ * Optional hyperlink to add to the item. Item will be rendered as a
165
+ * HTML <a> or as a Dash-style link depending on whether the link is
166
+ * deemed to be internal or external. Override this automatic detection
167
+ * with the external_link argument.
168
+ */
169
+ href : PropTypes . string ,
170
+ /**
171
+ * If true, the browser will treat this as an external link,
172
+ * forcing a page refresh at the new location. If false,
173
+ * this just changes the location without triggering a page
174
+ * refresh. Use this if you are observing dcc.Location, for
175
+ * instance. Defaults to true for absolute URLs and false
176
+ * otherwise.
160
177
*/
161
- href : PropTypes . string
178
+ external_link : PropTypes . bool
162
179
} )
163
180
) . isRequired ,
164
181
0 commit comments