-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from Kodylow/tailwind-stuff
Tailwind improvements
- Loading branch information
Showing
13 changed files
with
144 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use leptos::*; | ||
|
||
use crate::components::SubmitForm; | ||
use crate::utils::empty_view; | ||
|
||
#[component] | ||
pub fn CreateWallet<F>(on_select: F) -> impl IntoView | ||
where | ||
F: Fn(String) + 'static + Copy, | ||
{ | ||
let (loading, set_loading) = create_signal(false); | ||
let (show_create_wallet_form, set_show_create_wallet_form) = create_signal(false); | ||
let select = move |name: String| { | ||
set_loading.set(true); | ||
on_select(name); | ||
}; | ||
|
||
view! { | ||
<div class="flex justify-center"> | ||
<Show when=move || !show_create_wallet_form.get() fallback=|| empty_view() > | ||
<button | ||
class="mt-4 px-4 py-2 bg-blue-500 text-white font-bold rounded hover:bg-blue-700 focus:outline-none focus:shadow-outline min-w-[200px]" | ||
on:click=move |_| { | ||
set_show_create_wallet_form.set(true); | ||
} | ||
> | ||
"Create a new wallet" | ||
</button> | ||
</Show> | ||
<Show when=move || show_create_wallet_form.get() fallback=|| empty_view() > | ||
<SubmitForm | ||
description="Enter a name for the new wallet".into() | ||
on_submit=move |name| { | ||
set_show_create_wallet_form.set(false); | ||
select(name); | ||
} | ||
placeholder="Wallet Name".into() | ||
submit_label="Create".into() | ||
loading=loading | ||
/> | ||
</Show> | ||
</div> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,61 @@ | ||
use leptos::*; | ||
|
||
use super::{NoteBlock, SubmitForm, WarningBlock}; | ||
use super::{NoteBlock, WarningBlock}; | ||
use crate::utils::empty_view; | ||
|
||
#[component] | ||
pub fn WalletSelector<F>(available: Vec<String>, on_select: F) -> impl IntoView | ||
where | ||
F: Fn(String) + 'static + Copy, | ||
{ | ||
let (loading, set_loading) = create_signal(false); | ||
let (_, set_loading) = create_signal(false); | ||
let select = move |name: String| { | ||
set_loading.set(true); | ||
on_select(name); | ||
}; | ||
|
||
let available_clone = available.clone(); | ||
let wallets_available = move || available_clone.len() > 0; | ||
|
||
const MAX_NAME_LEN: usize = 20; | ||
|
||
let available_list = available | ||
.into_iter() | ||
.map(|name| { | ||
let select_name = name.clone(); | ||
let abbreviated_name = if name.len() > MAX_NAME_LEN { | ||
let part_len = MAX_NAME_LEN / 2 - 1; | ||
format!("{}...{}", &name[..part_len], &name[name.len() - part_len..]) | ||
} else { | ||
name.clone() | ||
}; | ||
view! { | ||
<li> | ||
<a | ||
class="text-xl underline" | ||
href="#" | ||
<button | ||
class="px-4 w-4/5 py-2 bg-blue-400 text-white font-bold rounded hover:bg-blue-700 focus:outline-none focus:shadow-outline min-w-[200px]" | ||
on:click=move |ev| { | ||
ev.prevent_default(); | ||
select(select_name.clone()); | ||
} | ||
> | ||
{name} | ||
</a> | ||
</li> | ||
{abbreviated_name} | ||
</button> | ||
} | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
view! { | ||
<NoteBlock class="mb-8"> | ||
<NoteBlock class="mb-8"> | ||
"To switch wallets after selecting one just reload the web app." | ||
</NoteBlock> | ||
<WarningBlock class="mb-8"> | ||
"Webimint is a highly experimental Fedimint wallet, use at your own risk. | ||
It's currently compatible with the 0.2 release of Fedimint." | ||
"Webimint is a highly experimental Fedimint wallet, use at your own risk." | ||
</WarningBlock> | ||
|
||
<h1 class="font-heading text-gray-900 text-4xl font-semibold mb-6">"Select a wallet:"</h1> | ||
<ul class="mb-6 list-disc"> | ||
{ available_list } | ||
</ul> | ||
|
||
<SubmitForm | ||
description="… or create a new one".into() | ||
on_submit=select | ||
placeholder="Wallet Name".into() | ||
submit_label="Create".into() | ||
loading=loading | ||
/> | ||
<Show when=wallets_available fallback=|| empty_view() > | ||
<h1 class="font-heading text-gray-900 font-semibold mb-6">"Select a wallet:"</h1> | ||
</Show> | ||
<div class="flex flex-col items-center mb-6 gap-y-4"> | ||
{ available_list } | ||
</div> | ||
} | ||
} |