Skip to content

Commit

Permalink
simpler version - no need for link props
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnMarieW committed Dec 31, 2023
1 parent dbd7e9b commit 0331986
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
38 changes: 0 additions & 38 deletions src/components/carousel/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,9 @@ const Carousel = props => {
} = props;

const slides = items.map(item => {
// note - the default 'd-block w-100' is from the examples in the Bootstrap docs.
item.imgClassName =
typeof item.imgClassName !== 'undefined'
? item.imgClassName
: 'd-block w-100';

const useLink = item.href && true;
const additionalProps = useLink
? {
href: item.href,
external_link: item.external_link,
target: item.target || '_self'
}
: {};

return (
<RBCarousel.Item
key={item.key}
as={item.href ? Link : 'div'}
{...additionalProps}
>
{item.children}
<RBCarousel.Caption>
Expand Down Expand Up @@ -125,27 +108,6 @@ Carousel.propTypes = {
* The slide caption
*/
caption: PropTypes.node,

/**
* Optional hyperlink to add to the item. Item will be rendered as a
* HTML <a> or as a Dash-style link depending on whether the link is
* deemed to be internal or external. Override this automatic detection
* with the external_link argument.
*/
href: PropTypes.string,
/**
* Optional target attribute for the link. Only applies if `href` is set, default `_self`.
*/
target: PropTypes.string,
/**
* If true, the browser will treat this as an external link,
* forcing a page refresh at the new location. If false,
* this just changes the location without triggering a page
* refresh. Use this if you are observing dcc.Location, for
* instance. Defaults to true for absolute URLs and false
* otherwise.
*/
external_link: PropTypes.bool
})
).isRequired,

Expand Down
2 changes: 2 additions & 0 deletions usage_carousel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
className="border",
style={"height": 800, "padding": 100},
)
slide5= dbc.NavLink(html.Img(src=slide1, width="100%"), href="/home")

carousel = dbc.Carousel(
items = [
Expand All @@ -33,6 +34,7 @@
"caption": html.H1("Hi Again", className="text-primary"),
},
{"key": "4", "children": slide4, "caption": "Slide 4 caption"},
{"key": "5", "children": slide5, "caption": "Slide with link"},
],
interval=2000,
ride="carousel",
Expand Down

0 comments on commit 0331986

Please sign in to comment.