Collapse
This commit is contained in:
@@ -1,8 +1,15 @@
|
|||||||
<div class={`bg-white rounded overflow-hidden shadow m-2 flex-grow flex flex-col ${$$props.class}`}>
|
<script lang="ts">
|
||||||
|
import { slide } from 'svelte/transition';
|
||||||
|
export let isOpen: boolean = true;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class={`bg-white rounded overflow-hidden shadow m-2 flex-grow flex flex-col `}>
|
||||||
<div class="bg-blue-400 border-gray-400 p-2 flex-none">
|
<div class="bg-blue-400 border-gray-400 p-2 flex-none">
|
||||||
<slot name="title" />
|
<slot name="title" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-grow overflow-auto">
|
{#if isOpen}
|
||||||
<slot />
|
<div class="flex-grow overflow-auto" transition:slide>
|
||||||
</div>
|
<slot />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
});
|
});
|
||||||
editor.layout({
|
editor.layout({
|
||||||
height: divEl.parentElement.offsetHeight,
|
height: divEl.parentElement.offsetHeight,
|
||||||
width: divEl.offsetWidth
|
width: divEl.parentElement.offsetWidth
|
||||||
});
|
});
|
||||||
const resizeObserver = new ResizeObserver((entries) => {
|
const resizeObserver = new ResizeObserver((entries) => {
|
||||||
editor.layout({
|
editor.layout({
|
||||||
@@ -71,7 +71,8 @@
|
|||||||
width: entries[0].contentRect.width
|
width: entries[0].contentRect.width
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
resizeObserver.observe(divEl);
|
|
||||||
|
resizeObserver.observe(divEl.parentElement.parentElement);
|
||||||
return () => {
|
return () => {
|
||||||
editor.dispose();
|
editor.dispose();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
const HISTORY_SAVE_INTERVAL: number = 1000;
|
const HISTORY_SAVE_INTERVAL: number = 5000;
|
||||||
|
|
||||||
const tabSelectHandler = (message: CustomEvent<Tab>) => {
|
const tabSelectHandler = (message: CustomEvent<Tab>) => {
|
||||||
autoHistoryMode.set('timeline' === message.detail.id);
|
autoHistoryMode.set('timeline' === message.detail.id);
|
||||||
@@ -65,12 +65,14 @@
|
|||||||
saveHistory(true);
|
saveHistory(true);
|
||||||
}, HISTORY_SAVE_INTERVAL);
|
}, HISTORY_SAVE_INTERVAL);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let isOpen = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card class="h-52">
|
<Card {isOpen}>
|
||||||
<div slot="title" class="flex justify-between">
|
<div slot="title" class="flex justify-between">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<Tabs on:select={tabSelectHandler} {tabs} title="History" />
|
<Tabs on:select={tabSelectHandler} bind:isOpen {tabs} title="History" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-x-4 text-white">
|
<div class="flex gap-x-4 text-white">
|
||||||
<button class="bg-yellow-500 hover:bg-yellow-700 rounded px-1" on:click={() => saveHistory()}
|
<button class="bg-yellow-500 hover:bg-yellow-700 rounded px-1" on:click={() => saveHistory()}
|
||||||
@@ -81,7 +83,7 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul class="p-2 space-y-2 overflow-auto">
|
<ul class="p-2 space-y-2 overflow-auto h-56">
|
||||||
{#each $historyStore as { state, time, name }}
|
{#each $historyStore as { state, time, name }}
|
||||||
<li class="rounded p-2 shadow flex-col">
|
<li class="rounded p-2 shadow flex-col">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
import { fade } from 'svelte/transition';
|
||||||
|
|
||||||
export let tabs: Tab[] = [];
|
export let tabs: Tab[] = [];
|
||||||
export let activeTabID: string = tabs[0].id;
|
export let activeTabID: string = tabs[0].id;
|
||||||
export let title: string;
|
export let title: string;
|
||||||
|
|
||||||
|
export let isOpen = false;
|
||||||
const dispatch = createEventDispatcher<TabEvents>();
|
const dispatch = createEventDispatcher<TabEvents>();
|
||||||
const toggleTabs = (tab: Tab) => {
|
const toggleTabs = (tab: Tab) => {
|
||||||
activeTabID = tab.id;
|
activeTabID = tab.id;
|
||||||
@@ -11,20 +14,22 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<span class="text-white mr-2">{title}</span>
|
<span class="text-white mr-2" on:click={() => (isOpen = !isOpen)}>{title}</span>
|
||||||
<ul class="flex list-none flex-wrap flex-row">
|
{#if isOpen}
|
||||||
{#each tabs as tab}
|
<ul class="flex list-none flex-wrap flex-row" transition:fade>
|
||||||
<li class="mr-2 last:mr-0 flex-auto text-center">
|
{#each tabs as tab}
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
<li class="mr-2 last:mr-0 flex-auto text-center">
|
||||||
<a
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
class="text font-bold min-w-16 w-auto px-2 py-1 -mb-4 rounded-t block leading-normal {activeTabID ===
|
<a
|
||||||
tab.id
|
class="text font-bold min-w-16 w-auto px-2 py-1 -mb-4 rounded-t block leading-normal {activeTabID ===
|
||||||
? 'text-blue-500 bg-white border-white'
|
tab.id
|
||||||
: 'text-white bg-blue-500 border-blue-500'}"
|
? 'text-blue-500 bg-white border-white'
|
||||||
on:click={() => toggleTabs(tab)}
|
: 'text-white bg-blue-500 border-blue-500'}"
|
||||||
>
|
on:click={() => toggleTabs(tab)}
|
||||||
{tab.title}
|
>
|
||||||
</a>
|
{tab.title}
|
||||||
</li>
|
</a>
|
||||||
{/each}
|
</li>
|
||||||
</ul>
|
{/each}
|
||||||
|
</ul>
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import View from '$lib/components/view.svelte';
|
import View from '$lib/components/view.svelte';
|
||||||
import Card from '$lib/components/card.svelte';
|
import Card from '$lib/components/card.svelte';
|
||||||
import Tabs from '$lib/components/tabs.svelte';
|
import Tabs from '$lib/components/tabs.svelte';
|
||||||
import History from '$lib/components/history/index.svelte';
|
import History from '$lib/components/history/history.svelte';
|
||||||
import {
|
import {
|
||||||
initURLSubscription,
|
initURLSubscription,
|
||||||
updateCode,
|
updateCode,
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-full flex-grow flex flex-col">
|
<div class="h-full flex-grow flex-shrink-0 flex flex-col">
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<Editor on:update={updateHandler} {language} {text} {errorMarkers} />
|
<Editor on:update={updateHandler} {language} {text} {errorMarkers} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user