some kind of reactivity
This commit is contained in:
parent
0dee6d64ed
commit
55ac4b7502
5 changed files with 47 additions and 10 deletions
4
README.md
Normal file
4
README.md
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# Ситуация
|
||||||
|
|
||||||
|
На свелте мне нравится что получается что-то, но пока не нравится что получается.
|
||||||
|
Как будто бы надо будет сделать больбшой рефакторинг, но пока пускай будет хоть что-то.
|
|
@ -1,4 +1,8 @@
|
||||||
<!-- Кнопка "Создать" -->
|
<!-- Кнопка "Создать" -->
|
||||||
|
<script>
|
||||||
|
let { onclick } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="create">
|
<div class="create">
|
||||||
<button class="rounded" id="create">Создать</button>
|
<button class="rounded" id="create" {onclick}>Создать</button>
|
||||||
</div>
|
</div>
|
|
@ -31,15 +31,24 @@
|
||||||
} -->
|
} -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import HorisontalItem from "./horisontal_item.svelte";
|
||||||
import AddButton from "./add_button.svelte";
|
import AddButton from "./add_button.svelte";
|
||||||
import Image from "./image.svelte";
|
import Image from "./image.svelte";
|
||||||
let { label = "", type = "text" } = $props();
|
|
||||||
|
let { value = $bindable([]), label = "", type = "text" } = $props();
|
||||||
|
let items = $state([]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="horisontal-bar {type == "text" ? "input" : ""} rounded">
|
<div class="horisontal-bar {type == "text" ? "input" : ""} rounded">
|
||||||
<p>{label}</p>
|
<p>{label}</p>
|
||||||
{#if type == "text"}
|
{#if type == "text"}
|
||||||
<AddButton handler={() => {}} />
|
{#each items as item}
|
||||||
|
<HorisontalItem text={item}/>
|
||||||
|
{/each}
|
||||||
|
<AddButton handler={() => {
|
||||||
|
items.push("test");
|
||||||
|
value = items;
|
||||||
|
}} />
|
||||||
{:else if type == "image"}
|
{:else if type == "image"}
|
||||||
<Image />
|
<Image />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
7
vnshed/src/lib/components/horisontal_item.svelte
Normal file
7
vnshed/src/lib/components/horisontal_item.svelte
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<script>
|
||||||
|
let { text } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="horisontal-item rounded">
|
||||||
|
{text}
|
||||||
|
</div>
|
|
@ -7,6 +7,19 @@
|
||||||
import QueueItem from '$lib/components/queue_item.svelte';
|
import QueueItem from '$lib/components/queue_item.svelte';
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
|
|
||||||
|
let page_data = {
|
||||||
|
title: "",
|
||||||
|
description: "",
|
||||||
|
time_to_read: "",
|
||||||
|
genres: [],
|
||||||
|
tags: [],
|
||||||
|
badges: []
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_json() {
|
||||||
|
console.log(JSON.stringify(page_data))
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
@ -21,15 +34,15 @@
|
||||||
|
|
||||||
<div class="fields rounded" id="fields">
|
<div class="fields rounded" id="fields">
|
||||||
<!-- Название -->
|
<!-- Название -->
|
||||||
<input type="text" class="input rounded" placeholder="Название">
|
<input type="text" class="input rounded" placeholder="Название" bind:value={page_data["title"]}>
|
||||||
|
|
||||||
<!-- Описание -->
|
<!-- Описание -->
|
||||||
<textarea class="input rounded" placeholder="Описание" rows="4"></textarea>
|
<textarea class="input rounded" placeholder="Описание" rows="4" bind:value={page_data["description"]}></textarea>
|
||||||
|
|
||||||
<!-- Время на чтение -->
|
<!-- Время на чтение -->
|
||||||
<div class="horisontal-bar">
|
<div class="horisontal-bar">
|
||||||
<p>Время на чтение</p>
|
<p>Время на чтение</p>
|
||||||
<select class="input rounded" id="hours-count">
|
<select class="input rounded" id="hours-count" bind:value={page_data["time_to_read"]}>
|
||||||
<option value="first">менее 2-х часов</option>
|
<option value="first">менее 2-х часов</option>
|
||||||
<option value="second">2-10 часов</option>
|
<option value="second">2-10 часов</option>
|
||||||
<option value="third">10-30 часов</option>
|
<option value="third">10-30 часов</option>
|
||||||
|
@ -37,9 +50,9 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<HorisontalBar label="Жанры"/>
|
<HorisontalBar label="Жанры" bind:value={page_data["genres"]}/>
|
||||||
<HorisontalBar label="Теги"/>
|
<HorisontalBar label="Теги" bind:value={page_data["tags"]}/>
|
||||||
<HorisontalBar label="Баджи"/>
|
<HorisontalBar label="Баджи" bind:value={page_data["badges"]}/>
|
||||||
|
|
||||||
<p>Скриншоты</p>
|
<p>Скриншоты</p>
|
||||||
<HorisontalBar type="image" />
|
<HorisontalBar type="image" />
|
||||||
|
@ -57,7 +70,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CreateButton />
|
<CreateButton onclick={send_json}/>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@import '$lib/css/global.css';
|
@import '$lib/css/global.css';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue