|
29 | 29 |
|
30 | 30 | const optionsStore: Writable<PlotInputs> = writable(options); |
31 | 31 |
|
| 32 | + function* range(start, end) { |
| 33 | + yield start; |
| 34 | + if (start === end) return; |
| 35 | + yield* range(start + 1, end); |
| 36 | + } |
| 37 | +
|
32 | 38 | function* spacedDegrees() { |
33 | | - // TODO rewrite this, looks too boring |
34 | | - let i = 0; |
| 39 | + let current = 0, |
| 40 | + round = 0; |
35 | 41 |
|
36 | 42 | while (true) { |
37 | | - yield 120 * (i % 3) + (i > 2 ? 60 / Math.floor(i / 3) : 0); |
38 | | - i++; |
| 43 | + for (const i of range(0, 3 * (2 ^ round))) { |
| 44 | + current += 120 / (2 ^ round); |
| 45 | + if (i % 2 === 0) { |
| 46 | + yield current % 360; |
| 47 | + console.log(current); |
| 48 | + } |
| 49 | + } |
| 50 | + console.log("finished round"); |
| 51 | + round++; |
39 | 52 | } |
40 | 53 | } |
41 | 54 |
|
|
58 | 71 | onDestroy(unsubscribe); |
59 | 72 | </script> |
60 | 73 |
|
61 | | -<div> |
| 74 | +<div class="fplt-create-modal"> |
62 | 75 | <div class="fplt-container"> |
63 | | - <div class="fplt-options"> |
64 | | - <div class="fplt-settings"> |
65 | | - <SettingItem name="Title"> |
66 | | - <TextInput bind:value={$optionsStore.title} /> |
67 | | - </SettingItem> |
68 | | - <SettingItem name="Label X"> |
69 | | - <TextInput bind:value={$optionsStore.xAxis.label} /> |
70 | | - </SettingItem> |
71 | | - <SettingItem name="Label Y"> |
72 | | - <TextInput bind:value={$optionsStore.yAxis.label} /> |
73 | | - </SettingItem> |
74 | | - <SettingItem name="Domain"> |
75 | | - <NumberInput |
76 | | - placeholder="X min" |
77 | | - bind:value={$optionsStore.xAxis.domain.min} |
78 | | - /> |
79 | | - <NumberInput |
80 | | - placeholder="X max" |
81 | | - bind:value={$optionsStore.xAxis.domain.max} |
82 | | - /> |
83 | | - <NumberInput |
84 | | - placeholder="Y min" |
85 | | - bind:value={$optionsStore.yAxis.domain.min} |
86 | | - /> |
87 | | - <NumberInput |
88 | | - placeholder="Y max" |
89 | | - bind:value={$optionsStore.yAxis.domain.max} |
90 | | - /> |
91 | | - </SettingItem> |
92 | | - <SettingItem name="Disable Zoom"> |
93 | | - <Switch bind:checked={$optionsStore.disableZoom} /> |
94 | | - </SettingItem> |
95 | | - <SettingItem name="Show Grid"> |
96 | | - <Switch bind:checked={$optionsStore.grid} /> |
97 | | - </SettingItem> |
98 | | - </div> |
99 | | - </div> |
100 | | - <div class="fplt-data"> |
101 | | - Data |
102 | | - <div class="fplt-fns-container"> |
103 | | - <div class="fplt-list"> |
104 | | - {#each $optionsStore.data as datum} |
105 | | - <Function |
106 | | - bind:datum |
107 | | - unmount={() => { |
108 | | - $optionsStore.data = $optionsStore.data.filter( |
109 | | - (val) => val.id != datum.id |
110 | | - ); |
111 | | - }} |
| 76 | + <div class="fplt-left"> |
| 77 | + <div class="fplt-options"> |
| 78 | + <div class="fplt-settings"> |
| 79 | + <SettingItem name="Title"> |
| 80 | + <TextInput bind:value={$optionsStore.title} /> |
| 81 | + </SettingItem> |
| 82 | + <SettingItem name="Label X"> |
| 83 | + <TextInput bind:value={$optionsStore.xAxis.label} /> |
| 84 | + </SettingItem> |
| 85 | + <SettingItem name="Label Y"> |
| 86 | + <TextInput bind:value={$optionsStore.yAxis.label} /> |
| 87 | + </SettingItem> |
| 88 | + <SettingItem name="Domain"> |
| 89 | + <NumberInput |
| 90 | + placeholder="Xmin" |
| 91 | + bind:value={$optionsStore.xAxis.domain.min} |
| 92 | + /> |
| 93 | + <NumberInput |
| 94 | + placeholder="Xmax" |
| 95 | + bind:value={$optionsStore.xAxis.domain.max} |
| 96 | + /> |
| 97 | + <NumberInput |
| 98 | + placeholder="Ymin" |
| 99 | + bind:value={$optionsStore.yAxis.domain.min} |
112 | 100 | /> |
113 | | - {:else} |
114 | | - <div class="fplt-empty"><i>No data</i></div> |
115 | | - {/each} |
| 101 | + <NumberInput |
| 102 | + placeholder="Ymax" |
| 103 | + bind:value={$optionsStore.yAxis.domain.max} |
| 104 | + /> |
| 105 | + </SettingItem> |
| 106 | + <SettingItem name="Disable Zoom"> |
| 107 | + <Switch bind:checked={$optionsStore.disableZoom} /> |
| 108 | + </SettingItem> |
| 109 | + <SettingItem name="Show Grid"> |
| 110 | + <Switch bind:checked={$optionsStore.grid} /> |
| 111 | + </SettingItem> |
116 | 112 | </div> |
117 | | - <div class="fplt-add"> |
118 | | - <Button on:click={newDataItem}> |
119 | | - <IconWrapper style="margin-right: 0.5em"> |
120 | | - <Plus /> |
121 | | - </IconWrapper> |
122 | | - Add data |
123 | | - </Button> |
| 113 | + </div> |
| 114 | + <div class="fplt-data"> |
| 115 | + Data |
| 116 | + <div class="fplt-fns-container"> |
| 117 | + <div class="fplt-list"> |
| 118 | + {#each $optionsStore.data as datum} |
| 119 | + <Function |
| 120 | + bind:datum |
| 121 | + unmount={() => { |
| 122 | + $optionsStore.data = $optionsStore.data.filter( |
| 123 | + (val) => val.id != datum.id |
| 124 | + ); |
| 125 | + }} |
| 126 | + /> |
| 127 | + {:else} |
| 128 | + <div class="fplt-empty"><i>No data</i></div> |
| 129 | + {/each} |
| 130 | + </div> |
| 131 | + <div class="fplt-add"> |
| 132 | + <Button on:click={newDataItem}> |
| 133 | + <IconWrapper style="margin-right: 0.5em"> |
| 134 | + <Plus /> |
| 135 | + </IconWrapper> |
| 136 | + Add data |
| 137 | + </Button> |
| 138 | + </div> |
124 | 139 | </div> |
125 | 140 | </div> |
126 | 141 | </div> |
127 | | - <div class="fplt-preview" bind:this={$optionsStore.target} /> |
128 | | - <div class="fplt-sliders">hi</div> |
| 142 | + <div class="fplt-right"> |
| 143 | + <div class="fplt-preview" bind:this={$optionsStore.target} /> |
| 144 | + <div class="fplt-sliders">hi</div> |
| 145 | + </div> |
129 | 146 | </div> |
130 | 147 |
|
131 | | - <SettingItem style="position:absolute;bottom:0;left:0;right:0"> |
132 | | - <Dropdown bind:value={$optionsStore.renderer}> |
133 | | - {#each Object.entries(rendererOptions) as [value, name]} |
134 | | - <option {value}>{name}</option> |
135 | | - {/each} |
136 | | - </Dropdown> |
137 | | - <Button |
138 | | - cta={true} |
139 | | - on:click={() => { |
140 | | - submit($optionsStore); |
141 | | - }} |
142 | | - > |
143 | | - Finish |
144 | | - </Button> |
145 | | - </SettingItem> |
| 148 | + <div class="fplt-actionbar"> |
| 149 | + <SettingItem> |
| 150 | + <Dropdown bind:value={$optionsStore.renderer}> |
| 151 | + {#each Object.entries(rendererOptions) as [value, name]} |
| 152 | + <option {value}>{name}</option> |
| 153 | + {/each} |
| 154 | + </Dropdown> |
| 155 | + <Button |
| 156 | + cta={true} |
| 157 | + on:click={() => { |
| 158 | + submit($optionsStore); |
| 159 | + }} |
| 160 | + > |
| 161 | + Done |
| 162 | + </Button> |
| 163 | + </SettingItem> |
| 164 | + </div> |
146 | 165 | </div> |
147 | 166 |
|
148 | 167 | <style lang="scss"> |
149 | | - .fplt-container { |
| 168 | + .fplt-create-modal { |
150 | 169 | display: grid; |
151 | | - grid-template-columns: initial 1fr; |
152 | | - grid-template-rows: min-content 1fr; |
153 | | - grid-template-areas: |
154 | | - "options preview" |
155 | | - "data sliders"; |
156 | | - } |
157 | | -
|
158 | | - .fplt-options { |
159 | | - grid-area: options; |
| 170 | + grid-template-rows: 1fr min-content; |
| 171 | + gap: 1em; |
| 172 | + height: 100%; |
160 | 173 | } |
161 | 174 |
|
162 | | - .fplt-data { |
163 | | - grid-area: data; |
| 175 | + .fplt-container { |
| 176 | + min-height: 0; |
| 177 | + display: grid; |
| 178 | + grid-template-columns: 26em 1fr; |
| 179 | + gap: 1em; |
| 180 | + height: 100%; |
| 181 | + width: 100%; |
| 182 | + overflow: hidden; |
164 | 183 | } |
165 | 184 |
|
166 | | - .fplt-preview { |
167 | | - grid-area: preview; |
| 185 | + .fplt-left, |
| 186 | + .fplt-right { |
| 187 | + display: flex; |
| 188 | + flex-direction: column; |
| 189 | + place-items: stretch start; |
| 190 | + gap: 1em; |
| 191 | + min-height: 0; |
| 192 | + max-height: 100%; |
| 193 | + overflow-y: auto; |
168 | 194 | } |
169 | 195 |
|
170 | | - .fplt-sliders { |
171 | | - grid-area: sliders; |
| 196 | + .fplt-actionbar { |
| 197 | + padding-top: 1em; |
| 198 | + border-top: 1px solid var(--background-modifier-border); |
| 199 | + height: min-content; |
172 | 200 | } |
173 | 201 |
|
174 | 202 | .fplt-fns-container { |
175 | 203 | display: flex; |
176 | 204 | flex-direction: column; |
177 | 205 | gap: 1em; |
178 | 206 | } |
| 207 | +
|
| 208 | + .fplt-add { |
| 209 | + display: flex; |
| 210 | + flex-direction: row; |
| 211 | + place-items: center; |
| 212 | + } |
179 | 213 | </style> |
0 commit comments