spirali / nelsie

Framework for Creating Slides
MIT License
39 stars 4 forks source link

List counting trough multiple pages #40

Closed ZakkProjects closed 3 months ago

ZakkProjects commented 3 months ago

There is (afaik) no way to continue numbered lists across multiple pages.

When using "counters" parameter q_lst = ListBox(b, list_type="1", counters=[0]) , there is weird behaviour with appending [0] to the end of counters. Which results in counting restart. First i thought it has something with nesting lists, but it does not seem to be the case.

Is there a propper way to continue list on next slide (not show part) ? Or even better, an option to set starting number when using numbered lists ?

spirali commented 3 months ago

I am not sure that I understand your problem. If you want split a list on more steps (= pdf pages) then you can use "show" parameter.

    lst = ListBox(slide)
    lst.text("One")
    lst.text(show="2+", text="Two")
    lst.text(show="3+", text="Three")
ZakkProjects commented 3 months ago

Showing/hiding feature works great.

Problem arises once i try to make a list spanning multiple pages, but hiding all previous content. Quick example:image

Since boxes reserve their space even if not showed this code:

@deck.slide()
def foo(slide):
    b = slide.box(align_items="flex-start", width="100%", p_left="30", p_right="30", p_top="30", p_bottom="80", flex_grow=1, justify_content="start", gap=(10, 10))
    q_lst = ListBox(b, list_type="1")
    q_lst.text("Point 1", show="1")
    lst = q_lst.list()
    lst.text("content 1", show="1")
    lst.text("content 1", show="1")
    lst.text("content 1", show="1")
    lst.text("content 1", show="1")
    lst.text("content 1", show="1")
    lst.text("content 1", show="1")

    q_lst.text("Point 2", show="2")
    lst = q_lst.list()
    lst.text("content 2", show="2")
    lst.text("content 2", show="2")
    lst.text("content 2", show="2")
    lst.text("content 2", show="2")
    lst.text("content 2", show="2")
    lst.text("content 2", show="2")
    lst.text("content 2", show="2")

results in lot of empty space and possibly overflowing slide image

After reading more documentation, i discovered "active" parameter. But active parameter on text object inside list does not apply to bullets (similar issue with show which was since fixed ??)

which makes this code almost work perfectly:

@deck.slide()
def foo(slide):
    b = slide.box(align_items="flex-start", width="100%", p_left="30", p_right="30", p_top="30", p_bottom="80", flex_grow=1, justify_content="start", gap=(10, 10))
    q_lst = ListBox(b, list_type="1")
    q_lst.text("Point 1", active="1")
    lst = q_lst.list(active="1")
    lst.text("content 1", active="1")
    lst.text("content 1", active="1")
    lst.text("content 1", active="1")
    lst.text("content 1", active="1")
    lst.text("content 1", active="1")
    lst.text("content 1", active="1")

    q_lst.text("Point 2", active="2")
    lst = q_lst.list(active="2")
    lst.text("content 2", active="2")
    lst.text("content 2", active="2")
    lst.text("content 2", active="2")
    lst.text("content 2", active="2")
    lst.text("content 2", active="2")
    lst.text("content 2", active="2")
    lst.text("content 2", active="2")

image

So in the end, the solution could be applying similar propagation behavior of show to active.

spirali commented 3 months ago

Thank you for the explanation. I did not consider this situation. A hotfix is to modify counters directly:

    list = ListBox(slide, list_type="1")
    list.counters[-1] = 2
    list.text("Hello")

It will start the counter on different values. I will think about it and prepare a more elegant solution.