Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix anime text tags #136

Merged
merged 2 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import Modal from "@/components/UI/Modal.svelte";
import Input from "@/components/UI/Input.svelte";
import Button from "@/components/UI/Button.svelte";
import Notify from "@/components/UI/Notify.svelte";

export let notify = null;


const dispatch = createEventDispatcher();

Expand All @@ -24,6 +28,9 @@
</script>

<Modal on:close title="{title}" {...$$restProps}>
{#if notify}
<Notify {...notify} />
{/if}
<div class="p-5">
<Input label="{_('words.filename')}" on:update="{onUpdate}" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

let fileManager = false;
let insetTextModal = false;
let fileManagerNotify = null;
let splitter = { x: 200, width: 4, min: 100, max: 500 };

const accept = ["image", "audio", "text", "video", "font"];
Expand Down Expand Up @@ -56,12 +57,10 @@
.upload({ name, buffer })
.then((uplodedFile) => {
dispatch("file", uplodedFile);
closeInsertTextModal();
})
.catch((error) => {
console.log("ERROR >>>", error);
})
.then(() => {
closeInsertTextModal();
fileManagerNotify = { type: "error", message: error };
});
}

Expand Down Expand Up @@ -115,6 +114,7 @@
/>

<InsertTextModal
notify="{fileManagerNotify}"
bind:opened="{insetTextModal}"
on:save="{insertText}"
on:close="{closeInsertTextModal}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script>
import api from "@/api/twitch";
import { _ } from "@/libs/i18next";

export let widget;

let tags = [];

api.getEventNames().then((names) => {
const arr = names.find((event) => event.name === widget.eventName);
tags = arr ? arr.tags : [];
});
</script>

<div class="pt-5 px-5 flex gap-2">
{#each tags as tag}
<div class="px-2 bg-gray-900 rounded cursor-pointer">${tag}</div>
{/each}
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import api from "@/api/twitch";
import { _ } from "@/libs/i18next";
import TagList from "./TagList.svelte";
import { fetchText } from "../../libs/utils";
import { createEventDispatcher } from "svelte";
import Modal from "@/components/UI/Modal.svelte";
Expand All @@ -11,39 +11,17 @@
export let widget;
export let opened;

let tags = [];
let textarea;

api.getEventNames().then((names) => {
const arr = names.find((event) => event.name === widget.eventName);
tags = arr ? arr.tags : [];
});

const dispatch = createEventDispatcher();

$: title = opened && item.target.filename;

function insertTag(tag) {
const [start, end] = [textarea.selectionStart, textarea.selectionEnd];
textarea.setRangeText(`$${tag}`, start, end, "select");
}

function codeMirrorUpdate({ detail }) {
dispatch("textFileChange", { item, text: detail });
}
</script>

<Modal on:close opened="{opened}" {...$$restProps} title="{title}">
<div class="pt-5 px-5 flex gap-2">
{#each tags as tag}
<div
on:click="{insertTag.bind(null, tag)}"
class="px-2 bg-gray-900 rounded cursor-pointer"
>
${tag}
</div>
{/each}
</div>
<TagList widget="{widget}" />
<div class="p-5">
{#await fetchText(item.target.filename)}
Loading....
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

export let data;

let widget = null;
let initialItems = [];
let widget = data.widget;
let timelineOpened = false;

fetchItems();
$: widget = data.widget;
$: widget && fetchItems();

function fetchItems() {
actionsAPI.get(widget.id).then(({ items } = {}) => {
Expand Down