Skip to content

Commit

Permalink
improved layout
Browse files Browse the repository at this point in the history
  • Loading branch information
rambip committed Oct 15, 2023
1 parent fe8947a commit 761831f
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,8 @@ fn Description<'a>(example: &'a Example) -> impl IntoView {
}


/// the in-browser demo of the example
#[component]
fn Showcase<'a>(example: &'a Example) -> impl IntoView {
view!{
<div style="border: 2px solid black; height: 50%; overflow-y: scroll"
css=example.css>
{example.code}
</div>
}
}

fn random_small_int(n: usize) -> usize {
let mut buf: &mut [u8] = &mut [0,0];
let buf: &mut [u8] = &mut [0,0];
getrandom(buf).unwrap();
let (a,b) = (buf[0] as usize, buf[1] as usize);
(a*256 + b) % n
Expand Down Expand Up @@ -76,11 +65,17 @@ fn ExampleView<F,I> (
Some(e) => view!{
<Description example=e/>
// the code
<div style="height: 50%; overflow-y: scroll"
inner_html=e.highlighted_source
>
<div style="display:flex; height: 100%">
<div style="width: 50%; height: 100%; overflow-y: scroll"
inner_html=e.highlighted_source
>
</div>
// the in-browser demo
<div style="border: 2px solid black; margin: 10px; width: 50%; height: 100%; overflow-y: scroll"
css=e.css>
{e.code}
</div>
</div>
<Showcase example=e/>
}.into_view(),
None => fallback(name()).into_view()
}
Expand All @@ -107,8 +102,11 @@ fn App(examples: examples::Examples,

view!{
<Router>
<FuzzyFinder snippets=snippets choice=set_current_example_by_index.clone()/>
<RandomSelector choice=set_current_example_by_index n=N_EXAMPLES/>
<div style:display="flex">
<FuzzyFinder snippets=snippets choice=set_current_example_by_index.clone()/>
<RandomSelector choice=set_current_example_by_index n=N_EXAMPLES/>
</div>
<h2>{current_name}</h2>
<ExampleView
examples=examples
name=current_name
Expand Down

0 comments on commit 761831f

Please sign in to comment.