Skip to content

Commit d9adca5

Browse files
committed
fix layout
1 parent b66b321 commit d9adca5

File tree

4 files changed

+73
-12
lines changed

4 files changed

+73
-12
lines changed

NetworkDynamicsInspector/assets/app.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,34 @@ html, body {
1616
//font-size: 12px;
1717
//color: blue;
1818
}
19+
20+
.maingrid {
21+
display: grid;
22+
grid-template-columns: 25% 75%;
23+
width: 100%;
24+
}
25+
.graphplot-col {
26+
display: grid;
27+
grid-template-columns: 100%;
28+
}
29+
.timeseries-col{
30+
display: grid;
31+
grid-template-columns: 100%;
32+
}
33+
34+
.graphplot-card {
35+
heigth:400px;
36+
/* grid-column: 1; */
37+
}
38+
.gpstate-control-card.vertex {
39+
height:min-content;
40+
/* grid-column: 1; */
41+
}
42+
.gpstate-control-card.edge {
43+
height:min-content;
44+
/* grid-column: 1; */
45+
}
46+
47+
.timeslider-card {
48+
height:min-content;
49+
}

NetworkDynamicsInspector/src/NetworkDynamicsInspector.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function graphplot_card(app; kwargs...)
158158
@debug "GP: viewport => adapt xy scaling"
159159
adapt_xy_scaling!(ax)
160160
end
161-
Card(fig; kwargs...)
161+
Card(fig; class="graphplot-card", kwargs...)
162162
end
163163
function _gracefully_extract_states!(vec, sol, t, idxs, rel)
164164
isvalid(s) = SII.is_variable(sol, s) || SII.is_parameter(sol, s) || SII.is_observed(sol, s)
@@ -172,6 +172,7 @@ function _gracefully_extract_states!(vec, sol, t, idxs, rel)
172172
end
173173
end
174174
function adapt_xy_scaling!(ax)
175+
autolimits!(ax)
175176
vp = ax.scene.viewport[]
176177
fl = ax.finallimits[]
177178
vp_aspect = reduce(/, vp.widths)
@@ -212,6 +213,7 @@ function timeslider_card(app)
212213
justify_content="begin",
213214
align_items="center",
214215
);
216+
class="timeslider-card"
215217
);
216218
end
217219

@@ -222,6 +224,7 @@ function gpstate_control_card(app, type)
222224
stateobs_rel = type ==:vertex ? app.graphplot.nstate_rel : app.graphplot.estate_rel
223225
colorrange = type == :vertex ? app.graphplot.ncolorrange : app.graphplot.ecolorrange
224226
colorscheme = type == :vertex ? app.graphplot.ncolorscheme : app.graphplot.ecolorscheme
227+
class = type == :vertex ? "gpstate-control-card vertex" : "gpstate-control-card edge"
225228

226229
####
227230
#### State selection
@@ -306,7 +309,8 @@ function gpstate_control_card(app, type)
306309
cslider,
307310
# RoundedLabel(@lift $maxrange[2]; style=Styles("text-align"=>"left"));
308311
columns="100%",
309-
)
312+
);
313+
class
310314
)
311315
end
312316
function _maxrange(sol, idxs, rel)

NetworkDynamicsInspector/src/widgets.jl

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,22 @@ function Bonito.jsrender(session::Session, slider::ContinuousSlider)
282282
}
283283
}, { signal: controller.signal });
284284
}
285+
286+
// update positions on resize
287+
const observer = new ResizeObserver(entries => {
288+
thumbpos_r = isNaN(thumbval_r) ? 0 : val_to_pos(thumbval_r);
289+
thumbpos_l = isNaN(thumbval_l) ? 0 : val_to_pos(thumbval_l);
290+
291+
const thumb_width = thumb_r.offsetWidth / 2;
292+
const left_r = (thumbpos_r - thumb_width) + 'px';
293+
const left_l = (thumbpos_l - thumb_width) + 'px';
294+
295+
thumb_l.style.left = left_l;
296+
thumb_r.style.left = left_r;
297+
track_active.style.left = thumbpos_l + 'px'; // Update the active track
298+
track_active.style.width = (thumbpos_r-thumbpos_l) + 'px'; // Update the active track
299+
});
300+
observer.observe(container);
285301
}
286302
"""
287303
onload(session, container, jscode)
@@ -383,14 +399,17 @@ function Bonito.jsrender(session::Session, multiselect::MultiSelect)
383399
select
384400
)
385401

386-
# jqdocument = Bonito.JSString(raw"$(document)")
402+
jqdocument = Bonito.JSString(raw"$(document)")
387403
jqselect = Bonito.JSString(raw"$('#"* id * raw"')")
388404

389405
esc = Bonito.JSString(raw"$")
390406
js_onload = js"""
391407
(select) => {
392-
$jqselect.select2({
393-
placeholder: $(multiselect.placeholder)
408+
$(jqdocument).ready(function(){
409+
$jqselect.select2({
410+
width: '100%',
411+
placeholder: $(multiselect.placeholder)
412+
});
394413
});
395414
396415
function array_equal(a1, a2){

test/Inspector_test.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,20 @@ let
8181
@info "start new session"
8282
WGLMakie.activate!(resize_to=:parent)
8383
NetworkDynamicsInspector.clear_obs!(app)
84-
Grid(
85-
NetworkDynamicsInspector.graphplot_card(app; height="400px"),
86-
NetworkDynamicsInspector.gpstate_control_card(app, :vertex),
87-
NetworkDynamicsInspector.gpstate_control_card(app, :edge),
88-
NetworkDynamicsInspector.timeslider_card(app),
89-
columns="100%",
90-
width="500px"
84+
DOM.div(
85+
DOM.div(
86+
NetworkDynamicsInspector.graphplot_card(app),
87+
NetworkDynamicsInspector.gpstate_control_card(app, :vertex),
88+
NetworkDynamicsInspector.gpstate_control_card(app, :edge),
89+
class="graphplot-col"
90+
),
91+
DOM.div(
92+
NetworkDynamicsInspector.timeslider_card(app),
93+
class="timeseries-col"
94+
),
95+
# columns="1fr 2fr",
96+
# width="500px",
97+
class="maingrid"
9198
) |> wrap_assets
9299
end;
93100
serve_app(_app)

0 commit comments

Comments
 (0)