Skip to content

Commit 151c031

Browse files
authored
Merge pull request #3110 from github/koesie10/result-styled
Switch to styled-components for some components in the results view
2 parents d72f3f4 + 3f2114a commit 151c031

File tree

6 files changed

+50
-59
lines changed

6 files changed

+50
-59
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { styled } from "styled-components";
2+
3+
export const VerticalRule = styled.span`
4+
border-left: 1px solid var(--vscode-dropdown-border);
5+
height: 100%;
6+
position: absolute;
7+
top: 0;
8+
bottom: 0;
9+
`;

extensions/ql-vscode/src/view/results/AlertTablePathNodeRow.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as Keys from "./result-keys";
44
import { SarifLocation } from "./locations/SarifLocation";
55
import { selectableZebraStripe } from "./result-table-utils";
66
import { useCallback, useMemo } from "react";
7+
import { VerticalRule } from "../common/VerticalRule";
78

89
interface Props {
910
step: Sarif.ThreadFlowLocation;
@@ -54,10 +55,10 @@ export function AlertTablePathNodeRow(props: Props) {
5455
className={isSelected ? "vscode-codeql__selected-path-node" : undefined}
5556
>
5657
<td className="vscode-codeql__icon-cell">
57-
<span className="vscode-codeql__vertical-rule"></span>
58+
<VerticalRule />
5859
</td>
5960
<td className="vscode-codeql__icon-cell">
60-
<span className="vscode-codeql__vertical-rule"></span>
61+
<VerticalRule />
6162
</td>
6263
<td
6364
{...selectableZebraStripe(

extensions/ql-vscode/src/view/results/AlertTablePathRow.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { selectableZebraStripe } from "./result-table-utils";
55
import { AlertTablePathNodeRow } from "./AlertTablePathNodeRow";
66
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
77
import { useCallback, useMemo } from "react";
8+
import { VerticalRule } from "../common/VerticalRule";
89

910
interface Props {
1011
path: Sarif.ThreadFlow;
@@ -53,7 +54,7 @@ export function AlertTablePathRow(props: Props) {
5354
{...selectableZebraStripe(isPathSpecificallySelected, resultIndex)}
5455
>
5556
<td className="vscode-codeql__icon-cell">
56-
<span className="vscode-codeql__vertical-rule"></span>
57+
<VerticalRule />
5758
</td>
5859
<AlertTableDropdownIndicatorCell
5960
expanded={currentPathExpanded}
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import * as React from "react";
2+
import { styled } from "styled-components";
23
import { sendTelemetry } from "../common/telemetry";
34

45
function sendCodeQLLanguageGuidesTelemetry() {
56
sendTelemetry("codeql-language-guides-link");
67
}
78

9+
const Root = styled.div`
10+
height: 300px;
11+
display: flex;
12+
align-items: center;
13+
justify-content: center;
14+
`;
15+
16+
const Container = styled.span`
17+
max-width: 80%;
18+
font-size: 14px;
19+
text-align: center;
20+
`;
21+
822
export function EmptyQueryResultsMessage(): JSX.Element {
923
return (
10-
<div className="vscode-codeql__empty-query-message">
11-
<span>
24+
<Root>
25+
<Container>
1226
This query returned no results. If this isn&apos;t what you were
1327
expecting, and for effective query-writing tips, check out the{" "}
1428
<a
@@ -18,7 +32,7 @@ export function EmptyQueryResultsMessage(): JSX.Element {
1832
CodeQL language guides
1933
</a>
2034
.
21-
</span>
22-
</div>
35+
</Container>
36+
</Root>
2337
);
2438
}
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import * as React from "react";
2+
import { styled } from "styled-components";
3+
4+
const Octicon = styled.svg`
5+
fill: var(--vscode-editor-foreground);
6+
margin-top: 0.25em;
7+
`;
8+
9+
const OcticonLight = styled(Octicon)`
10+
opacity: 0.6;
11+
`;
212

313
/**
414
* These icons come from https://github.com/microsoft/vscode-icons
515
* and are used under the Creative Commons License, see `LICENSE`
616
* file in this directory.
717
*/
818
export const chevronDown = (
9-
<svg
10-
className="octicon"
19+
<Octicon
1120
width="16"
1221
height="16"
1322
viewBox="0 0 16 16"
@@ -19,25 +28,23 @@ export const chevronDown = (
1928
clipRule="evenodd"
2029
d="M7.976 10.072l4.357-4.357.62.618L8.284 11h-.618L3 6.333l.62-.618 4.356 4.357z"
2130
/>
22-
</svg>
31+
</Octicon>
2332
);
2433

2534
export const chevronRight = (
26-
<svg
27-
className="octicon"
35+
<Octicon
2836
width="16"
2937
height="16"
3038
viewBox="0 0 16 16"
3139
fill="none"
3240
xmlns="http://www.w3.org/2000/svg"
3341
>
3442
<path d="M5.7 13.7L5 13l4.6-4.6L5 3.7l.7-.7 5 5v.7l-5 5z" />
35-
</svg>
43+
</Octicon>
3644
);
3745

3846
export const listUnordered = (
39-
<svg
40-
className="octicon octicon-light"
47+
<OcticonLight
4148
width="16"
4249
height="16"
4350
viewBox="0 0 16 16"
@@ -49,12 +56,11 @@ export const listUnordered = (
4956
clipRule="evenodd"
5057
d="M2 3H1v1h1V3zm0 3H1v1h1V6zM1 9h1v1H1V9zm1 3H1v1h1v-1zm2-9h11v1H4V3zm11 3H4v1h11V6zM4 9h11v1H4V9zm11 3H4v1h11v-1z"
5158
/>
52-
</svg>
59+
</OcticonLight>
5360
);
5461

5562
export const info = (
56-
<svg
57-
className="octicon octicon-light"
63+
<OcticonLight
5864
width="16"
5965
height="16"
6066
viewBox="0 0 16 16"
@@ -66,5 +72,5 @@ export const info = (
6672
clipRule="evenodd"
6773
d="M8.568 1.03a6.8 6.8 0 0 1 4.192 2.02 7.06 7.06 0 0 1 .46 9.39 6.85 6.85 0 0 1-8.58 1.74 7 7 0 0 1-3.12-3.5 7.12 7.12 0 0 1-.23-4.71 7 7 0 0 1 2.77-3.79 6.8 6.8 0 0 1 4.508-1.15zm.472 12.85a5.89 5.89 0 0 0 3.41-2.07 6.07 6.07 0 0 0-.4-8.06 5.82 5.82 0 0 0-7.43-.74 6.06 6.06 0 0 0 .5 10.29 5.81 5.81 0 0 0 3.92.58zM8.51 7h-1v4h1V7zm0-2h-1v1h1V5z"
6874
/>
69-
</svg>
75+
</OcticonLight>
7076
);

extensions/ql-vscode/src/view/results/resultsView.css

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -144,43 +144,3 @@ td.vscode-codeql__path-index-cell {
144144
.vscode-codeql__location-cell {
145145
text-align: right !important;
146146
}
147-
148-
.vscode-codeql__vertical-rule {
149-
border-left: 1px solid var(--vscode-dropdown-border);
150-
height: 100%;
151-
position: absolute;
152-
top: 0;
153-
bottom: 0;
154-
}
155-
156-
.vscode-codeql__title {
157-
/* Something that isn't a link, but which has a title attribute */
158-
text-decoration-line: underline;
159-
text-decoration-style: dotted;
160-
}
161-
162-
.octicon {
163-
fill: var(--vscode-editor-foreground);
164-
margin-top: 0.25em;
165-
}
166-
167-
.octicon-light {
168-
opacity: 0.6;
169-
}
170-
171-
.vscode-codeql__empty-query-message {
172-
height: 300px;
173-
display: flex;
174-
align-items: center;
175-
justify-content: center;
176-
}
177-
178-
.vscode-codeql__empty-query-message > span {
179-
max-width: 80%;
180-
font-size: 14px;
181-
text-align: center;
182-
}
183-
184-
.vscode-codeql__result-table-location-link {
185-
text-decoration: none;
186-
}

0 commit comments

Comments
 (0)