Last active
June 18, 2026 05:02
-
-
Save maxsei/7f2c5dce59f23df5a561ee975ba33e8a to your computer and use it in GitHub Desktop.
CSS page transitions API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- templates/index.html --> | |
| {{ template "layout" . }} | |
| {{ define "title" }}Home{{ end }} | |
| {{ define "content" }} | |
| <h1>Home</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- templates/layout.html --> | |
| {{ define "layout" }} | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>{{ block "title" . }}{{ end }}</title> | |
| <link rel="stylesheet" href="/static/style.css" /> | |
| </head> | |
| <body> | |
| <nav> | |
| <a href="/one">One</a> | |
| <a href="/two">Two</a> | |
| <a href="/three">Three</a> | |
| </nav> | |
| <main> | |
| {{ block "content" . }}{{ end }} | |
| </main> | |
| </body> | |
| </html> | |
| {{ end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "html/template" | |
| "log" | |
| "net/http" | |
| "time" | |
| ) | |
| func main() { | |
| http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) | |
| http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
| render(w, "index.html") | |
| }) | |
| http.HandleFunc("/one", func(w http.ResponseWriter, r *http.Request) { | |
| render(w, "one.html") | |
| }) | |
| http.HandleFunc("/two", func(w http.ResponseWriter, r *http.Request) { | |
| render(w, "two.html") | |
| }) | |
| http.HandleFunc("/three", func(w http.ResponseWriter, r *http.Request) { | |
| render(w, "three.html") | |
| }) | |
| log.Println("listening on http://localhost:8080") | |
| log.Fatal(http.ListenAndServe(":8080", nil)) | |
| } | |
| func render(w http.ResponseWriter, page string) { | |
| time.Sleep(500 * time.Millisecond) | |
| tmpl := template.Must(template.ParseFiles("templates/layout.html", "templates/"+page)) | |
| tmpl.ExecuteTemplate(w, "layout", nil) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- templates/one.html --> | |
| {{ template "layout" . }} | |
| {{ define "title" }}Page One{{ end }} | |
| {{ define "content" }} | |
| <h1>Page One</h1> | |
| <p>Hello from page one!</p> | |
| {{ end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* static/style.css */ | |
| @view-transition { | |
| navigation: auto; | |
| } | |
| ::view-transition-old(main), | |
| ::view-transition-new(main) { | |
| animation-duration: 300ms; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- templates/three.html --> | |
| {{ template "layout" . }} | |
| {{ define "title" }}Page Three{{ end }} | |
| {{ define "content" }} | |
| <h1>Page Three</h1> | |
| <p>Hello from page three!</p> | |
| {{ end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- templates/two.html --> | |
| {{ template "layout" . }} | |
| {{ define "title" }}Page Two{{ end }} | |
| {{ define "content" }} | |
| <h1>Page Two</h1> | |
| <p>Hello from page two!</p> | |
| {{ end }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment