Skip to content

Commit

Permalink
DRY: boostrap version
Browse files Browse the repository at this point in the history
  • Loading branch information
isosphere committed Jun 19, 2024
1 parent b9e4863 commit cb5d66c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/yew-bootstrap/src/icons/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,14 @@ pub struct BIFiles {
pub license: &'static str,
}

impl BIFiles {
/// Version of the package.
pub const VERSION: &'static str = "v1.11.3";
/// allows compile time concatenation with other strings to make const 'static str
macro_rules! version { () => ( "v1.11.3" ) }
/// provides a resuable path to the bootstrap-icons files that we can make const 'static str with
macro_rules! path { () => ( concat!("../../bootstrap-icons-", version!(), "/") ) }

impl BIFiles {
/// Name of the package.
pub const NAME: &'static str = "bootstrap-icons-v1.11.3";
pub const NAME: &'static str = concat!("bootstrap-icons-", version!());

/// All bootstrap-icons files.
///
Expand All @@ -221,10 +223,10 @@ impl BIFiles {
/// ```
/// (That way it will be an error if a file is added/removed.)
pub const FILES: Self = Self {
css: include_str!("../../bootstrap-icons-v1.11.3/bootstrap-icons.css"),
font_woff: include_bytes!("../../bootstrap-icons-v1.11.3/fonts/bootstrap-icons.woff"),
font_woff2: include_bytes!("../../bootstrap-icons-v1.11.3/fonts/bootstrap-icons.woff2"),
license: include_str!("../../bootstrap-icons-v1.11.3/fonts/LICENSE"),
css: include_str!(concat!(path!(), "bootstrap-icons.css")),
font_woff: include_bytes!(concat!(path!(), "fonts/bootstrap-icons.woff")),
font_woff2: include_bytes!(concat!(path!(), "fonts/bootstrap-icons.woff2")),
license: include_str!(concat!(path!(), "fonts/LICENSE")),
};

/// Load the bootstrap-icons files from the official cdn.
Expand All @@ -233,7 +235,11 @@ impl BIFiles {
pub const fn cdn() -> VNode {
VNode::VRaw(VRaw {
html: AttrValue::Static(
r#"<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">"#,
concat!(
r#"<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@"#,
version!(),
r#"/font/bootstrap-icons.css">"#
),
),
})
}
Expand Down

0 comments on commit cb5d66c

Please sign in to comment.