This repository has been archived by the owner on Sep 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Visualize.svelte
91 lines (82 loc) · 2.55 KB
/
Visualize.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<script>
import Tabs from 'layout/partials/bulma/Tabs.svelte';
import AnnotateTab from './visualize/AnnotateTab.svelte';
import ChartTypeTab from './visualize/ChartTypeTab.svelte';
import DesignTab from './visualize/DesignTab.svelte';
import RefineTab from './visualize/RefineTab.svelte';
import { getContext } from 'svelte';
export let chart;
export let data;
export let visualizations;
const config = getContext('config');
$: stickyHeaderThreshold = $config.stickyHeaderThreshold;
const tabs = [
{ id: 'vis', title: 'Chart type', ui: ChartTypeTab },
{ id: 'refine', title: 'Refine', ui: RefineTab },
{ id: 'annotate', title: 'Annotate', ui: AnnotateTab },
{ id: 'design', title: 'Design', ui: DesignTab }
];
let active = 'refine';
$: activeTab = tabs.find(d => d.id === active) || tabs[0];
let scrollY = 0;
let innerHeight = 0;
</script>
<svelte:window bind:innerHeight bind:scrollY />
<div class="container">
<div class="columns">
<div class="column is-one-third">
<div
class="vis-controls block"
class:sticking={scrollY >= 50}
class:is-sticky={innerHeight > stickyHeaderThreshold}
>
<Tabs items={tabs} bind:active />
</div>
<div class="block">
<svelte:component this={activeTab.ui} {data} {chart} {visualizations} />
</div>
</div>
<div class="column">
<div class="preview" class:sticky-nav={innerHeight > stickyHeaderThreshold}>
<div class="box block">chart preview</div>
<div class="block" style="text-align: center;">
- - - - - Some more controls - - - - -<br />x x x x x x
</div>
</div>
</div>
</div>
</div>
<style>
.box {
margin-left: auto;
margin-right: auto;
width: 600px;
height: 500px;
}
.preview {
position: sticky;
top: 20px;
}
.preview.sticky-nav {
top: 170px;
}
.vis-controls.is-sticky {
position: sticky;
top: 150px;
z-index: 920;
}
.vis-controls.is-sticky.sticking {
background: var(--color-dw-background);
padding-top: 20px;
padding-bottom: 20px;
}
/* .vis-controls.is-sticky:before {
content: " ";
display: block;
background: red;
width: 100%;
height: 30px;
position: absolute;
bottom: 0;
} */
</style>