UX: Improve git/code oneboxes (#30822)

This commit is contained in:
Jarek Radosz 2025-01-21 21:20:36 +01:00 committed by GitHub
parent f0d6e9758d
commit 8c31f1aa5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 42 additions and 23 deletions

View File

@ -18,7 +18,7 @@ a > code {
code { code {
color: var(--primary-very-high); color: var(--primary-very-high);
background: var(--hljs-bg); background: var(--hljs-bg);
border-radius: var(--d-button-border-radius); border-radius: var(--d-border-radius);
font-size: 0.875em; font-size: 0.875em;
line-height: calc((13 + 4) / 13); line-height: calc((13 + 4) / 13);
} }

View File

@ -109,6 +109,7 @@ aside.onebox {
header { header {
align-items: center; align-items: center;
display: flex; display: flex;
line-height: var(--line-height-medium);
margin-bottom: 1em; margin-bottom: 1em;
.d-icon { .d-icon {
@ -230,9 +231,8 @@ aside.onebox {
} }
} }
// tighten bottom margin on last para
p:last-child { p:last-child {
margin-bottom: 4px; margin-bottom: 0;
} }
// twitter fixes // twitter fixes
@ -374,19 +374,24 @@ pre.onebox {
// -- Onebox Github Code Blob -- // -- Onebox Github Code Blob --
pre.onebox code ol.lines li::before { pre.onebox code ol.lines li::before {
box-sizing: border-box;
position: absolute; position: absolute;
display: inline-block; display: inline-block;
width: 35px; width: 3.5em;
left: -40px; left: calc(-3em + 1px);
color: #afafaf; color: var(--primary-600);
text-align: right; text-align: right;
padding-right: 5px; padding-right: 0.5em;
font-size: var(--font-down-1); font-size: var(--font-down-1);
line-height: var(--line-height-large); line-height: calc((13 + 9.4) / 13); // matches the `code` line-height
content: counter(li-counter); content: counter(li-counter);
counter-increment: li-counter; counter-increment: li-counter;
} }
pre.onebox code ol.lines li.selected::before {
background-color: var(--highlight-bg);
}
.onebox.githubblob, .onebox.githubblob,
.onebox.gitlabblob { .onebox.gitlabblob {
.onebox-body h4 { .onebox-body h4 {
@ -397,6 +402,11 @@ pre.onebox code ol.lines li::before {
.git-blob-info { .git-blob-info {
font-size: var(--font-down-1); font-size: var(--font-down-1);
line-height: var(--line-height-small);
}
pre {
margin-bottom: 0;
} }
} }
@ -410,26 +420,28 @@ pre.onebox code {
} }
pre.onebox code li { pre.onebox code li {
padding-left: 5px; padding-left: 0.5em;
} }
pre.onebox code ol.lines { pre.onebox code ol.lines {
position: relative; position: relative;
margin: 0 0 0 40px; margin: 0 0 0 2.5em;
padding-left: 0.5em;
} }
pre.onebox code ol.lines li { pre.onebox code ol.lines li {
list-style-type: none; list-style-type: none;
padding-left: 5px; padding-left: 0.5em;
margin-left: 0; margin-left: 0;
border-left: 1px solid #cfcfcf; border-left: 1px solid var(--primary-300);
min-height: 1.5em; //show empty li lines min-height: 1.5em; //show empty li lines
white-space: pre; white-space: pre;
width: max-content; width: max-content;
} }
pre.onebox code li.selected { pre.onebox code ol.lines li.selected {
background-color: var(--highlight-bg); background-color: var(--highlight-bg);
border-left-color: rgba(var(--primary-rgb), 0.2);
} }
pre.onebox code { pre.onebox code {
@ -493,17 +505,17 @@ pre.onebox code {
.github-icon { .github-icon {
grid-area: icon; grid-area: icon;
align-self: center; align-self: stretch;
width: 100%; max-width: 1.8em;
height: 100%; height: auto;
max-width: 2.15em; justify-self: center;
margin: 0 auto;
fill: var(--primary-high); fill: var(--primary-high);
} }
.branches { .branches {
grid-area: branches; grid-area: branches;
font-size: var(--font-down-1); font-size: var(--font-down-1);
line-height: var(--line-height-medium);
code { code {
word-break: break-all; word-break: break-all;
@ -527,7 +539,7 @@ pre.onebox code {
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
width: 100%; width: 100%;
gap: 0.15em 1em; gap: 0.15em 0.75em;
.lines { .lines {
font-weight: bold; font-weight: bold;
@ -555,16 +567,21 @@ pre.onebox code {
overflow-y: auto; overflow-y: auto;
word-break: break-word; word-break: break-word;
font-family: var(--d-font-family--monospace); font-family: var(--d-font-family--monospace);
font-size: 0.875em;
line-height: calc((13 + 4) / 13);
box-sizing: border-box; box-sizing: border-box;
.show-more { .show-more {
font-family: var(--font-family);
// padding on right for larger hitzone // padding on right for larger hitzone
padding: 0.5em 1.5em 0 0.25em; padding: 0.5em 1em 0 0.2em;
} }
} }
.onebox-avatar-inline { .onebox-avatar-inline {
border-radius: 2px; border-radius: 2px;
vertical-align: text-bottom;
} }
.labels span { .labels span {

View File

@ -78,7 +78,7 @@
float: none; float: none;
} }
.topic-post article.boxed .select-posts { .topic-post > article.boxed .select-posts {
width: auto; width: auto;
left: auto; left: auto;
right: 0; right: 0;

View File

@ -10,12 +10,12 @@
} }
.topic-post-visited { .topic-post-visited {
+ .topic-post article { + .topic-post > article {
border-top: none; border-top: none;
} }
} }
.topic-post article { .topic-post > article {
border-top: 1px solid var(--primary-low); border-top: 1px solid var(--primary-low);
padding: 15px 0 8px 0; padding: 15px 0 8px 0;
} }

View File

@ -34,7 +34,9 @@ $max_image_height: 150px;
.onebox-body .aspect-image { .onebox-body .aspect-image {
max-width: 50%; max-width: 50%;
} }
}
.onebox:not(.githubpullrequest, .githubcommit, .githubissue) {
@container (width < 400px) { @container (width < 400px) {
.onebox-body { .onebox-body {
display: flex; display: flex;