aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorJohn Barratt <[email protected]>2023-03-07 10:29:49 -0800
committerJohn Barratt <[email protected]>2023-03-07 10:29:49 -0800
commit8ef9568cd1bd822495ce005d4e4cfaa6cb0d92ce (patch)
tree4ea5530cc2b7e5d970dc8a84cacfecfe2cce46b7 /src/components
parentc97fb43abba375920fff361ec5fa4eb64a5a0d3f (diff)
parent0f44e3283c25c9783a52cf20957661da49d2f90b (diff)
downloadcoinos-ui-8ef9568cd1bd822495ce005d4e4cfaa6cb0d92ce.tar.gz
coinos-ui-8ef9568cd1bd822495ce005d4e4cfaa6cb0d92ce.zip
Merge branch 'master' of https://github.com/coinos/coinos-ui into notificationsnotifications
Diffstat (limited to 'src/components')
-rw-r--r--src/components/About.svelte13
-rw-r--r--src/components/AppHeader.svelte1
-rw-r--r--src/components/Balance.svelte2
-rw-r--r--src/components/Code.svelte31
-rw-r--r--src/components/LandingHeader.svelte26
-rw-r--r--src/components/Lnurlp.svelte2
-rw-r--r--src/components/Numpad.svelte55
-rw-r--r--src/components/Slider.svelte56
-rw-r--r--src/components/index.js2
9 files changed, 132 insertions, 56 deletions
diff --git a/src/components/About.svelte b/src/components/About.svelte
index d51b9268..0a0ff874 100644
--- a/src/components/About.svelte
+++ b/src/components/About.svelte
@@ -18,19 +18,6 @@
socials: []
},
{
- name: 'karnage',
- socials: [
- { type: 'twitter', url: 'https://twitter.com/KarnageBitcoin', color: 'bg-[#1D9BF0]' }
- ]
- },
- {
- name: 'secondl1ght',
- socials: [
- { type: 'twitter', url: 'https://www.twitter.com/secondl1ght', color: 'bg-[#1D9BF0]' },
- { type: 'github', url: 'https://github.com/secondl1ght', color: 'bg-gray-800' }
- ]
- },
- {
name: 'shauna',
socials: [
{ type: 'twitter', url: 'https://twitter.com/ShaunaCollister', color: 'bg-[#1D9BF0]' },
diff --git a/src/components/AppHeader.svelte b/src/components/AppHeader.svelte
index 74afd7b9..51c70851 100644
--- a/src/components/AppHeader.svelte
+++ b/src/components/AppHeader.svelte
@@ -15,7 +15,6 @@
let menuButtons;
if (user)
menuButtons = [
- { key: 'nav.profile', icon: 'profile', href: `/${user.username}` },
{ key: 'nav.settings', icon: 'settings', href: `/${user.username}/settings` },
{ key: 'nav.support', icon: 'support', href: `/support` },
{ key: 'nav.signOut', icon: 'logout', href: `/logout` }
diff --git a/src/components/Balance.svelte b/src/components/Balance.svelte
index e95e5dde..cc923b7d 100644
--- a/src/components/Balance.svelte
+++ b/src/components/Balance.svelte
@@ -9,7 +9,7 @@
<div class="space-y-2">
<div class="text-5xl font-bold tabular-nums">
{#if isNaN($animatedRate)}
- <div class="text-gray-200">---</div>
+ <div class="text-gray-200">&mdash;</div>
{:else}
{f((user.balance * $animatedRate) / sats, user.currency)}
{/if}
diff --git a/src/components/Code.svelte b/src/components/Code.svelte
new file mode 100644
index 00000000..0e09191e
--- /dev/null
+++ b/src/components/Code.svelte
@@ -0,0 +1,31 @@
+<script>
+ import { copy } from '$lib/utils';
+ import { Icon } from '$comp';
+ import samples from '$lib/samples';
+ export let sample;
+</script>
+
+<div
+ class="bg-black text-white rounded-lg p-4 flex gap-4 whitespace-pre-wrap font-mono"
+>
+ <div class="overflow-x-scroll max-w-full scrollbar-hide">
+ <div class="break-all min-w-[800px]">{samples[sample]}</div>
+ </div>
+ <button
+ class="ml-auto my-auto invert opacity-90"
+ on:click={() => copy(samples[sample].replace(/^\s+/gm, '').replace(/\n/g, ''))}
+ ><Icon icon="copy" style="w-10 max-w-none" /></button
+ >
+</div>
+
+<style>
+ .scrollbar-hide::-webkit-scrollbar {
+ display: none;
+ }
+
+ /* For IE, Edge and Firefox */
+ .scrollbar-hide {
+ -ms-overflow-style: none; /* IE and Edge */
+ scrollbar-width: none; /* Firefox */
+ }
+</style>
diff --git a/src/components/LandingHeader.svelte b/src/components/LandingHeader.svelte
index f9db5ea0..ed7907c1 100644
--- a/src/components/LandingHeader.svelte
+++ b/src/components/LandingHeader.svelte
@@ -40,29 +40,29 @@
<button class="hover:opacity-80" on:click={() => scroll(about)}>{$t('about.header')}</button
>
{/if}
- {#if !user}
+ {#if user}
<button
- class="border rounded-full px-6 py-2 font-bold hover:opacity-80"
- on:click={() => goto('/register')}
- >{$t('nav.startInSeconds')}
+ class="border rounded-full px-6 py-2 font-bold"
+ on:click={() => goto(`/${user.username}`)}
+ >Home
</button>
<button
- class="bg-black text-white border rounded-full px-6 py-2 font-bold hover:opacity-80"
- on:click={() => goto('/login')}
+ class="bg-black text-white border rounded-full px-6 py-2 font-bold"
+ on:click={() => goto('/logout')}
>
- {$t('nav.signIn')}
+ {$t('nav.signOut')}
</button>
{:else}
<button
- class="border rounded-full px-6 py-2 font-bold"
- on:click={() => goto(`/${user.username}`)}
- >{$t('nav.account')}
+ class="border rounded-full px-6 py-2 font-bold hover:opacity-80"
+ on:click={() => goto('/register')}
+ >{$t('nav.startInSeconds')}
</button>
<button
- class="bg-black text-white border rounded-full px-6 py-2 font-bold"
- on:click={() => goto('/logout')}
+ class="bg-black text-white border rounded-full px-6 py-2 font-bold hover:opacity-80"
+ on:click={() => goto('/login')}
>
- {$t('nav.signOut')}
+ {$t('nav.signIn')}
</button>
{/if}
</div>
diff --git a/src/components/Lnurlp.svelte b/src/components/Lnurlp.svelte
index 22364fcf..ab0c50ce 100644
--- a/src/components/Lnurlp.svelte
+++ b/src/components/Lnurlp.svelte
@@ -8,7 +8,7 @@
let { currency } = data.user;
let { minSendable, maxSendable, callback, metadata } = data;
- let amount = minSendable,
+ let amount = Math.round(minSendable / 1000),
loading;
let submit = () => (loading = true);
</script>
diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte
index 5ffaa2ea..47bd9375 100644
--- a/src/components/Numpad.svelte
+++ b/src/components/Numpad.svelte
@@ -9,11 +9,18 @@
fiat = !amount,
submit = undefined;
- export let amountFiat = amount ? amount * ($selectedRate / sats) : 0;
-
+ let amountFiat = 0;
let arrow = '<';
- let amountSats = amount;
+ $: update(amount, amountFiat);
+ let update = (a, f) => {
+ if (fiat) {
+ amount = Math.round(f / ($selectedRate / sats));
+ } else {
+ amountFiat = ((a * $selectedRate) / sats).toFixed(2);
+ }
+ };
+
let loading = false;
let symbol =
@@ -33,14 +40,6 @@
KRW: '₩'
}[currency] || '';
- $: amount = parseInt(fiat ? Math.round(amountFiat / ($selectedRate / sats)) : amountSats);
-
- $: amountSatsFormatted = s(amountSats);
-
- $: amountFiatConverted = f(amountSats * ($selectedRate / sats), currency);
-
- $: amountSatsConverted = sat(amountFiat / ($selectedRate / sats));
-
const numPad = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '0', '<'];
const handleInput = (value) => {
@@ -58,7 +57,7 @@
amountFiat = amountFiat.slice(0, amountFiat.length - 1);
if (amountFiat.length === 0) {
amountFiat = 0;
- amountSats = 0;
+ amount = 0;
}
}
} else if (value !== '.' && value !== '<' && parseInt(amountFiat + value) > $selectedRate) {
@@ -71,25 +70,27 @@
} else {
if (value === '.') {
return;
- } else if (!amountSats && value !== '<' && value !== '0') {
- amountSats = parseInt(value);
+ } else if (!amount && value !== '<' && value !== '0') {
+ amount = parseInt(value);
} else if (value === '<') {
- if (amountSats !== 0) {
- amountSats = Math.floor(amountSats / 10);
- if (amountSats.length === 0) {
- amountSats = 0;
+ if (amount !== 0) {
+ amount = Math.floor(amount / 10);
+ if (amount.length === 0) {
+ amount = 0;
amountFiat = 0;
}
}
- } else if (value !== '<' && parseInt(amountSats + value) > sats) {
+ } else if (value !== '<' && parseInt(amount + value) > sats) {
warning($t('user.receive.lessThan1BTCWarning'));
} else {
- amountSats = parseInt(amountSats + value);
+ console.log('CLICK', amount.toString(), value);
+ amount = parseInt(amount.toString() + value);
+ console.log('AMOUNT', amount);
}
}
};
- $: html = fiat ? amountFiat : s(amountSats);
+ $: html = fiat ? amountFiat : s(amount);
let prev = '';
@@ -124,10 +125,10 @@
if (fiat) {
amountFiat = html;
} else {
- amountSats = parseInt(html.replace(/,/g, ''));
+ amount = parseInt(html.replace(/,/g, ''));
}
- if (!amountSats) amountSats = null;
+ if (!amount) amount = null;
setTimeout(() => {
if (!fiat) {
@@ -178,16 +179,16 @@
/>
</div>
<div class="mt-2">
- <span class="text-secondary mr-1">{fiat ? amountSatsConverted : amountFiatConverted}</span>
+ <span class="text-secondary mr-1">{fiat ? sat(amount) : f(amountFiat, currency)}</span>
<button
type="button"
on:click={() => {
if (fiat) {
- amountSats = parseInt((amountFiat / ($selectedRate / sats)).toFixed(0));
+ amount = parseInt((amountFiat / ($selectedRate / sats)).toFixed(0));
} else {
amountFiat =
- (amountSats * ($selectedRate / sats)).toFixed(2) > 0.0
- ? (amountSats * ($selectedRate / sats)).toFixed(2)
+ (amount * ($selectedRate / sats)).toFixed(2) > 0.0
+ ? (amount * ($selectedRate / sats)).toFixed(2)
: 0;
}
fiat = !fiat;
diff --git a/src/components/Slider.svelte b/src/components/Slider.svelte
new file mode 100644
index 00000000..3c94d127
--- /dev/null
+++ b/src/components/Slider.svelte
@@ -0,0 +1,56 @@
+<script>
+ export let value,
+ handle,
+ min = 0,
+ max = 100;
+</script>
+
+<input
+ id="slider"
+ type="range"
+ {min}
+ {max}
+ bind:value
+ class="px-0 py-0 my-5"
+ style="--bgPercent: {((value - min) * 100) / (max - min)}%;"
+ on:input={handle}
+/>
+
+<style>
+ #slider {
+ -webkit-appearance: none;
+ width: 100%;
+ height: 6px;
+ border-radius: 5px;
+ background: linear-gradient(
+ to right,
+ black 0%,
+ black var(--bgPercent),
+ #f5f7fa var(--bgPercent),
+ #f5f7fa 100%
+ );
+ outline: none;
+ }
+
+ #slider:active {
+ background-color: black;
+ }
+
+ #slider::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ appearance: none;
+ width: 30px;
+ height: 30px;
+ border-radius: 50%;
+ background: black;
+ cursor: pointer;
+ }
+
+ #slider::-moz-range-thumb {
+ width: 30px;
+ height: 30px;
+ border-radius: 50%;
+ background: black;
+ cursor: pointer;
+ }
+</style>
diff --git a/src/components/index.js b/src/components/index.js
index ab54e09f..1853e7c9 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -1,3 +1,5 @@
+export { default as Code } from './Code.svelte';
+export { default as Slider } from './Slider.svelte';
export { default as Pinpad } from './Pinpad.svelte';
export { default as Balance } from './Balance.svelte';
export { default as Lnurlp } from './Lnurlp.svelte';