yew_bootstrap/util/
include.rs

1use crate::icons::BIFiles;
2use yew::{html, virtual_dom::VNode};
3
4/// Links to the Bootstrap CSS CDN
5pub fn include_cdn() -> VNode {
6    html! {
7        <link
8            href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
9            rel="stylesheet"
10            integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
11            crossorigin="anonymous"
12        />
13    }
14}
15
16/// Links to the Bootstrap JS CDN, including the map file which must be explicitly mentioned for Trunk to copy it
17pub fn include_cdn_js() -> VNode {
18    html! {
19        <>
20            <link data-trunk={"true"} rel="copy-file" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js.map" />
21            <script
22                src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
23                data-trunk={"true"}
24                integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
25                crossorigin="anonymous"
26            >
27            </script>
28        </>
29    }
30}
31
32/// Inserts the bootstrap CSS directly into the content of the page
33pub fn include_inline() -> VNode {
34    html! {
35        <style>
36            {include_str!("bootstrap-5.1.3.min.css")}
37        </style>
38    }
39}
40
41
42/// Include the Bootstrap Icons CDN
43#[inline(always)]
44#[deprecated = "Use icons::BIFiles::cdn() instead"]
45pub fn include_cdn_icons() -> VNode {
46    BIFiles::cdn()
47}