pub struct Octicon { /* private fields */ }
Expand description
Structure for Octicon configuration.
Implementations§
source§impl Octicon
impl Octicon
sourcepub fn width<'a>(&'a mut self, width: usize) -> &'a mut Octicon
pub fn width<'a>(&'a mut self, width: usize) -> &'a mut Octicon
Set the width attribute of the <svg>
element. The height attribute will not be scaled
automatically.
let dash = format!("{}", DASH.clone().width(32));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="32" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
sourcepub fn height<'a>(&'a mut self, height: usize) -> &'a mut Octicon
pub fn height<'a>(&'a mut self, height: usize) -> &'a mut Octicon
Set the height attribute of the <svg>
element. The width attribute will not be scaled
automatically.
let dash = format!("{}", DASH.clone().height(48));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="48" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
sourcepub fn class<'a>(&'a mut self, class: Option<&'static str>) -> &'a mut Octicon
pub fn class<'a>(&'a mut self, class: Option<&'static str>) -> &'a mut Octicon
Set the class attribute of the <svg>
element. To prevent the attribute from being
rendered, set it to None
.
let dash = format!("{}", DASH.clone().class(None));
let expected = r#"<svg version="1.1" aria-hidden="true" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
let dash = format!("{}", DASH.clone().class(Some("left right")));
let expected = r#"<svg version="1.1" aria-hidden="true" class="left right" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
sourcepub fn fill<'a>(&'a mut self, fill: Option<&'static str>) -> &'a mut Octicon
pub fn fill<'a>(&'a mut self, fill: Option<&'static str>) -> &'a mut Octicon
Set the fill attribute of the <svg>
. To prevent the attribute from being rendered, set it
to None
.
let dash = format!("{}", DASH.clone().fill(None));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
let dash = format!("{}", DASH.clone().fill(Some("#ff0")));
let expected = r##"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" fill="#ff0" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);
sourcepub fn xmlns<'a>(&'a mut self, xmlns: Option<&'static str>) -> &'a mut Octicon
pub fn xmlns<'a>(&'a mut self, xmlns: Option<&'static str>) -> &'a mut Octicon
Set the xmlns attribute of the <svg>
. To prevent the attribute from being rendered, set it
to None
. NOTE: the xmlns attribute is required by some browsers if the svg is served
alone. If the svg element will be part of an HTML document then you can omit the xmlns
attribute.
let dash = format!("{}", DASH.clone().xmlns(None));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
let dash = format!("{}", DASH.clone().xmlns(Some("http://www.w3.org/2000/svg")));
let expected = r##"<svg xmlns="http://www.w3.org/2000/svg" version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);
sourcepub fn version<'a>(
&'a mut self,
version: Option<&'static str>
) -> &'a mut Octicon
pub fn version<'a>( &'a mut self, version: Option<&'static str> ) -> &'a mut Octicon
Set the version attribute of the <svg>
. To prevent the attribute from being rendered, set it
to None
.
NOTE: the version attribute is apparently ignored by every user agent. If you want to save
some bandwidth you are probably safe omitting it until the release of further major
versions.
let dash = format!("{}", DASH.clone().version(None));
let expected = r#"<svg aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
let dash = format!("{}", DASH.clone().version(Some("1.1")));
let expected = r##"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);
sourcepub fn aria_label<'a>(
&'a mut self,
aria_label: Option<&'static str>
) -> &'a mut Octicon
pub fn aria_label<'a>( &'a mut self, aria_label: Option<&'static str> ) -> &'a mut Octicon
Set an aria-label on the <svg>
. To prevent the attribute from being rendered, set it
to None
. If the aria-label is set, then the aria-hidden attribute is not rendered
regardless of its value. Additionally the role attribute will be set to img.
let dash = format!("{}", DASH.clone().aria_label(None));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
let dash = format!("{}", DASH.clone().aria_label(Some("dash")));
let expected = r##"<svg version="1.1" aria-label="dash" role="img" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);
Set an aria-hidden attribute on the <svg>
. To prevent the attribute from being rendered, set it
to false. If the aria-label is set, then the aria-hidden attribute is not rendered
regardless of its value.
let dash = format!("{}", DASH.clone().aria_hidden(false));
let expected = r#"<svg version="1.1" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
let dash = format!("{}", DASH.clone().aria_hidden(true));
let expected = r##"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);