andreasKroepelin / polylux

A package for creating slides in Typst
https://polylux.dev/book
MIT License
1.18k stars 55 forks source link

Feature: Resizable text blocks #63

Closed ntjess closed 1 year ago

ntjess commented 1 year ago

Similar to Powerpoint's "resize shape to fit text" feature. See the demo here:

https://github.com/andreasKroepelin/polylux/assets/23620506/e0aaaac9-1343-46e0-aaba-db1f957ec7db

The only downside is it requires the user to place a <before-fill> label prior to the command. Since query does not let you search for specific content blocks, this seemed like the best stand-in solution.

ntjess commented 1 year ago

I made another modification I think will be helpful. Previously, content couldn't be made larger, only smaller to resize. Also, scaled content would no longer wrap to the edge of the slide. These are now both fixed:

Content now wraps to the edge of the page

https://github.com/andreasKroepelin/polylux/assets/23620506/da834eec-a02a-49ad-a270-cfc7cecb7086

Content now resizes larger when the user doesn't constrain its initial width:

https://github.com/andreasKroepelin/polylux/assets/23620506/99ac21f9-aa4d-49da-bbe7-796477f78fe5

ntjess commented 1 year ago

I realize some documentation might be helpful, do you think it is worth including something like this? (of course along with the source file)

autosizing.pdf

andreasKroepelin commented 1 year ago

Extensive documentation is very appreciated. However, let us add this as a page in the book together with some preview images. I'm on vacation currently, I can work on that afterwards (feel free to start a markdown document as well, we'll figure out where to put it later).

andreasKroepelin commented 1 year ago

I had to change some of the logic a bit because the measured available height was wrong on slides with lots of stuff above the actual slide content. Also, there is only one function now, fit-to-height, and you can give a height of 1fr to specify that you want the remaining space. Smaller interface, whoop whoop! 🥳

Thanks for the idea and the bulk of the implementation! I will add proper documentation later.