Skip to content

Commit 0d8bd05

Browse files
authored
style: update webview green based on vscode theme type VSCODE-297 (#363)
1 parent e64b5f4 commit 0d8bd05

File tree

9 files changed

+75
-36
lines changed

9 files changed

+75
-36
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@import "~../styles/_variables";
2+
3+
:root {
4+
// NOTE: This green is updated in the code dynamically
5+
// and updates on the current color theme of vscode (light vs dark).
6+
--mongodb-green: @green;
7+
}
8+
9+
a {
10+
color: var(--mongodb-green);
11+
}
12+
13+
a:hover {
14+
color: var(--mongodb-green);
15+
}
16+
17+
*:focus {
18+
outline-color: @green-selected;
19+
}
20+
21+
a:focus {
22+
outline-color: @green-selected;
23+
}

src/views/webview-app/components/app.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717

1818
const styles = require('../connect.module.less');
1919

20+
import './app.less';
21+
2022
type DispatchProps = {
2123
onConnectedEvent: (
2224
connectionAttemptId: string,
@@ -34,6 +36,23 @@ type DispatchProps = {
3436
};
3537

3638
export class App extends React.Component<DispatchProps> {
39+
constructor(props) {
40+
super(props);
41+
42+
// Update the MongoDB green color we used based on the current
43+
// theme kind of the VSCode user.
44+
const element = document.querySelector('body');
45+
if (element?.getAttribute('data-vscode-theme-kind') === 'vscode-light') {
46+
document.documentElement.style.setProperty(
47+
'--mongodb-green', '#00684A' // Forest green
48+
);
49+
} else {
50+
document.documentElement.style.setProperty(
51+
'--mongodb-green', '#00ED64' // Base green
52+
);
53+
}
54+
}
55+
3756
componentDidMount(): void {
3857
window.addEventListener('message', (event) => {
3958
const message: MESSAGE_FROM_EXTENSION_TO_WEBVIEW = event.data;

src/views/webview-app/components/atlas-cta/atlas-cta.less

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
margin: 0 32px;
1616
}
1717

18-
.atlas-cta-text-link {
19-
color: @green;
20-
}
21-
2218
.atlas-cta-logo {
2319
display: inline-block;
2420
margin-left: auto;

src/views/webview-app/components/connect-form/connection-form.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
margin-bottom: -1px;
7878
pointer-events: none;
7979
outline: none;
80-
background-color: @green;
80+
background-color: var(--mongodb-green);
8181
border-top-left-radius: 3px;
8282
border-top-right-radius: 3px;
8383
animation-name: selectedConnectionTabAnimation;

src/views/webview-app/components/connection-status/connection-status.less

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626

2727
.connection-status-dot-connected:before {
28-
background-color: @green;
28+
background-color: var(--mongodb-green);
2929
}
3030

3131
.connection-status-dot-disconnected:before {
@@ -47,19 +47,24 @@
4747

4848
.connection-status-create-playground-button {
4949
display: inline-block;
50-
border: none;
50+
border: 1px solid rgb(21, 130, 66);
5151
border-radius: 3px;
5252
margin: 0 20px;
5353
margin-top: 20px;
5454
height: 32px;
5555
width: 161px;
56+
transition: 150ms all;
5657
color: white;
57-
background-color: #13aa52;
58-
transition: 250ms all;
58+
background-color: var(--mongodb-green);
59+
background-image: linear-gradient(rgb(19, 170, 82), rgb(24, 150, 76));
60+
box-shadow: rgb(21, 130, 66) 0px -1px 0px inset;
5961

6062
&:hover {
6163
cursor: pointer;
62-
background-color: #3F864B;
64+
color: white;
65+
background-color: #109648;
66+
background-image: linear-gradient(#129f4c, #148040);
67+
border-color: rgb(21, 130, 66);
6368
}
6469
}
6570

src/views/webview-app/components/form/form.less

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
}
115115

116116
.btn {
117-
background-color: @green;
117+
background-color: var(--mongodb-green);;
118118
padding: 9px 28px 10px;
119119
margin: 6px 0 0 0;
120120
display: inline-block;
@@ -142,8 +142,8 @@
142142

143143
.btn-primary {
144144
color: white;
145-
background-color: @green;
146-
background-image: linear-gradient(@green, rgb(24, 150, 76));
145+
background-color: var(--mongodb-green);
146+
background-image: linear-gradient(rgb(19, 170, 82), rgb(24, 150, 76));
147147

148148
border-color: rgb(21, 130, 66);
149149
box-shadow: rgb(21, 130, 66) 0px -1px 0px inset;
@@ -190,7 +190,7 @@
190190

191191
&-success {
192192
color: white;
193-
background: @green;
193+
background: var(--mongodb-green);
194194
padding: 4px 10px;
195195
border-radius: 3px;
196196
}

src/views/webview-app/components/mongodb-logo/mongodb-logo.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ const styles = require('./mongodb-logo.less');
88

99
class MongoDBLogo extends React.PureComponent {
1010
render(): React.ReactNode {
11+
let darkMode = true;
12+
// Update the MongoDB green color we used based on the current
13+
// theme kind of the VSCode user.
14+
const element = document.querySelector('body');
15+
if (element?.getAttribute('data-vscode-theme-kind') === 'vscode-light') {
16+
darkMode = false;
17+
}
18+
1119
return (
1220
<LeafyGreenMongoDBLogo
1321
className={styles['mdb-logo-svg']}
14-
color={'green-base'}
22+
color={darkMode ? 'green-base' : 'green-dark-2'}
1523
/>
1624
);
1725
}

src/views/webview-app/components/resources-panel/resources-panel.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
.resources-panel-header {
7878
font-size: 21px;
79-
color: @green;
79+
color: var(--mongodb-green);
8080
text-align: left;
8181
}
8282

src/views/webview-app/connect.module.less

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
@import "~./styles/_variables";
22

3-
a:hover {
4-
color: @green;
5-
}
6-
7-
*:focus {
8-
outline-color: @green-selected;
9-
}
10-
11-
a:focus {
12-
outline-color: @green-selected;
13-
}
14-
153
.page {
164
display: flex;
175
flex-direction: row;
@@ -35,13 +23,6 @@ a:focus {
3523
}
3624
}
3725

38-
label {
39-
display: inline-block;
40-
max-width: 100%;
41-
margin-bottom: 5px;
42-
font-weight: bold;
43-
}
44-
4526
.connect-form-help-panel {
4627
margin: 30px;
4728
display: inline-block;
@@ -51,8 +32,15 @@ label {
5132
.connect {
5233
min-width: 700px;
5334

35+
label {
36+
display: inline-block;
37+
max-width: 100%;
38+
margin-bottom: 5px;
39+
font-weight: bold;
40+
}
41+
5442
&-is-connected {
55-
border: 2px solid @green;
43+
border: 2px solid var(--mongodb-green);
5644
}
5745

5846
::-webkit-scrollbar {

0 commit comments

Comments
 (0)