summaryrefslogtreecommitdiff
path: root/tests/typ/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-07 20:00:21 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-07 20:00:21 +0100
commit68503b9a07b00bce3f4d377bcfe945452de815ea (patch)
tree3719ef491b993c59b619ca215963000f4847e78f /tests/typ/layout
parent9730e785a885a4ab5fcc52ce705298654f82f9c2 (diff)
Redesigned template layout
Diffstat (limited to 'tests/typ/layout')
-rw-r--r--tests/typ/layout/box-block.typ1
-rw-r--r--tests/typ/layout/page-box.typ14
-rw-r--r--tests/typ/layout/page-margin.typ20
-rw-r--r--tests/typ/layout/page-style.typ28
-rw-r--r--tests/typ/layout/page.typ39
-rw-r--r--tests/typ/layout/pagebreak.typ34
-rw-r--r--tests/typ/layout/spacing.typ27
-rw-r--r--tests/typ/layout/stack-1.typ2
8 files changed, 102 insertions, 63 deletions
diff --git a/tests/typ/layout/box-block.typ b/tests/typ/layout/box-block.typ
index 14258c1e..c6928074 100644
--- a/tests/typ/layout/box-block.typ
+++ b/tests/typ/layout/box-block.typ
@@ -15,6 +15,7 @@ Apart
#set page(height: 60pt)
First!
+
#block[
But, soft! what light through yonder window breaks? It is the east, and Juliet
is the sun.
diff --git a/tests/typ/layout/page-box.typ b/tests/typ/layout/page-box.typ
new file mode 100644
index 00000000..ed9d3e14
--- /dev/null
+++ b/tests/typ/layout/page-box.typ
@@ -0,0 +1,14 @@
+// Test that you can't do page related stuff in a container.
+
+---
+A
+#box[
+ B
+ #pagebreak()
+ #set page("a4")
+]
+C
+
+// No consequences from the page("A4") call here.
+#pagebreak()
+D
diff --git a/tests/typ/layout/page-margin.typ b/tests/typ/layout/page-margin.typ
new file mode 100644
index 00000000..44126d2d
--- /dev/null
+++ b/tests/typ/layout/page-margin.typ
@@ -0,0 +1,20 @@
+// Test page margins.
+
+---
+// Set all margins at once.
+[
+ #set page(height: 20pt, margins: 5pt)
+ #place(top + left)[TL]
+ #place(bottom + right)[BR]
+]
+
+---
+// Set individual margins.
+#set page(height: 40pt)
+[#set page(left: 0pt); #align(left)[Left]]
+[#set page(right: 0pt); #align(right)[Right]]
+[#set page(top: 0pt); #align(top)[Top]]
+[#set page(bottom: 0pt); #align(bottom)[Bottom]]
+
+// Ensure that specific margins override general margins.
+[#set page(margins: 0pt, left: 20pt); Overriden]
diff --git a/tests/typ/layout/page-style.typ b/tests/typ/layout/page-style.typ
new file mode 100644
index 00000000..f27551b2
--- /dev/null
+++ b/tests/typ/layout/page-style.typ
@@ -0,0 +1,28 @@
+// Test setting page styles.
+
+---
+// Empty with styles
+// Should result in one conifer-colored A11 page.
+#set page("a11", flipped: true, fill: conifer)
+
+---
+// Empty with styles and then pagebreak
+// Should result in two forest-colored pages.
+#set page(fill: forest)
+#pagebreak()
+
+---
+// Empty with multiple page styles.
+// Should result in a small white page.
+#set page("a4")
+#set page("a5")
+#set page(width: 1cm, height: 1cm)
+
+---
+// Empty with multiple page styles.
+// Should result in one eastern-colored A11 page.
+#set page("a4")
+#set page("a5")
+#set page("a11", flipped: true, fill: eastern)
+#set text("Roboto", white, smallcaps: true)
+Typst
diff --git a/tests/typ/layout/page.typ b/tests/typ/layout/page.typ
index 35f338f4..89d0f2fb 100644
--- a/tests/typ/layout/page.typ
+++ b/tests/typ/layout/page.typ
@@ -1,34 +1,33 @@
-// Test configuring page sizes and margins.
+// Test the page class.
+
+---
+// Just empty page.
+// Should result in auto-sized page, just like nothing.
+#page[]
+
+---
+// Just empty page with styles.
+// Should result in one conifer-colored A11 page.
+#page("a11", flipped: true, fill: conifer)[]
---
// Set width and height.
+// Should result in one high and one wide page.
#set page(width: 80pt, height: 80pt)
[#set page(width: 40pt);High]
[#set page(height: 40pt);Wide]
-// Set all margins at once.
-[
- #set page(margins: 5pt)
- #place(top + left)[TL]
- #place(bottom + right)[BR]
-]
-
-// Set individual margins.
-#set page(height: 40pt)
-[#set page(left: 0pt); #align(left)[Left]]
-[#set page(right: 0pt); #align(right)[Right]]
-[#set page(top: 0pt); #align(top)[Top]]
-[#set page(bottom: 0pt); #align(bottom)[Bottom]]
-
-// Ensure that specific margins override general margins.
-[#set page(margins: 0pt, left: 20pt); Overriden]
-
// Flipped predefined paper.
[#set page(paper: "a11", flipped: true);Flipped A11]
---
+// Test page fill.
#set page(width: 80pt, height: 40pt, fill: eastern)
#text(15pt, "Roboto", fill: white, smallcaps: true)[Typst]
+#page(width: 40pt, fill: none, margins: auto, top: 10pt)[Hi]
-#set page(width: 40pt, fill: none, margins: auto, top: 10pt)
-Hi
+---
+// Just page followed by pagebreak.
+// Should result in one forest-colored A11 page and one auto-sized page.
+#page("a11", flipped: true, fill: forest)[]
+#pagebreak()
diff --git a/tests/typ/layout/pagebreak.typ b/tests/typ/layout/pagebreak.typ
index 81af710c..005ca244 100644
--- a/tests/typ/layout/pagebreak.typ
+++ b/tests/typ/layout/pagebreak.typ
@@ -1,35 +1,23 @@
// Test forced page breaks.
---
-First of two
+// Just a pagebreak.
+// Should result in two auto-sized pages.
#pagebreak()
-#set page(height: 40pt)
-Second of two
---
-// Make sure that you can't do page related stuff in a container.
-A
-#box[
- B
- #pagebreak()
- #set page("a4")
-]
-C
-
-// No consequences from the page("A4") call here.
+// Pagebreak, empty with styles and then pagebreak
+// Should result in one auto-sized page and two conifer-colored A11 pages.
+#pagebreak()
+#set page(width: 2cm, fill: conifer)
#pagebreak()
-D
---
-// Test a combination of pages with bodies and normal content.
-
+// Test a combination of pagebreaks, styled pages and pages with bodies.
#set page(width: 80pt, height: 30pt)
-
-[#set page(width: 80pt); First]
-#pagebreak()
+[#set page(width: 60pt); First]
#pagebreak()
#pagebreak()
-Fourth
-#page(height: 20pt)[]
-Sixth
-[#set page(); Seventh]
+Third
+#page(height: 20pt, fill: forest)[]
+Fif[#set page();th]
diff --git a/tests/typ/layout/spacing.typ b/tests/typ/layout/spacing.typ
index 37aa8eaa..82531efc 100644
--- a/tests/typ/layout/spacing.typ
+++ b/tests/typ/layout/spacing.typ
@@ -1,38 +1,27 @@
// Test the `h` and `v` functions.
---
-// Ends paragraphs.
-Tightly #v(0pt) packed
+// Linebreak and v(0pt) are equivalent.
+#box[A \ B] #box[A #v(0pt) B]
// Eating up soft spacing.
-Inv #h(0pt) isible
+Inv#h(0pt)isible
// Multiple spacings in a row.
Add #h(10pt) #h(10pt) up
// Relative to area.
#let x = 25% - 4pt
-| #h(x) | #h(x) | #h(x) | #h(x) |
+|#h(x)|#h(x)|#h(x)|#h(x)|
// Fractional.
| #h(1fr) | #h(2fr) | #h(1fr) |
---
-// Test spacing collapsing with parbreaks.
-#v(0pt)
-A
-#v(0pt)
-B
-#v(0pt)
-
-C #parbreak() D
-
----
-// Test that spacing can carry paragraph and page style properties.
-
-A[#set par(align: right);#h(1cm)]B
-[#set page(height: 20pt);#v(1cm)]
-B
+// Test spacing collapsing before spacing.
+#set par(align: right)
+A #h(0pt) B #h(0pt) \
+A B
---
// Missing spacing.
diff --git a/tests/typ/layout/stack-1.typ b/tests/typ/layout/stack-1.typ
index d8075e9d..eee1f4d1 100644
--- a/tests/typ/layout/stack-1.typ
+++ b/tests/typ/layout/stack-1.typ
@@ -31,7 +31,7 @@
---
// Test spacing.
#set page(width: 50pt, margins: 0pt)
-#set par(spacing: 5pt)
+#set par(leading: 5pt)
#let x = square(size: 10pt, fill: eastern)
#stack(dir: rtl, spacing: 5pt, x, x, x)