Skip to content

Commit

Permalink
storage config fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dlaxcess committed Jan 22, 2024
1 parent 8c60565 commit 5f8877e
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
"avoid-sha3": "warn"
},
"window.zoomLevel": 0,
"workbench.colorTheme": "Default Light+",
"workbench.colorTheme": "Default Dark+",
"workbench.layoutControl.enabled": true,
"workbench.statusBar.visible": true,
"favorites.sortOrder": "DESC",
"workbench.preferredLightColorTheme": "Kimbie Dark"
}
}
10 changes: 6 additions & 4 deletions gulp/scss/front-md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@
}

.menu {
input {
input#burger {
display: none;

& + label {
&+label.burger {
display: none;
}
}

ul {
li {
a {

a,
button.kre-nav-button {
transition: all 300ms ease-in-out;

&:hover {
Expand Down Expand Up @@ -181,4 +183,4 @@
.kre-copy-ref-container:hover .copy-ref {
visibility: visible;
opacity: 1;
}
}
20 changes: 13 additions & 7 deletions gulp/scss/front.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
}

.nav-krd {
z-index: 10;

nav {
ul {
padding: 0;
Expand All @@ -45,7 +47,9 @@
}

&.active {
a {

a,
button.kre-nav-button {
color: $white;

&:hover {
Expand Down Expand Up @@ -111,7 +115,7 @@
header {
margin-bottom: 50px;

h1 + .btn {
h1+.btn {
position: absolute;
right: 0;
top: 0;
Expand Down Expand Up @@ -198,7 +202,7 @@
height: 100%;
}

& + strong {
&+strong {
display: inline-block;
vertical-align: middle;
}
Expand Down Expand Up @@ -321,6 +325,7 @@
}

&:hover {

&::after,
.fas {
opacity: 1;
Expand Down Expand Up @@ -398,7 +403,7 @@
margin-bottom: 0;
}

& + .flex {
&+.flex {
.t-light {
opacity: 0.5;
}
Expand Down Expand Up @@ -428,7 +433,7 @@
pointer-events: auto;
}

& > div {
&>div {
max-width: 800px;
@include border-radius();
position: absolute;
Expand Down Expand Up @@ -486,7 +491,7 @@
pointer-events: auto;
transition: all 300ms ease-in-out;

& > div {
&>div {
max-width: 800px;
@include border-radius();
position: absolute;
Expand Down Expand Up @@ -560,6 +565,7 @@
.modal-window {
.modal-content {
.modal-body {

.media-video,
.media-image {
width: 100%;
Expand All @@ -568,4 +574,4 @@
}
}
}
}
}
58 changes: 58 additions & 0 deletions svelte/components/Global/Config.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script lang="ts">
import { clickOutside } from "@helpers/clickOutside";
import { fade } from "svelte/transition";
import InputConfigFields from "../Input/InputConfigFields.svelte";
let userConfig;
let open = false;
const toggle = () => (open = !open);
</script>

<button class="kre-nav-button" on:click|preventDefault={toggle} on:keydown={toggle}>
<i class="fa fa-cog" aria-hidden="true" /><br />
Config
</button>

{#if open}
<!-- Modal Config -->
<div class="modal-window" transition:fade>
<div class="modal-content" use:clickOutside={() => (open = false)} transition:fade>
<span on:click={toggle} on:keydown={toggle} title="Close" class="btn modal-close"><i class="fa fa-times" /></span>

<div class="modal-body">
<div class="titre">
<i class="fas fa-plus fa-left c-green" />Your Config
</div>

<InputConfigFields bind:userConfig />
</div>
</div>
</div>
{/if}

<style>
button.kre-nav-button {
background-color: transparent;
border: none;
cursor: pointer;
}
.modal-window {
visibility: visible;
opacity: 1;
z-index: 1000;
color: #1e1e43;
pointer-events: auto;
}
.modal-content {
min-height: 360px;
}
.modal-body {
text-align: left;
}
</style>
6 changes: 5 additions & 1 deletion svelte/components/Global/Navigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { versionGet } from "@helpers/version";
import logo from "../Images/logo-kredeum.svg";
import { networks } from "@lib/common/networks";
import Config from "./Config.svelte";
export let chainId: number;
Expand Down Expand Up @@ -47,12 +48,15 @@
<li class="active">
<p>
<a href="." on:click={toggle}>
<i class="fas {mainnets ? "fa-flask" : "fa-road"}" /><br />
<i class="fas {mainnets ? 'fa-flask' : 'fa-road'}" /><br />
{@html mainnets ? "testnet" : "mainnet"}<br />
networks
</a>
</p>
</li>
<li class="active">
<Config />
</li>
{/if}
</ul>
</nav>
Expand Down
118 changes: 118 additions & 0 deletions svelte/components/Input/InputConfigFields.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<script lang="ts">
import type { Properties } from "@lib/common/types";
/////////////////////////////////////////////////
// <InputConfigFields />
// Set User config
/////////////////////////////////////////////////
// let userConfig: Properties;
let userConfig: { key: string; value: string };
let attributes = [{ key: "", value: "" }];
const saveConfig = () => {
console.log("save userConfig:", userConfig);
if (typeof localStorage !== "undefined") {
for (const [key, value] of Object.entries(userConfig)) {
console.log("saveConfig ~ key:", key, value);
localStorage.setItem(key, value);
}
}
};
$: attributes && handleProperties();
const handleProperties = () => {
userConfig = attributes
.filter((attribute) => attribute.key !== "" && attribute.value !== "")
.reduce((allAttr, attr) => {
return {
...allAttr,
[attr.key]: attr.value
// [attr.key]: { key: attr.key, value: attr.value }
};
}, {});
};
const addField = (): void => {
attributes = [...attributes, { key: "", value: "" }];
};
const removeField = (i: number): void => {
if (attributes.length > 1) {
attributes = attributes.filter((_, index) => i !== index);
} else {
attributes[i] = { key: "", value: "" };
}
};
$: console.log("attributes:", attributes);
$: console.log("userConfig:", userConfig);
</script>

<div class="section">
<div class="titre">UserConfig</div>
{#if attributes}
{#each attributes as attribute, i}
<div class="kre-section-small">
<input type="text" class="kre-field-outline" placeholder="add key" bind:value={attribute.key} />
<input type="text" class="kre-field-outline" placeholder="add value" bind:value={attribute.value} />

<button
value="Remove"
class="kre-delete-file {attributes.length < 2 ? 'disabled' : ''}"
on:click={() => removeField(i)}
>
<i class="fa fa-trash" aria-hidden="true" />
</button>
</div>
{/each}
{/if}

<button class="kre-button-grey" on:click|preventDefault={addField}
><i class="fa fa-plus fa-left" aria-hidden="true" />Add</button
>

<div class="txtright">
<button class="btn btn-default btn-sell" on:click|preventDefault={saveConfig}>Save</button>
</div>
</div>

<style>
.kre-section-small {
display: flex;
gap: 5px;
align-items: center;
}
.kre-delete-file {
background-color: #192146;
border-radius: 50%;
width: 35px;
height: 35px;
display: flex;
cursor: pointer;
}
.kre-delete-file.disabled {
opacity: 0.5;
}
.kre-delete-file i {
color: white;
margin: auto;
}
.kre-button-grey {
border: 2px solid #9a9aa4;
color: #9a9aa4;
border-radius: 360px;
cursor: pointer;
display: inline-block;
font-size: 15px;
padding: 15px 25px;
transition: all 0.3s ease-in-out;
vertical-align: middle;
background-color: white;
}
</style>

0 comments on commit 5f8877e

Please sign in to comment.