From 11e985ffa801db583bbe1c9a274f437a6c8fa34f Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Tue, 22 Aug 2023 16:52:39 +0800 Subject: [PATCH] feat(hn): toggle comments by details > summary (#532) --- .../src/routes/item/[id]/Comment.svelte | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/sites/hn.svelte.dev/src/routes/item/[id]/Comment.svelte b/sites/hn.svelte.dev/src/routes/item/[id]/Comment.svelte index 5cd232eb..75fc6bf8 100644 --- a/sites/hn.svelte.dev/src/routes/item/[id]/Comment.svelte +++ b/sites/hn.svelte.dev/src/routes/item/[id]/Comment.svelte @@ -9,36 +9,32 @@ * }} */ export let comment; - - let hidden = false; {#if !comment.deleted} -
-
(hidden = !hidden)} - on:keyup={(e) => e.key === ' ' && (hidden = !hidden)} - > - - {comment.user} - {comment.time_ago} - -
- -
- {@html comment.content} -
- - {#if comment.comments.length > 0} - - {/if} +
+
+ +
+ + {comment.user} + {comment.time_ago} + +
+
+ +
+ {@html comment.content} +
+ + {#if comment.comments.length > 0} +
    + {#each comment.comments as child} +
  • + {/each} +
+ {/if} +
{/if} @@ -54,24 +50,28 @@ .meta-bar { padding: 1em 0; cursor: pointer; - background: 100% 50% no-repeat url(./fold.svg); + background: 100% 50% no-repeat url(./unfold.svg); background-size: 1em 1em; } - .hidden .meta-bar { - background-image: url(./unfold.svg); + .comment details[open] .meta-bar { + background-image: url(./fold.svg); } - .comment .children { - padding: 0 0 0 1em; - margin: 0; + .comment details > summary { + list-style-type: none; } - .hidden .body, - .hidden .children { + .comment details > summary::marker, + .comment details > summary::-webkit-details-marker { display: none; } + .comment .children { + padding: 0 0 0 1em; + margin: 0; + } + @media (min-width: 720px) { .comment .children { padding: 0 0 0 2em;