Skip to content

Commit 1307dd0

Browse files
authored
Codeblock: Fix codeblock types not overlapping in callout (#416)
1 parent 724263b commit 1307dd0

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

assets/css/v2/style.css

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,10 +2019,6 @@ blockquote {
20192019
}
20202020
}
20212021

2022-
.callout-content {
2023-
margin: 0;
2024-
}
2025-
20262022
/* To help them align with text, side callouts should not have top margin*/
20272023
&[data-grid="last-third"] {
20282024
--margin-callout: 0 0 0 1rem;
@@ -2296,6 +2292,8 @@ a:has(code:not(pre code)) {
22962292
.code-block {
22972293
position: relative;
22982294
margin: var(--margin-codeblock); /* Expand into the gutter */
2295+
display: flex;
2296+
flex-direction: column;
22992297

23002298
tr::after {
23012299
display: none;
@@ -2307,20 +2305,38 @@ a:has(code:not(pre code)) {
23072305
}
23082306

23092307
.code-type {
2310-
display: inline-block;
2311-
height: 1.5rem;
2312-
border-top: 1px solid oklch(var(--color-codeblock-border));
2313-
border-left: 1px solid oklch(var(--color-codeblock-border));
2314-
border-right: 1px solid oklch(var(--color-codeblock-border));
2308+
position: relative;
2309+
border: none;
23152310
text-transform: uppercase;
2316-
padding: 0.15rem 0.5rem;
23172311
font-size: 0.75rem;
2318-
z-index: 2;
2319-
margin: 0 0 -1px 0;
2312+
display: flex;
2313+
2314+
&::after {
2315+
content: "";
2316+
display: block;
2317+
flex: 1;
2318+
height: auto;
2319+
border-bottom: 1px solid oklch(var(--color-codeblock-border));
2320+
}
2321+
2322+
.title {
2323+
display: inline-block;
2324+
padding: 0.15rem 0.5rem;
2325+
border-top: 1px solid oklch(var(--color-codeblock-border));
2326+
border-left: 1px solid oklch(var(--color-codeblock-border));
2327+
border-right: 1px solid oklch(var(--color-codeblock-border));
2328+
border-bottom: none;
2329+
}
2330+
2331+
/* Hide the top border only if code-type exists in code-block */
2332+
& + .code-container {
2333+
border-top: none;
2334+
}
23202335
}
23212336

23222337
.code-container {
23232338
box-shadow: 3px 3px 0px oklch(var(--color-shadow));
2339+
border: 1px solid oklch(var(--color-codeblock-border));
23242340

23252341
&:hover {
23262342
.code-copy-button {
@@ -2354,7 +2370,7 @@ a:has(code:not(pre code)) {
23542370
}
23552371

23562372
.code-content {
2357-
border: 1px solid oklch(var(--color-codeblock-border));
2373+
box-sizing: border-box;
23582374
overflow-x: scroll;
23592375
scrollbar-width: none;
23602376
line-height: 150%;

layouts/_default/_markup/render-codeblock.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{{- else -}}
1616
<div class="code-block">
1717
{{- if and (ne .Type "") (ne .Type "none") -}}
18-
<span class="code-type chroma">{{ .Type }}</span>
18+
<figcaption class="code-type"><span class="title chroma">{{ .Type }}</span></figcaption>
1919
{{- end -}}
2020
<div class="code-container chroma">
2121
<button onclick="copyToClipBoard(this, {{ $codeBlockId }})" class="code-copy-button multi-line" type="button">Copy</button>

layouts/partials/callout.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@
5252

5353
<blockquote class="{{ $class }} note" data-title="{{ $cleanTitle }}" data-grid="{{ $dataGrid }}">
5454
<div class="callout-content">
55-
{{- with $icon -}}
56-
<i class="{{ . }}"></i>
57-
{{- end -}}
58-
<div class="callout-content">
59-
{{ .content | markdownify }}
60-
</div>
55+
{{ .content | markdownify }}
6156
</div>
6257
</blockquote>
6358

0 commit comments

Comments
 (0)