Skip to main content

CarouselItem

Struct CarouselItem 

Source
pub struct CarouselItem {
    pub image_src: String,
    pub image_alt: String,
    pub caption_title: Option<String>,
    pub caption_text: Option<String>,
    pub active: bool,
}
Expand description

A carousel slide item.

Fields§

§image_src: String§image_alt: String§caption_title: Option<String>§caption_text: Option<String>§active: bool

Implementations§

Source§

impl CarouselItem

Source

pub fn new(src: impl Into<String>, alt: impl Into<String>) -> Self

Create a new carousel item.

Examples found in repository?
examples/bootstrap_docs.rs (lines 651-654)
638fn carousel_section() -> Element<Section> {
639    Element::<Section>::new()
640        .attr("id", "carousel")
641        .class("mb-5")
642        .child::<H2, _>(|h| h.class("border-bottom pb-2").text("Carousel"))
643        .child::<P, _>(|p| {
644            p.class("lead")
645                .text("A slideshow component for cycling through elements.")
646        })
647        .child::<H4, _>(|h| h.class("mt-4").text("Basic Example"))
648        .child::<Div, _>(|d| {
649            d.class("bd-example mb-3").child::<Div, _>(|_| {
650                let items = vec![
651                    carousel::CarouselItem::new(
652                        "https://via.placeholder.com/800x400/007bff/ffffff?text=First+Slide",
653                        "First slide",
654                    )
655                    .active()
656                    .caption(
657                        "First slide label",
658                        "Some representative placeholder content.",
659                    ),
660                    carousel::CarouselItem::new(
661                        "https://via.placeholder.com/800x400/6c757d/ffffff?text=Second+Slide",
662                        "Second slide",
663                    )
664                    .caption("Second slide label", "Some more placeholder content."),
665                    carousel::CarouselItem::new(
666                        "https://via.placeholder.com/800x400/28a745/ffffff?text=Third+Slide",
667                        "Third slide",
668                    )
669                    .caption("Third slide label", "Even more placeholder content."),
670                ];
671                carousel::carousel_with_indicators("carouselExample", &items)
672            })
673        })
674}
Source

pub const fn active(self) -> Self

Mark this slide as active.

Examples found in repository?
examples/bootstrap_docs.rs (line 655)
638fn carousel_section() -> Element<Section> {
639    Element::<Section>::new()
640        .attr("id", "carousel")
641        .class("mb-5")
642        .child::<H2, _>(|h| h.class("border-bottom pb-2").text("Carousel"))
643        .child::<P, _>(|p| {
644            p.class("lead")
645                .text("A slideshow component for cycling through elements.")
646        })
647        .child::<H4, _>(|h| h.class("mt-4").text("Basic Example"))
648        .child::<Div, _>(|d| {
649            d.class("bd-example mb-3").child::<Div, _>(|_| {
650                let items = vec![
651                    carousel::CarouselItem::new(
652                        "https://via.placeholder.com/800x400/007bff/ffffff?text=First+Slide",
653                        "First slide",
654                    )
655                    .active()
656                    .caption(
657                        "First slide label",
658                        "Some representative placeholder content.",
659                    ),
660                    carousel::CarouselItem::new(
661                        "https://via.placeholder.com/800x400/6c757d/ffffff?text=Second+Slide",
662                        "Second slide",
663                    )
664                    .caption("Second slide label", "Some more placeholder content."),
665                    carousel::CarouselItem::new(
666                        "https://via.placeholder.com/800x400/28a745/ffffff?text=Third+Slide",
667                        "Third slide",
668                    )
669                    .caption("Third slide label", "Even more placeholder content."),
670                ];
671                carousel::carousel_with_indicators("carouselExample", &items)
672            })
673        })
674}
Source

pub fn caption(self, title: impl Into<String>, text: impl Into<String>) -> Self

Add a caption to this slide.

Examples found in repository?
examples/bootstrap_docs.rs (lines 656-659)
638fn carousel_section() -> Element<Section> {
639    Element::<Section>::new()
640        .attr("id", "carousel")
641        .class("mb-5")
642        .child::<H2, _>(|h| h.class("border-bottom pb-2").text("Carousel"))
643        .child::<P, _>(|p| {
644            p.class("lead")
645                .text("A slideshow component for cycling through elements.")
646        })
647        .child::<H4, _>(|h| h.class("mt-4").text("Basic Example"))
648        .child::<Div, _>(|d| {
649            d.class("bd-example mb-3").child::<Div, _>(|_| {
650                let items = vec![
651                    carousel::CarouselItem::new(
652                        "https://via.placeholder.com/800x400/007bff/ffffff?text=First+Slide",
653                        "First slide",
654                    )
655                    .active()
656                    .caption(
657                        "First slide label",
658                        "Some representative placeholder content.",
659                    ),
660                    carousel::CarouselItem::new(
661                        "https://via.placeholder.com/800x400/6c757d/ffffff?text=Second+Slide",
662                        "Second slide",
663                    )
664                    .caption("Second slide label", "Some more placeholder content."),
665                    carousel::CarouselItem::new(
666                        "https://via.placeholder.com/800x400/28a745/ffffff?text=Third+Slide",
667                        "Third slide",
668                    )
669                    .caption("Third slide label", "Even more placeholder content."),
670                ];
671                carousel::carousel_with_indicators("carouselExample", &items)
672            })
673        })
674}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.