From ed02e10c3afbdd8330961e474129d3d7a3b6f8cc Mon Sep 17 00:00:00 2001 From: daudix Date: Tue, 17 Sep 2024 04:02:44 +0300 Subject: [PATCH] Redo the table of contents dropdown, with new animation as well --- content/blog/the-quill-of-duck/index.md | 6 ++++ sass/_article.scss | 47 +++++++++++++++++++++---- sass/_input.scss | 2 +- sass/_typography.scss | 2 +- sass/_variables.scss | 14 ++++---- templates/article.html | 22 ++++++++++-- 6 files changed, 76 insertions(+), 17 deletions(-) diff --git a/content/blog/the-quill-of-duck/index.md b/content/blog/the-quill-of-duck/index.md index f3ff778..ce269c5 100644 --- a/content/blog/the-quill-of-duck/index.md +++ b/content/blog/the-quill-of-duck/index.md @@ -34,6 +34,12 @@ disclaimer = """ # host = "alpha.polymaths.social" # user = "orbitalmartian" # id = "01J7ETKJ19FGBDQGS1ZWZ3KEPP" +# +# Post on Sharkey +# +# host = "is-a.wyvern.rip" +# user = "volpeon" +# id = "9qy755nsnu2c0hbc" host = "toot.community" user = "sungsphinx" id = "111789185826519979" diff --git a/sass/_article.scss b/sass/_article.scss index 4e56ec8..cf7c691 100644 --- a/sass/_article.scss +++ b/sass/_article.scss @@ -80,6 +80,18 @@ background-color: transparent; padding: 0; + &[open] summary ~ * { + transform-origin: bottom right; + animation: toc-dropdown-open var(--transition); + + @keyframes toc-dropdown-open { + from { + transform: scale(50%) translate(1rem, 1rem); + opacity: 0; + } + } + } + summary { &::before { display: none; @@ -94,9 +106,11 @@ } } - div { + #toc-dropdown { -webkit-backdrop-filter: var(--blur); + display: flex; position: absolute; + flex-direction: column; backdrop-filter: var(--blur); inset-block-end: 0; inset-inline-end: 3rem; @@ -105,18 +119,39 @@ background-color: var(--nav-bg); padding: 1rem; width: min(calc(var(--container-width) / 3), 90vw); + max-height: 50vh; - h2 { - margin-block-start: 0; + &-title { color: var(--fg-muted-4); - font-weight: bold; font-size: var(--font-size-x-large); - font-family: var(--font-system-ui); + line-height: 1; + } + + &-container { + flex: 1; + mask-image: linear-gradient(to bottom, transparent, black 1rem, black calc(100% - 1rem), transparent); + margin: 0 -1rem -1rem; + padding: 1rem; + padding-block-start: 0; + overflow: auto; } ul { - margin-block-start: 0; + margin: 0; padding-inline-start: 0.75rem; + font-size: var(--font-size-small); + + &:first-child { + margin-block-start: 0.75rem; + } + + li::marker { + color: var(--fg-muted-5); + } + + a { + color: var(--fg-muted-5); + } } } } diff --git a/sass/_input.scss b/sass/_input.scss index c9b7c35..20c66c8 100644 --- a/sass/_input.scss +++ b/sass/_input.scss @@ -29,7 +29,7 @@ input[type="checkbox"] { &::before { display: block; position: absolute; - transform: scale(0.5); + transform: scale(50%); opacity: 0; transition: var(--transition); background-color: var(--contrast-color); diff --git a/sass/_typography.scss b/sass/_typography.scss index 020f791..913b8c4 100644 --- a/sass/_typography.scss +++ b/sass/_typography.scss @@ -259,7 +259,7 @@ details { transform: scaleY(-100%); } - &~* { + & ~ * { animation: details-open var(--transition); @keyframes details-open { diff --git a/sass/_variables.scss b/sass/_variables.scss index 5246761..bf8b49a 100644 --- a/sass/_variables.scss +++ b/sass/_variables.scss @@ -64,8 +64,8 @@ --container-width: 720px; // CORNERS - --rounded-corner-small: 0.5rem; --rounded-corner: 0.75rem; + --rounded-corner-small: 0.5rem; // FILTERS --blur: saturate(180%) blur(0.75rem); @@ -109,23 +109,23 @@ --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; // OPACITY - --disabled-opacity: 60%; - --dim-opacity: 80%; --color-opacity: 10%; + --dim-opacity: 80%; + --disabled-opacity: 60%; // SHADOWS - --edge-highlight: inset 0 0.0625rem 0 rgb(255 255 255 / 10%); + --shadow: 0 0 0 0.0625rem rgb(0 0 0 / 3%), 0 0.0625rem 0.1875rem 0.0625rem rgb(0 0 0 / 7%), 0 0.125rem 0.375rem 0.125rem rgb(0 0 0 / 3%); --shadow-raised: 0 0 0 0.0625rem rgb(0 0 0 / 6%), 0 0.125rem 0.375rem 0.125rem rgb(0 0 0 / 14%), 0 0.25rem 0.75rem 0.25rem rgb(0 0 0 / 6%); --shadow-glass: 0 0.75rem 1.5rem -1rem rgb(0 0 0 / 50%); - --shadow: 0 0 0 0.0625rem rgb(0 0 0 / 3%), 0 0.0625rem 0.1875rem 0.0625rem rgb(0 0 0 / 7%), 0 0.125rem 0.375rem 0.125rem rgb(0 0 0 / 3%); + --edge-highlight: inset 0 0.0625rem 0 rgb(255 255 255 / 10%); // STATES --hover: scale(110%); --active: scale(90%); // TRANSITIONS - --transition-long: 0.8s; - --transition-longer: 0.4s; --transition: 0.2s; + --transition-longer: 0.4s; + --transition-long: 0.8s; } } diff --git a/templates/article.html b/templates/article.html index 006f222..0ad558f 100644 --- a/templates/article.html +++ b/templates/article.html @@ -76,8 +76,26 @@ {%- if page.extra.toc -%}
-
- {%- include "partials/toc.html" -%} +
+ {{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }} +
+
    + {%- for h1 in page.toc -%} +
  • + {{ h1.title }} + {%- if h1.children -%} +
      + {%- for h2 in h1.children -%} +
    • + {{ h2.title }} +
    • + {%- endfor -%} +
    + {%- endif -%} +
  • + {%- endfor -%} +
+
{%- endif -%}