-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Hamish Peebles <[email protected]>
- Loading branch information
1 parent
8d23269
commit 27e9aed
Showing
23 changed files
with
457 additions
and
56 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
102 changes: 102 additions & 0 deletions
102
frontend/app/src/components/home/profile/AccountSelector.svelte
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,102 @@ | ||
<script lang="ts"> | ||
import { _ } from "svelte-i18n"; | ||
import type { NamedAccount } from "openchat-client"; | ||
import ChevronDown from "svelte-material-icons/ChevronDown.svelte"; | ||
import { iconSize } from "../../../stores/iconSize"; | ||
import MenuIcon from "../../MenuIcon.svelte"; | ||
import Menu from "../../Menu.svelte"; | ||
import MenuItem from "../../MenuItem.svelte"; | ||
import { mobileWidth } from "../../../stores/screenDimensions"; | ||
export let accounts: NamedAccount[]; | ||
export let targetAccount: string; | ||
let selectedName: string | undefined = undefined; | ||
let menuIcon: MenuIcon; | ||
$: { | ||
selectedName = accounts.find((a) => { | ||
return a.account.toLowerCase() === targetAccount.toLowerCase(); | ||
})?.name; | ||
} | ||
function collapseAccount(account: string) { | ||
if (account.length > 23) { | ||
return account.slice(0, 10) + "..." + account.slice(account.length - 10); | ||
} | ||
return account; | ||
} | ||
function selectAccount(namedAccount: NamedAccount) { | ||
targetAccount = namedAccount.account; | ||
} | ||
function showMenu() { | ||
menuIcon.showMenu(); | ||
} | ||
</script> | ||
|
||
<div role="combobox" tabindex="0" class="selected" on:click|stopPropagation={showMenu}> | ||
<div class="name"> | ||
{selectedName ?? $_("tokenTransfer.chooseAddress")} | ||
</div> | ||
<div class="icon"> | ||
<MenuIcon bind:this={menuIcon} position={$mobileWidth ? "top" : "bottom"} align={"end"}> | ||
<div slot="icon"> | ||
<ChevronDown viewBox={"0 -3 24 24"} size={$iconSize} color={"var(--icon-txt)"} /> | ||
</div> | ||
<div slot="menu"> | ||
<Menu> | ||
{#each accounts as namedAccount} | ||
<MenuItem unpadded on:click={() => selectAccount(namedAccount)}> | ||
<div slot="text" class="named-account"> | ||
<div class="name"> | ||
{namedAccount.name} | ||
</div> | ||
<div class="account"> | ||
{collapseAccount(namedAccount.account)} | ||
</div> | ||
</div> | ||
</MenuItem> | ||
{/each} | ||
</Menu> | ||
</div> | ||
</MenuIcon> | ||
</div> | ||
</div> | ||
|
||
<style lang="scss"> | ||
.selected { | ||
display: flex; | ||
align-items: center; | ||
gap: $sp3; | ||
cursor: pointer; | ||
@include font(book, normal, fs-80); | ||
.name { | ||
color: var(--primary); | ||
} | ||
.icon { | ||
transition: transform 250ms ease-in-out; | ||
transform-origin: 50%; | ||
} | ||
} | ||
.named-account { | ||
padding: $sp3; | ||
display: flex; | ||
flex-direction: column; | ||
@include font(book, normal, fs-80); | ||
font-family: "Roboto", sans-serif; | ||
.name { | ||
color: var(--primary); | ||
} | ||
.account { | ||
@include font(light, normal, fs-70); | ||
color: var(--menu-disabled-txt); | ||
} | ||
} | ||
</style> |
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
47 changes: 47 additions & 0 deletions
47
frontend/app/src/components/home/profile/SaveAccount.svelte
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,47 @@ | ||
<script lang="ts"> | ||
import type { NamedAccount, OpenChat } from "openchat-client"; | ||
import Input from "../../Input.svelte"; | ||
import { getContext } from "svelte"; | ||
import { _ } from "svelte-i18n"; | ||
import Legend from "../../Legend.svelte"; | ||
const client = getContext<OpenChat>("client"); | ||
export let account: string; | ||
export let accounts: NamedAccount[]; | ||
export let valid = false; | ||
let name = ""; | ||
$: trimmedName = name.trim(); | ||
$: { | ||
valid = | ||
trimmedName.length > 0 && | ||
accounts.find((a) => a.name.toLowerCase() === trimmedName.toLowerCase()) === undefined; | ||
} | ||
export function saveAccount() { | ||
return client.saveCryptoAccount({ | ||
account, | ||
name: trimmedName, | ||
}); | ||
} | ||
</script> | ||
|
||
<Legend label={$_("tokenTransfer.saveAccountMessage")} /> | ||
|
||
<p class="account">{account}</p> | ||
|
||
<Input | ||
bind:value={name} | ||
autofocus | ||
countdown={false} | ||
maxlength={100} | ||
placeholder={$_("tokenTransfer.enterAccountName")} /> | ||
|
||
<style lang="scss"> | ||
.account { | ||
@include input(); | ||
margin-bottom: $sp3; | ||
} | ||
</style> |
Oops, something went wrong.