view transitions with almost no css
Some checks failed
test / cargo test (push) Failing after 1m10s

This commit is contained in:
Michal Vanko 2024-10-09 11:18:47 +02:00
parent d9d17bb971
commit 086ec33d7b
8 changed files with 50 additions and 10 deletions

View File

@ -266,3 +266,18 @@ article a {
transform: translate(0, 0); transform: translate(0, 0);
} }
} }
@view-transition {
navigation: auto;
}
/* Define the animation for persistent elements (like the header and title) */
/* ::view-transition-group(*) { */
/* transition: transform 3.4s ease-in-out; */
/* } */
/* ::view-transition-group(blog_post_preview) { */
/* animation-duration: 5.5s; */
/* transition: transform 5.4s ease-in-out; */
/* opacity: 1; */
/* } */

View File

@ -1908,6 +1908,28 @@ article a:visited {
} }
} }
@view-transition {
navigation: auto;
}
/* Define the animation for persistent elements (like the header and title) */
/* ::view-transition-group(*) { */
/* transition: transform 3.4s ease-in-out; */
/* } */
/* ::view-transition-group(blog_post_preview) { */
/* animation-duration: 5.5s; */
/* transition: transform 5.4s ease-in-out; */
/* opacity: 1; */
/* } */
.visited\:text-blue-950:visited { .visited\:text-blue-950:visited {
color: rgb(11 39 70 ); color: rgb(11 39 70 );
} }

View File

@ -17,12 +17,12 @@
{% block content %} {% block content %}
<article class="mb-6"> <article class="mb-6">
<header class="px-4 max-w-read mx-auto"> <header class="px-4 max-w-read mx-auto">
<h1 class="text-3xl md:text-4xl lg:text-6xl lg:mt-20 text-blue-900 mb-3 font-bold">{{title}}</h1> <h1 class="text-3xl md:text-4xl lg:text-6xl lg:mt-20 text-blue-900 mb-3 font-bold" style="view-transition-name: post_title_{{slug}};">{{title}}</h1>
<aside class="flex justify-between flex-row"> <aside class="flex justify-between flex-row">
{% include "post_tag_list.html" %} {% include "post_tag_list.html" %}
<section class="created-at m-1 text-right text-sm text-slate-600 md:text-lg"> <section class="created-at m-1 text-right text-sm text-slate-600 md:text-lg">
<span>Published on</span> <span>Published on</span>
<time datetime="{date}"> {{date|pretty_date}} </time> <time datetime="{date}" style="view-transition-name: post_date_{{slug}}"> {{date|pretty_date}} </time>
</section> </section>
</aside> </aside>
</header> </header>

View File

@ -1,4 +1,7 @@
<article class="sm:grid sm:grid-cols-[max-content_1fr] sm:grid-rows-[max-content_1fr_max-content] sm:grid-flow-col sm:gap-4 md:gap-x-8 break-inside-avoid clear-both sm:clear-none"> <article
class="sm:grid sm:grid-cols-[max-content_1fr] sm:grid-rows-[max-content_1fr_max-content] sm:grid-flow-col sm:gap-4 md:gap-x-8 break-inside-avoid clear-both sm:clear-none"
style="view-transition-name:blog_post_preview_{{post.slug}};"
>
<aside class="row-span-3 self-center float-start sm:float-none mr-3 mb-3 sm:ml-0 sm:mb-0"> <aside class="row-span-3 self-center float-start sm:float-none mr-3 mb-3 sm:ml-0 sm:mb-0">
{% match post.metadata.thumbnail %} {% match post.metadata.thumbnail %}
{% when Some with (orig_path) %} {% when Some with (orig_path) %}
@ -10,13 +13,13 @@
{% endmatch %} {% endmatch %}
</aside> </aside>
<header> <header>
<h3 class="text-lg font-bold mb-1 md:text-3xl"> <h3 class="text-lg font-bold mb-1 md:text-3xl" style="view-transition-name: post_title_{{post.slug}}">
<a rel="prefetch" href="/{{segment}}/{{post.slug}}" class="text-blue-950 visited:text-purple-700 no-underline">{{post.metadata.title}}</a> <a rel="prefetch" href="/{{segment}}/{{post.slug}}" class="text-blue-950 visited:text-purple-700 no-underline">{{post.metadata.title}}</a>
</h3> </h3>
</header> </header>
<section class="text-base leading-5 text-slate-800 md:text-xl text-justify">{{post.body|truncate_md(2)|parse_markdown|safe}}</section> <section class="text-base leading-5 text-slate-800 md:text-xl text-justify">{{post.body|truncate_md(2)|parse_markdown|safe}}</section>
<footer class="text-sm md:text-base lg:text-lg mt-3 sm:mt-0 clear-both sm:clear-none"> <footer class="text-sm md:text-base lg:text-lg mt-3 sm:mt-0 clear-both sm:clear-none">
<ul class="inline-block"> <ul class="inline-block" style="view-transition-name: post_tags_{{post.slug}}">
{% for tag in post.metadata.tags %} {% for tag in post.metadata.tags %}
<li class="inline-block"> <li class="inline-block">
<a href="/{{segment}}/tags/{{tag}}" class="text-pink-950 no-underline">#{{tag|capitalize}}</a> <a href="/{{segment}}/tags/{{tag}}" class="text-pink-950 no-underline">#{{tag|capitalize}}</a>
@ -24,7 +27,7 @@
{% endfor %} {% endfor %}
</ul> </ul>
| |
<time datetime="{{post.metadata.date}}" class="text-pink-950"> {{post.metadata.date|pretty_date}} </time> <time datetime="{{post.metadata.date}}" class="text-pink-950" style="view-transition-name: post_date_{{post.slug}}" > {{post.metadata.date|pretty_date}} </time>
</footer> </footer>
</article> </article>

View File

@ -1,4 +1,4 @@
<section class="border rounded-md bg-white p-4 break-inside-avoid"> <section class="border rounded-md bg-white p-4 break-inside-avoid" style="view-transition-name: project_preview_{{project.slug}};">
<header class="px-4 mb-3"> <header class="px-4 mb-3">
<h2 class="text-xl font-semibold text-blue-900 md:text-2xl"> <h2 class="text-xl font-semibold text-blue-900 md:text-2xl">
{% match project.metadata.link %} {% match project.metadata.link %}

View File

@ -1,6 +1,6 @@
<section class="article-tags text-base"> <section class="article-tags text-base">
{% if tags.len() > 0 %} {% if tags.len() > 0 %}
<ul class="inline"> <ul class="inline" style="view-transition-name: post_tags_{{slug}}">
{% for tag in tags %} {% for tag in tags %}
<li class="inline italic text-blue-700 md:text-lg"> <li class="inline italic text-blue-700 md:text-lg">
<a href="/{{segment}}/tags/{{tag}}">#{{tag}}</a> <a href="/{{segment}}/tags/{{tag}}">#{{tag}}</a>

View File

@ -1,4 +1,4 @@
<footer class="my-4"> <footer class="my-4" view-transition-name="site_footer">
<hr class="mb-4 border-slate-300 mx-5"> <hr class="mb-4 border-slate-300 mx-5">
<section class="flex justify-around"> <section class="flex justify-around">
<p <p

View File

@ -1,4 +1,4 @@
<header class="min-h-full bg-blue-50 mb-5"> <header class="min-h-full bg-blue-50 mb-5" view-transition-name="site_header">
<nav class="flex"> <nav class="flex">
{% match header_props.back_link %} {% match header_props.back_link %}
{% when Some with (link) %} {% when Some with (link) %}