aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsecondl1ght <[email protected]>2022-08-16 10:59:19 -0600
committersecondl1ght <[email protected]>2022-08-16 10:59:19 -0600
commitc26e004f4a05f231242587c1265a620b7fcd873a (patch)
tree54ac64420712c0343d693b97988a940eda66257e /src
parent94bb8a163f2d1197544977bdbd3c225a815f9c0e (diff)
downloadcoinos-ui-c26e004f4a05f231242587c1265a620b7fcd873a.tar.gz
coinos-ui-c26e004f4a05f231242587c1265a620b7fcd873a.zip
run format
Diffstat (limited to 'src')
-rw-r--r--src/components/LandingHeader.svelte29
-rw-r--r--src/components/LocaleSelector.svelte12
-rw-r--r--src/lib/i18n.js51
-rw-r--r--src/locales/en.json17
-rw-r--r--src/locales/fr.json17
-rw-r--r--src/routes/[username]/settings.svelte8
-rw-r--r--src/routes/__layout.svelte12
7 files changed, 70 insertions, 76 deletions
diff --git a/src/components/LandingHeader.svelte b/src/components/LandingHeader.svelte
index 544e2a9d..b6519ca9 100644
--- a/src/components/LandingHeader.svelte
+++ b/src/components/LandingHeader.svelte
@@ -3,7 +3,7 @@
import { scroll } from '$lib/utils';
import { Icon, LocaleSelector } from '$comp';
import { user } from '$lib/store';
- import { _ } from 'svelte-i18n';
+ import { _ } from 'svelte-i18n';
export let howItWorks;
export let faq;
@@ -18,17 +18,15 @@
<header class="w-full lg:w-5/6 py-5 mx-auto fixed md:sticky z-10 top-0 bg-white/90">
<nav class="block xl:flex flex-wrap justify-between items-center">
-<div class='flex justify-start md:justify-center items-center md:space-x-10'>
- <a href="/" class="hidden md:block">
- <Icon icon="logo" style="mb-5 xl:mb-0" />
- </a>
- <Icon icon="logo" style="block md:hidden ml-5 w-48" />
-<LocaleSelector style='hidden md:block py-1 mb-5 xl:mb-0' />
-</div>
+ <div class="flex justify-start md:justify-center items-center md:space-x-10">
+ <a href="/" class="hidden md:block">
+ <Icon icon="logo" style="mb-5 xl:mb-0" />
+ </a>
+ <Icon icon="logo" style="block md:hidden ml-5 w-48" />
+ <LocaleSelector style="hidden md:block py-1 mb-5 xl:mb-0" />
+ </div>
<!-- desktop nav -->
<div class="hidden space-x-10 md:flex flex-wrap justify-center items-center font-bold">
-
-
<button on:click={() => scroll(howItWorks)}>{$_('nav.howItWorks')}</button>
<button on:click={() => scroll(faq)}>{$_('nav.faq')}</button>
<button on:click={() => scroll(about)}>{$_('nav.about')}</button>
@@ -55,7 +53,6 @@
Sign out
</button>
{/if}
-
</div>
<!-- mobile nav -->
@@ -71,13 +68,13 @@
: 'right-[-100%]'} transition-all ease-in-out duration-300 h-[100vh] w-full bg-white"
>
<div class="space-y-8 mt-24 ml-10 font-bold text-xl">
-
-
<button on:click={() => mobileMenuButtonClick(howItWorks)} class="block"
>{$_('nav.howItWorks')}</button
>
<button on:click={() => mobileMenuButtonClick(faq)} class="block">{$_('nav.faq')}</button>
- <button on:click={() => mobileMenuButtonClick(about)} class="block">{$_('nav.about')}</button>
+ <button on:click={() => mobileMenuButtonClick(about)} class="block"
+ >{$_('nav.about')}</button
+ >
{#if !$user}
<button
class="border rounded-full px-6 py-2 font-bold block"
@@ -88,7 +85,7 @@
class="bg-black text-white border rounded-full px-6 py-2 font-bold block"
on:click={() => goto('/login')}
>
- {$_('nav.signIn')}
+ {$_('nav.signIn')}
</button>
{:else}
<button
@@ -104,7 +101,7 @@
</button>
{/if}
- <LocaleSelector style='py-1' />
+ <LocaleSelector style="py-1" />
</div>
</div>
</nav>
diff --git a/src/components/LocaleSelector.svelte b/src/components/LocaleSelector.svelte
index 3f173109..2ae65986 100644
--- a/src/components/LocaleSelector.svelte
+++ b/src/components/LocaleSelector.svelte
@@ -1,10 +1,10 @@
<script>
- import { _, locale, locales } from 'svelte-i18n';
- export let style
+ import { _, locale, locales } from 'svelte-i18n';
+ export let style;
</script>
-<select name='language' bind:value={$locale} class={style}>
- {#each $locales as locale}
- <option value={locale}>{locale}</option>
- {/each}
+<select name="language" bind:value={$locale} class={style}>
+ {#each $locales as locale}
+ <option value={locale}>{locale}</option>
+ {/each}
</select>
diff --git a/src/lib/i18n.js b/src/lib/i18n.js
index fdf5de3c..3105c709 100644
--- a/src/lib/i18n.js
+++ b/src/lib/i18n.js
@@ -2,41 +2,40 @@ import { register, init, getLocaleFromNavigator } from 'svelte-i18n';
// The list of locales to look for
// ADD ALL NEW LANGUAGE CODES TO THIS LIST
-const localeCodes = ["en", "fr"];
+const localeCodes = ['en', 'fr'];
// the default locale to use if none was found
-const defaultLocale = "en";
+const defaultLocale = 'en';
// Adds a new locale based on its code
function addLocale(localeCode) {
- register(localeCode, () => import(`../locales/${localeCode}.json`));
+ register(localeCode, () => import(`../locales/${localeCode}.json`));
}
// Picks the default locale based on navigator locale and the list of available locales
function pickLocale(navigatorLocale, availableLocales) {
- // locale can be null the first time you load this
- // return the default locale in that case - reloading should fix this
- if (!navigatorLocale)
- return defaultLocale;
+ // locale can be null the first time you load this
+ // return the default locale in that case - reloading should fix this
+ if (!navigatorLocale) return defaultLocale;
- // determine langugage part of locale
- // (e.g. if navigatorLocale is 'en-US', languageCode is 'en')
- let dashIndex = navigatorLocale ? navigatorLocale.indexOf("-") : -1;
- let languageCode; // navigator locale without the regional part
- if (dashIndex === -1) {
- languageCode = navigatorLocale;
- } else {
- languageCode = navigatorLocale.slice(0, dashIndex);
- }
+ // determine langugage part of locale
+ // (e.g. if navigatorLocale is 'en-US', languageCode is 'en')
+ let dashIndex = navigatorLocale ? navigatorLocale.indexOf('-') : -1;
+ let languageCode; // navigator locale without the regional part
+ if (dashIndex === -1) {
+ languageCode = navigatorLocale;
+ } else {
+ languageCode = navigatorLocale.slice(0, dashIndex);
+ }
- // get locale
- if (availableLocales.includes(navigatorLocale)) {
- return navigatorLocale;
- } else if (availableLocales.includes(languageCode)) {
- return languageCode;
- } else {
- return navigatorLocale;
- }
+ // get locale
+ if (availableLocales.includes(navigatorLocale)) {
+ return navigatorLocale;
+ } else if (availableLocales.includes(languageCode)) {
+ return languageCode;
+ } else {
+ return navigatorLocale;
+ }
}
// add locales
@@ -44,6 +43,6 @@ localeCodes.forEach(addLocale);
let initialLocale = pickLocale(getLocaleFromNavigator(), localeCodes);
init({
- fallbackLocale: defaultLocale,
- initialLocale: initialLocale,
+ fallbackLocale: defaultLocale,
+ initialLocale: initialLocale
});
diff --git a/src/locales/en.json b/src/locales/en.json
index c5c36c4b..a44c202f 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -1,11 +1,10 @@
{
- "langname": "English",
- "nav": {
- "howItWorks": "How It Works",
- "faq": "FAQ",
- "about": "About",
- "startInSeconds": "Start in Seconds",
- "signIn": "Sign In"
-}
-
+ "langname": "English",
+ "nav": {
+ "howItWorks": "How It Works",
+ "faq": "FAQ",
+ "about": "About",
+ "startInSeconds": "Start in Seconds",
+ "signIn": "Sign In"
+ }
}
diff --git a/src/locales/fr.json b/src/locales/fr.json
index d2c9d758..9adc9488 100644
--- a/src/locales/fr.json
+++ b/src/locales/fr.json
@@ -1,11 +1,10 @@
{
- "langname": "Français",
-"nav": {
- "howItWorks": "Comment Ça Fonctionne",
- "faq": "FAQ",
- "about": "À Propos",
- "startInSeconds": "Commence en Secondes",
- "signIn": "Connexion"
-}
-
+ "langname": "Français",
+ "nav": {
+ "howItWorks": "Comment Ça Fonctionne",
+ "faq": "FAQ",
+ "about": "À Propos",
+ "startInSeconds": "Commence en Secondes",
+ "signIn": "Connexion"
+ }
}
diff --git a/src/routes/[username]/settings.svelte b/src/routes/[username]/settings.svelte
index 11e0977a..e4d7b0bf 100644
--- a/src/routes/[username]/settings.svelte
+++ b/src/routes/[username]/settings.svelte
@@ -44,10 +44,10 @@
</div>
{#if setting === 'account'}
- <div>
- <label for="language" class="font-bold block mb-1">Language</label>
- <LocaleSelector style='block py-3 w-full'/>
- </div>
+ <div>
+ <label for="language" class="font-bold block mb-1">Language</label>
+ <LocaleSelector style="block py-3 w-full" />
+ </div>
<div>
<label for="username" class="font-bold mb-1 block">Username</label>
diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte
index c5234c7d..5f9f1456 100644
--- a/src/routes/__layout.svelte
+++ b/src/routes/__layout.svelte
@@ -1,16 +1,16 @@
<script context="module">
- import { waitLocale } from 'svelte-i18n'
+ import { waitLocale } from 'svelte-i18n';
- export async function preload() {
- // awaits for the loading of the 'en-US' and 'en' dictionaries
- return waitLocale()
- }
+ export async function preload() {
+ // awaits for the loading of the 'en-US' and 'en' dictionaries
+ return waitLocale();
+ }
</script>
<script>
import { SvelteToast } from '@zerodevx/svelte-toast';
import '../app.css';
- import '$lib/i18n';
+ import '$lib/i18n';
import { onMount } from 'svelte';
import { connect } from '$lib/socket';
import { user, token } from '$lib/store';