Skip to content

Commit 6b3649d

Browse files
authored
Move ads to right sidebar to reduce reflow (#41506)
* Move ads to right sidebar to reduce reflow * Adjust and fix linter * More
1 parent 29b45d4 commit 6b3649d

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

site/src/layouts/DocsLayout.astro

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ if (frontmatter.toc) {
7878
<div class="bd-subtitle">
7979
{frontmatter.description && <Fragment set:html={processMarkdownToHtml(frontmatter.description)} />}
8080
</div>
81-
<Ads />
8281
</div>
8382

84-
{
85-
frontmatter.toc && headings && (
86-
<div class="bd-toc mt-3 mb-5 my-lg-0 mb-lg-5 px-sm-1 text-body-secondary">
83+
84+
<div class="bd-toc mt-3 mb-5 my-lg-0 mb-lg-5 px-sm-1 text-body-secondary">
85+
{
86+
frontmatter.toc && headings && (
8787
<button
8888
class="btn btn-link p-md-0 mb-2 mb-md-0 text-decoration-none bd-toc-toggle d-md-none"
8989
type="button"
@@ -104,9 +104,10 @@ if (frontmatter.toc) {
104104
<TableOfContents headings={headings} />
105105
</nav>
106106
</div>
107-
</div>
108-
)
109-
}
107+
)
108+
}
109+
<Ads />
110+
</div>
110111

111112
<div class="bd-content ps-lg-2">
112113
{

site/src/scss/_ads.scss

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66

77
#carbonads {
88
position: static;
9-
display: block;
109
max-width: 400px;
1110
padding: 15px 15px 15px 160px;
12-
margin: 2rem 0;
11+
margin: 1rem 0;
1312
overflow: hidden;
1413
@include font-size(.8125rem);
1514
line-height: 1.4;
@@ -31,8 +30,33 @@
3130
margin-left: -145px;
3231
}
3332

33+
@container (max-width: 240px) {
34+
#carbonads {
35+
padding-left: 15px;
36+
}
37+
38+
.carbon-img {
39+
display: block;
40+
float: none;
41+
margin-left: 0;
42+
}
43+
44+
.carbon-wrap {
45+
display: flex;
46+
flex-direction: column;
47+
gap: .5rem;
48+
}
49+
50+
.carbon-img > img {
51+
width: 100%;
52+
max-width: 100% !important;
53+
height: auto;
54+
@include border-radius(var(--bs-border-radius-sm));
55+
}
56+
}
57+
3458
.carbon-poweredby {
3559
display: block;
3660
margin-top: .75rem;
37-
color: var(--bs-body-color) !important;
61+
color: var(--bs-fg-3) !important;
3862
}

site/src/scss/_masthead.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
}
5555

5656
#carbonads { // stylelint-disable-line selector-max-id
57+
max-width: 400px;
5758
margin-inline: auto;
59+
margin-block: 2rem;
5860
}
5961

6062
@include media-breakpoint-up(md) {

site/src/scss/_toc.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// stylelint-disable selector-max-type, selector-no-qualifying-type
22

33
.bd-toc {
4+
font-size: .875rem;
5+
container-type: inline-size;
6+
47
@include media-breakpoint-up(lg) {
58
position: sticky;
69
top: 5rem;

0 commit comments

Comments
 (0)