Skip to content

Commit 86268eb

Browse files
committed
use custom marker for summary element
- use custom marker for summary element to get uniform style and behavior across browsers - add example for collapsible blocks to UI preview - prevent summary text from being highlighted in webkit-based browsers
1 parent 7e8d89b commit 86268eb

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

preview-src/index.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,22 @@ This is an example paragraph.
5454
.Summary
5555
[%collapsible]
5656
====
57+
Details.
58+
5759
Loads of details.
5860
====
5961

62+
[,asciidoc]
63+
----
64+
Voila!
65+
----
66+
67+
.Result
68+
[%collapsible.result]
69+
====
70+
Voila!
71+
====
72+
6073
=== Some Code
6174

6275
How about some code?

src/css/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ button::-moz-focus-inner {
7575

7676
summary {
7777
cursor: pointer;
78+
-webkit-tap-highlight-color: transparent;
7879
}
7980

8081
table {

src/css/doc.css

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,12 +642,53 @@ h1.page + aside.toc.embedded {
642642
padding-bottom: 0;
643643
}
644644

645+
.doc details {
646+
margin-left: 1.25rem;
647+
}
648+
649+
.doc details > summary {
650+
display: flex;
651+
line-height: var(--doc-line-height);
652+
margin-bottom: 0.5rem;
653+
}
654+
655+
.doc details > summary::before {
656+
content: "";
657+
border: solid transparent;
658+
border-left-color: currentColor;
659+
border-width: 0.3em 0 0.3em 0.5em;
660+
position: absolute;
661+
margin-top: calc((var(--doc-line-height) * 0.5 - 0.3) * 1em);
662+
margin-left: -1.25rem;
663+
transform: translateX(25%);
664+
}
665+
666+
.doc details[open] > summary::before {
667+
border-color: currentColor transparent transparent;
668+
border-width: 0.5rem 0.3rem 0;
669+
transform: translateX(10%) translateY(15%);
670+
}
671+
672+
.doc details > summary::after {
673+
content: "";
674+
width: 1.25rem;
675+
height: 1em;
676+
position: absolute;
677+
margin-top: calc((var(--doc-line-height) * 0.5 - 0.5) * 1em);
678+
margin-left: -1.25rem;
679+
}
680+
645681
.doc details.result {
646682
margin-top: 0.25rem;
647683
}
648684

649685
.doc details.result > summary {
650686
color: var(--caption-font-color);
687+
margin-bottom: 0;
688+
}
689+
690+
.doc details.result > .content {
691+
margin-left: -1.25rem;
651692
}
652693

653694
.doc .exampleblock > .content,
@@ -666,7 +707,7 @@ h1.page + aside.toc.embedded {
666707
}
667708

668709
.doc .exampleblock > .content > :first-child,
669-
.doc details.result > .content > :first-child {
710+
.doc details > .content > :first-child {
670711
margin-top: 0;
671712
}
672713

0 commit comments

Comments
 (0)