Skip to content

Commit

Permalink
Merge pull request #1 from invopop/multi-currency
Browse files Browse the repository at this point in the history
Multi currency
  • Loading branch information
samlown authored May 13, 2024
2 parents 399ebcf + 3df5886 commit f15577d
Show file tree
Hide file tree
Showing 48 changed files with 2,328 additions and 4,511 deletions.
51 changes: 51 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = ["serve", "-p", "3001", "--pdf", "prince"]
bin = "./gobl.html"
cmd = "templ generate && go build ./cmd/gobl.html"
delay = 1000
exclude_dir = ["tmp", "vendor", "testdata"]
exclude_file = ["gobl.html"]
exclude_regex = ["_test.go", "_templ.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "templ", "css", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[proxy]
enabled = true
app_port = 3001
proxy_port = 3000

[screen]
clear_on_rebuild = false
keep_scroll = true
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,34 @@ GOBL HTML uses [templ](https://templ.guide/) to define a set of components in Go
templ generate
```

During development, it can help massive to have hot reload to be able to make changes and see them quickly. You can do this using the following example command:
During development, it can help massive to have hot reload to be able to make changes and see them quickly. There are two mechanisms we're currently using:

#### Air

Air is a great tool to auto reload potentially any project, but works great with Go. Install with:

```bash
go install github.com/cosmtrek/air@latest
```

The `.toml` is already configured and ready in this repository, so simply run:

```bash
air
```

Air is a bit more reliable at detecting file changes, especially for stylesheets. It's configured to offer a proxy with auto-reload, but of course that will only work at the moment when viewing HTML documents, not PDFs. You'll always need to wait a few seconds before page reloads to give the system chance to recompile.

#### Templ Watcher

Templ comes with a watch flag that can also be useful. It has the disadvantage however that it uses `.txt` files for comparisons and the generated code should not be uploaded to git directly. Start the process with:

```bash
templ generate --watch --cmd="go run ./cmd/gobl.html serve --pdf prince"
```

Before uploading changes to git, be sure to re-run the regular `templ generate` command, as the live version makes temporary modifications to files that need to be replaced.

### Testing

Tests are currently pretty limited. To ensure the basics are covered, the contents of the `examples` directory are converted to HTML, pretty printed, and output to the `examples/out` directory. The tests will ensure the output is as expected. To update the output test data run:
Expand Down
9 changes: 9 additions & 0 deletions assets/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Package assets contains the static resources for things like styles.
package assets

import "embed"

//go:embed styles

// Content stores all the asset contents.
var Content embed.FS
98 changes: 98 additions & 0 deletions assets/styles/envelope.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@page {
font-family: "Inter", sans-serif;
size: A4 portrait;
margin: 10mm;
margin-bottom: 20mm;
counter-increment: page;
font-size: 9pt;
line-height: 1.5em;
color: #4B5563;
}
body {
font-family: "Inter", sans-serif;
font-size: 9pt;
line-height: 1.5em;
margin: 0;
margin-bottom: 0mm;
/* color: #030712; */
/* color: #6B7280; */
color: #4B5563;
}
@media screen {
body {
margin: 10mm;
}
footer.screen {
display: block;
}
footer.print {
display: none;
}
}
article.envelope {
min-height: 100%;
}
article, section, header, div, h1, h2, h3, h4, table, th, td, p {
font-size: 1em;
margin: 0;
}
h1, h2, h3, h4 {
font-weight: 500;
/* color: #030712; */
}
a {
color: #4B5563;
}
table {
border-spacing: 0;
border-collapse: collapse;
}
th, td {
text-align: left;
}
section.footer span.page-number:before {
content: counter(page);
}
@media print {
footer.screen {
display: none;
}
footer.print {
display: block;
}
}
@page {
@bottom {
content: element(footer);
}
}
footer {
height: 12mm;
text-align: right;
padding: 4mm 0mm;
}
footer.print {
position: running(footer);
}
footer.screen {
padding: 2mm 0mm;
}
footer .page-number {
content: counter(page);
}
footer .pages-number {
content: counter(pages);
}
footer .gobl-logo {
float: left;
}
footer.print .notes:after {
content: " · ";
}
footer .gobl-logo img {
width: 8mm;
height: 8mm;
}
footer.print .gobl-logo {
margin-top: -7mm;
}
Loading

0 comments on commit f15577d

Please sign in to comment.