M4-M5: index strips and Lucio branding
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6d39dc1713
commit
45105d292f
47 files changed
+2016
-210
No files matched your search
@@ -37,6 +37,7 @@ site/
|
||||
current -> builds/<id>
|
||||
builds/<id>/index.html, index.<id>.json, a/<slug>/index.html, a/<slug>/manifest.<id>.json, t -> ../../t
|
||||
t/<photo-hash>/<tile-id>.webp
|
||||
og/<hash>.jpg
|
||||
state/
|
||||
site.key
|
||||
pyramids/<photo-hash>.json
|
||||
@@ -51,4 +52,6 @@ npm --prefix web ci
|
||||
npm --prefix web run build
|
||||
```
|
||||
|
||||
`build` type-checks with `tsc --noEmit` (strict) and bundles `app.js`, `app.css` and `worker.js` with esbuild. Each site build copies them to `/assets/` under content-hashed names.
|
||||
`build` type-checks with `tsc --noEmit` (strict) and bundles `app.js`, `app.css`, `worker.js`, the favicon, the chop and the self-hosted woff2 fonts (latin and latin-ext of Bricolage Grotesque, IBM Plex Sans and IBM Plex Mono, from the `@fontsource` packages) with esbuild. Each site build copies them to `/assets/` under content-hashed names.
|
||||
|
||||
Brand files come from the Lucio brand repository. `scripts/sync-brand.sh` copies the tokens, `lucio-morph.js`, the favicon and the chop from `../LUCIO_ip` (or `$LUCIO_IP_DIR`) into `web/brand/`, stripping comments; the copies are committed.
|
||||
+39
-6
@@ -43,6 +43,7 @@ type Summary struct {
|
||||
type albumPlan struct {
|
||||
album *album.Album
|
||||
coverHash string
|
||||
ogHash string
|
||||
coverCrop [4]int
|
||||
hashes []string
|
||||
pending int
|
||||
@@ -148,6 +149,17 @@ func (b *builder) run(ctx context.Context) (*Summary, error) {
|
||||
}
|
||||
plan.coverCrop = crop
|
||||
plan.coverHash = b.proc.CoverHash(coverSrc, crop)
|
||||
ogRegion := process.OGRegion(coverSrc.Width, coverSrc.Height, crop)
|
||||
plan.ogHash = b.proc.OGHash(coverSrc, ogRegion)
|
||||
if !b.proc.HasOG(plan.ogHash) {
|
||||
if _, ok := jobs[plan.ogHash]; !ok {
|
||||
job := &process.Job{Hash: plan.ogHash, Kind: "og", Label: a.Slug + "/" + a.Cover.Photo, Source: coverSrc, Crop: &ogRegion}
|
||||
jobs[plan.ogHash] = job
|
||||
order = append(order, job)
|
||||
}
|
||||
plan.pending++
|
||||
users[plan.ogHash] = append(users[plan.ogHash], plan)
|
||||
}
|
||||
type need struct {
|
||||
hash string
|
||||
kind string
|
||||
@@ -199,6 +211,8 @@ func (b *builder) run(ctx context.Context) (*Summary, error) {
|
||||
if ctx.Err() == nil {
|
||||
b.log.Printf("%s %s: failed after %s: %v", job.Kind, job.Label, round(res.Duration), res.Err)
|
||||
}
|
||||
} else if job.Kind == "og" {
|
||||
b.log.Printf("og %s: %dx%d JPEG in %s", job.Label, res.Record.Width, res.Record.Height, round(res.Duration))
|
||||
} else {
|
||||
sum.Processed++
|
||||
records[job.Hash] = res.Record
|
||||
@@ -347,6 +361,7 @@ func (b *builder) manifest(id string, plan *albumPlan, records map[string]*proce
|
||||
ShowEXIF: *a.ShowEXIF,
|
||||
Tiles: b.tiles(),
|
||||
Cover: &cover,
|
||||
OG: plan.ogHash,
|
||||
Photos: make([]site.Photo, len(a.Photos)),
|
||||
}
|
||||
for i, photo := range a.Photos {
|
||||
@@ -358,8 +373,10 @@ func (b *builder) manifest(id string, plan *albumPlan, records map[string]*proce
|
||||
Alt: photo.Alt,
|
||||
Slides: photo.Slides,
|
||||
}
|
||||
if m.ShowEXIF {
|
||||
p.EXIF = rec.EXIF
|
||||
if m.ShowEXIF && rec.EXIF != nil {
|
||||
exif := *rec.EXIF
|
||||
exif.Exposure = process.NormalizeExposure(exif.Exposure)
|
||||
p.EXIF = &exif
|
||||
}
|
||||
m.Photos[i] = p
|
||||
}
|
||||
@@ -410,8 +427,10 @@ func (b *builder) writeBuild(id string, manifests []*site.Manifest) error {
|
||||
_ = os.RemoveAll(stage)
|
||||
}
|
||||
}()
|
||||
if err := os.Symlink(filepath.Join("..", "..", "t"), filepath.Join(stage, "t")); err != nil {
|
||||
return fmt.Errorf("link tiles: %w", err)
|
||||
for _, shared := range []string{"t", "og"} {
|
||||
if err := os.Symlink(filepath.Join("..", "..", shared), filepath.Join(stage, shared)); err != nil {
|
||||
return fmt.Errorf("link %s: %w", shared, err)
|
||||
}
|
||||
}
|
||||
assets := site.StaticAssets()
|
||||
if err := assets.Write(stage); err != nil {
|
||||
@@ -423,6 +442,7 @@ func (b *builder) writeBuild(id string, manifests []*site.Manifest) error {
|
||||
MaxDPR: b.cfg.Loading.MaxDPR,
|
||||
Concurrency: b.cfg.Loading.Concurrency,
|
||||
BlockContextMenu: b.cfg.Protection.BlockContextMenu,
|
||||
BaseURL: strings.TrimRight(b.cfg.Server.BaseURL, "/"),
|
||||
}
|
||||
|
||||
index := &site.Index{Build: id, Tiles: b.tiles(), Albums: []site.IndexAlbum{}}
|
||||
@@ -439,6 +459,7 @@ func (b *builder) writeBuild(id string, manifests []*site.Manifest) error {
|
||||
Photos: len(m.Photos),
|
||||
Manifest: site.ManifestURL(id, m.Slug),
|
||||
Cover: m.Cover,
|
||||
OG: m.OG,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -523,8 +544,9 @@ func (b *builder) cleanup(id string) (int, int, error) {
|
||||
removed++
|
||||
}
|
||||
refs := map[string]bool{}
|
||||
ogRefs := map[string]bool{}
|
||||
for _, name := range kept {
|
||||
if err := collectRefs(filepath.Join(b.builds, name), name, refs); err != nil {
|
||||
if err := collectRefs(filepath.Join(b.builds, name), name, refs, ogRefs); err != nil {
|
||||
errs = append(errs, fmt.Errorf("build %s unreadable, keeping all tiles: %w", name, err))
|
||||
return removed, 0, errors.Join(errs...)
|
||||
}
|
||||
@@ -533,6 +555,9 @@ func (b *builder) cleanup(id string) (int, int, error) {
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if _, err := b.proc.ForgetOG(ogRefs); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
return removed, tilesRemoved, errors.Join(errs...)
|
||||
}
|
||||
|
||||
@@ -540,10 +565,11 @@ type pyramidRef struct {
|
||||
Hash string `json:"hash"`
|
||||
}
|
||||
|
||||
func collectRefs(dir, id string, refs map[string]bool) error {
|
||||
func collectRefs(dir, id string, refs, ogRefs map[string]bool) error {
|
||||
var index struct {
|
||||
Albums []struct {
|
||||
Cover *pyramidRef `json:"cover"`
|
||||
OG string `json:"og"`
|
||||
} `json:"albums"`
|
||||
}
|
||||
if err := fsutil.ReadJSON(filepath.Join(dir, site.IndexName(id)), &index); err != nil {
|
||||
@@ -553,6 +579,9 @@ func collectRefs(dir, id string, refs map[string]bool) error {
|
||||
if a.Cover != nil {
|
||||
refs[a.Cover.Hash] = true
|
||||
}
|
||||
if a.OG != "" {
|
||||
ogRefs[a.OG] = true
|
||||
}
|
||||
}
|
||||
albums, err := os.ReadDir(filepath.Join(dir, "a"))
|
||||
if err != nil {
|
||||
@@ -564,6 +593,7 @@ func collectRefs(dir, id string, refs map[string]bool) error {
|
||||
}
|
||||
var m struct {
|
||||
Cover *pyramidRef `json:"cover"`
|
||||
OG string `json:"og"`
|
||||
Photos []pyramidRef `json:"photos"`
|
||||
}
|
||||
if err := fsutil.ReadJSON(filepath.Join(dir, "a", entry.Name(), site.ManifestName(id)), &m); err != nil {
|
||||
@@ -572,6 +602,9 @@ func collectRefs(dir, id string, refs map[string]bool) error {
|
||||
if m.Cover != nil {
|
||||
refs[m.Cover.Hash] = true
|
||||
}
|
||||
if m.OG != "" {
|
||||
ogRefs[m.OG] = true
|
||||
}
|
||||
for _, p := range m.Photos {
|
||||
refs[p.Hash] = true
|
||||
}
|
||||
|
||||
@@ -222,9 +222,27 @@ func round(v float64, digits int) float64 {
|
||||
}
|
||||
|
||||
func formatExposure(r *big.Rat) string {
|
||||
seconds := ratFloat(r)
|
||||
if seconds >= 0.3 {
|
||||
return strconv.FormatFloat(round(seconds, 1), 'f', -1, 64)
|
||||
return formatSeconds(ratFloat(r))
|
||||
}
|
||||
|
||||
func NormalizeExposure(value string) string {
|
||||
if value == "" || strings.Contains(value, "/") || strings.HasSuffix(value, "s") {
|
||||
return value
|
||||
}
|
||||
return "1/" + strconv.Itoa(int(math.Round(1/seconds)))
|
||||
seconds, err := strconv.ParseFloat(value, 64)
|
||||
if err != nil || seconds <= 0 {
|
||||
return value
|
||||
}
|
||||
return formatSeconds(seconds)
|
||||
}
|
||||
|
||||
func formatSeconds(seconds float64) string {
|
||||
if seconds >= 1 {
|
||||
return strconv.FormatFloat(round(seconds, 1), 'f', -1, 64) + "s"
|
||||
}
|
||||
denominator := 1 / seconds
|
||||
if denominator < 10 && math.Abs(denominator-math.Round(denominator)) > 0.05 {
|
||||
return "1/" + strconv.FormatFloat(round(denominator, 1), 'f', -1, 64)
|
||||
}
|
||||
return "1/" + strconv.Itoa(int(math.Round(denominator)))
|
||||
}
|
||||
@@ -76,6 +76,7 @@ type Processor struct {
|
||||
key []byte
|
||||
fingerprint string
|
||||
TilesDir string
|
||||
OGDir string
|
||||
StateDir string
|
||||
recordsDir string
|
||||
workDir string
|
||||
@@ -84,9 +85,10 @@ type Processor struct {
|
||||
|
||||
func New(ctx context.Context, cfg *config.Config) (*Processor, error) {
|
||||
tiles := filepath.Join(cfg.Paths.Output, "t")
|
||||
og := filepath.Join(cfg.Paths.Output, "og")
|
||||
records := filepath.Join(cfg.State, "pyramids")
|
||||
work := filepath.Join(cfg.Paths.Cache, "work")
|
||||
for _, dir := range []string{cfg.Paths.Output, tiles, cfg.State, records, cfg.Paths.Cache, work} {
|
||||
for _, dir := range []string{cfg.Paths.Output, tiles, og, cfg.State, records, cfg.Paths.Cache, work} {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -128,6 +130,7 @@ func New(ctx context.Context, cfg *config.Config) (*Processor, error) {
|
||||
key: key,
|
||||
fingerprint: fingerprint,
|
||||
TilesDir: tiles,
|
||||
OGDir: og,
|
||||
StateDir: cfg.State,
|
||||
recordsDir: records,
|
||||
workDir: work,
|
||||
@@ -185,6 +188,9 @@ type Job struct {
|
||||
}
|
||||
|
||||
func (j *Job) pixels() int {
|
||||
if j.Kind == "og" {
|
||||
return 0
|
||||
}
|
||||
if j.Crop != nil {
|
||||
return j.Crop[2] * j.Crop[3]
|
||||
}
|
||||
@@ -266,6 +272,38 @@ func (p *Processor) ForgetUnreferenced(keep map[string]bool) (int, error) {
|
||||
return removed, firstErr
|
||||
}
|
||||
|
||||
func (p *Processor) OGHash(src *Source, region [4]int) string {
|
||||
return p.hashWith(src.digest, fmt.Sprintf("og:%d,%d,%d,%d:%dx%d:q%d", region[0], region[1], region[2], region[3], OGWidth, OGHeight, OGQuality))
|
||||
}
|
||||
|
||||
func (p *Processor) HasOG(hash string) bool {
|
||||
info, err := os.Stat(filepath.Join(p.OGDir, hash+".jpg"))
|
||||
return err == nil && info.Mode().IsRegular() && info.Size() > 0
|
||||
}
|
||||
|
||||
func (p *Processor) ForgetOG(keep map[string]bool) (int, error) {
|
||||
entries, err := os.ReadDir(p.OGDir)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
removed := 0
|
||||
var firstErr error
|
||||
for _, entry := range entries {
|
||||
name := entry.Name()
|
||||
if keep[strings.TrimSuffix(name, ".jpg")] {
|
||||
continue
|
||||
}
|
||||
if err := os.Remove(filepath.Join(p.OGDir, name)); err != nil {
|
||||
if firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
continue
|
||||
}
|
||||
removed++
|
||||
}
|
||||
return removed, firstErr
|
||||
}
|
||||
|
||||
func (p *Processor) CleanWork() {
|
||||
entries, err := os.ReadDir(p.workDir)
|
||||
if err != nil {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -64,7 +65,57 @@ func (r *refFile) release() {
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
OGWidth = 1200
|
||||
OGHeight = 630
|
||||
OGQuality = 80
|
||||
)
|
||||
|
||||
func OGRegion(width, height int, crop [4]int) [4]int {
|
||||
h := min(height, crop[3])
|
||||
w := int(math.Round(float64(h) * OGWidth / OGHeight))
|
||||
if w > width {
|
||||
w = width
|
||||
h = min(height, int(math.Round(float64(w)*OGHeight/OGWidth)))
|
||||
}
|
||||
cx := float64(crop[0]) + float64(crop[2])/2
|
||||
cy := float64(crop[1]) + float64(crop[3])/2
|
||||
x := max(0, min(width-w, int(math.Round(cx-float64(w)/2))))
|
||||
y := max(0, min(height-h, int(math.Round(cy-float64(h)/2))))
|
||||
return [4]int{x, y, max(1, w), max(1, h)}
|
||||
}
|
||||
|
||||
func (p *Processor) renderOG(ctx context.Context, job *Job) (*Record, error) {
|
||||
work := filepath.Join(p.workDir, job.Hash)
|
||||
if err := os.RemoveAll(work); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.MkdirAll(work, 0o755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer os.RemoveAll(work)
|
||||
prepared := filepath.Join(work, "og.v")
|
||||
if err := p.prepare(ctx, job, work, prepared); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
final := filepath.Join(p.OGDir, job.Hash+".jpg")
|
||||
tmp := fsutil.TempName(final) + ".jpg"
|
||||
if err := p.vips.Run(ctx, "thumbnail", prepared, tmp+p.vips.SaveOptions(OGQuality),
|
||||
strconv.Itoa(OGWidth), "--height", strconv.Itoa(OGHeight), "--crop", "centre"); err != nil {
|
||||
_ = os.Remove(tmp)
|
||||
return nil, err
|
||||
}
|
||||
if err := os.Rename(tmp, final); err != nil {
|
||||
_ = os.Remove(tmp)
|
||||
return nil, err
|
||||
}
|
||||
return &Record{Pyramid: Pyramid{Hash: job.Hash, Width: OGWidth, Height: OGHeight}, Kind: "og", Format: "jpeg"}, nil
|
||||
}
|
||||
|
||||
func (p *Processor) process(ctx context.Context, job *Job) (*Record, error) {
|
||||
if job.Kind == "og" {
|
||||
return p.renderOG(ctx, job)
|
||||
}
|
||||
work := filepath.Join(p.workDir, job.Hash)
|
||||
stage := filepath.Join(p.TilesDir, "."+job.Hash+fsutil.TempMarker+"stage")
|
||||
for _, dir := range []string{work, stage} {
|
||||
|
||||
+58
-11
@@ -4,18 +4,23 @@ import (
|
||||
"crypto/sha256"
|
||||
"embed"
|
||||
"encoding/hex"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/luciochen233/luphoto/internal/fsutil"
|
||||
)
|
||||
|
||||
//go:embed static/app.js static/app.css static/worker.js
|
||||
//go:embed static
|
||||
var staticFiles embed.FS
|
||||
|
||||
var preloadFonts = []string{"bricolage-grotesque-latin-wght-normal.", "ibm-plex-sans-latin-400-normal."}
|
||||
|
||||
type Asset struct {
|
||||
Name string
|
||||
URL string
|
||||
@@ -23,24 +28,54 @@ type Asset struct {
|
||||
}
|
||||
|
||||
type Assets struct {
|
||||
JS Asset
|
||||
CSS Asset
|
||||
Worker Asset
|
||||
JS Asset
|
||||
CSS Asset
|
||||
Worker Asset
|
||||
Favicon Asset
|
||||
Fonts []Asset
|
||||
Preload []Asset
|
||||
Chop template.HTML
|
||||
}
|
||||
|
||||
var loadAssets = sync.OnceValue(func() Assets {
|
||||
return Assets{
|
||||
JS: hashedAsset("static/app.js"),
|
||||
CSS: hashedAsset("static/app.css"),
|
||||
Worker: hashedAsset("static/worker.js"),
|
||||
assets := Assets{
|
||||
JS: hashedAsset("static/app.js"),
|
||||
CSS: hashedAsset("static/app.css"),
|
||||
Worker: hashedAsset("static/worker.js"),
|
||||
Favicon: hashedAsset("static/favicon.svg"),
|
||||
Chop: template.HTML(strings.TrimSpace(string(mustRead("static/lucio-chop-chen.svg")))),
|
||||
}
|
||||
entries, err := fs.ReadDir(staticFiles, "static")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, entry := range entries {
|
||||
name := entry.Name()
|
||||
if path.Ext(name) != ".woff2" {
|
||||
continue
|
||||
}
|
||||
font := Asset{Name: name, URL: "/assets/" + name, data: mustRead("static/" + name)}
|
||||
assets.Fonts = append(assets.Fonts, font)
|
||||
for _, prefix := range preloadFonts {
|
||||
if strings.HasPrefix(name, prefix) {
|
||||
assets.Preload = append(assets.Preload, font)
|
||||
}
|
||||
}
|
||||
}
|
||||
sort.Slice(assets.Preload, func(i, j int) bool { return assets.Preload[i].Name < assets.Preload[j].Name })
|
||||
return assets
|
||||
})
|
||||
|
||||
func hashedAsset(source string) Asset {
|
||||
func mustRead(source string) []byte {
|
||||
data, err := staticFiles.ReadFile(source)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func hashedAsset(source string) Asset {
|
||||
data := mustRead(source)
|
||||
sum := sha256.Sum256(data)
|
||||
base := path.Base(source)
|
||||
ext := path.Ext(base)
|
||||
@@ -57,8 +92,20 @@ func (a Assets) Write(buildDir string) error {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, asset := range []Asset{a.JS, a.CSS, a.Worker} {
|
||||
if err := fsutil.WriteFileAtomic(filepath.Join(dir, asset.Name), asset.data, 0o644); err != nil {
|
||||
files := append([]Asset{a.JS, a.CSS, a.Worker, a.Favicon}, a.Fonts...)
|
||||
errs := make(chan error, len(files))
|
||||
var wg sync.WaitGroup
|
||||
for _, asset := range files {
|
||||
wg.Add(1)
|
||||
go func(asset Asset) {
|
||||
defer wg.Done()
|
||||
errs <- fsutil.WriteFileAtomic(filepath.Join(dir, asset.Name), asset.data, 0o644)
|
||||
}(asset)
|
||||
}
|
||||
wg.Wait()
|
||||
close(errs)
|
||||
for err := range errs {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
+75
-17
@@ -2,8 +2,10 @@ package site
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
"net/url"
|
||||
|
||||
"github.com/luciochen233/luphoto/internal/process"
|
||||
)
|
||||
@@ -13,6 +15,11 @@ var templateFiles embed.FS
|
||||
|
||||
var templates = template.Must(template.ParseFS(templateFiles, "templates/*.html"))
|
||||
|
||||
const (
|
||||
SiteName = "Photos · Lucio"
|
||||
SiteDescription = "Photographs by Guoliang Chen · 陈国梁 · Lucio."
|
||||
)
|
||||
|
||||
type Tiles struct {
|
||||
Format string `json:"format"`
|
||||
TileSize int `json:"tile_size"`
|
||||
@@ -41,6 +48,7 @@ type Manifest struct {
|
||||
ShowEXIF bool `json:"show_exif"`
|
||||
Tiles Tiles `json:"tiles"`
|
||||
Cover *process.Pyramid `json:"cover"`
|
||||
OG string `json:"og,omitempty"`
|
||||
Photos []Photo `json:"photos"`
|
||||
}
|
||||
|
||||
@@ -53,6 +61,7 @@ type IndexAlbum struct {
|
||||
Photos int `json:"photos"`
|
||||
Manifest string `json:"manifest"`
|
||||
Cover *process.Pyramid `json:"cover"`
|
||||
OG string `json:"og,omitempty"`
|
||||
}
|
||||
|
||||
type Index struct {
|
||||
@@ -65,8 +74,12 @@ func IndexURL(build string) string {
|
||||
return "/index." + build + ".json"
|
||||
}
|
||||
|
||||
func AlbumPath(slug string) string {
|
||||
return "/a/" + url.PathEscape(slug) + "/"
|
||||
}
|
||||
|
||||
func ManifestURL(build, slug string) string {
|
||||
return "/a/" + slug + "/manifest." + build + ".json"
|
||||
return AlbumPath(slug) + "manifest." + build + ".json"
|
||||
}
|
||||
|
||||
func ManifestName(build string) string {
|
||||
@@ -77,52 +90,97 @@ func IndexName(build string) string {
|
||||
return "index." + build + ".json"
|
||||
}
|
||||
|
||||
func OGPath(hash string) string {
|
||||
if hash == "" {
|
||||
return ""
|
||||
}
|
||||
return "/og/" + hash + ".jpg"
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
Assets Assets
|
||||
BudgetMS int
|
||||
MaxDPR float64
|
||||
Concurrency int
|
||||
BlockContextMenu bool
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
type head struct {
|
||||
Page
|
||||
Build string
|
||||
Title string
|
||||
Description string
|
||||
Path string
|
||||
Image string
|
||||
IndexURL string
|
||||
}
|
||||
|
||||
func (h head) Absolute(path string) string {
|
||||
if path == "" {
|
||||
return ""
|
||||
}
|
||||
return h.BaseURL + path
|
||||
}
|
||||
|
||||
type indexPage struct {
|
||||
Page
|
||||
Build string
|
||||
IndexURL string
|
||||
Albums []IndexAlbum
|
||||
head
|
||||
Albums []IndexAlbum
|
||||
}
|
||||
|
||||
type albumPage struct {
|
||||
Page
|
||||
Build string
|
||||
head
|
||||
AlbumTitle string
|
||||
Slug string
|
||||
Title string
|
||||
Subtitle string
|
||||
Date string
|
||||
Photos int
|
||||
ManifestURL string
|
||||
IndexURL string
|
||||
}
|
||||
|
||||
func RenderIndex(w io.Writer, index *Index, page Page) error {
|
||||
image := ""
|
||||
if len(index.Albums) > 0 {
|
||||
image = OGPath(index.Albums[0].OG)
|
||||
}
|
||||
return templates.ExecuteTemplate(w, "index.html", indexPage{
|
||||
Page: page,
|
||||
Build: index.Build,
|
||||
IndexURL: IndexURL(index.Build),
|
||||
Albums: index.Albums,
|
||||
head: head{
|
||||
Page: page,
|
||||
Build: index.Build,
|
||||
Title: SiteName,
|
||||
Description: SiteDescription,
|
||||
Path: "/",
|
||||
Image: image,
|
||||
IndexURL: IndexURL(index.Build),
|
||||
},
|
||||
Albums: index.Albums,
|
||||
})
|
||||
}
|
||||
|
||||
func RenderAlbum(w io.Writer, m *Manifest, page Page) error {
|
||||
description := m.Subtitle
|
||||
if description == "" {
|
||||
description = fmt.Sprintf("%d photographs by Lucio", len(m.Photos))
|
||||
if m.Date != "" {
|
||||
description += ", " + m.Date
|
||||
}
|
||||
description += "."
|
||||
}
|
||||
return templates.ExecuteTemplate(w, "album.html", albumPage{
|
||||
Page: page,
|
||||
Build: m.Build,
|
||||
head: head{
|
||||
Page: page,
|
||||
Build: m.Build,
|
||||
Title: m.Title + " · Lucio",
|
||||
Description: description,
|
||||
Path: AlbumPath(m.Slug),
|
||||
Image: OGPath(m.OG),
|
||||
IndexURL: IndexURL(m.Build),
|
||||
},
|
||||
AlbumTitle: m.Title,
|
||||
Slug: m.Slug,
|
||||
Title: m.Title,
|
||||
Subtitle: m.Subtitle,
|
||||
Date: m.Date,
|
||||
Photos: len(m.Photos),
|
||||
ManifestURL: ManifestURL(m.Build, m.Slug),
|
||||
IndexURL: IndexURL(m.Build),
|
||||
})
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
:root{--graphite: #111114;--paper: #f3f1ec;--beam: #fff3cf;--steel: #8a94a6;--steel-deep: #3f4b60;--cinnabar: #c3361f;--font-display: "Bricolage Grotesque", "Noto Sans SC", system-ui, sans-serif;--font-body: "IBM Plex Sans", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;--font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;--font-chop: "Noto Serif SC", "Songti SC", serif;--ease-light: cubic-bezier(.16, 1, .3, 1);--t-hover: .12s;--t-reveal: .24s;color-scheme:dark}html,body{margin:0;min-height:100%;background:var(--graphite);color:var(--paper);font-family:var(--font-body);-webkit-font-smoothing:antialiased}a{color:var(--paper)}:focus-visible{outline:2px solid var(--beam);outline-offset:3px}.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.index-list{max-width:48rem;margin:0 auto;padding:48px 16px}.index-list h1{font-family:var(--font-display);font-weight:600}.index-list li{margin:8px 0}.index-list time,.index-list span{font-family:var(--font-mono);color:var(--steel);font-size:.85em}.has-viewer body.viewer{position:fixed;inset:0;overflow:hidden;overscroll-behavior:none}.album-fallback{padding:48px 16px}.has-viewer .album-fallback{display:none}.stage{overflow:hidden;background:var(--graphite);touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;cursor:grab}.has-viewer .stage{position:fixed;inset:0}.stage.is-dragging{cursor:grabbing}.stage-canvas,.stage-fade{position:absolute;inset:0;width:100%;height:100%;display:block}.stage-fade{pointer-events:none;opacity:0;transition:opacity var(--t-reveal) var(--ease-light)}.caption{position:absolute;left:0;bottom:0;box-sizing:border-box;max-height:60%;overflow:hidden;padding:72px 24px 20px;background:linear-gradient(to top,#111114e6,#1111149e 55%,#11111400);opacity:0;pointer-events:none;transition:opacity var(--t-reveal) var(--ease-light)}.caption.is-visible{opacity:1}.caption-meta{margin:0;font-family:var(--font-mono);font-size:12px;letter-spacing:.04em;color:var(--steel);font-variant-numeric:tabular-nums}.caption-title{margin:10px 0 0;font-family:var(--font-display);font-size:22px;font-weight:600;line-height:1.2}.caption-text{margin:8px 0 0;max-width:62ch;font-size:15px;line-height:1.55}.caption-text em{font-style:italic}.end-card{position:absolute;top:0;left:0;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:20px;will-change:transform}.chop{width:56px;height:56px;display:grid;place-items:center;border-radius:8px;background:var(--cinnabar);color:var(--paper);font-family:var(--font-chop);font-size:34px;line-height:1}.signature{margin:0;font-family:var(--font-display);font-size:28px}.next-album{display:flex;flex-direction:column;align-items:center;gap:6px;margin-top:24px;text-decoration:none;transition:color var(--t-hover) var(--ease-light)}.next-album:hover .next-title{color:var(--beam)}.next-eyebrow{font-family:var(--font-mono);font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--steel)}.next-title{font-family:var(--font-display);font-size:24px;font-weight:600}@media (prefers-reduced-motion: reduce){.next-album{transition:none}}
|
||||
:root{--lucio-graphite: #111114;--lucio-graphite-2: #1A1A1F;--lucio-graphite-3: #26262D;--lucio-paper: #F3F1EC;--lucio-paper-2: #E9E6DF;--lucio-paper-3: #D9D6CD;--lucio-beam: #FFF3CF;--lucio-beam-deep: #5E5238;--lucio-beam-glow: #FFFBF0;--lucio-steel: #8A94A6;--lucio-steel-deep: #3F4B60;--lucio-cinnabar: #C3361F;--lucio-cinnabar-light: #F08A77;--lucio-ash: #666A74;--lucio-ash-dark: #43464F;--lucio-ash-light: #A6A9B3;--lucio-font-display: "Bricolage Grotesque", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;--lucio-font-body: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;--lucio-font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;--lucio-font-cjk-display: "Noto Serif SC", "Songti SC", "SimSun", serif;--lucio-font-cjk-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;--lucio-space-1: 4px;--lucio-space-2: 8px;--lucio-space-3: 12px;--lucio-space-4: 16px;--lucio-space-5: 24px;--lucio-space-6: 32px;--lucio-space-7: 48px;--lucio-space-8: 64px;--lucio-space-9: 96px;--lucio-space-10: 128px;--lucio-radius-none: 0px;--lucio-radius-sm: 4px;--lucio-radius-md: 8px;--lucio-radius-lg: 16px;--lucio-radius-icon: 22%;--lucio-shadow-glow: 0 0 0 1px rgba(255,243,207,.3), 0 8px 32px -8px rgba(255,243,207,.35);--lucio-motion-fast: .12s;--lucio-ease-fast: cubic-bezier(.2, 0, 0, 1);--lucio-motion-base: .24s;--lucio-ease-base: cubic-bezier(.2, 0, 0, 1);--lucio-motion-glow: .9s;--lucio-ease-glow: cubic-bezier(.16, 1, .3, 1)}@font-face{font-family:Bricolage Grotesque;font-style:normal;font-weight:200 800;font-display:swap;src:url("./bricolage-grotesque-latin-ext-wght-normal.EMW626ZA.woff2") format("woff2-variations");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Bricolage Grotesque;font-style:normal;font-weight:200 800;font-display:swap;src:url("./bricolage-grotesque-latin-wght-normal.HY2A4V5R.woff2") format("woff2-variations");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-ext-400-normal.EDOVP6TU.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-400-normal.COQVXTP6.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-sans-latin-ext-500-normal.SG2XNXKB.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-sans-latin-500-normal.JTONHBWS.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:600;font-display:swap;src:url("./ibm-plex-sans-latin-ext-600-normal.ZNWKNRXL.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:600;font-display:swap;src:url("./ibm-plex-sans-latin-600-normal.DTNZULF4.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:italic;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-ext-400-italic.VMPJJ47P.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:italic;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-400-italic.PR7YQ55B.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,Line truncated
|
||||
@@ -1 +1 @@
|
||||
"use strict";(()=>{function _(){let t=navigator.deviceMemory,e=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,i=Math.min(screen.width,screen.height)<=820;return t!==void 0&&t<=4||e&&i?120*1048576:250*1048576}var L=class{constructor(t){this.budget=t;this.entries=new Map;this.used=0}get(t){let e=this.entries.get(t);return e&&(this.entries.delete(t),this.entries.set(t,e)),e}has(t){return this.entries.has(t)}put(t,e){let i=this.entries.get(t);if(i){i.bitmap!==e&&e.close();return}let n=e.width*e.height*4;this.entries.set(t,{bitmap:e,bytes:n,at:performance.now()}),this.used+=n,this.evict()}evict(){for(;this.used>this.budget&&this.entries.size>1;){let t=this.entries.keys().next();if(t.done)return;let e=this.entries.get(t.value);this.entries.delete(t.value),e&&(this.used-=e.bytes,e.bitmap.close())}}};var P=class extends Error{constructor(){super("aborted"),this.name="AbortError"}},R=class{constructor(t,e){this.concurrency=t;this.byId=new Map;this.byKey=new Map;this.queue=[];this.workers=[];this.running=0;this.nextKey=1;this.nextSeq=1;this.nextWorker=0;if(typeof Worker>"u"||e==="")return;let i=(navigator.hardwareConcurrency??2)>=4?2:1;for(let n=0;n<i;n++)try{let s=new Worker(e),o=this.workers.length;s.onmessage=h=>this.onReply(h.data),s.onerror=()=>this.dropWorker(o),this.workers.push(s)}catch{break}}request(t,e,i,n){return n.aborted?Promise.reject(new P):new Promise((s,o)=>{let h=this.byId.get(t);h?i<h.priority&&(h.priority=i):(h={key:this.nextKey++,id:t,url:e,priority:i,seq:this.nextSeq++,waiters:new Set,running:!1,worker:-1,controller:null},this.byId.set(t,h),this.byKey.set(h.key,h),this.queue.push(h));let c={resolve:s,reject:o};h.waiters.add(c);let a=h;n.addEventListener("abort",()=>{a.waiters.delete(c)&&(o(new P),a.waiters.size===0&&setTimeout(()=>{a.waiters.size===0&&this.byKey.get(a.key)===a&&this.cancel(a)},0))},{once:!0}),this.pump()})}cancel(t){if(this.forget(t),!t.running){let e=this.queue.indexOf(t);e>=0&&this.queue.splice(e,1);return}t.running=!1,this.running--,t.controller?t.controller.abort():t.worker>=0&&this.workers[t.worker]&&this.workers[t.worker].postMessage({type:"abort",key:t.key}),this.pump()}forget(t){this.byId.get(t.id)===t&&this.byId.delete(t.id),this.byKey.delete(t.key)}pump(){for(;this.running<this.concurrency&&this.queue.length>0;){let t=0;for(let i=1;i<this.queue.length;i++){let n=this.queue[i],s=this.queue[t];(n.priority<s.priority||n.priority===s.priority&&n.seq<s.seq)&&(t=i)}let e=this.queue.splice(t,1)[0];e.running=!0,this.running++,this.start(e)}}start(t){let e=this.liveWorkers();if(e.length>0){let i=e[this.nextWorker++%e.length];t.worker=i,this.workers[i].postMessage({type:"fetch",key:t.key,url:t.url});return}t.worker=-1,t.controller=new AbortController,this.fetchOnMainThread(t,t.controller.signal)}liveWorkers(){let t=[];return this.workers.forEach((e,i)=>{e&&t.push(i)}),t}dropWorker(t){let e=this.workers[t];if(e){e.terminate(),delete this.workers[t];for(let i of this.byKey.values())i.running&&i.worker===t&&(i.worker=-1,i.controller=new AbortController,this.fetchOnMainThread(i,i.controller.signal))}}async fetchOnMainThread(t,e){let i=performance.now();try{let n=await fetch(t.url,{signal:e,credentials:"same-origin"});if(!n.ok)throw new Error("HTTP "+n.status);let s=await n.blob(),o=performance.now()-i,h=await createImageBitmap(s);this.onReply({key:t.key,ok:!0,bitmap:h,bytes:s.size,ms:o})}catch(n){this.onReply({key:t.key,ok:!1,bytes:0,ms:0,error:String(n)})}}onReply(t){let e=this.byKey.get(t.key);if(!e||!e.running){t.bitmap?.close();return}e.running=!1,this.running--,this.forget(e);let i=[...e.waiters];if(e.waiters.clear(),t.ok&&t.bitmap){let n={bitmap:t.bitmap,bytes:t.bytes,ms:t.ms};for(let s of i)s.resolve(n);i.length===0&&t.bitmap.close()}else{let n=new Error(t.error??"tile failed");for(let s of i)s.reject(n)}this.pump()}};function X(r){let t=r.dataset,e=(i,n)=>{let s=Number(i);return Number.isFinite(s)&&s>0?s:n};return{page:t.page??"",build:t.build??"",slug:t.album??"",manifestUrl:t.manifest??"",indexUrl:t.index??"",workerUrl:t.worker??"",budgetMs:e(t.budgetMs,3e3),maxDpr:e(t.maxDpr,2),concurrency:Math.max(1,Math.round(e(t.concurrency,6))),blockContextMenu:t.blockContextMenu!=="false"}}function Y(r){return r<10?"0"+r:String(r)}function it(r){let t=(r.model??"").trim(),e=(r.make??"").trim(),i=e.split(/\s+/)[0]??"";i&&t.toLowerCase().startsWith(i.toLowerCase()+" ")&&(t=t.slice(i.length+1).trim());let n=/^([A-Za-z]{1,3}) (\d+[A-Za-z0-9]*)$/.exec(t);return n&&(t=n[1]+n[2]),t||e}function nt(r){let t=/(\d+(?:\.\d+)?(?:-\d+(?:\.\d+)?)?)\s*mm\s*(?:F|f\/?)\s*([\d.]+(?:-[\d.]+)?)/.exec(r);return t?t[1]+" f/"+t[2]:r.trim()}function K(r){return String(Math.round(r*10)/10)}function st(r,t,e,i){let n=[Y(r+1)+" / "+Y(t)],s=e.exif;if(i&&s){let o=it(s);o&&n.push(o),s.lens&&n.push(nt(s.lens)),s.focal_length&&n.push(K(s.focal_length)+"mm"),s.f_number&&n.push("f/"+K(s.f_number)),s.exposure&&n.push(s.exposure.includes("/")?s.exposure:s.exposure+"s"),s.iso&&n.push("ISO "+s.isLine truncated
|
||||
"use strict";(()=>{function dt(){let t=navigator.deviceMemory,e=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,i=Math.min(screen.width,screen.height)<=820;return t!==void 0&&t<=4||e&&i?120*1048576:250*1048576}var U=class{constructor(t){this.budget=t;this.entries=new Map;this.used=0}get(t){let e=this.entries.get(t);return e&&(this.entries.delete(t),this.entries.set(t,e)),e}has(t){return this.entries.has(t)}put(t,e){let i=this.entries.get(t);if(i){i.bitmap!==e&&e.close();return}let s=e.width*e.height*4;this.entries.set(t,{bitmap:e,bytes:s,at:performance.now()}),this.used+=s,this.evict()}evict(){for(;this.used>this.budget&&this.entries.size>1;){let t=this.entries.keys().next();if(t.done)return;let e=this.entries.get(t.value);this.entries.delete(t.value),e&&(this.used-=e.bytes,e.bitmap.close())}}};(function(a){let t={from:"Guoliang",to:"Lucio",letters:[{ch:"G",kind:"keep",shared:"M8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50",fullA:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",fullB:"M8.50 0.00L8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50L80.00 91.50",out:[{d:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00",P:79.21,j:"end"},{d:"M58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",P:73.21,j:"start"}],in:[{d:"M8.50 22.00L8.50 0.00",P:22,j:"start"},{d:"M58.00 91.50L80.00 91.50",P:22,j:"start"}],x0:0,x1:0,dot:null},{ch:"u",kind:"keep",shared:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullA:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullB:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",out:[],in:[],x0:88.8,x1:88,dot:null},{ch:"o",kind:"keep",shared:"M38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullB:"M60.00 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50L60.00 91.50",out:[{d:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50",P:60.41,j:"both"}],in:[{d:"M38.00 46.50L60.00 46.50",P:22,j:"start"},{d:"M38.00 91.50L60.00 91.50",P:22,j:"start"}],x0:159,x1:158.2,dot:null},{ch:"l",kind:"fade",d:"M8.50 0.00L8.50 100.00",x0:230.8,x1:230.8,dot:null},{ch:"i",kind:"keep",shared:"M8.50 38.00L8.50 100.00",fullA:"M8.50 38.00L8.50 100.00",fullB:"M8.50 38.00L8.50 100.00",out:[],in:[],x0:262.8,x1:227.9,dot:[0,14,17]},{ch:"a",kind:"fade",d:"M38.00 91.50L51.50 91.50L51.50 78.00L51.50 60.00L51.50 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",x0:291.6,x1:291.6,dot:null},{ch:"n",kind:"fade",d:"M51.50 100.00L51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00L8.50 100.00",x0:362.7,x1:362.7,dot:null},{ch:"g",kind:"keep",shared:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M0.00 127.50L38.00 127.50A13.50 13.50 0 0 0 51.50 114.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00",fullB:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",out:[{d:"M51.50 60.00L51.50 114.00A13.50 13.50 0 0 1 38.00 127.50L0.00 127.50",P:113.21,j:"start"}],in:[],x0:432.9,x1:256.7,dot:null}],pad:17,vbw:526.9,vbh:170,stroke:17,raysT:"translate(0.000 22.727) scale(0.7727)"},e="M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z",i="http://www.w3.org/2000/svg",s=(c,w)=>{let l=document.createElementNS(i,c);for(let u in w)l.setAttribute(u,w[u]);return l},n=()=>a.matchMedia&&a.matchMedia("(prefers-reduced-motion: reduce)").matches,r=c=>Math.max(0,Math.min(1,c)),o=c=>c*c*(3-2*c),d=.5;function h(c,w){let l=0,u=0,p=null,b=0;function C(y){let v=(y-b)/w;b=y,l=l<u?Math.min(u,l+v):Math.max(u,l-v),c(l),p=l===u?null:requestAnimationFrame(C)}function f(y){if(u=y,n()){l=y,c(l);return}p===null&&(b=performance.now(),p=requestAnimationFrame(C))}return{play:()=>f(1),reverse:()=>f(0),toggle:()=>f(u?0:1),set:y=>{cancelAnimationFrame(p),p=null,u=l=y,c(l)},stop:()=>{cancelAnimationFrame(p),p=nulLine truncated
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Lucio icon">
|
||||
<title>Lucio icon</title>
|
||||
<rect width="64" height="64" rx="14" fill="#111114"/><g transform="translate(11.50 11.50)"><path d="M35.889 5.111A5.500 5.500 0 0 0 32.000 3.500H9.000A5.500 5.500 0 0 0 3.500 9.000V32.000A5.500 5.500 0 0 0 9.000 37.500H32.000A5.500 5.500 0 0 0 37.500 32.000V9.000A5.500 5.500 0 0 0 35.889 5.111Z" fill="none" stroke="#F3F1EC" stroke-width="7" stroke-linecap="butt" stroke-dasharray="63.279 63.279" stroke-dashoffset="-31.639"/><path d="M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z" fill="#FFF3CF" transform="translate(0.000 9.182) scale(0.3182)"/></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 783 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" role="img" aria-label="Lucio chop (chen)">
|
||||
<title>Lucio chop (chen)</title>
|
||||
<rect width="100" height="100" rx="3" fill="#C3361F"/>
|
||||
<rect x="7" y="7" width="86" height="86" fill="none" stroke="#F3F1EC" stroke-width="2.5"/>
|
||||
<text x="50" y="52" text-anchor="middle" dominant-baseline="central" font-family="'Noto Serif SC', 'Songti SC', 'SimSun', serif" font-weight="700" font-size="60" fill="#F3F1EC">陈</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 504 B |
@@ -1,23 +1,19 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="robots" content="noimageindex">
|
||||
<meta name="theme-color" content="#111114">
|
||||
<title>{{.Title}} · Lucio</title>
|
||||
<link rel="stylesheet" href="{{.Assets.CSS.URL}}">
|
||||
{{template "head" .}}
|
||||
<link rel="preload" href="{{.ManifestURL}}" as="fetch" crossorigin>
|
||||
<script src="{{.Assets.JS.URL}}" defer></script>
|
||||
</head>
|
||||
<body class="viewer" data-page="album" data-build="{{.Build}}" data-album="{{.Slug}}" data-manifest="{{.ManifestURL}}" data-index="{{.IndexURL}}" data-worker="{{.Assets.Worker.URL}}" data-budget-ms="{{.BudgetMS}}" data-max-dpr="{{.MaxDPR}}" data-concurrency="{{.Concurrency}}" data-block-context-menu="{{.BlockContextMenu}}">
|
||||
<main id="stage" class="stage" aria-label="{{.Title}}">
|
||||
<h1 class="visually-hidden">{{.Title}}{{if .Subtitle}} · {{.Subtitle}}{{end}}</h1>
|
||||
<body class="viewer" data-page="album" data-album="{{.Slug}}" data-manifest="{{.ManifestURL}}"{{template "body-data" .}}>
|
||||
<a class="home-mark" href="/" aria-label="Lucio, all albums"><span class="wordmark-text">Lucio</span></a>
|
||||
<main id="stage" class="stage" aria-label="{{.AlbumTitle}}">
|
||||
<h1 class="visually-hidden">{{.AlbumTitle}}{{if .Subtitle}} · {{.Subtitle}}{{end}}</h1>
|
||||
</main>
|
||||
<div class="album-fallback">
|
||||
<p>{{.Photos}} photos{{if .Date}} · <time>{{.Date}}</time>{{end}}</p>
|
||||
<noscript><p>This album needs JavaScript to draw its photos.</p></noscript>
|
||||
<p><a href="/">All albums</a></p>
|
||||
</div>
|
||||
<template id="chop-template"><span class="chop">{{.Assets.Chop}}</span></template>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,30 @@
|
||||
{{define "head"}}<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="robots" content="noimageindex">
|
||||
<meta name="theme-color" content="#111114">
|
||||
<meta name="color-scheme" content="dark">
|
||||
<title>{{.Title}}</title>
|
||||
<meta name="description" content="{{.Description}}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:site_name" content="Photos · Lucio">
|
||||
<meta property="og:title" content="{{.Title}}">
|
||||
<meta property="og:description" content="{{.Description}}">
|
||||
{{- if .BaseURL}}
|
||||
<meta property="og:url" content="{{.Absolute .Path}}">
|
||||
<link rel="canonical" href="{{.Absolute .Path}}">
|
||||
{{- end}}
|
||||
{{- if .Image}}
|
||||
<meta property="og:image" content="{{.Absolute .Image}}">
|
||||
<meta property="og:image:width" content="1200">
|
||||
<meta property="og:image:height" content="630">
|
||||
<meta property="og:image:type" content="image/jpeg">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
{{- end}}
|
||||
<link rel="icon" type="image/svg+xml" href="{{.Assets.Favicon.URL}}">
|
||||
{{- range .Assets.Preload}}
|
||||
<link rel="preload" href="{{.URL}}" as="font" type="font/woff2" crossorigin>
|
||||
{{- end}}
|
||||
<link rel="stylesheet" href="{{.Assets.CSS.URL}}">
|
||||
<script src="{{.Assets.JS.URL}}" defer></script>
|
||||
{{- end}}
|
||||
{{define "body-data"}} data-build="{{.Build}}" data-index="{{.IndexURL}}" data-worker="{{.Assets.Worker.URL}}" data-budget-ms="{{.BudgetMS}}" data-max-dpr="{{.MaxDPR}}" data-concurrency="{{.Concurrency}}" data-block-context-menu="{{.BlockContextMenu}}"{{end}}
|
||||
@@ -1,22 +1,26 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="robots" content="noimageindex">
|
||||
<meta name="theme-color" content="#111114">
|
||||
<title>Photos · Lucio</title>
|
||||
<link rel="stylesheet" href="{{.Assets.CSS.URL}}">
|
||||
{{template "head" .}}
|
||||
<link rel="preload" href="{{.IndexURL}}" as="fetch" crossorigin>
|
||||
</head>
|
||||
<body class="index" data-page="index" data-build="{{.Build}}" data-index="{{.IndexURL}}">
|
||||
<main class="index-list">
|
||||
<h1>Photos · Lucio</h1>
|
||||
<ul>
|
||||
<body class="index-page" data-page="index"{{template "body-data" .}}>
|
||||
<header class="site-header">
|
||||
<a class="wordmark" href="/" aria-label="Lucio, all albums"><span class="wordmark-text">Lucio</span></a>
|
||||
</header>
|
||||
<main id="strips" class="strips">
|
||||
<h1 class="visually-hidden">Photos by Lucio</h1>
|
||||
{{- range .Albums}}
|
||||
<li><a href="/a/{{.Slug}}/">{{.Title}}</a>{{if .Subtitle}} <span>{{.Subtitle}}</span>{{end}}{{if .Date}} <time>{{.Date}}</time>{{end}}</li>
|
||||
<a class="strip" href="/a/{{.Slug}}/" data-slug="{{.Slug}}">
|
||||
<span class="strip-text">{{if .Date}}<span class="strip-eyebrow">{{.Date}}</span>{{end}}<span class="strip-title">{{.Title}}</span>{{if .Subtitle}}<span class="strip-subtitle">{{.Subtitle}}</span>{{end}}</span>
|
||||
</a>
|
||||
{{- else}}
|
||||
<p class="empty">No albums yet.</p>
|
||||
{{- end}}
|
||||
</ul>
|
||||
</main>
|
||||
<footer class="site-footer">
|
||||
<p class="footer-line">Guoliang Chen · 陈国梁 · Lucio</p>
|
||||
<span class="chop">{{.Assets.Chop}}</span>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
+16
-1
@@ -17,7 +17,22 @@ case "$(uname -s)" in
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${LUPHOTO_DEV_REBUILD:-0}" = "1" ] || ! docker image inspect "$image" >/dev/null 2>&1; then
|
||||
image_present() {
|
||||
local attempt
|
||||
for attempt in 1 2 3; do
|
||||
if [ -n "$(docker images -q "$image" 2>/dev/null)" ]; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ "${LUPHOTO_DEV_REBUILD:-0}" = "1" ] || ! image_present; then
|
||||
if [ "$image" != "luphoto-dev" ] && [ "${LUPHOTO_DEV_REBUILD:-0}" != "1" ]; then
|
||||
echo "dev.sh: image $image not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
docker build -t "$image" -f "$scripts_host/dev.Dockerfile" "$scripts_host"
|
||||
fi
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
repo_dir="$(dirname "$scripts_dir")"
|
||||
brand_dir="${LUCIO_IP_DIR:-$repo_dir/../LUCIO_ip}"
|
||||
out_dir="$repo_dir/web/brand"
|
||||
|
||||
for required in tokens/tokens.css motion/lucio-morph.js logo/favicon.svg logo/lucio-chop-chen.svg; do
|
||||
if [ ! -f "$brand_dir/$required" ]; then
|
||||
echo "sync-brand: $brand_dir/$required not found (set LUCIO_IP_DIR)" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p "$out_dir"
|
||||
|
||||
strip_js() {
|
||||
perl -0777 -pe 's{(\x22(?:\\.|[^\x22\\\n])*\x22|\x27(?:\\.|[^\x27\\\n])*\x27|\x60(?:\\.|[^\x60\\])*\x60)|/\*.*?\*/|//[^\n]*}{defined $1 ? $1 : ""}gse; s/\r//g; s/[ \t]+$//mg; s/\n{2,}/\n/g; s/\A\n+//'
|
||||
}
|
||||
|
||||
strip_svg() {
|
||||
perl -0777 -pe 's/\r//g; s/<!--.*?-->//gs; s/\n{2,}/\n/g'
|
||||
}
|
||||
|
||||
{
|
||||
echo ":root {"
|
||||
perl -0777 -ne 'if (/:root\s*\{(.*?)\n\}/s) { print $1 }' "$brand_dir/tokens/tokens.css" \
|
||||
| perl -0777 -pe 's{/\*.*?\*/}{}gs' \
|
||||
| grep -E '^\s*--lucio-(graphite|paper|beam|steel|cinnabar|ash|font|space|radius|shadow-glow|motion|ease)[a-z0-9-]*:' \
|
||||
| sed -E 's/^\s+/ /'
|
||||
echo "}"
|
||||
} > "$out_dir/tokens.css"
|
||||
|
||||
strip_js < "$brand_dir/motion/lucio-morph.js" > "$out_dir/lucio-morph.js"
|
||||
strip_svg < "$brand_dir/logo/favicon.svg" > "$out_dir/favicon.svg"
|
||||
strip_svg < "$brand_dir/logo/lucio-chop-chen.svg" > "$out_dir/lucio-chop-chen.svg"
|
||||
|
||||
echo "sync-brand: copied tokens.css, lucio-morph.js, favicon.svg, lucio-chop-chen.svg from $brand_dir into $out_dir"
|
||||
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Lucio icon">
|
||||
<title>Lucio icon</title>
|
||||
<rect width="64" height="64" rx="14" fill="#111114"/><g transform="translate(11.50 11.50)"><path d="M35.889 5.111A5.500 5.500 0 0 0 32.000 3.500H9.000A5.500 5.500 0 0 0 3.500 9.000V32.000A5.500 5.500 0 0 0 9.000 37.500H32.000A5.500 5.500 0 0 0 37.500 32.000V9.000A5.500 5.500 0 0 0 35.889 5.111Z" fill="none" stroke="#F3F1EC" stroke-width="7" stroke-linecap="butt" stroke-dasharray="63.279 63.279" stroke-dashoffset="-31.639"/><path d="M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z" fill="#FFF3CF" transform="translate(0.000 9.182) scale(0.3182)"/></g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 783 B |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" role="img" aria-label="Lucio chop (chen)">
|
||||
<title>Lucio chop (chen)</title>
|
||||
<rect width="100" height="100" rx="3" fill="#C3361F"/>
|
||||
<rect x="7" y="7" width="86" height="86" fill="none" stroke="#F3F1EC" stroke-width="2.5"/>
|
||||
<text x="50" y="52" text-anchor="middle" dominant-baseline="central" font-family="'Noto Serif SC', 'Songti SC', 'SimSun', serif" font-weight="700" font-size="60" fill="#F3F1EC">陈</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 504 B |
@@ -0,0 +1,111 @@
|
||||
(function (global) {
|
||||
const WORD = {"from":"Guoliang","to":"Lucio","letters":[{"ch":"G","kind":"keep","shared":"M8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50","fullA":"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00","fullB":"M8.50 0.00L8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50L80.00 91.50","out":[{"d":"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00","P":79.21,"j":"end"},{"d":"M58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00","P":73.21,"j":"start"}],"in":[{"d":"M8.50 22.00L8.50 0.00","P":22.0,"j":"start"},{"d":"M58.00 91.50L80.00 91.50","P":22.0,"j":"start"}],"x0":0.0,"x1":0.0,"dot":null},{"ch":"u","kind":"keep","shared":"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00","fullA":"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00","fullB":"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00","out":[],"in":[],"x0":88.8,"x1":88.0,"dot":null},{"ch":"o","kind":"keep","shared":"M38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","fullA":"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","fullB":"M60.00 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50L60.00 91.50","out":[{"d":"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50","P":60.41,"j":"both"}],"in":[{"d":"M38.00 46.50L60.00 46.50","P":22.0,"j":"start"},{"d":"M38.00 91.50L60.00 91.50","P":22.0,"j":"start"}],"x0":159.0,"x1":158.2,"dot":null},{"ch":"l","kind":"fade","d":"M8.50 0.00L8.50 100.00","x0":230.8,"x1":230.8,"dot":null},{"ch":"i","kind":"keep","shared":"M8.50 38.00L8.50 100.00","fullA":"M8.50 38.00L8.50 100.00","fullB":"M8.50 38.00L8.50 100.00","out":[],"in":[],"x0":262.8,"x1":227.9,"dot":[0,14,17]},{"ch":"a","kind":"fade","d":"M38.00 91.50L51.50 91.50L51.50 78.00L51.50 60.00L51.50 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","x0":291.6,"x1":291.6,"dot":null},{"ch":"n","kind":"fade","d":"M51.50 100.00L51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00L8.50 100.00","x0":362.7,"x1":362.7,"dot":null},{"ch":"g","kind":"keep","shared":"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","fullA":"M0.00 127.50L38.00 127.50A13.50 13.50 0 0 0 51.50 114.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00","fullB":"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50","out":[{"d":"M51.50 60.00L51.50 114.00A13.50 13.50 0 0 1 38.00 127.50L0.00 127.50","P":113.21,"j":"start"}],"in":[],"x0":432.9,"x1":256.7,"dot":null}],"pad":17,"vbw":526.9,"vbh":170,"stroke":17,"raysT":"translate(0.000 22.727) scale(0.7727)"};
|
||||
const RAYS = "M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z";
|
||||
const NS = "http://www.w3.org/2000/svg";
|
||||
const el = (n, a) => { const e = document.createElementNS(NS, n); for (const k in a) e.setAttribute(k, a[k]); return e; };
|
||||
const reduced = () => global.matchMedia && global.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
const clamp01 = v => Math.max(0, Math.min(1, v));
|
||||
const smooth = t => t * t * (3 - 2 * t);
|
||||
const SPLIT = 0.5;
|
||||
function engine(render, duration) {
|
||||
let t = 0, target = 0, raf = null, last = 0;
|
||||
function tick(now) {
|
||||
const step = (now - last) / duration; last = now;
|
||||
t = t < target ? Math.min(target, t + step) : Math.max(target, t - step);
|
||||
render(t);
|
||||
raf = t === target ? null : requestAnimationFrame(tick);
|
||||
}
|
||||
function go(v) {
|
||||
target = v;
|
||||
if (reduced()) { t = v; render(t); return; }
|
||||
if (raf === null) { last = performance.now(); raf = requestAnimationFrame(tick); }
|
||||
}
|
||||
return { play: () => go(1), reverse: () => go(0), toggle: () => go(target ? 0 : 1),
|
||||
set: v => { cancelAnimationFrame(raf); raf = null; target = t = v; render(t); },
|
||||
stop: () => { cancelAnimationFrame(raf); raf = null; }, get t() { return t; } };
|
||||
}
|
||||
function setDash(path, P, j, frac) {
|
||||
const v = clamp01(frac) * P;
|
||||
path.style.visibility = v < 0.05 ? "hidden" : "visible";
|
||||
if (j === "both") { const h = v / 2; path.setAttribute("stroke-dasharray", h.toFixed(2) + " " + Math.max(0, P - 2*h).toFixed(2) + " " + h.toFixed(2)); path.setAttribute("stroke-dashoffset", "0"); }
|
||||
else if (j === "end") { path.setAttribute("stroke-dasharray", v.toFixed(2) + " " + (2*P+20).toFixed(2)); path.setAttribute("stroke-dashoffset", (-(P - v)).toFixed(2)); }
|
||||
else { path.setAttribute("stroke-dasharray", v.toFixed(2) + " " + (2*P+20).toFixed(2)); path.setAttribute("stroke-dashoffset", "0"); }
|
||||
}
|
||||
function wordmark(container, opts = {}) {
|
||||
const o = Object.assign({ trigger: "hover", color: "currentColor", rays: "#FFF3CF", duration: 450, autoDelay: 1800 }, opts);
|
||||
const svg = el("svg", { viewBox: "0 0 " + WORD.vbw + " " + WORD.vbh, role: "img", "aria-label": "Guoliang Chen, Lucio" });
|
||||
svg.style.display = "block"; svg.style.width = "100%"; svg.style.height = "auto";
|
||||
const root = el("g", { transform: "translate(" + WORD.pad + " " + WORD.pad + ")", fill: "none", stroke: o.color, "stroke-width": WORD.stroke, "stroke-linejoin": "miter", "stroke-linecap": "butt" });
|
||||
svg.appendChild(root);
|
||||
const letters = WORD.letters.map(L => {
|
||||
const g = el("g", { transform: "translate(" + L.x0 + " 0)" }); root.appendChild(g);
|
||||
const R = Object.assign({ g, outEls: [], inEls: [] }, L);
|
||||
if (L.kind === "fade") { R.fadeEl = el("path", { d: L.d }); g.appendChild(R.fadeEl); }
|
||||
else {
|
||||
R.fullA = el("path", { d: L.fullA }); g.appendChild(R.fullA);
|
||||
R.fullB = el("path", { d: L.fullB }); g.appendChild(R.fullB);
|
||||
if (L.shared) g.appendChild(el("path", { d: L.shared }));
|
||||
for (const c of L.out) { const p = el("path", { d: c.d }); g.appendChild(p); R.outEls.push([p, c]); }
|
||||
for (const c of L.in) { const p = el("path", { d: c.d }); g.appendChild(p); R.inEls.push([p, c]); }
|
||||
}
|
||||
if (L.dot) { R.dotEl = el("rect", { x: L.dot[0], y: L.dot[1], width: L.dot[2], height: L.dot[2], rx: L.dot[2] * 0.22, fill: o.color, stroke: "none" }); g.appendChild(R.dotEl); }
|
||||
return R;
|
||||
});
|
||||
const rays = el("path", { d: RAYS, fill: o.rays, stroke: "none", opacity: 0 }); root.appendChild(rays);
|
||||
container.appendChild(svg);
|
||||
function render(t) {
|
||||
const tA = smooth(clamp01(t / SPLIT)), tB = smooth(clamp01((t - SPLIT) / (1 - SPLIT)));
|
||||
for (const L of letters) {
|
||||
if (L.kind === "fade") { L.fadeEl.setAttribute("opacity", (1 - tA).toFixed(3)); if (L.dotEl) L.dotEl.setAttribute("opacity", (1 - tA).toFixed(3)); }
|
||||
else {
|
||||
for (const [p, c] of L.outEls) setDash(p, c.P, c.j, 1 - tA);
|
||||
for (const [p, c] of L.inEls) setDash(p, c.P, c.j, tA);
|
||||
L.fullA.style.visibility = tA <= 0.001 ? "visible" : "hidden";
|
||||
L.fullB.style.visibility = tA >= 0.999 ? "visible" : "hidden";
|
||||
}
|
||||
L.g.setAttribute("transform", "translate(" + (L.x0 + (L.x1 - L.x0) * tB).toFixed(2) + " 0)");
|
||||
}
|
||||
rays.setAttribute("transform", "translate(" + (letters[0].x0 + (letters[0].x1 - letters[0].x0) * tB).toFixed(2) + " 0) " + WORD.raysT);
|
||||
rays.setAttribute("opacity", clamp01((t - 0.8) / 0.2).toFixed(3));
|
||||
}
|
||||
const a = engine(render, o.duration); render(0);
|
||||
if (o.trigger === "hover") { container.addEventListener("mouseenter", a.play); container.addEventListener("mouseleave", a.reverse); container.addEventListener("focus", a.play); container.addEventListener("blur", a.reverse); }
|
||||
if (o.trigger === "click") container.addEventListener("click", a.toggle);
|
||||
if (o.trigger === "auto") setInterval(a.toggle, o.autoDelay + o.duration);
|
||||
return Object.assign(a, { svg });
|
||||
}
|
||||
const LET = { C: [0, .75], L: [.25, .75], U: [.25, 1], I: [.75, 1], O: [.75, 1.75] };
|
||||
function frame(S, w, r) {
|
||||
const m = w / 2, R = r - m, c = m + R, k = R * Math.SQRT1_2, f = v => v.toFixed(3);
|
||||
const d = "M" + f(S-c+k) + " " + f(c-k) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(S-c) + " " + f(m) + "H" + f(c) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(m) + " " + f(c) + "V" + f(S-c) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(c) + " " + f(S-m) + "H" + f(S-c) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(S-m) + " " + f(S-c) + "V" + f(c) + "A" + f(R) + " " + f(R) + " 0 0 0 " + f(S-c+k) + " " + f(c-k) + "Z";
|
||||
return { d, P: 4 * (S - 2 * c) + 2 * Math.PI * R };
|
||||
}
|
||||
function loader(container, opts = {}) {
|
||||
const o = Object.assign({ sequence: "LUCIO", color: "#F3F1EC", track: "#26262D", rays: "#FFF3CF", hold: 480, morph: 640, size: 96, stroke: 0.17, radius: 0.22 }, opts);
|
||||
const S = 120, w = S * o.stroke, r = S * o.radius, F = frame(S, w, r);
|
||||
const svg = el("svg", { viewBox: "0 0 " + S + " " + S, width: o.size, height: o.size, role: "img", "aria-label": "Loading" });
|
||||
if (o.track) svg.appendChild(el("path", { d: F.d, fill: "none", stroke: o.track, "stroke-width": w }));
|
||||
const path = el("path", { d: F.d, fill: "none", stroke: o.color, "stroke-width": w, "stroke-linecap": "butt" });
|
||||
const k = w / 22, rays = el("path", { d: RAYS, fill: o.rays, transform: "translate(" + (w - 22*k).toFixed(3) + " " + (S - w - 78*k).toFixed(3) + ") scale(" + k.toFixed(4) + ")", opacity: 0 });
|
||||
svg.appendChild(path); svg.appendChild(rays);
|
||||
const seg = (s, e) => { const len = Math.min(1, Math.max(0, e - s)) * F.P; path.setAttribute("stroke-dasharray", len.toFixed(3) + " " + Math.max(0, F.P - len).toFixed(3)); path.setAttribute("stroke-dashoffset", (-s * F.P).toFixed(3)); };
|
||||
const target = (cur, ch) => { const [s2, e2] = LET[ch]; for (let q = -1; q < 6; q++) { if (s2 + q >= cur[0] - 1e-6 && e2 + q >= cur[1] - 1e-6) return [s2 + q, e2 + q]; } return [s2, e2]; };
|
||||
const seq = o.sequence.split(""); let i = 0, cur = LET[seq[0]].slice(), raf, timer, stopped = false;
|
||||
seg(cur[0], cur[1]); rays.setAttribute("opacity", seq[0] === "L" ? 1 : 0);
|
||||
function next() {
|
||||
if (stopped) return;
|
||||
const j = (i + 1) % seq.length, to = target(cur, seq[j]), from = cur.slice(), wasL = seq[i] === "L", isL = seq[j] === "L";
|
||||
const finish = () => { cur = to; const n = Math.floor(cur[0]); cur[0] -= n; cur[1] -= n; i = j; seg(cur[0], cur[1]); rays.setAttribute("opacity", isL ? 1 : 0); timer = setTimeout(next, o.hold); };
|
||||
if (reduced()) { finish(); return; }
|
||||
const start = performance.now();
|
||||
const step = now => { const t = Math.min(1, (now - start) / o.morph), u = t < 0.5 ? 4*t*t*t : 1 - Math.pow(-2*t + 2, 3) / 2; seg(from[0] + (to[0]-from[0])*u, from[1] + (to[1]-from[1])*u);
|
||||
rays.setAttribute("opacity", isL ? Math.max(0, (t - .6) / .4).toFixed(3) : wasL ? Math.max(0, 1 - t * 2.5).toFixed(3) : 0);
|
||||
if (t < 1) raf = requestAnimationFrame(step); else finish(); };
|
||||
raf = requestAnimationFrame(step);
|
||||
}
|
||||
timer = setTimeout(next, o.hold);
|
||||
container.appendChild(svg);
|
||||
return { svg, stop: () => { stopped = true; cancelAnimationFrame(raf); clearTimeout(timer); } };
|
||||
}
|
||||
global.LucioMorph = { wordmark, loader };
|
||||
})(window);
|
||||
@@ -0,0 +1,45 @@
|
||||
:root {
|
||||
--lucio-graphite: #111114;
|
||||
--lucio-graphite-2: #1A1A1F;
|
||||
--lucio-graphite-3: #26262D;
|
||||
--lucio-paper: #F3F1EC;
|
||||
--lucio-paper-2: #E9E6DF;
|
||||
--lucio-paper-3: #D9D6CD;
|
||||
--lucio-beam: #FFF3CF;
|
||||
--lucio-beam-deep: #5E5238;
|
||||
--lucio-beam-glow: #FFFBF0;
|
||||
--lucio-steel: #8A94A6;
|
||||
--lucio-steel-deep: #3F4B60;
|
||||
--lucio-cinnabar: #C3361F;
|
||||
--lucio-cinnabar-light: #F08A77;
|
||||
--lucio-ash: #666A74;
|
||||
--lucio-ash-dark: #43464F;
|
||||
--lucio-ash-light: #A6A9B3;
|
||||
--lucio-font-display: "Bricolage Grotesque", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
|
||||
--lucio-font-body: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
|
||||
--lucio-font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
|
||||
--lucio-font-cjk-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
|
||||
--lucio-font-cjk-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
--lucio-space-1: 4px;
|
||||
--lucio-space-2: 8px;
|
||||
--lucio-space-3: 12px;
|
||||
--lucio-space-4: 16px;
|
||||
--lucio-space-5: 24px;
|
||||
--lucio-space-6: 32px;
|
||||
--lucio-space-7: 48px;
|
||||
--lucio-space-8: 64px;
|
||||
--lucio-space-9: 96px;
|
||||
--lucio-space-10: 128px;
|
||||
--lucio-radius-none: 0px;
|
||||
--lucio-radius-sm: 4px;
|
||||
--lucio-radius-md: 8px;
|
||||
--lucio-radius-lg: 16px;
|
||||
--lucio-radius-icon: 22%;
|
||||
--lucio-shadow-glow: 0 0 0 1px rgba(255,243,207,0.30), 0 8px 32px -8px rgba(255,243,207,0.35);
|
||||
--lucio-motion-fast: 120ms;
|
||||
--lucio-ease-fast: cubic-bezier(0.2, 0, 0, 1);
|
||||
--lucio-motion-base: 240ms;
|
||||
--lucio-ease-base: cubic-bezier(0.2, 0, 0, 1);
|
||||
--lucio-motion-glow: 900ms;
|
||||
--lucio-ease-glow: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
Generated
+33
@@ -8,6 +8,9 @@
|
||||
"name": "luphoto-web",
|
||||
"version": "0.0.0",
|
||||
"devDependencies": {
|
||||
"@fontsource-variable/bricolage-grotesque": "5.3.0",
|
||||
"@fontsource/ibm-plex-mono": "5.3.0",
|
||||
"@fontsource/ibm-plex-sans": "5.3.0",
|
||||
"esbuild": "0.24.2",
|
||||
"typescript": "5.7.3"
|
||||
}
|
||||
@@ -437,6 +440,36 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource-variable/bricolage-grotesque": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource-variable/bricolage-grotesque/-/bricolage-grotesque-5.3.0.tgz",
|
||||
"integrity": "sha512-TLi9Q4hJjS2UvoTMRSS2nHu6c4R56lAw60NR9QYtVRCHn0XtsFpiEhNffZ8Glsoxu6wEEwLKBP8lb94J52PNBA==",
|
||||
"dev": true,
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource/ibm-plex-mono": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource/ibm-plex-mono/-/ibm-plex-mono-5.3.0.tgz",
|
||||
"integrity": "sha512-eTgnZjZEGk1QtD3ZstF+Vclo2HLAni8YMy34/DxllwZvyz1lR/1RF/xTiAquOBO7MvqBx8D2Ig2WCPMVfdZu7Q==",
|
||||
"dev": true,
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@fontsource/ibm-plex-sans": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource/ibm-plex-sans/-/ibm-plex-sans-5.3.0.tgz",
|
||||
"integrity": "sha512-CbE4CbbEEZJX860XyUiRpsksXIQR8Rp2XDva2VO53NJox9tVNtusrysd2x5YkUEY3ErQ66W1IiiQL8/wihhw5w==",
|
||||
"dev": true,
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.24.2",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.2.tgz",
|
||||
|
||||
+6
-2
@@ -5,10 +5,14 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit",
|
||||
"bundle": "esbuild src/app.ts src/worker.ts src/app.css --bundle --minify --target=es2020,safari15 --legal-comments=none --outdir=../internal/site/static",
|
||||
"build": "npm run typecheck && npm run bundle"
|
||||
"bundle": "npm run clean && esbuild src/app.ts src/worker.ts src/app.css brand/favicon.svg brand/lucio-chop-chen.svg --bundle --minify --target=es2020,safari15 --legal-comments=none --loader:.svg=copy --loader:.woff2=file --entry-names=[name] --asset-names=[name].[hash] --outdir=../internal/site/static",
|
||||
"build": "npm run typecheck && npm run bundle",
|
||||
"clean": "node -e \"require('fs').rmSync('../internal/site/static',{recursive:true,force:true})\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fontsource-variable/bricolage-grotesque": "5.3.0",
|
||||
"@fontsource/ibm-plex-mono": "5.3.0",
|
||||
"@fontsource/ibm-plex-sans": "5.3.0",
|
||||
"esbuild": "0.24.2",
|
||||
"typescript": "5.7.3"
|
||||
}
|
||||
|
||||
+350
-89
@@ -1,37 +1,49 @@
|
||||
@import "../brand/tokens.css";
|
||||
@import "./fonts.css";
|
||||
|
||||
:root {
|
||||
--graphite: #111114;
|
||||
--paper: #f3f1ec;
|
||||
--beam: #fff3cf;
|
||||
--steel: #8a94a6;
|
||||
--steel-deep: #3f4b60;
|
||||
--cinnabar: #c3361f;
|
||||
--font-display: "Bricolage Grotesque", "Noto Sans SC", system-ui, sans-serif;
|
||||
--font-body: "IBM Plex Sans", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
--font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
||||
--font-chop: "Noto Serif SC", "Songti SC", serif;
|
||||
--ease-light: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
--t-hover: 120ms;
|
||||
--t-reveal: 240ms;
|
||||
color-scheme: dark;
|
||||
--strip-closed: min(calc(100vw * 6 / 32), 28vh);
|
||||
--strip-open: min(calc(100vw * 9 / 32), 62vh);
|
||||
--strip-gap: var(--lucio-space-2);
|
||||
--gutter: var(--lucio-space-4);
|
||||
--veil: rgba(17, 17, 20, 0.78);
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
:root {
|
||||
--strip-gap: var(--lucio-space-4);
|
||||
--gutter: var(--lucio-space-6);
|
||||
}
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100%;
|
||||
background: var(--graphite);
|
||||
color: var(--paper);
|
||||
font-family: var(--font-body);
|
||||
background: var(--lucio-graphite);
|
||||
color: var(--lucio-paper);
|
||||
font-family: var(--lucio-font-body);
|
||||
font-size: 17px;
|
||||
line-height: 1.6;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--paper);
|
||||
color: var(--lucio-paper);
|
||||
text-decoration-color: var(--lucio-ash-light);
|
||||
text-underline-offset: 0.15em;
|
||||
}
|
||||
|
||||
::selection {
|
||||
background: var(--lucio-graphite-3);
|
||||
color: var(--lucio-paper);
|
||||
}
|
||||
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--beam);
|
||||
outline-offset: 3px;
|
||||
outline: 2px solid var(--lucio-beam);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.visually-hidden {
|
||||
@@ -46,26 +58,231 @@ a {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.index-list {
|
||||
max-width: 48rem;
|
||||
margin: 0 auto;
|
||||
padding: 48px 16px;
|
||||
.strip-eyebrow,
|
||||
.next-eyebrow {
|
||||
font-family: var(--lucio-font-mono);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--lucio-ash-light);
|
||||
}
|
||||
|
||||
.index-list h1 {
|
||||
font-family: var(--font-display);
|
||||
.wordmark,
|
||||
.home-mark {
|
||||
display: block;
|
||||
color: var(--lucio-paper);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wordmark-text {
|
||||
font-family: var(--lucio-font-display);
|
||||
font-weight: 700;
|
||||
font-size: 28px;
|
||||
line-height: 1;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.has-svg .wordmark-text {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0 0 0 0);
|
||||
}
|
||||
|
||||
.wordmark-svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.chop {
|
||||
display: block;
|
||||
width: clamp(28px, 7vmin, 72px);
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.chop svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.site-header {
|
||||
padding: var(--lucio-space-5) var(--gutter);
|
||||
}
|
||||
|
||||
.site-header .wordmark {
|
||||
width: 128px;
|
||||
}
|
||||
|
||||
.strips {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--strip-gap);
|
||||
}
|
||||
|
||||
.strip {
|
||||
position: relative;
|
||||
display: block;
|
||||
height: var(--strip-closed);
|
||||
overflow: hidden;
|
||||
background: var(--lucio-graphite-2);
|
||||
color: var(--lucio-paper);
|
||||
text-decoration: none;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
transition: height var(--lucio-motion-base) var(--lucio-ease-base);
|
||||
}
|
||||
|
||||
.strip.is-open {
|
||||
height: var(--strip-open);
|
||||
}
|
||||
|
||||
.strip:focus-visible {
|
||||
outline: 2px solid var(--lucio-beam);
|
||||
outline-offset: -2px;
|
||||
box-shadow: var(--lucio-shadow-glow);
|
||||
}
|
||||
|
||||
.strip-canvas {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
display: block;
|
||||
will-change: transform;
|
||||
transition: transform var(--lucio-motion-base) var(--lucio-ease-base);
|
||||
}
|
||||
|
||||
.strip::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(to top, var(--veil) 0%, rgba(17, 17, 20, 0.3) 40%, rgba(17, 17, 20, 0) 68%);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity var(--lucio-motion-fast) var(--lucio-ease-fast);
|
||||
}
|
||||
|
||||
.strip-text {
|
||||
position: absolute;
|
||||
left: var(--gutter);
|
||||
right: var(--gutter);
|
||||
bottom: var(--lucio-space-5);
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--lucio-space-1);
|
||||
max-width: 68ch;
|
||||
}
|
||||
|
||||
.strip-eyebrow,
|
||||
.strip-title,
|
||||
.strip-subtitle {
|
||||
opacity: 0;
|
||||
transition: opacity var(--lucio-motion-fast) var(--lucio-ease-fast);
|
||||
}
|
||||
|
||||
.strip-title {
|
||||
font-family: var(--lucio-font-display);
|
||||
font-weight: 600;
|
||||
font-size: clamp(22px, 2.6vw, 36px);
|
||||
line-height: 1.15;
|
||||
letter-spacing: -0.015em;
|
||||
}
|
||||
|
||||
.index-list li {
|
||||
margin: 8px 0;
|
||||
.strip-subtitle {
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--lucio-ash-light);
|
||||
}
|
||||
|
||||
.index-list time,
|
||||
.index-list span {
|
||||
font-family: var(--font-mono);
|
||||
color: var(--steel);
|
||||
font-size: 0.85em;
|
||||
.strip.is-open::after,
|
||||
.strip.is-open .strip-eyebrow,
|
||||
.strip.is-open .strip-title,
|
||||
.strip.is-open .strip-subtitle {
|
||||
opacity: 1;
|
||||
transition: opacity var(--lucio-motion-glow) var(--lucio-ease-glow) var(--lucio-motion-base);
|
||||
}
|
||||
|
||||
.strip.is-open .strip-title {
|
||||
transition-delay: calc(var(--lucio-motion-base) + var(--lucio-motion-fast));
|
||||
}
|
||||
|
||||
.strip.is-open .strip-subtitle {
|
||||
transition-delay: calc(var(--lucio-motion-base) + var(--lucio-motion-fast) * 2);
|
||||
}
|
||||
|
||||
html:not(.has-strips) .strip::after,
|
||||
html:not(.has-strips) .strip-eyebrow,
|
||||
html:not(.has-strips) .strip-title,
|
||||
html:not(.has-strips) .strip-subtitle {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.empty {
|
||||
margin: 0;
|
||||
padding: var(--lucio-space-9) var(--gutter);
|
||||
color: var(--lucio-ash-light);
|
||||
}
|
||||
|
||||
.site-footer {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: var(--lucio-space-4);
|
||||
padding: var(--lucio-space-7) var(--gutter) var(--lucio-space-6);
|
||||
}
|
||||
|
||||
.footer-line {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--lucio-ash-light);
|
||||
}
|
||||
|
||||
.busy {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
right: max(var(--lucio-space-6), calc(env(safe-area-inset-right) + var(--lucio-space-6)));
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
margin-top: -28px;
|
||||
z-index: 5;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity var(--lucio-motion-base) var(--lucio-ease-base);
|
||||
}
|
||||
|
||||
.busy.is-visible {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.busy svg {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.progress {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
z-index: 6;
|
||||
background: var(--lucio-beam);
|
||||
transform: scaleX(0);
|
||||
transform-origin: 0 50%;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: transform var(--lucio-motion-base) var(--lucio-ease-base), opacity var(--lucio-motion-base) var(--lucio-ease-base);
|
||||
}
|
||||
|
||||
.progress.is-visible {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.has-viewer body.viewer {
|
||||
@@ -76,16 +293,29 @@ a {
|
||||
}
|
||||
|
||||
.album-fallback {
|
||||
padding: 48px 16px;
|
||||
padding: var(--lucio-space-7) var(--gutter);
|
||||
}
|
||||
|
||||
.has-viewer .album-fallback {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.home-mark {
|
||||
position: fixed;
|
||||
top: max(var(--lucio-space-5), env(safe-area-inset-top));
|
||||
left: max(var(--lucio-space-5), env(safe-area-inset-left));
|
||||
z-index: 4;
|
||||
width: 88px;
|
||||
transition: opacity var(--lucio-motion-base) var(--lucio-ease-base);
|
||||
}
|
||||
|
||||
.is-idle:not(.has-caption) .home-mark:not(:focus-visible) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.stage {
|
||||
overflow: hidden;
|
||||
background: var(--graphite);
|
||||
background: var(--lucio-graphite);
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
@@ -115,7 +345,7 @@ a {
|
||||
.stage-fade {
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: opacity var(--t-reveal) var(--ease-light);
|
||||
transition: opacity var(--lucio-motion-base) var(--lucio-ease-glow);
|
||||
}
|
||||
|
||||
.caption {
|
||||
@@ -125,11 +355,11 @@ a {
|
||||
box-sizing: border-box;
|
||||
max-height: 60%;
|
||||
overflow: hidden;
|
||||
padding: 72px 24px 20px;
|
||||
padding: var(--lucio-space-8) var(--lucio-space-5) var(--lucio-space-5);
|
||||
background: linear-gradient(to top, rgba(17, 17, 20, 0.9) 0%, rgba(17, 17, 20, 0.62) 55%, rgba(17, 17, 20, 0) 100%);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity var(--t-reveal) var(--ease-light);
|
||||
transition: opacity var(--lucio-motion-base) var(--lucio-ease-base);
|
||||
}
|
||||
|
||||
.caption.is-visible {
|
||||
@@ -138,26 +368,28 @@ a {
|
||||
|
||||
.caption-meta {
|
||||
margin: 0;
|
||||
font-family: var(--font-mono);
|
||||
font-family: var(--lucio-font-mono);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--steel);
|
||||
color: var(--lucio-steel);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.caption-title {
|
||||
margin: 10px 0 0;
|
||||
font-family: var(--font-display);
|
||||
margin: var(--lucio-space-2) 0 0;
|
||||
font-family: var(--lucio-font-display);
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.caption-text {
|
||||
margin: 8px 0 0;
|
||||
max-width: 62ch;
|
||||
font-size: 15px;
|
||||
line-height: 1.55;
|
||||
margin: var(--lucio-space-2) 0 0;
|
||||
max-width: 68ch;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.caption-text em {
|
||||
@@ -170,62 +402,91 @@ a {
|
||||
left: 0;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 20px;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.chop {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 8px;
|
||||
background: var(--cinnabar);
|
||||
color: var(--paper);
|
||||
font-family: var(--font-chop);
|
||||
font-size: 34px;
|
||||
line-height: 1;
|
||||
.next-album {
|
||||
display: block;
|
||||
color: var(--lucio-paper);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.next-strip {
|
||||
position: relative;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.next-album.has-strip .next-strip {
|
||||
background: var(--lucio-graphite-2);
|
||||
}
|
||||
|
||||
.next-album.has-strip .next-strip::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(to top, var(--veil) 0%, rgba(17, 17, 20, 0) 65%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.next-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--lucio-space-1);
|
||||
}
|
||||
|
||||
.next-album.has-strip .next-text {
|
||||
position: absolute;
|
||||
left: var(--lucio-space-5);
|
||||
bottom: var(--lucio-space-4);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.next-title {
|
||||
font-family: var(--lucio-font-display);
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.next-album:hover .next-title {
|
||||
text-decoration: underline;
|
||||
text-decoration-color: var(--lucio-ash-light);
|
||||
text-underline-offset: 0.15em;
|
||||
}
|
||||
|
||||
.next-album:focus-visible {
|
||||
outline-offset: 4px;
|
||||
box-shadow: var(--lucio-shadow-glow);
|
||||
}
|
||||
|
||||
.signoff {
|
||||
position: absolute;
|
||||
right: var(--lucio-space-6);
|
||||
bottom: var(--lucio-space-6);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: var(--lucio-space-2);
|
||||
}
|
||||
|
||||
.signature {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.next-album {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 24px;
|
||||
text-decoration: none;
|
||||
transition: color var(--t-hover) var(--ease-light);
|
||||
}
|
||||
|
||||
.next-album:hover .next-title {
|
||||
color: var(--beam);
|
||||
}
|
||||
|
||||
.next-eyebrow {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--steel);
|
||||
}
|
||||
|
||||
.next-title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 24px;
|
||||
font-family: var(--lucio-font-display);
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.next-album {
|
||||
transition: none;
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
transition-duration: 0ms !important;
|
||||
transition-delay: 0ms !important;
|
||||
animation-duration: 0ms !important;
|
||||
}
|
||||
}
|
||||
+37
-14
@@ -1,31 +1,54 @@
|
||||
import { TileCache, cacheBudget } from "./cache";
|
||||
import { IndexPage } from "./index";
|
||||
import { Scheduler } from "./scheduler";
|
||||
import { readSettings, type Manifest } from "./types";
|
||||
import { readSettings, type Manifest, type Settings, type SiteIndex } from "./types";
|
||||
import { Viewer } from "./viewer";
|
||||
|
||||
async function startAlbum(stage: HTMLElement): Promise<void> {
|
||||
const settings = readSettings(document.body);
|
||||
const response = await fetch(settings.manifestUrl, { credentials: "same-origin" });
|
||||
async function fetchJSON<T>(url: string): Promise<T> {
|
||||
const response = await fetch(url, { credentials: "same-origin" });
|
||||
if (!response.ok) {
|
||||
throw new Error("manifest " + response.status);
|
||||
throw new Error(url + " " + response.status);
|
||||
}
|
||||
const manifest = (await response.json()) as Manifest;
|
||||
return (await response.json()) as T;
|
||||
}
|
||||
|
||||
function shared(settings: Settings): { scheduler: Scheduler; cache: TileCache } {
|
||||
return { scheduler: new Scheduler(settings.concurrency, settings.workerUrl), cache: new TileCache(cacheBudget()) };
|
||||
}
|
||||
|
||||
async function startAlbum(stage: HTMLElement, settings: Settings): Promise<void> {
|
||||
const manifest = await fetchJSON<Manifest>(settings.manifestUrl);
|
||||
if (manifest.photos.length === 0) {
|
||||
return;
|
||||
}
|
||||
const scheduler = new Scheduler(settings.concurrency, settings.workerUrl);
|
||||
const cache = new TileCache(cacheBudget());
|
||||
const { scheduler, cache } = shared(settings);
|
||||
document.documentElement.classList.add("has-viewer");
|
||||
new Viewer(stage, manifest, settings, { scheduler, cache, settings, tiles: manifest.tiles });
|
||||
}
|
||||
|
||||
async function startIndex(root: HTMLElement, settings: Settings): Promise<void> {
|
||||
const index = await fetchJSON<SiteIndex>(settings.indexUrl);
|
||||
const { scheduler, cache } = shared(settings);
|
||||
new IndexPage(root, index, settings, { scheduler, cache, settings, tiles: index.tiles });
|
||||
}
|
||||
|
||||
function boot(): void {
|
||||
const stage = document.getElementById("stage");
|
||||
if (document.body.dataset.page === "album" && stage) {
|
||||
startAlbum(stage).catch((error: unknown) => {
|
||||
stage.dataset.error = String(error);
|
||||
document.documentElement.classList.remove("has-viewer");
|
||||
});
|
||||
const settings = readSettings(document.body);
|
||||
if (settings.page === "album") {
|
||||
const stage = document.getElementById("stage");
|
||||
if (stage) {
|
||||
startAlbum(stage, settings).catch((error: unknown) => {
|
||||
stage.dataset.error = String(error);
|
||||
document.documentElement.classList.remove("has-viewer");
|
||||
});
|
||||
}
|
||||
} else if (settings.page === "index") {
|
||||
const root = document.getElementById("strips");
|
||||
if (root) {
|
||||
startIndex(root, settings).catch((error: unknown) => {
|
||||
root.dataset.error = String(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import "../brand/lucio-morph.js";
|
||||
|
||||
export interface MorphHandle {
|
||||
play(): void;
|
||||
reverse(): void;
|
||||
toggle(): void;
|
||||
set(t: number): void;
|
||||
stop(): void;
|
||||
readonly t: number;
|
||||
svg: SVGSVGElement;
|
||||
}
|
||||
|
||||
export interface LoaderHandle {
|
||||
svg: SVGSVGElement;
|
||||
stop(): void;
|
||||
}
|
||||
|
||||
export interface WordmarkOptions {
|
||||
trigger?: "hover" | "click" | "auto" | "manual";
|
||||
color?: string;
|
||||
rays?: string;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export interface LoaderOptions {
|
||||
size?: number;
|
||||
color?: string;
|
||||
track?: string;
|
||||
rays?: string;
|
||||
hold?: number;
|
||||
morph?: number;
|
||||
}
|
||||
|
||||
interface LucioMorphApi {
|
||||
wordmark(container: Element, options?: WordmarkOptions): MorphHandle;
|
||||
loader(container: Element, options?: LoaderOptions): LoaderHandle;
|
||||
}
|
||||
|
||||
export const palette = {
|
||||
graphite: "#111114",
|
||||
graphite3: "#26262D",
|
||||
paper: "#F3F1EC",
|
||||
beam: "#FFF3CF",
|
||||
};
|
||||
|
||||
export function lucioMorph(): LucioMorphApi | null {
|
||||
const api = (window as unknown as { LucioMorph?: LucioMorphApi }).LucioMorph;
|
||||
return api ?? null;
|
||||
}
|
||||
|
||||
export function mountWordmark(link: HTMLElement, animated: boolean): MorphHandle | null {
|
||||
const api = lucioMorph();
|
||||
if (!api) {
|
||||
return null;
|
||||
}
|
||||
const holder = document.createElement("span");
|
||||
holder.className = "wordmark-svg";
|
||||
holder.setAttribute("aria-hidden", "true");
|
||||
link.appendChild(holder);
|
||||
const handle = api.wordmark(holder, { trigger: "manual", color: palette.paper, rays: palette.beam });
|
||||
handle.svg.setAttribute("aria-hidden", "true");
|
||||
handle.svg.removeAttribute("role");
|
||||
if (!animated) {
|
||||
handle.set(1);
|
||||
}
|
||||
link.classList.add("has-svg");
|
||||
return handle;
|
||||
}
|
||||
|
||||
export function cloneChop(): HTMLElement | null {
|
||||
const template = document.getElementById("chop-template");
|
||||
if (!(template instanceof HTMLTemplateElement)) {
|
||||
return null;
|
||||
}
|
||||
const node = template.content.firstElementChild;
|
||||
return node ? (node.cloneNode(true) as HTMLElement) : null;
|
||||
}
|
||||
+20
-1
@@ -30,6 +30,25 @@ function trimNumber(n: number): string {
|
||||
return String(Math.round(n * 10) / 10);
|
||||
}
|
||||
|
||||
export function formatShutter(exposure: string): string {
|
||||
const value = exposure.trim();
|
||||
if (value.includes("/") || value.endsWith("s")) {
|
||||
return value;
|
||||
}
|
||||
const seconds = Number(value);
|
||||
if (!Number.isFinite(seconds) || seconds <= 0) {
|
||||
return value;
|
||||
}
|
||||
if (seconds >= 1) {
|
||||
return trimNumber(seconds) + "s";
|
||||
}
|
||||
const denominator = 1 / seconds;
|
||||
if (denominator < 10 && Math.abs(denominator - Math.round(denominator)) > 0.05) {
|
||||
return "1/" + trimNumber(denominator);
|
||||
}
|
||||
return "1/" + Math.round(denominator);
|
||||
}
|
||||
|
||||
export function metaLine(index: number, total: number, photo: Photo, showExif: boolean): string {
|
||||
const parts = [pad(index + 1) + " / " + pad(total)];
|
||||
const exif = photo.exif;
|
||||
@@ -48,7 +67,7 @@ export function metaLine(index: number, total: number, photo: Photo, showExif: b
|
||||
parts.push("f/" + trimNumber(exif.f_number));
|
||||
}
|
||||
if (exif.exposure) {
|
||||
parts.push(exif.exposure.includes("/") ? exif.exposure : exif.exposure + "s");
|
||||
parts.push(formatShutter(exif.exposure));
|
||||
}
|
||||
if (exif.iso) {
|
||||
parts.push("ISO " + exif.iso);
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
@font-face {
|
||||
font-family: "Bricolage Grotesque";
|
||||
font-style: normal;
|
||||
font-weight: 200 800;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource-variable/bricolage-grotesque/files/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2-variations");
|
||||
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Bricolage Grotesque";
|
||||
font-style: normal;
|
||||
font-weight: 200 800;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource-variable/bricolage-grotesque/files/bricolage-grotesque-latin-wght-normal.woff2") format("woff2-variations");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-ext-400-normal.woff2") format("woff2");
|
||||
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-ext-500-normal.woff2") format("woff2");
|
||||
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-ext-600-normal.woff2") format("woff2");
|
||||
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-ext-400-italic.woff2") format("woff2");
|
||||
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-400-italic.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Mono";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-ext-400-normal.woff2") format("woff2");
|
||||
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Mono";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Mono";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-ext-500-normal.woff2") format("woff2");
|
||||
unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IBM Plex Mono";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("../node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
|
||||
unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
import { mountWordmark, type MorphHandle } from "./brand";
|
||||
import { BusyIndicator } from "./indicator";
|
||||
import { Strip, type StripEnv } from "./strip";
|
||||
import type { SiteIndex, Settings } from "./types";
|
||||
|
||||
const hysteresis = 24;
|
||||
|
||||
export class IndexPage {
|
||||
private readonly strips: Strip[] = [];
|
||||
private readonly onScreen = new Set<Strip>();
|
||||
private readonly indicator: BusyIndicator;
|
||||
private readonly hoverMode: MediaQueryList;
|
||||
private wordmark: MorphHandle | null = null;
|
||||
private opened: Strip | null = null;
|
||||
private scrollFrame = 0;
|
||||
private sizeKey = "";
|
||||
|
||||
constructor(
|
||||
private readonly root: HTMLElement,
|
||||
index: SiteIndex,
|
||||
private readonly settings: Settings,
|
||||
env: StripEnv,
|
||||
) {
|
||||
const anchors = Array.from(root.querySelectorAll<HTMLElement>("a.strip"));
|
||||
const bySlug = new Map(index.albums.map((album) => [album.slug, album]));
|
||||
for (const anchor of anchors) {
|
||||
const album = bySlug.get(anchor.dataset.slug ?? "");
|
||||
if (!album || !album.cover) {
|
||||
continue;
|
||||
}
|
||||
this.strips.push(new Strip(anchor, album.cover, album.collapsed_focus_y ?? 0.5, env, (strip) => this.onStripStatus(strip)));
|
||||
}
|
||||
this.hoverMode = matchMedia("(hover: hover) and (pointer: fine)");
|
||||
const header = document.querySelector<HTMLElement>(".site-header .wordmark");
|
||||
this.indicator = new BusyIndicator(document.body, () => !this.wordmarkMoving());
|
||||
if (header) {
|
||||
this.wordmark = mountWordmark(header, true);
|
||||
const play = () => {
|
||||
if (this.wordmark && !this.indicator.visible) {
|
||||
this.wordmark.play();
|
||||
}
|
||||
};
|
||||
const reverse = () => this.wordmark?.reverse();
|
||||
header.addEventListener("mouseenter", play);
|
||||
header.addEventListener("mouseleave", reverse);
|
||||
header.addEventListener("focus", play);
|
||||
header.addEventListener("blur", reverse);
|
||||
}
|
||||
document.documentElement.classList.add("has-strips");
|
||||
this.measure();
|
||||
this.observe();
|
||||
this.bind();
|
||||
}
|
||||
|
||||
private wordmarkMoving(): boolean {
|
||||
const t = this.wordmark?.t ?? 0;
|
||||
return t > 0 && t < 1;
|
||||
}
|
||||
|
||||
private measure(): void {
|
||||
const width = this.root.clientWidth || window.innerWidth;
|
||||
const height = window.innerHeight;
|
||||
const closed = Math.round(Math.min((width * 6) / 32, height * 0.28));
|
||||
const open = Math.round(Math.min((width * 9) / 32, height * 0.62));
|
||||
const dpr = Math.min(window.devicePixelRatio || 1, this.settings.maxDpr);
|
||||
const key = width + "x" + closed + "x" + open + "@" + dpr;
|
||||
if (key === this.sizeKey) {
|
||||
return;
|
||||
}
|
||||
this.sizeKey = key;
|
||||
this.root.style.setProperty("--strip-closed", closed + "px");
|
||||
this.root.style.setProperty("--strip-open", open + "px");
|
||||
for (const strip of this.strips) {
|
||||
strip.layout({ width, closed, open, dpr });
|
||||
}
|
||||
}
|
||||
|
||||
private observe(): void {
|
||||
const byElement = new Map(this.strips.map((strip) => [strip.element as Element, strip]));
|
||||
const near = new IntersectionObserver(
|
||||
(entries) => {
|
||||
for (const entry of entries) {
|
||||
byElement.get(entry.target)?.setNear(entry.isIntersecting);
|
||||
}
|
||||
},
|
||||
{ rootMargin: "100% 0px" },
|
||||
);
|
||||
const visible = new IntersectionObserver(
|
||||
(entries) => {
|
||||
for (const entry of entries) {
|
||||
const strip = byElement.get(entry.target);
|
||||
if (!strip) {
|
||||
continue;
|
||||
}
|
||||
if (entry.isIntersecting) {
|
||||
strip.attach();
|
||||
} else {
|
||||
strip.detach();
|
||||
}
|
||||
}
|
||||
},
|
||||
{ rootMargin: "25% 0px" },
|
||||
);
|
||||
const screen = new IntersectionObserver((entries) => {
|
||||
for (const entry of entries) {
|
||||
const strip = byElement.get(entry.target);
|
||||
if (!strip) {
|
||||
continue;
|
||||
}
|
||||
if (entry.isIntersecting) {
|
||||
this.onScreen.add(strip);
|
||||
} else {
|
||||
this.onScreen.delete(strip);
|
||||
}
|
||||
}
|
||||
this.watchFirst();
|
||||
this.scheduleCentre();
|
||||
});
|
||||
for (const strip of this.strips) {
|
||||
near.observe(strip.element);
|
||||
visible.observe(strip.element);
|
||||
screen.observe(strip.element);
|
||||
}
|
||||
}
|
||||
|
||||
private watchFirst(): void {
|
||||
const first = this.strips.find((strip) => this.onScreen.has(strip)) ?? null;
|
||||
this.indicator.watch(first ? first.loader : null);
|
||||
}
|
||||
|
||||
private onStripStatus(strip: Strip): void {
|
||||
this.indicator.update(strip.loader);
|
||||
}
|
||||
|
||||
private bind(): void {
|
||||
for (const strip of this.strips) {
|
||||
const element = strip.element;
|
||||
element.addEventListener("mouseenter", () => {
|
||||
if (this.hoverMode.matches) {
|
||||
this.open(strip);
|
||||
}
|
||||
});
|
||||
element.addEventListener("mouseleave", () => {
|
||||
if (this.hoverMode.matches && this.opened === strip) {
|
||||
this.open(null);
|
||||
}
|
||||
});
|
||||
element.addEventListener("focus", () => this.open(strip));
|
||||
element.addEventListener("blur", () => {
|
||||
if (this.opened === strip && !this.hoverMode.matches) {
|
||||
this.scheduleCentre();
|
||||
} else if (this.opened === strip) {
|
||||
this.open(null);
|
||||
}
|
||||
});
|
||||
element.addEventListener("dragstart", (e) => e.preventDefault());
|
||||
if (this.settings.blockContextMenu) {
|
||||
element.addEventListener("contextmenu", (e) => e.preventDefault());
|
||||
}
|
||||
}
|
||||
window.addEventListener("scroll", () => this.scheduleCentre(), { passive: true });
|
||||
new ResizeObserver(() => {
|
||||
this.measure();
|
||||
this.scheduleCentre();
|
||||
}).observe(this.root);
|
||||
}
|
||||
|
||||
private open(strip: Strip | null): void {
|
||||
if (strip === this.opened) {
|
||||
return;
|
||||
}
|
||||
this.opened?.setOpen(false);
|
||||
this.opened = strip;
|
||||
strip?.setOpen(true);
|
||||
}
|
||||
|
||||
private scheduleCentre(): void {
|
||||
if (this.hoverMode.matches || this.scrollFrame !== 0) {
|
||||
return;
|
||||
}
|
||||
this.scrollFrame = requestAnimationFrame(() => {
|
||||
this.scrollFrame = 0;
|
||||
this.pickCentre();
|
||||
});
|
||||
}
|
||||
|
||||
private pickCentre(): void {
|
||||
if (this.hoverMode.matches) {
|
||||
return;
|
||||
}
|
||||
const centre = window.innerHeight / 2;
|
||||
let best: Strip | null = null;
|
||||
let bestDistance = Infinity;
|
||||
let currentDistance = Infinity;
|
||||
for (const strip of this.onScreen) {
|
||||
const rect = strip.element.getBoundingClientRect();
|
||||
const distance = Math.abs(rect.top + rect.height / 2 - centre);
|
||||
if (distance < bestDistance) {
|
||||
bestDistance = distance;
|
||||
best = strip;
|
||||
}
|
||||
if (strip === this.opened) {
|
||||
currentDistance = distance;
|
||||
}
|
||||
}
|
||||
if (best && best !== this.opened && bestDistance + hysteresis < currentDistance) {
|
||||
this.open(best);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
import { lucioMorph, palette, type LoaderHandle } from "./brand";
|
||||
import type { PhotoLoader } from "./loader";
|
||||
|
||||
const showAfterMs = 400;
|
||||
|
||||
export class BusyIndicator {
|
||||
private readonly element: HTMLElement;
|
||||
private handle: LoaderHandle | null = null;
|
||||
private loader: PhotoLoader | null = null;
|
||||
private timer = 0;
|
||||
private hideTimer = 0;
|
||||
visible = false;
|
||||
|
||||
constructor(parent: HTMLElement, private readonly canShow: () => boolean = () => true) {
|
||||
this.element = document.createElement("div");
|
||||
this.element.className = "busy";
|
||||
this.element.setAttribute("role", "status");
|
||||
this.element.setAttribute("aria-label", "Loading");
|
||||
parent.appendChild(this.element);
|
||||
}
|
||||
|
||||
watch(loader: PhotoLoader | null): void {
|
||||
if (loader === this.loader) {
|
||||
this.update(loader);
|
||||
return;
|
||||
}
|
||||
this.loader = loader;
|
||||
clearTimeout(this.timer);
|
||||
this.timer = 0;
|
||||
this.hide();
|
||||
this.update(loader);
|
||||
}
|
||||
|
||||
update(loader: PhotoLoader | null): void {
|
||||
if (!loader || loader !== this.loader) {
|
||||
return;
|
||||
}
|
||||
const status = loader.status;
|
||||
if (!status.active || status.sharp) {
|
||||
clearTimeout(this.timer);
|
||||
this.timer = 0;
|
||||
this.hide();
|
||||
return;
|
||||
}
|
||||
if (!this.visible && this.timer === 0) {
|
||||
const wait = Math.max(0, showAfterMs - (performance.now() - status.started));
|
||||
this.timer = window.setTimeout(() => this.check(), wait);
|
||||
}
|
||||
}
|
||||
|
||||
private check(): void {
|
||||
this.timer = 0;
|
||||
const loader = this.loader;
|
||||
if (!loader || !loader.status.active || loader.status.sharp) {
|
||||
return;
|
||||
}
|
||||
if (!this.canShow()) {
|
||||
this.timer = window.setTimeout(() => this.check(), 100);
|
||||
return;
|
||||
}
|
||||
this.show();
|
||||
}
|
||||
|
||||
private show(): void {
|
||||
if (this.visible) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(this.hideTimer);
|
||||
this.visible = true;
|
||||
if (!this.handle) {
|
||||
const api = lucioMorph();
|
||||
if (api) {
|
||||
this.handle = api.loader(this.element, { size: 56, color: palette.paper, track: palette.graphite3, rays: palette.beam });
|
||||
this.handle.svg.setAttribute("aria-hidden", "true");
|
||||
}
|
||||
}
|
||||
this.element.classList.add("is-visible");
|
||||
}
|
||||
|
||||
private hide(): void {
|
||||
if (!this.visible) {
|
||||
return;
|
||||
}
|
||||
this.visible = false;
|
||||
this.element.classList.remove("is-visible");
|
||||
clearTimeout(this.hideTimer);
|
||||
this.hideTimer = window.setTimeout(() => {
|
||||
if (!this.visible && this.handle) {
|
||||
this.handle.stop();
|
||||
this.handle.svg.remove();
|
||||
this.handle = null;
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
export class ProgressLine {
|
||||
private readonly element: HTMLElement;
|
||||
private loader: PhotoLoader | null = null;
|
||||
private shown = false;
|
||||
private value = -1;
|
||||
|
||||
constructor(parent: HTMLElement) {
|
||||
this.element = document.createElement("div");
|
||||
this.element.className = "progress";
|
||||
this.element.setAttribute("aria-hidden", "true");
|
||||
parent.appendChild(this.element);
|
||||
}
|
||||
|
||||
watch(loader: PhotoLoader | null): void {
|
||||
this.loader = loader;
|
||||
this.value = -1;
|
||||
this.update(loader);
|
||||
}
|
||||
|
||||
update(loader: PhotoLoader | null): void {
|
||||
if (!loader || loader !== this.loader) {
|
||||
return;
|
||||
}
|
||||
const status = loader.status;
|
||||
const active = status.active && !status.sharp && status.planned > 0;
|
||||
const fraction = status.planned > 0 ? Math.min(1, status.done / status.planned) : 0;
|
||||
if (active !== this.shown) {
|
||||
this.shown = active;
|
||||
this.element.classList.toggle("is-visible", active);
|
||||
}
|
||||
const rounded = Math.round(fraction * 1000) / 1000;
|
||||
if (rounded !== this.value) {
|
||||
this.value = rounded;
|
||||
this.element.style.transform = "scaleX(" + (active ? rounded : 1) + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
+56
-4
@@ -10,6 +10,15 @@ export interface LoaderEnv {
|
||||
settings: Settings;
|
||||
tiles: Tiles;
|
||||
requestDraw: () => void;
|
||||
onStatus?: (loader: PhotoLoader) => void;
|
||||
}
|
||||
|
||||
export interface LoadStatus {
|
||||
active: boolean;
|
||||
started: number;
|
||||
planned: number;
|
||||
done: number;
|
||||
sharp: boolean;
|
||||
}
|
||||
|
||||
const fadeMs = 180;
|
||||
@@ -35,6 +44,8 @@ export class PhotoLoader {
|
||||
private session: AbortController | null = null;
|
||||
private prefetchController: AbortController | null = null;
|
||||
finalLevel = -1;
|
||||
private targetLevel = -1;
|
||||
readonly status: LoadStatus = { active: false, started: 0, planned: 0, done: 0, sharp: false };
|
||||
|
||||
constructor(readonly pyramid: Pyramid, private readonly env: LoaderEnv) {}
|
||||
|
||||
@@ -113,13 +124,41 @@ export class PhotoLoader {
|
||||
return Math.max(0, neededLevel(this.pyramid, view.displayWidth, dpr) - probeStep);
|
||||
}
|
||||
|
||||
private notify(): void {
|
||||
this.env.onStatus?.(this);
|
||||
}
|
||||
|
||||
private track(tiles: TileRef[], controller: AbortController, signal: AbortSignal): Promise<PromiseSettledResult<TileResult>[]> {
|
||||
this.status.planned += tiles.length;
|
||||
this.notify();
|
||||
return Promise.allSettled(
|
||||
tiles.map((tile) =>
|
||||
this.fetchTile(tile, PRIORITY_CURRENT, signal).finally(() => {
|
||||
if (this.session === controller) {
|
||||
this.status.done++;
|
||||
this.notify();
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
start(view: View, dpr: number, onSettled: () => void): void {
|
||||
this.stopSession();
|
||||
const controller = new AbortController();
|
||||
this.session = controller;
|
||||
this.targetLevel = -1;
|
||||
this.status.active = true;
|
||||
this.status.started = performance.now();
|
||||
this.status.planned = 0;
|
||||
this.status.done = 0;
|
||||
this.status.sharp = false;
|
||||
this.notify();
|
||||
void this.run(view, dpr, controller).then(() => {
|
||||
if (this.session === controller) {
|
||||
this.session = null;
|
||||
this.status.active = false;
|
||||
this.notify();
|
||||
}
|
||||
if (!controller.signal.aborted || controller.signal.reason === "deadline") {
|
||||
onSettled();
|
||||
@@ -141,7 +180,7 @@ export class PhotoLoader {
|
||||
const probe = Math.max(0, needed - probeStep);
|
||||
const probeTiles = this.uncached(probe, view).slice(0, 2);
|
||||
if (probeTiles.length > 0) {
|
||||
const results = await this.fetchAll(probeTiles, PRIORITY_CURRENT, signal);
|
||||
const results = await this.track(probeTiles, controller, signal);
|
||||
let bytes = 0;
|
||||
let ms = 0;
|
||||
for (const result of results) {
|
||||
@@ -175,8 +214,10 @@ export class PhotoLoader {
|
||||
plan.push(final);
|
||||
}
|
||||
this.finalLevel = final;
|
||||
this.targetLevel = final;
|
||||
this.env.requestDraw();
|
||||
for (const level of plan) {
|
||||
await this.fetchAll(this.uncached(level, view), PRIORITY_CURRENT, signal);
|
||||
await this.track(this.uncached(level, view), controller, signal);
|
||||
if (signal.aborted) {
|
||||
return;
|
||||
}
|
||||
@@ -215,8 +256,12 @@ export class PhotoLoader {
|
||||
}
|
||||
|
||||
stopSession(): void {
|
||||
this.session?.abort("superseded");
|
||||
this.session = null;
|
||||
if (this.session) {
|
||||
this.session.abort("superseded");
|
||||
this.session = null;
|
||||
this.status.active = false;
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
|
||||
stop(): void {
|
||||
@@ -281,6 +326,13 @@ export class PhotoLoader {
|
||||
g.restore();
|
||||
}
|
||||
|
||||
const sharpLevel = this.targetLevel >= 0 ? Math.min(this.targetLevel, needed) : needed;
|
||||
const sharp = base >= sharpLevel;
|
||||
if (sharp !== this.status.sharp) {
|
||||
this.status.sharp = sharp;
|
||||
queueMicrotask(() => this.notify());
|
||||
}
|
||||
|
||||
let animating = false;
|
||||
for (let l = Math.max(0, base); l <= needed; l++) {
|
||||
const level = levels[l];
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
import type { View } from "./geometry";
|
||||
import { PhotoLoader, type LoaderEnv } from "./loader";
|
||||
import type { Pyramid } from "./types";
|
||||
|
||||
export type StripEnv = Omit<LoaderEnv, "requestDraw" | "onStatus">;
|
||||
|
||||
export interface StripSize {
|
||||
width: number;
|
||||
closed: number;
|
||||
open: number;
|
||||
dpr: number;
|
||||
}
|
||||
|
||||
interface Geometry {
|
||||
width: number;
|
||||
closed: number;
|
||||
open: number;
|
||||
dpr: number;
|
||||
coverWidth: number;
|
||||
coverHeight: number;
|
||||
x: number;
|
||||
y: number;
|
||||
band: number;
|
||||
}
|
||||
|
||||
const settleMs = 260;
|
||||
|
||||
export class Strip {
|
||||
readonly loader: PhotoLoader;
|
||||
private canvas: HTMLCanvasElement | null = null;
|
||||
private g: CanvasRenderingContext2D | null = null;
|
||||
private geometry: Geometry | null = null;
|
||||
private expanded = false;
|
||||
private canvasOpen = false;
|
||||
private near = false;
|
||||
private settleTimer = 0;
|
||||
private frame = 0;
|
||||
|
||||
constructor(
|
||||
readonly element: HTMLElement,
|
||||
readonly cover: Pyramid,
|
||||
private readonly focusY: number,
|
||||
env: StripEnv,
|
||||
private readonly onStatus: (strip: Strip) => void,
|
||||
) {
|
||||
this.loader = new PhotoLoader(cover, {
|
||||
...env,
|
||||
requestDraw: () => this.requestDraw(),
|
||||
onStatus: () => this.onStatus(this),
|
||||
});
|
||||
}
|
||||
|
||||
get isOpen(): boolean {
|
||||
return this.expanded;
|
||||
}
|
||||
|
||||
layout(size: StripSize): void {
|
||||
const cover = this.cover;
|
||||
const scale = Math.max(size.width / cover.width, size.open / cover.height);
|
||||
const coverWidth = cover.width * scale;
|
||||
const coverHeight = cover.height * scale;
|
||||
const y = (size.open - coverHeight) / 2;
|
||||
const centre = y + this.focusY * coverHeight;
|
||||
const band = Math.max(0, Math.min(size.open - size.closed, centre - size.closed / 2));
|
||||
const previous = this.geometry;
|
||||
this.geometry = {
|
||||
width: size.width,
|
||||
closed: size.closed,
|
||||
open: size.open,
|
||||
dpr: size.dpr,
|
||||
coverWidth,
|
||||
coverHeight,
|
||||
x: (size.width - coverWidth) / 2,
|
||||
y,
|
||||
band,
|
||||
};
|
||||
if (this.canvas) {
|
||||
this.sizeCanvas(this.canvasOpen);
|
||||
this.drawNow();
|
||||
}
|
||||
if (
|
||||
this.near &&
|
||||
previous &&
|
||||
(previous.width !== size.width || previous.closed !== size.closed || previous.open !== size.open || previous.dpr !== size.dpr)
|
||||
) {
|
||||
this.startSession();
|
||||
}
|
||||
}
|
||||
|
||||
attach(): void {
|
||||
if (this.canvas) {
|
||||
return;
|
||||
}
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.className = "strip-canvas";
|
||||
canvas.setAttribute("aria-hidden", "true");
|
||||
const g = canvas.getContext("2d", { alpha: false });
|
||||
if (!g) {
|
||||
return;
|
||||
}
|
||||
this.canvas = canvas;
|
||||
this.g = g;
|
||||
this.element.prepend(canvas);
|
||||
this.sizeCanvas(this.expanded);
|
||||
this.drawNow();
|
||||
}
|
||||
|
||||
detach(): void {
|
||||
if (!this.canvas) {
|
||||
return;
|
||||
}
|
||||
cancelAnimationFrame(this.frame);
|
||||
this.frame = 0;
|
||||
this.canvas.width = 0;
|
||||
this.canvas.height = 0;
|
||||
this.canvas.remove();
|
||||
this.canvas = null;
|
||||
this.g = null;
|
||||
}
|
||||
|
||||
setNear(near: boolean): void {
|
||||
if (near === this.near) {
|
||||
return;
|
||||
}
|
||||
this.near = near;
|
||||
if (near) {
|
||||
this.startSession();
|
||||
} else {
|
||||
this.loader.stop();
|
||||
}
|
||||
}
|
||||
|
||||
setOpen(open: boolean): void {
|
||||
if (open === this.expanded) {
|
||||
return;
|
||||
}
|
||||
this.expanded = open;
|
||||
this.element.classList.toggle("is-open", open);
|
||||
clearTimeout(this.settleTimer);
|
||||
const geometry = this.geometry;
|
||||
const canvas = this.canvas;
|
||||
if (open) {
|
||||
if (canvas && this.canvasOpen) {
|
||||
canvas.style.transition = "";
|
||||
canvas.style.transform = "translate3d(0,0,0)";
|
||||
} else if (canvas && geometry) {
|
||||
this.sizeCanvas(true);
|
||||
canvas.style.transition = "none";
|
||||
canvas.style.transform = "translate3d(0," + -geometry.band + "px,0)";
|
||||
this.drawNow();
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(() => {
|
||||
if (this.expanded && this.canvas === canvas) {
|
||||
canvas.style.transition = "";
|
||||
canvas.style.transform = "translate3d(0,0,0)";
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} else if (canvas && geometry) {
|
||||
canvas.style.transition = "";
|
||||
canvas.style.transform = "translate3d(0," + -geometry.band + "px,0)";
|
||||
this.settleTimer = window.setTimeout(() => {
|
||||
if (!this.expanded && this.canvas === canvas) {
|
||||
this.sizeCanvas(false);
|
||||
this.drawNow();
|
||||
}
|
||||
}, settleMs);
|
||||
}
|
||||
if (this.near) {
|
||||
this.startSession();
|
||||
}
|
||||
}
|
||||
|
||||
private sizeCanvas(open: boolean): void {
|
||||
const canvas = this.canvas;
|
||||
const geometry = this.geometry;
|
||||
if (!canvas || !geometry) {
|
||||
return;
|
||||
}
|
||||
this.canvasOpen = open;
|
||||
const height = open ? geometry.open : geometry.closed;
|
||||
const width = Math.max(1, Math.round(geometry.width * geometry.dpr));
|
||||
const deviceHeight = Math.max(1, Math.round(height * geometry.dpr));
|
||||
if (canvas.width !== width || canvas.height !== deviceHeight) {
|
||||
canvas.width = width;
|
||||
canvas.height = deviceHeight;
|
||||
}
|
||||
canvas.style.height = height + "px";
|
||||
if (!open) {
|
||||
canvas.style.transition = "none";
|
||||
canvas.style.transform = "translate3d(0,0,0)";
|
||||
}
|
||||
}
|
||||
|
||||
view(): View | null {
|
||||
const geometry = this.geometry;
|
||||
if (!geometry) {
|
||||
return null;
|
||||
}
|
||||
const top = this.expanded ? 0 : geometry.band;
|
||||
const height = this.expanded ? geometry.open : geometry.closed;
|
||||
return {
|
||||
displayWidth: geometry.coverWidth,
|
||||
u0: Math.max(0, -geometry.x / geometry.coverWidth),
|
||||
u1: Math.min(1, (geometry.width - geometry.x) / geometry.coverWidth),
|
||||
v0: Math.max(0, (top - geometry.y) / geometry.coverHeight),
|
||||
v1: Math.min(1, (top + height - geometry.y) / geometry.coverHeight),
|
||||
};
|
||||
}
|
||||
|
||||
startSession(): void {
|
||||
const view = this.view();
|
||||
if (!view || !this.geometry) {
|
||||
return;
|
||||
}
|
||||
this.loader.start(view, this.geometry.dpr, () => undefined);
|
||||
}
|
||||
|
||||
requestDraw(): void {
|
||||
if (this.frame === 0 && this.canvas) {
|
||||
this.frame = requestAnimationFrame((now) => {
|
||||
this.frame = 0;
|
||||
if (this.draw(now)) {
|
||||
this.requestDraw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private drawNow(): void {
|
||||
if (this.draw(performance.now())) {
|
||||
this.requestDraw();
|
||||
}
|
||||
}
|
||||
|
||||
private draw(now: number): boolean {
|
||||
const g = this.g;
|
||||
const canvas = this.canvas;
|
||||
const geometry = this.geometry;
|
||||
if (!g || !canvas || !geometry) {
|
||||
return false;
|
||||
}
|
||||
g.setTransform(1, 0, 0, 1, 0, 0);
|
||||
g.globalAlpha = 1;
|
||||
g.fillStyle = "#111114";
|
||||
g.fillRect(0, 0, canvas.width, canvas.height);
|
||||
const shift = this.canvasOpen ? 0 : -geometry.band;
|
||||
return this.loader.draw({
|
||||
g,
|
||||
originX: geometry.x * geometry.dpr,
|
||||
originY: (geometry.y + shift) * geometry.dpr,
|
||||
width: geometry.coverWidth * geometry.dpr,
|
||||
height: geometry.coverHeight * geometry.dpr,
|
||||
canvasWidth: canvas.width,
|
||||
canvasHeight: canvas.height,
|
||||
displayWidth: geometry.coverWidth,
|
||||
dpr: geometry.dpr,
|
||||
now,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ export interface Manifest {
|
||||
show_exif: boolean;
|
||||
tiles: Tiles;
|
||||
cover: Pyramid;
|
||||
og?: string;
|
||||
photos: Photo[];
|
||||
}
|
||||
|
||||
@@ -64,6 +65,7 @@ export interface IndexAlbum {
|
||||
photos: number;
|
||||
manifest: string;
|
||||
cover: Pyramid;
|
||||
og?: string;
|
||||
}
|
||||
|
||||
export interface SiteIndex {
|
||||
|
||||
+131
-35
@@ -1,6 +1,9 @@
|
||||
import { cloneChop, mountWordmark } from "./brand";
|
||||
import { CaptionPanel } from "./caption";
|
||||
import type { View } from "./geometry";
|
||||
import { BusyIndicator, ProgressLine } from "./indicator";
|
||||
import { PhotoLoader, type LoaderEnv } from "./loader";
|
||||
import { Strip } from "./strip";
|
||||
import type { Manifest, Settings, SiteIndex } from "./types";
|
||||
|
||||
interface PhotoLayout {
|
||||
@@ -38,6 +41,7 @@ const tapMs = 300;
|
||||
const flickSpeed = 0.35;
|
||||
const rubberBand = 0.35;
|
||||
const captionZone = 0.2;
|
||||
const idleMs = 2500;
|
||||
|
||||
function cubicBezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number {
|
||||
const cx = 3 * x1;
|
||||
@@ -96,6 +100,12 @@ export class Viewer {
|
||||
private readonly caption: CaptionPanel;
|
||||
private readonly endCard: HTMLElement;
|
||||
private readonly nextLink: HTMLAnchorElement;
|
||||
private readonly nextFrame: HTMLElement;
|
||||
private readonly indicator: BusyIndicator;
|
||||
private readonly progress: ProgressLine;
|
||||
private readonly homeMark: HTMLElement | null;
|
||||
private nextStrip: Strip | null = null;
|
||||
private idleTimer = 0;
|
||||
private readonly reducedMotion: MediaQueryList;
|
||||
private readonly loaders: Array<PhotoLoader | undefined>;
|
||||
private layouts: PhotoLayout[] = [];
|
||||
@@ -125,7 +135,7 @@ export class Viewer {
|
||||
private readonly stage: HTMLElement,
|
||||
private readonly manifest: Manifest,
|
||||
private readonly settings: Settings,
|
||||
private readonly env: Omit<LoaderEnv, "requestDraw">,
|
||||
private readonly env: Omit<LoaderEnv, "requestDraw" | "onStatus">,
|
||||
) {
|
||||
this.canvas = document.createElement("canvas");
|
||||
this.canvas.className = "stage-canvas";
|
||||
@@ -142,9 +152,16 @@ export class Viewer {
|
||||
this.g = g;
|
||||
this.endCard = this.buildEndCard();
|
||||
this.nextLink = this.endCard.querySelector("a.next-album") as HTMLAnchorElement;
|
||||
this.nextFrame = this.endCard.querySelector(".next-strip") as HTMLElement;
|
||||
stage.prepend(this.canvas, this.fade);
|
||||
stage.appendChild(this.endCard);
|
||||
this.caption = new CaptionPanel(stage);
|
||||
this.progress = new ProgressLine(document.body);
|
||||
this.indicator = new BusyIndicator(document.body);
|
||||
this.homeMark = document.querySelector<HTMLElement>(".home-mark");
|
||||
if (this.homeMark) {
|
||||
mountWordmark(this.homeMark, false);
|
||||
}
|
||||
this.loaders = new Array(manifest.photos.length);
|
||||
this.reducedMotion = matchMedia("(prefers-reduced-motion: reduce)");
|
||||
this.measure();
|
||||
@@ -153,36 +170,54 @@ export class Viewer {
|
||||
this.bind();
|
||||
this.activate(-1);
|
||||
this.requestDraw();
|
||||
this.wake();
|
||||
this.loadNextAlbum();
|
||||
}
|
||||
|
||||
private buildEndCard(): HTMLElement {
|
||||
const card = document.createElement("section");
|
||||
card.className = "end-card";
|
||||
card.setAttribute("aria-label", "End of album");
|
||||
const chop = document.createElement("div");
|
||||
chop.className = "chop";
|
||||
chop.setAttribute("aria-hidden", "true");
|
||||
chop.textContent = "陈";
|
||||
const signature = document.createElement("p");
|
||||
signature.className = "signature";
|
||||
signature.textContent = "— Lucio";
|
||||
const next = document.createElement("a");
|
||||
next.className = "next-album";
|
||||
next.href = "/";
|
||||
const frame = document.createElement("span");
|
||||
frame.className = "next-strip";
|
||||
const text = document.createElement("span");
|
||||
text.className = "next-text";
|
||||
const eyebrow = document.createElement("span");
|
||||
eyebrow.className = "next-eyebrow";
|
||||
eyebrow.textContent = "All albums";
|
||||
const title = document.createElement("span");
|
||||
title.className = "next-title";
|
||||
next.append(eyebrow, title);
|
||||
card.append(chop, signature, next);
|
||||
text.append(eyebrow, title);
|
||||
frame.appendChild(text);
|
||||
next.appendChild(frame);
|
||||
const signoff = document.createElement("div");
|
||||
signoff.className = "signoff";
|
||||
const chop = cloneChop();
|
||||
if (chop) {
|
||||
signoff.appendChild(chop);
|
||||
}
|
||||
const signature = document.createElement("p");
|
||||
signature.className = "signature";
|
||||
signature.textContent = "— Lucio";
|
||||
signoff.appendChild(signature);
|
||||
card.append(next, signoff);
|
||||
return card;
|
||||
}
|
||||
|
||||
private loader(index: number): PhotoLoader {
|
||||
let loader = this.loaders[index];
|
||||
if (!loader) {
|
||||
loader = new PhotoLoader(this.manifest.photos[index], { ...this.env, requestDraw: () => this.requestDraw() });
|
||||
loader = new PhotoLoader(this.manifest.photos[index], {
|
||||
...this.env,
|
||||
requestDraw: () => this.requestDraw(),
|
||||
onStatus: (changed) => {
|
||||
this.indicator.update(changed);
|
||||
this.progress.update(changed);
|
||||
},
|
||||
});
|
||||
this.loaders[index] = loader;
|
||||
}
|
||||
return loader;
|
||||
@@ -218,6 +253,43 @@ export class Viewer {
|
||||
this.endLeft = start + gutter / 2;
|
||||
this.stops.push({ photo: -1, slide: 0, camera: this.endLeft + this.vw / 2 });
|
||||
this.endCard.style.width = this.vw + "px";
|
||||
this.layoutNextStrip();
|
||||
}
|
||||
|
||||
private layoutNextStrip(): void {
|
||||
if (!this.nextStrip) {
|
||||
return;
|
||||
}
|
||||
const width = Math.max(1, Math.min(this.vw - 64, 1200));
|
||||
const closed = Math.round(Math.min((width * 6) / 32, this.vh * 0.28));
|
||||
this.nextFrame.style.width = width + "px";
|
||||
this.nextFrame.style.height = closed + "px";
|
||||
this.nextStrip.layout({ width, closed, open: Math.round((closed * 9) / 6), dpr: this.dpr });
|
||||
}
|
||||
|
||||
private syncNextStrip(): void {
|
||||
const strip = this.nextStrip;
|
||||
if (!strip) {
|
||||
return;
|
||||
}
|
||||
const stop = this.stops[this.current];
|
||||
const near = stop.photo < 0 || stop.photo === this.manifest.photos.length - 1;
|
||||
if (near) {
|
||||
strip.attach();
|
||||
} else {
|
||||
strip.detach();
|
||||
}
|
||||
strip.setNear(near);
|
||||
}
|
||||
|
||||
private wake(): void {
|
||||
document.body.classList.remove("is-idle");
|
||||
clearTimeout(this.idleTimer);
|
||||
this.idleTimer = window.setTimeout(() => {
|
||||
if (this.pointerId === null) {
|
||||
document.body.classList.add("is-idle");
|
||||
}
|
||||
}, idleMs);
|
||||
}
|
||||
|
||||
private stopForHash(): number {
|
||||
@@ -280,6 +352,7 @@ export class Viewer {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey) {
|
||||
return;
|
||||
}
|
||||
this.wake();
|
||||
const target = e.target as HTMLElement | null;
|
||||
if (target && (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName))) {
|
||||
return;
|
||||
@@ -331,6 +404,9 @@ export class Viewer {
|
||||
}
|
||||
|
||||
private onPointerMove(e: PointerEvent): void {
|
||||
if (e.pointerType === "mouse") {
|
||||
this.wake();
|
||||
}
|
||||
if (this.pointerId === null) {
|
||||
if (e.pointerType === "mouse") {
|
||||
this.hover = this.inCaptionZone(e.clientX, e.clientY);
|
||||
@@ -514,6 +590,10 @@ export class Viewer {
|
||||
loader.stopPrefetch();
|
||||
}
|
||||
});
|
||||
if (stop.photo < 0) {
|
||||
this.indicator.watch(null);
|
||||
this.progress.watch(null);
|
||||
}
|
||||
if (stop.photo >= 0) {
|
||||
const photo = this.manifest.photos[stop.photo];
|
||||
this.caption.set(photo, stop.photo, this.manifest.photos.length, this.manifest.show_exif);
|
||||
@@ -522,9 +602,7 @@ export class Viewer {
|
||||
}
|
||||
this.startSession();
|
||||
}
|
||||
if (stop.photo < 0 || stop.photo === this.manifest.photos.length - 1) {
|
||||
this.loadNextAlbum();
|
||||
}
|
||||
this.syncNextStrip();
|
||||
this.updateCaption();
|
||||
}
|
||||
|
||||
@@ -534,11 +612,14 @@ export class Viewer {
|
||||
return;
|
||||
}
|
||||
const index = this.current;
|
||||
this.loader(stop.photo).start(this.viewAt(stop), this.dpr, () => {
|
||||
const loader = this.loader(stop.photo);
|
||||
loader.start(this.viewAt(stop), this.dpr, () => {
|
||||
if (this.current === index) {
|
||||
this.prefetchAround(index);
|
||||
}
|
||||
});
|
||||
this.indicator.watch(loader);
|
||||
this.progress.watch(loader);
|
||||
}
|
||||
|
||||
private prefetchAround(index: number): void {
|
||||
@@ -608,6 +689,7 @@ export class Viewer {
|
||||
this.caption.place(rect.left, rect.right - rect.left, this.vh - rect.bottom);
|
||||
}
|
||||
this.caption.show(visible);
|
||||
document.body.classList.toggle("has-caption", visible);
|
||||
}
|
||||
|
||||
private loadNextAlbum(): void {
|
||||
@@ -617,31 +699,45 @@ export class Viewer {
|
||||
this.indexRequested = true;
|
||||
fetch(this.settings.indexUrl, { credentials: "same-origin" })
|
||||
.then((response) => (response.ok ? (response.json() as Promise<SiteIndex>) : Promise.reject(new Error("index"))))
|
||||
.then((index) => {
|
||||
const albums = index.albums;
|
||||
if (albums.length === 0) {
|
||||
return;
|
||||
}
|
||||
const at = albums.findIndex((album) => album.slug === this.manifest.slug);
|
||||
const next = albums[(at + 1) % albums.length];
|
||||
if (!next || next.slug === this.manifest.slug) {
|
||||
return;
|
||||
}
|
||||
this.nextLink.href = "/a/" + encodeURIComponent(next.slug) + "/";
|
||||
const eyebrow = this.nextLink.querySelector(".next-eyebrow");
|
||||
const title = this.nextLink.querySelector(".next-title");
|
||||
if (eyebrow) {
|
||||
eyebrow.textContent = "Next album" + (next.date ? " · " + next.date : "");
|
||||
}
|
||||
if (title) {
|
||||
title.textContent = next.title;
|
||||
}
|
||||
})
|
||||
.then((index) => this.showNextAlbum(index))
|
||||
.catch(() => {
|
||||
this.indexRequested = false;
|
||||
});
|
||||
}
|
||||
|
||||
private showNextAlbum(index: SiteIndex): void {
|
||||
const albums = index.albums;
|
||||
if (albums.length === 0) {
|
||||
return;
|
||||
}
|
||||
const at = albums.findIndex((album) => album.slug === this.manifest.slug);
|
||||
const next = albums[(at + 1) % albums.length];
|
||||
if (!next || next.slug === this.manifest.slug) {
|
||||
return;
|
||||
}
|
||||
this.nextLink.href = "/a/" + encodeURIComponent(next.slug) + "/";
|
||||
const eyebrow = this.nextLink.querySelector(".next-eyebrow");
|
||||
const title = this.nextLink.querySelector(".next-title");
|
||||
if (eyebrow) {
|
||||
eyebrow.textContent = "Next album" + (next.date ? " · " + next.date : "");
|
||||
}
|
||||
if (title) {
|
||||
title.textContent = next.title;
|
||||
}
|
||||
if (next.cover) {
|
||||
this.nextStrip = new Strip(
|
||||
this.nextFrame,
|
||||
next.cover,
|
||||
next.collapsed_focus_y ?? 0.5,
|
||||
{ ...this.env, tiles: index.tiles },
|
||||
() => undefined,
|
||||
);
|
||||
this.nextLink.classList.add("has-strip");
|
||||
this.layoutNextStrip();
|
||||
this.syncNextStrip();
|
||||
}
|
||||
}
|
||||
|
||||
private requestDraw(): void {
|
||||
if (this.frame === 0) {
|
||||
this.frame = requestAnimationFrame((now) => {
|
||||
|
||||
Reference in new issue
Block a user