From 104f70b0968d7138d6cf944da98d95a405b1a049 Mon Sep 17 00:00:00 2001 From: jelemux Date: Wed, 11 Nov 2020 23:28:29 +0100 Subject: add addresses, generate name, improve responsiveness --- src/name.rs | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'src/name.rs') 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!{ - <> +

{ "Name" }

-
+
-
+
-
+
-
+
-
+
-
+
- +
} } } \ No newline at end of file -- cgit v1.2.3