Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

[SG-43144]: Tables in code excerpts should use headers for line numbers #43389

Merged
merged 8 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/codeintellify/src/testutils/sourcegraph/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function generateSourcegraphCodeTable(lines: string[]): string {
const code = lines
.map(
(line, index) => `<tr>
<td class="line" data-line="${index + 1}"></td>
<th class="line" data-line="${index + 1}"></th>
<td class="code">${line}</td>
</tr>`
)
Expand Down
4 changes: 2 additions & 2 deletions client/codeintellify/src/testutils/sourcegraph/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
border-collapse: collapse;
}

.sourcegraph-testcase code.code td.line {
.sourcegraph-testcase code.code th.line {
text-align: right;
padding-left: 0.5rem;
min-width: 2rem;
Expand All @@ -61,7 +61,7 @@
vertical-align: top;
}

.sourcegraph-testcase td.line::before {
.sourcegraph-testcase th.line::before {
content: attr(data-line);
}

Expand Down
1 change: 1 addition & 0 deletions client/search-ui/src/components/CodeExcerpt.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:global(.line) {
min-width: 1.5rem;
text-align: right;
font-weight: inherit;
user-select: none;

&::before {
Expand Down
4 changes: 2 additions & 2 deletions client/search-ui/src/components/CodeExcerpt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const domFunctions: DOMFunctions = {
return row.cells[1]
},
getCodeElementFromLineNumber: (codeView: HTMLElement, line: number): HTMLTableCellElement | null => {
const lineElement = codeView.querySelector(`td[data-line="${line}"]`)
const lineElement = codeView.querySelector(`th[data-line="${line}"]`)
if (!lineElement) {
return null
}
Expand Down Expand Up @@ -341,7 +341,7 @@ export const CodeExcerpt: React.FunctionComponent<Props> = ({
<tbody>
{range(startLine, endLine).map(index => (
<tr key={index}>
<td className="line" data-line={index + 1} />
<th className="line" data-line={index + 1} />
{/* create empty space to fill viewport (as if the blob content were already fetched, otherwise we'll overfetch) */}
<td className="code"> </td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
table {
margin-bottom: 0 !important; /* Override docsite Markdown table CSS. A currently open PR removes that CSS and lets us remove this override. */
}
td:global(.line) {
th:global(.line) {
display: none;
}
td:global(.code) > span:first-child {
Expand Down
160 changes: 80 additions & 80 deletions client/search/src/integration/streaming-search-mocks.ts

Large diffs are not rendered by default.

Loading