Skip to content

Commit

Permalink
refactor: fixed problems with tests (#41)
Browse files Browse the repository at this point in the history
- corrected some minor problems within tests
- removed the code block body measurement
  • Loading branch information
TimeTravelPenguin authored Jan 5, 2025
1 parent db33533 commit 31e6c45
Show file tree
Hide file tree
Showing 33 changed files with 43 additions and 45 deletions.
Binary file modified assets/previews/frappe.webp
Binary file not shown.
Binary file modified assets/previews/latte.webp
Binary file not shown.
Binary file modified assets/previews/macchiato.webp
Binary file not shown.
Binary file modified assets/previews/mocha.webp
Binary file not shown.
Binary file modified assets/previews/preview.webp
Binary file not shown.
1 change: 1 addition & 0 deletions examples/requirements.typ
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#import "@preview/cetz:0.3.1"
#import "@preview/cetz-plot:0.1.0"
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@ update-test-refs:
typst-test util export
for dir in tests/*/out; do
mv "$dir" "$(dirname "$dir")/ref"
refpath="$(dirname "$dir")/ref"
mkdir -p "$refpath"
mv "$dir"/* "$refpath"
done
Binary file modified manual/manual_latte.pdf
Binary file not shown.
Binary file modified manual/manual_mocha.pdf
Binary file not shown.
Binary file added src/styling/code.pdf
Binary file not shown.
14 changes: 6 additions & 8 deletions src/styling/code.typ
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
outset: 3pt,
radius: 3pt,
breakable: false,
width: it => measure(it).width + 2cm,
)

#let default-code-box-config = (
Expand Down Expand Up @@ -42,17 +41,16 @@
#box(..config, it)
]

#show raw.where(block: true): it => (
#show raw.where(block: true): it => {
if not code-block {
return it
}

context [
#let config = default-code-block-config + (fill: palette.colors.crust.rgb) + block-config

#if type(config.at("width")) == function {
config.insert("width", (config.at("width"))(it))
}

#block(..config, it)
]
)
}

#body
]
Binary file modified tests/background/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/background/ref/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 26 additions & 25 deletions tests/background/test.typ
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
#import "/src/lib.typ": catppuccin, flavors, get-flavor, config-code-blocks

#set page(width: auto, height: auto)
#import "/src/lib.typ": catppuccin, flavors, get-flavor, config-code-blocks

#let perms = ()
#for flavor in flavors.keys() {
#for flavor in flavors.values() {
for code-block in (true, false) {
for syntax in (true, false) {
perms.push((flavor: flavor, code-block: code-block, syntax: syntax))
}
}
}

#for p in perms [
#pagebreak(weak: true)
#show: catppuccin.with(p.flavor, code-block: p.code-block, code-syntax: p.syntax)
#for p in perms {
show: catppuccin.with(p.flavor, code-block: p.code-block, code-syntax: p.syntax)
pagebreak(weak: true)

= #get-flavor(p.flavor).name
- Code block: #p.code-block
- Code syntax: #p.syntax
block([
= #p.flavor.name
- Code block: #p.code-block
- Code syntax: #p.syntax

```typ
#import "/src/lib.typ": catppuccin, flavors, get-flavor
```typ
#import "/src/lib.typ": catppuccin, flavors, get-flavor
#let perms = ()
#for flavor in flavors.values() {
for code-block in (true, false) {
for syntax in (true, false) {
perms.push((flavor: flavor, code-block: code-block, syntax: syntax))
#let perms = ()
#for flavor in flavors.values() {
for code-block in (true, false) {
for syntax in (true, false) {
perms.push((flavor: flavor, code-block: code-block, syntax: syntax))
}
}
}
}
#for p in perms [
#show: catppuccin.with(p.flavor, code-block: p.code-block, code-syntax: p.syntax)
= #get-flavor(p.flavor).name
== Code block: #p.code-block
== Code syntax: #p.syntax
]
```
]
#for p in perms [
#show: catppuccin.with(p.flavor, code-block: p.code-block, code-syntax: p.syntax)
= #p.flavor.name
== Code block: #p.code-block
== Code syntax: #p.syntax
]
```
])
}
Binary file modified tests/colors/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/colors/ref/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/colors/ref/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/colors/ref/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 7 additions & 11 deletions tests/colors/test.typ
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#import "/src/lib.typ": catppuccin, flavors, get-flavor

#set page(width: auto, height: auto)
#import "/src/lib.typ": catppuccin, flavors, get-flavor

#let color-swatches(palette) = {
let swatches = ()
Expand All @@ -19,16 +18,13 @@
grid(
columns: 4,
column-gutter: 1cm,
row-gutter: 1em,
row-gutter: 3.5mm,
..swatches,
)
}

#for flavor in flavors.keys() [
#pagebreak(weak: true)
#show: catppuccin.with(flavor)

#let palette = get-flavor(flavor)
#color-swatches(palette)
]

#for flavor in flavors.values() {
pagebreak(weak: true)
show: catppuccin.with(flavor)
color-swatches(flavor)
}

0 comments on commit 31e6c45

Please sign in to comment.