Skip to content

Commit fbbe2cb

Browse files
author
Hermes
committed
Improve sponsor title visibility
1 parent 221643d commit fbbe2cb

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

theme/pagetoc.css

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,15 @@
132132
backdrop-filter: blur(6px);
133133
}
134134
.sidesponsor img {
135-
height: auto;
136-
width: 60%;
135+
height: 45%;
136+
max-height: 150px;
137+
min-height: 95px;
138+
width: auto;
139+
max-width: 78%;
137140
padding: 10px;
141+
object-fit: contain;
142+
align-self: center;
143+
flex: 0 0 auto;
138144
transition-property: all;
139145
transition-timing-function: cubic-bezier(.4,0,.2,1);
140146
transition-duration: .3s;
@@ -166,9 +172,15 @@
166172
margin-left: 15px;
167173
margin-right: 15px;
168174
font-weight: 800;
169-
font-size: 2rem;
175+
font-size: var(--sponsor-title-font-size, clamp(1.28rem, 7.2cqw, 1.75rem));
170176
line-height: 1.08;
171177
color: var(--sponsor-fg);
178+
overflow-wrap: anywhere;
179+
text-align: center;
180+
flex: 0 0 auto;
181+
}
182+
.sidesponsor .sponsor-title.sponsor-title--long {
183+
line-height: 1.02;
172184
}
173185
.sidesponsor:hover .sponsor-title{
174186
grid-area: sponsor-title;
@@ -181,8 +193,8 @@
181193
}
182194
.sidesponsor .sponsor-description{
183195
display: block;
184-
margin-top: 5px;
185-
margin-bottom: 15px;
196+
margin-top: 0;
197+
margin-bottom: 0;
186198
margin-left: 15px;
187199
margin-right: 15px;
188200
color: var(--sponsor-fg);

theme/sponsor.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@
9595
return bsaScriptPromise
9696
}
9797

98+
function getSponsorTitleFontSize(title) {
99+
if (title.length > 45) {
100+
return "1.25rem"
101+
}
102+
103+
if (title.length > 28) {
104+
return "1.35rem"
105+
}
106+
107+
return ""
108+
}
109+
98110
function setLegacySponsorContent(sponsor, container, nodes) {
99111
nodes.img.src = sponsor.image_url
100112
nodes.img.alt = sponsor.name
@@ -104,12 +116,13 @@
104116
nodes.cta.textContent = sponsor.cta
105117
container.style.display = "flex"
106118

107-
if (sponsor.name.length > 45) {
108-
nodes.title.style.fontSize = "1.6rem"
109-
}
119+
nodes.title.classList.toggle("sponsor-title--long", sponsor.name.length > 28)
120+
nodes.title.style.fontSize = getSponsorTitleFontSize(sponsor.name)
110121

111122
if (sponsor.description.length > 250) {
112123
nodes.description.style.fontSize = "1.4rem"
124+
} else {
125+
nodes.description.style.fontSize = ""
113126
}
114127
}
115128

0 commit comments

Comments
 (0)