Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix margin-element node and make margin_top optional #137

Merged
merged 3 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
https://github.com/anvilistas/anvil-extras/pull/121
* storage - update and clear were missing from the documented api
https://github.com/anvilistas/anvil-extras/pull/125
* PageBreak - fix margin_top property and make it optional
https://github.com/anvilistas/anvil-extras/pull/137

## Updates
* Slider Component - bump javascript dependency and refactor. No changes to the component's public API.
Expand Down
2 changes: 1 addition & 1 deletion client_code/PageBreak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class PageBreak(PageBreakTemplate):
def __init__(self, margin_top, **properties):
def __init__(self, margin_top=0, **properties):
self.margin_node = _S(anvil.js.get_dom_node(self)).find(".margin-element")
self.margin_top = margin_top
self.init_components(**properties)
Expand Down
9 changes: 5 additions & 4 deletions client_code/PageBreak/form_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ container:
properties: {tooltip: '', background: '', foreground: '', border: '', visible: true,
role: null, html: "<!--\nBased on the snippet at https://anvil.works/forum/t/plots-in-pdf-being-divided-between-two-pages/7774/5\n\
-->\n<div class=\"break-container\" style=\"overflow: hidden;\">\n <div style=\"\
page-break-after:always;\"/>\n <div style=\"margin-top: 0px;\"/>\n</div>\n\n\
<style>\n .break-container {\n border: 1px solid grey;\n }\n @media print\
\ {\n .break-container {\n border: none;\n }\n }\n</style>"}
page-break-after:always;\"/>\n <div class=\"margin-element\" style=\"margin-top:\
\ 0px;\"/>\n</div>\n\n<style>\n .break-container {\n border: 1px solid grey;\n\
\ }\n @media print {\n .break-container {\n border: none;\n }\n\
\ }\n</style>"}
components: []
is_package: true
custom_component: true
properties:
- {name: margin_top, type: number, default_value: 0, default_binding_prop: true}
- {name: margin_top, type: number, default_value: 0, default_binding_prop: true, description: Use to adjust whitespace at the top of each page in the generated pdf. This is an optional property and defaults to 0. Can be positive or negative. Negative numbers will reduce whitespace in the generated pdf.}
4 changes: 4 additions & 0 deletions docs/guides/components/page_break.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
PageBreak
=========
For use in forms which are rendered to PDF to indicate that a page break is required.

The ``margin_top`` property is optional. In the generated pdf you may want more or less white space at the top of the page.
You can set the ``margin_top`` property to a positive/negative number to adjust the whitespace.
Most of the time this is unnecessary. This won't have any effect on the designer only the generated pdf.