When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:
main {
max-width: 38rem;
padding: 2rem;
margin: auto;
}| <script> | |
| document.documentElement.dataset.embed = window.location.search.includes('type=embed') ? "yep" : "nope"; | |
| </script> | |
| <main> | |
| <h1>Styling <code><details></code>: Horizontal Accordion <em>(no animation)</em></h1> | |
| <h2>Demo</h2> | |
| <div id="demo"> |
| // by goo - https://www.gurukhalsa.me/ | |
| // https://news.ycombinator.com/item?id=45219644 | |
| // creates a selection box like on Desktop OSes | |
| (() => { let startX, startY, box, dragging = false; | |
| const style = document.createElement('style'); | |
| style.textContent = ` | |
| .___selection-box { | |
| position: absolute; |
| <!-- just serve this with Caddy and access browser --> | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Document</title> | |
| <script type="importmap"> | |
| { |
| package main | |
| // inspiration: https://threedots.tech/post/safer-enums-in-go/ | |
| import "fmt" | |
| // don't use `type Role string` as it can accept any string | |
| type Role struct { | |
| s string | |
| } |
| func Recoverer(next http.Handler) http.Handler { | |
| fn := func(w http.ResponseWriter, r *http.Request) { | |
| defer func() { | |
| if err := recover(); err != nil { | |
| body, e := io.ReadAll(r.Body) | |
| if e != nil { | |
| body = []byte("recoverer: body unreadable") | |
| } | |
| slog.Error("panic", | |
| slog.String("path", u.Path), |
| default: | |
| just --list | |
| export GOBIN := `echo $PWD/bin` | |
| @devsetup: | |
| echo "installing dev dependencies at $GOBIN ..." | |
| go install -C ./tools github.com/golangci/golangci-lint/cmd/golangci-lint | |
| go install -C ./tools github.com/cespare/reflex | |
| package main | |
| import ( | |
| "encoding/gob" | |
| "fmt" | |
| "log" | |
| "net" | |
| "time" | |
| ) |
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| type Config struct { | |
| Timeout time.Duration | |
| Name string |
| package main | |
| import "fmt" | |
| // set these vars on build time: | |
| // go build -ldflags "-X main.version=v1.2.3 -X main.commit=$(git rev-parse --short HEAD) -X main.date=$(date -u '+%Y-%m-%dT%H:%M:%S')" -o foo -v ./foo.go | |
| var ( | |
| service = "some-service" | |
| version string | |
| commit string |