Skip to content

Commit adf4c92

Browse files
authored
refactor & perf: declare constant object for inline style of file Announcement (RooCodeInc#2650)
1 parent 21e95ab commit adf4c92

File tree

2 files changed

+37
-27
lines changed

2 files changed

+37
-27
lines changed

.changeset/brown-rats-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": patch
3+
---
4+
5+
refactor & perf: declare constant object for inline style of file `Announcement`

webview-ui/src/components/chat/Announcement.tsx

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,54 @@
11
import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react"
2-
import { memo } from "react"
2+
import { CSSProperties, memo } from "react"
33
import { getAsVar, VSC_DESCRIPTION_FOREGROUND, VSC_INACTIVE_SELECTION_BACKGROUND } from "../../utils/vscStyles"
4-
import { vscode } from "../../utils/vscode"
54

65
interface AnnouncementProps {
76
version: string
87
hideAnnouncement: () => void
98
}
109

10+
const containerStyle: CSSProperties = {
11+
backgroundColor: getAsVar(VSC_INACTIVE_SELECTION_BACKGROUND),
12+
borderRadius: "3px",
13+
padding: "12px 16px",
14+
margin: "5px 15px 5px 15px",
15+
position: "relative",
16+
flexShrink: 0,
17+
}
18+
const closeIconStyle: CSSProperties = { position: "absolute", top: "8px", right: "8px" }
19+
const h3TitleStyle: CSSProperties = { margin: "0 0 8px" }
20+
const ulStyle: CSSProperties = { margin: "0 0 8px", paddingLeft: "12px" }
21+
const accountIconStyle: CSSProperties = { fontSize: 11 }
22+
const hrStyle: CSSProperties = {
23+
height: "1px",
24+
background: getAsVar(VSC_DESCRIPTION_FOREGROUND),
25+
opacity: 0.1,
26+
margin: "8px 0",
27+
}
28+
const linkContainerStyle: CSSProperties = { margin: "0" }
29+
const linkStyle: CSSProperties = { display: "inline" }
30+
1131
/*
1232
You must update the latestAnnouncementId in ClineProvider for new announcements to show to users. This new id will be compared with whats in state for the 'last announcement shown', and if it's different then the announcement will render. As soon as an announcement is shown, the id will be updated in state. This ensures that announcements are not shown more than once, even if the user doesn't close it themselves.
1333
*/
1434
const Announcement = ({ version, hideAnnouncement }: AnnouncementProps) => {
1535
const minorVersion = version.split(".").slice(0, 2).join(".") // 2.0.0 -> 2.0
1636
return (
17-
<div
18-
style={{
19-
backgroundColor: getAsVar(VSC_INACTIVE_SELECTION_BACKGROUND),
20-
borderRadius: "3px",
21-
padding: "12px 16px",
22-
margin: "5px 15px 5px 15px",
23-
position: "relative",
24-
flexShrink: 0,
25-
}}>
26-
<VSCodeButton appearance="icon" onClick={hideAnnouncement} style={{ position: "absolute", top: "8px", right: "8px" }}>
37+
<div style={containerStyle}>
38+
<VSCodeButton appearance="icon" onClick={hideAnnouncement} style={closeIconStyle}>
2739
<span className="codicon codicon-close"></span>
2840
</VSCodeButton>
29-
<h3 style={{ margin: "0 0 8px" }}>
41+
<h3 style={h3TitleStyle}>
3042
🎉{" "}New in v{minorVersion}
3143
</h3>
32-
<ul style={{ margin: "0 0 8px", paddingLeft: "12px" }}>
44+
<ul style={ulStyle}>
3345
<li>
3446
<b>Add to Cline:</b> Right-click selected text in any file or terminal to quickly add context to your current
3547
task! Plus, when you see a lightbulb icon, select 'Fix with Cline' to have Cline fix errors in your code.
3648
</li>
3749
<li>
3850
<b>Billing Dashboard:</b> Track your remaining credits and transaction history right in the extension with a{" "}
39-
<span className="codicon codicon-account" style={{ fontSize: 11 }}></span> Cline account!
51+
<span className="codicon codicon-account" style={accountIconStyle}></span> Cline account!
4052
</li>
4153
<li>
4254
<b>Faster Inference:</b> Cline/OpenRouter users can sort underlying providers used by throughput, price, and
@@ -94,24 +106,17 @@ const Announcement = ({ version, hideAnnouncement }: AnnouncementProps) => {
94106
environments)
95107
</li>
96108
</ul>*/}
97-
<div
98-
style={{
99-
height: "1px",
100-
background: getAsVar(VSC_DESCRIPTION_FOREGROUND),
101-
opacity: 0.1,
102-
margin: "8px 0",
103-
}}
104-
/>
105-
<p style={{ margin: "0" }}>
109+
<div style={hrStyle} />
110+
<p style={linkContainerStyle}>
106111
Join us on{" "}
107-
<VSCodeLink style={{ display: "inline" }} href="https://x.com/cline">
112+
<VSCodeLink style={linkStyle} href="https://x.com/cline">
108113
X,
109114
</VSCodeLink>{" "}
110-
<VSCodeLink style={{ display: "inline" }} href="https://discord.gg/cline">
115+
<VSCodeLink style={linkStyle} href="https://discord.gg/cline">
111116
discord,
112117
</VSCodeLink>{" "}
113118
or{" "}
114-
<VSCodeLink style={{ display: "inline" }} href="https://www.reddit.com/r/cline/">
119+
<VSCodeLink style={linkStyle} href="https://www.reddit.com/r/cline/">
115120
r/cline
116121
</VSCodeLink>
117122
for more updates!

0 commit comments

Comments
 (0)