Skip to content

Commit 146732f

Browse files
authored
Merge pull request #3049 from github/koesie10/styled-transient-props
Use transient props for all styled components
2 parents 3cc4f5c + acc9ab3 commit 146732f

File tree

9 files changed

+35
-35
lines changed

9 files changed

+35
-35
lines changed

extensions/ql-vscode/src/view/common/Alert.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,46 @@ import { ReactNode } from "react";
33
import { styled } from "styled-components";
44

55
type ContainerProps = {
6-
type: "warning" | "error";
7-
inverse?: boolean;
6+
$type: "warning" | "error";
7+
$inverse?: boolean;
88
};
99

10-
const getBackgroundColor = ({ type, inverse }: ContainerProps): string => {
11-
if (!inverse) {
10+
const getBackgroundColor = ({ $type, $inverse }: ContainerProps): string => {
11+
if (!$inverse) {
1212
return "var(--vscode-notifications-background)";
1313
}
1414

15-
switch (type) {
15+
switch ($type) {
1616
case "warning":
1717
return "var(--vscode-editorWarning-foreground)";
1818
case "error":
1919
return "var(--vscode-debugExceptionWidget-border)";
2020
}
2121
};
2222

23-
const getTextColor = ({ type, inverse }: ContainerProps): string => {
24-
if (!inverse) {
23+
const getTextColor = ({ $type, $inverse }: ContainerProps): string => {
24+
if (!$inverse) {
2525
return "var(--vscode-editor-foreground)";
2626
}
2727

28-
switch (type) {
28+
switch ($type) {
2929
case "warning":
3030
return "var(--vscode-editor-background)";
3131
case "error":
3232
return "var(--vscode-list-activeSelectionForeground)";
3333
}
3434
};
3535

36-
const getBorderColor = ({ type }: ContainerProps): string => {
37-
switch (type) {
36+
const getBorderColor = ({ $type }: ContainerProps): string => {
37+
switch ($type) {
3838
case "warning":
3939
return "var(--vscode-editorWarning-foreground)";
4040
case "error":
4141
return "var(--vscode-editorError-foreground)";
4242
}
4343
};
4444

45-
const getTypeText = (type: ContainerProps["type"]): string => {
45+
const getTypeText = (type: ContainerProps["$type"]): string => {
4646
switch (type) {
4747
case "warning":
4848
return "Warning";
@@ -108,7 +108,7 @@ export const Alert = ({
108108
role,
109109
}: Props) => {
110110
return (
111-
<Container type={type} inverse={inverse} role={role}>
111+
<Container $type={type} $inverse={inverse} role={role}>
112112
<Title>
113113
{getTypeText(type)}: {title}
114114
</Title>

extensions/ql-vscode/src/view/common/Dropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { styled } from "styled-components";
44

55
const DISABLED_VALUE = "-";
66

7-
const StyledDropdown = styled.select<{ disabled?: boolean }>`
7+
const StyledDropdown = styled.select`
88
width: 100%;
99
height: calc(var(--input-height) * 1px);
1010
background: var(--vscode-dropdown-background);

extensions/ql-vscode/src/view/common/FileCodeSnippet/CodeSnippetMessage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ const MessageText = styled.div`
2727
`;
2828

2929
type CodeSnippetMessageContainerProps = {
30-
severity: ResultSeverity;
30+
$severity: ResultSeverity;
3131
};
3232

3333
const CodeSnippetMessageContainer = styled.div<CodeSnippetMessageContainerProps>`
3434
border-color: var(--vscode-editor-snippetFinalTabstopHighlightBorder);
3535
border-width: 0.1em;
3636
border-style: solid;
37-
border-left-color: ${(props) => getSeverityColor(props.severity)};
37+
border-left-color: ${(props) => getSeverityColor(props.$severity)};
3838
border-left-width: 0.3em;
3939
padding-top: 1em;
4040
padding-bottom: 1em;
@@ -58,7 +58,7 @@ export const CodeSnippetMessage = ({
5858
children,
5959
}: CodeSnippetMessageProps) => {
6060
return (
61-
<CodeSnippetMessageContainer severity={severity}>
61+
<CodeSnippetMessageContainer $severity={severity}>
6262
<MessageText>
6363
{message.tokens.map((token, index) => {
6464
switch (token.t) {
@@ -86,7 +86,7 @@ export const CodeSnippetMessage = ({
8686
})}
8787
{children && (
8888
<>
89-
<VerticalSpace size={2} />
89+
<VerticalSpace $size={2} />
9090
{children}
9191
</>
9292
)}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { styled } from "styled-components";
22

3-
export const HorizontalSpace = styled.div<{ size: 1 | 2 | 3 }>`
3+
export const HorizontalSpace = styled.div<{ $size: 1 | 2 | 3 }>`
44
flex: 0 0 auto;
55
display: inline-block;
6-
width: ${(props) => 0.2 * props.size}em;
6+
width: ${(props) => 0.2 * props.$size}em;
77
`;

extensions/ql-vscode/src/view/common/TextButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { styled } from "styled-components";
33

44
type Size = "x-small" | "small" | "medium" | "large" | "x-large";
55

6-
const StyledButton = styled.button<{ size: Size }>`
6+
const StyledButton = styled.button<{ $size: Size }>`
77
background: none;
88
color: var(--vscode-textLink-foreground);
99
border: none;
1010
cursor: pointer;
11-
font-size: ${(props) => props.size ?? "1em"};
11+
font-size: ${(props) => props.$size ?? "1em"};
1212
padding: 0;
1313
`;
1414

@@ -26,7 +26,7 @@ const TextButton = ({
2626
children: React.ReactNode;
2727
}) => (
2828
<StyledButton
29-
size={size}
29+
$size={size}
3030
onClick={onClick}
3131
className={className}
3232
title={title}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { styled } from "styled-components";
22

3-
export const VerticalSpace = styled.div<{ size: 1 | 2 | 3 }>`
3+
export const VerticalSpace = styled.div<{ $size: 1 | 2 | 3 }>`
44
flex: 0 0 auto;
5-
height: ${(props) => 0.5 * props.size}em;
5+
height: ${(props) => 0.5 * props.$size}em;
66
`;

extensions/ql-vscode/src/view/data-flow-paths/DataFlowPaths.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ export const DataFlowPaths = ({
4848

4949
return (
5050
<>
51-
<VerticalSpace size={2} />
51+
<VerticalSpace $size={2} />
5252
<SectionTitle>{ruleDescription}</SectionTitle>
53-
<VerticalSpace size={2} />
53+
<VerticalSpace $size={2} />
5454

5555
<PathsContainer>
5656
<PathDetailsContainer>
@@ -66,7 +66,7 @@ export const DataFlowPaths = ({
6666
</PathDropdownContainer>
6767
</PathsContainer>
6868

69-
<VerticalSpace size={2} />
69+
<VerticalSpace $size={2} />
7070
<CodePath
7171
codeFlow={selectedCodeFlow}
7272
severity={severity}

extensions/ql-vscode/src/view/method-modeling/MethodModeling.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ const DependencyContainer = styled.div`
3939
margin-bottom: 0.8rem;
4040
`;
4141

42-
const StyledVSCodeTag = styled(VSCodeTag)<{ visible: boolean }>`
43-
visibility: ${(props) => (props.visible ? "visible" : "hidden")};
42+
const StyledVSCodeTag = styled(VSCodeTag)<{ $visible: boolean }>`
43+
visibility: ${(props) => (props.$visible ? "visible" : "hidden")};
4444
`;
4545

4646
const UnsavedTag = ({ modelingStatus }: { modelingStatus: ModelingStatus }) => (
47-
<StyledVSCodeTag visible={modelingStatus === "unsaved"}>
47+
<StyledVSCodeTag $visible={modelingStatus === "unsaved"}>
4848
Unsaved
4949
</StyledVSCodeTag>
5050
);

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisRepositoriesStats.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,29 @@ function getIcon(
2727
if (variantAnalysisStatus === VariantAnalysisStatus.Canceled) {
2828
return (
2929
<>
30-
<HorizontalSpace size={2} />
30+
<HorizontalSpace $size={2} />
3131
<ErrorIcon label="Some analyses were stopped" />
3232
</>
3333
);
3434
} else {
3535
return (
3636
<>
37-
<HorizontalSpace size={2} />
37+
<HorizontalSpace $size={2} />
3838
<ErrorIcon label="Some analyses failed" />
3939
</>
4040
);
4141
}
4242
} else if (skippedRepositoryCount > 0) {
4343
return (
4444
<>
45-
<HorizontalSpace size={2} />
45+
<HorizontalSpace $size={2} />
4646
<WarningIcon label="Some repositories were skipped" />
4747
</>
4848
);
4949
} else if (variantAnalysisStatus === VariantAnalysisStatus.Succeeded) {
5050
return (
5151
<>
52-
<HorizontalSpace size={2} />
52+
<HorizontalSpace $size={2} />
5353
<SuccessIcon label="Completed" />
5454
</>
5555
);
@@ -68,7 +68,7 @@ export const VariantAnalysisRepositoriesStats = ({
6868
if (variantAnalysisStatus === VariantAnalysisStatus.Failed) {
6969
return (
7070
<>
71-
0<HorizontalSpace size={2} />
71+
0<HorizontalSpace $size={2} />
7272
<ErrorIcon label="Variant analysis failed" />
7373
</>
7474
);

0 commit comments

Comments
 (0)