DWKOK3CPTRVTLGADW6AC6V3RBQ4ZYAPSWGV7JVORPQ272L2WNH4AC
let capital_chars: Vec<_> = name.chars().filter(|c| c.is_uppercase()).collect();
if !capital_chars.is_empty() {
capital_chars[..2].into_iter().flat_map(|c| c.to_uppercase()).collect()
let capital_chars: Vec<_> =
name.chars().enumerate().filter(|(_, c)| c.is_uppercase()).collect();
if !capital_chars.is_empty() && capital_chars.iter().any(|(idx, _)| *idx == 0) {
capital_chars
.into_iter()
.take(2)
.into_iter()
.flat_map(|(_, c)| c.to_uppercase())
.collect()
name[..2].chars().into_iter().collect::<String>().to_upper_camel_case()
let tag: String = name.chars().take(2).into_iter().collect();
// Only switch casing if *all* letters of the name were lowercase
if name.chars().all(|c| c.is_lowercase()) {
tag.to_upper_camel_case()
} else {
tag
}
Some(Err(e)) => "><".to_string(),
Some(Err(_)) => "><".to_string(),
})
};
let username = move || {
user_status.with(|status| match status {
None | Some(Err(_)) => None,
Some(Ok(status)) => match status {
UserStatus::Anonymous => None,
UserStatus::LoggedIn { username, code } => Some(format!("{username}#{code}")),
},
ul tabindex=0 class="mt-3 z-[1] p-2 shadow menu menu-sm dropdown-content bg-base-200 rounded-box w-52" {
li { p { "apple"}}
ul tabindex=0 class="mt-2 z-[1] p-2 shadow menu menu-sm dropdown-content bg-base-200 rounded-box w-60" {
[match username() {
Some(username) => mview! {
li class="menu-title" { f["Logged in as {username}"] }
li {
button on:click={move |_| sign_out.dispatch(())} {
"Sign out"
}
}
}.into_view(),
None => mview! {
li { A href="login" { "Log in" } }
}.into_view()
}]
input type="password" id="password" name="password" class="input input-bordered w-full max-w-xs" class: input-error={login_form_has_error};
button type="submit" {
input type="password" id="password" name="password" class="input input-bordered w-full" class: input-error={login_form_has_error};
button type="submit" class="btn btn-block" {
div class="flex items-center justify-between w-full max-w-xs" {
f["Logged in as {display_name}"]
button class="btn" on:click={move |_| log_out.dispatch(())} {
div class="my-2 space-y-4 w-full" {
div class="text-center" {
f["Logged in as {display_name}"]
}
button class="btn btn-block" on:click={move |_| log_out.dispatch(())} {
input type="username" name="username" id="username" prop:value=[username.get()] class="input input-bordered w-full max-w-xs" on:input={move |ev| set_username.set(event_target_value(&ev))}
input type="username" name="username" id="username" prop:value=[username.get()] class="input input-bordered w-full" on:input={move |ev| set_username.set(event_target_value(&ev))}
input type="email" name="email" id="email" prop:value=[email.get()] class="input input-bordered w-full max-w-xs" on:input={move |ev| set_email.set(event_target_value(&ev))}
input type="email" name="email" id="email" prop:value=[email.get()] class="input input-bordered w-full" on:input={move |ev| set_email.set(event_target_value(&ev))}
input type="password" id="password" name="password" prop:value=[password.get()] class="input input-bordered w-full max-w-xs" on:input={move |ev| set_password.set(event_target_value(&ev))}
input type="password" id="password" name="password" prop:value=[password.get()] class="input input-bordered w-full" on:input={move |ev| set_password.set(event_target_value(&ev))}
div class="form-control max-w-xs" {
label class="label cursor-pointer" {
span class="label-text" { f["{:?}", mode.get()] }
input type="checkbox" class="toggle" prop:checked=[mode.get() == LoginViewMode::Signup] on:input={move |ev| if event_target_checked(&ev) {
set_mode.set(LoginViewMode::Signup)
} else {
set_mode.set(LoginViewMode::Login)
}};
div class="max-w-xs mx-auto flex flex-col mt-4" {
div class="form-control" {
button class="btn btn-neutral bg-base-100 hover:bg-base-100 border-transparent" on:click={move |_| {
set_mode.set(match mode.get() {
LoginViewMode::Signup => LoginViewMode::Login,
LoginViewMode::Login => LoginViewMode::Signup,
});
}} {
f["{}",
match mode.get() {
LoginViewMode::Signup => "Sign Up",
LoginViewMode::Login => "Log In",
}
]
}