File tree Expand file tree Collapse file tree 1 file changed +35
-35
lines changed
sites/hn.svelte.dev/src/routes/item/[id] Expand file tree Collapse file tree 1 file changed +35
-35
lines changed Original file line number Diff line number Diff line change 9
9
* }}
10
10
*/
11
11
export let comment;
12
-
13
- let hidden = false ;
14
12
</script >
15
13
16
14
{#if ! comment .deleted }
17
- <article class =" comment" class:hidden >
18
- <div
19
- class =" meta-bar"
20
- role =" button"
21
- tabindex =" 0"
22
- on:click ={() => (hidden = ! hidden )}
23
- on:keyup ={(e ) => e .key === ' ' && (hidden = ! hidden )}
24
- >
25
- <span class =" meta" >
26
- <a href ="/user/ {comment .user }" >{comment .user }</a >
27
- {comment .time_ago }
28
- </span >
29
- </div >
30
-
31
- <div class =" body" >
32
- {@html comment .content }
33
- </div >
34
-
35
- {#if comment .comments .length > 0 }
36
- <ul class =" children" >
37
- {#each comment .comments as child }
38
- <li ><svelte:self comment ={child } /></li >
39
- {/each }
40
- </ul >
41
- {/if }
15
+ <article class =" comment" >
16
+ <details open >
17
+ <summary >
18
+ <div class =" meta-bar" role =" button" tabindex =" 0" >
19
+ <span class =" meta" >
20
+ <a href ="/user/ {comment .user }" >{comment .user }</a >
21
+ {comment .time_ago }
22
+ </span >
23
+ </div >
24
+ </summary >
25
+
26
+ <div class =" body" >
27
+ {@html comment .content }
28
+ </div >
29
+
30
+ {#if comment .comments .length > 0 }
31
+ <ul class =" children" >
32
+ {#each comment .comments as child }
33
+ <li ><svelte:self comment ={child } /></li >
34
+ {/each }
35
+ </ul >
36
+ {/if }
37
+ </details >
42
38
</article >
43
39
{/if }
44
40
54
50
.meta-bar {
55
51
padding : 1em 0 ;
56
52
cursor : pointer ;
57
- background : 100% 50% no-repeat url (./fold .svg );
53
+ background : 100% 50% no-repeat url (./unfold .svg );
58
54
background-size : 1em 1em ;
59
55
}
60
56
61
- .hidden .meta-bar {
62
- background-image : url (./unfold .svg );
57
+ .comment details [ open ] .meta-bar {
58
+ background-image : url (./fold .svg );
63
59
}
64
60
65
- .comment .children {
66
- padding : 0 0 0 1em ;
67
- margin : 0 ;
61
+ .comment details > summary {
62
+ list-style-type : none ;
68
63
}
69
64
70
- .hidden .body ,
71
- .hidden .children {
65
+ .comment details > summary ::marker ,
66
+ .comment details > summary ::-webkit-details-marker {
72
67
display : none ;
73
68
}
74
69
70
+ .comment .children {
71
+ padding : 0 0 0 1em ;
72
+ margin : 0 ;
73
+ }
74
+
75
75
@media (min-width : 720px ) {
76
76
.comment .children {
77
77
padding : 0 0 0 2em ;
You can’t perform that action at this time.
0 commit comments