diff options
Diffstat (limited to 'src/name.rs')
-rw-r--r-- | src/name.rs | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/name.rs b/src/name.rs index bf91186..4b51def 100644 --- a/src/name.rs +++ b/src/name.rs @@ -1,4 +1,6 @@ use yew::prelude::*; +use vcard::properties; +use vcard::values::{self, text}; #[derive(Clone)] pub struct Name { @@ -44,6 +46,32 @@ impl Name { formatted_name } + pub fn to_vcard_name(&self) -> properties::Name { + let name_value = values::name_value::NameValue::from_components( + match self.last_name.is_empty() { + true => None, + false => Some(text::Component::from_str(&self.last_name).unwrap()), + }, + match self.first_name.is_empty() { + true => None, + false => Some(text::Component::from_str(&self.first_name).unwrap()), + }, + match self.middle_name.is_empty() { + true => None, + false => Some(text::Component::from_str(&self.middle_name).unwrap()), + }, + match self.prefix.is_empty() { + true => None, + false => Some(text::Component::from_str(&self.prefix).unwrap()), + }, + match self.suffix.is_empty() { + true => None, + false => Some(text::Component::from_str(&self.suffix).unwrap()), + }, + ); + + properties::Name::from_name_value(name_value) + } } pub struct NameView { @@ -94,12 +122,12 @@ impl Component for NameView { } fn view(&self) -> yew::virtual_dom::VNode { html!{ - <> + <div class="box"> <h3 class="subtitle">{ "Name" }</h3> - <div class="columns"> + <div class="columns is-mobile is-multiline"> - <div class="field column"> + <div class="field column is-one-fifth-widescreen is-one-quarter-desktop is-one-third-tablet is-half-mobile"> <label class="label">{ "Prefix" }</label> <div class="control"> <input id="prefix" @@ -110,7 +138,7 @@ impl Component for NameView { </div> </div> - <div class="field column"> + <div class="field column is-one-fifth-widescreen is-one-quarter-desktop is-one-third-tablet is-half-mobile"> <label class="label">{ "First name" }</label> <div class="control"> <input id="first_name" @@ -121,7 +149,7 @@ impl Component for NameView { </div> </div> - <div class="field column"> + <div class="field column is-one-fifth-widescreen is-one-quarter-desktop is-one-third-tablet is-half-mobile"> <label class="label">{ "Middle name" }</label> <div class="control"> <input id="middle_name" @@ -132,7 +160,7 @@ impl Component for NameView { </div> </div> - <div class="field column"> + <div class="field column is-one-fifth-widescreen is-one-quarter-desktop is-one-third-tablet is-half-mobile"> <label class="label">{ "Last name" }</label> <div class="control"> <input id="last_name" @@ -143,7 +171,7 @@ impl Component for NameView { </div> </div> - <div class="field column"> + <div class="field column is-one-fifth-widescreen is-one-quarter-desktop is-one-third-tablet is-half-mobile"> <label class="label">{ "Suffix" }</label> <div class="control"> <input id="suffix" @@ -155,7 +183,7 @@ impl Component for NameView { </div> </div> - </> + </div> } } }
\ No newline at end of file |