Skip to content

Commit 7eafbe8

Browse files
author
ptwng
authored
Add a new DataprocWidget base class that injects MUI themes. (#56)
1 parent af41f64 commit 7eafbe8

17 files changed

+279
-295
lines changed

src/controls/MuiWrappedInput.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,5 @@ export const Input = styled(InputInternal)<InputProps>({
3838
marginTop: '10px',
3939
'& .MuiInputBase-input': {
4040
padding: '9.5px 14px'
41-
},
42-
'& .MuiOutlinedInput-notchedOutline': {
43-
borderColor: 'rgb(0,0,0)'
4441
}
4542
});

src/controls/MuiWrappedSelect.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,5 @@ export const Select = styled(SelectInternal)<SelectProps>({
4141
marginTop: '10px',
4242
'& .MuiInputBase-input': {
4343
padding: '9.5px 14px'
44-
},
45-
'& .MuiOutlinedInput-notchedOutline': {
46-
borderStyle: 'none'
4744
}
4845
});

src/index.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
JupyterLab,
2222
ILabShell
2323
} from '@jupyterlab/application';
24-
import { MainAreaWidget } from '@jupyterlab/apputils';
24+
import { MainAreaWidget, IThemeManager } from '@jupyterlab/apputils';
2525
import { ILauncher } from '@jupyterlab/launcher';
2626
import { LabIcon } from '@jupyterlab/ui-components';
2727
import { IMainMenu } from '@jupyterlab/mainmenu';
@@ -47,13 +47,14 @@ import { RuntimeTemplate } from './runtime/runtimeTemplate';
4747
const extension: JupyterFrontEndPlugin<void> = {
4848
id: 'dataproc_jupyter_plugin:plugin',
4949
autoStart: true,
50-
optional: [ILauncher, IMainMenu, ILabShell, INotebookTracker],
50+
optional: [ILauncher, IMainMenu, ILabShell, INotebookTracker, IThemeManager],
5151
activate: async (
5252
app: JupyterFrontEnd,
5353
launcher: ILauncher,
5454
mainMenu: IMainMenu,
5555
labShell: ILabShell,
56-
notebookTracker: INotebookTracker
56+
notebookTracker: INotebookTracker,
57+
themeManager: IThemeManager
5758
) => {
5859
const { commands } = app;
5960
const iconAddRuntime = new LabIcon({
@@ -168,7 +169,7 @@ const extension: JupyterFrontEndPlugin<void> = {
168169
// @ts-ignore jupyter lab icon command issue
169170
icon: args => (args['isPalette'] ? null : iconAddRuntime),
170171
execute: () => {
171-
const content = new RuntimeTemplate(app as JupyterLab);
172+
const content = new RuntimeTemplate(app as JupyterLab, themeManager);
172173
const widget = new MainAreaWidget<RuntimeTemplate>({ content });
173174
widget.title.label = 'Runtime template';
174175
widget.title.icon = iconServerless;
@@ -210,7 +211,7 @@ const extension: JupyterFrontEndPlugin<void> = {
210211
commands.addCommand(createAuthLoginComponentCommand, {
211212
label: 'Cloud Dataproc Settings',
212213
execute: () => {
213-
const content = new AuthLogin();
214+
const content = new AuthLogin(themeManager);
214215
const widget = new MainAreaWidget<AuthLogin>({ content });
215216
widget.title.label = 'Config Setup';
216217
widget.title.icon = iconCluster;

src/login/authLogin.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { ReactWidget } from '@jupyterlab/apputils';
1918
import React, { useEffect, useState } from 'react';
2019
import { LabIcon } from '@jupyterlab/ui-components';
2120
import signinGoogleIcon from '../../style/icons/signin_google_icon.svg';
@@ -24,6 +23,7 @@ import ConfigSelection from './configSelection';
2423
import { LOGIN_STATE, STATUS_SUCCESS } from '../utils/const';
2524
import { checkConfig } from '../utils/utils';
2625
import { ClipLoader } from 'react-spinners';
26+
import { DataprocWidget } from '../controls/DataprocWidget';
2727

2828
// Create the LabIcon instance outside of the component
2929
const IconsigninGoogle = new LabIcon({
@@ -111,12 +111,8 @@ const AuthLoginComponent = (): React.JSX.Element => {
111111
);
112112
};
113113

114-
export class AuthLogin extends ReactWidget {
115-
constructor() {
116-
super();
117-
}
118-
119-
render(): React.JSX.Element {
114+
export class AuthLogin extends DataprocWidget {
115+
renderInternal(): React.JSX.Element {
120116
return <AuthLoginComponent />;
121117
}
122118
}

src/runtime/runtimeTemplate.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { ReactWidget } from '@jupyterlab/apputils';
1918
import React, { useEffect, useState } from 'react';
2019
import CreateRuntime from './createRunTime';
2120
import { JupyterLab } from '@jupyterlab/application';
2221
import { SessionTemplate } from '../utils/listRuntimeTemplateInterface';
22+
import { DataprocWidget } from '../controls/DataprocWidget';
23+
import { IThemeManager } from '@jupyterlab/apputils';
2324

2425
const RuntimeTemplateComponent = ({
2526
app
@@ -45,15 +46,15 @@ const RuntimeTemplateComponent = ({
4546
);
4647
};
4748

48-
export class RuntimeTemplate extends ReactWidget {
49+
export class RuntimeTemplate extends DataprocWidget {
4950
app: JupyterLab;
5051

51-
constructor(app: JupyterLab) {
52-
super();
52+
constructor(app: JupyterLab, themeManager: IThemeManager) {
53+
super(themeManager);
5354
this.app = app;
5455
}
5556

56-
render(): React.JSX.Element {
57+
renderInternal(): React.JSX.Element {
5758
return <RuntimeTemplateComponent app={this.app} />;
5859
}
5960
}

style/authLogin.css

+18-18
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
font-weight: 400;
2525
font-size: 18px;
2626
line-height: 22px;
27-
color: #000000;
27+
color: var(--jp-ui-font-color0);
2828
padding-left: 10px;
2929
padding-bottom: 5px;
3030
}
@@ -57,18 +57,18 @@
5757
line-height: 13px;
5858
display: flex;
5959
align-items: center;
60-
color: #000000;
60+
color: var(--jp-ui-font-color0);
6161
position: absolute;
62-
background-color: #fff;
62+
background-color: var(--jp-layout-color0);
6363
bottom: 32px;
6464
padding-left: 2px;
6565
left: 7px;
6666
}
6767

6868
.project-select {
6969
box-sizing: border-box;
70-
background: #ffffff !important;
71-
border: 1px solid rgba(0, 0, 0, 0.38) !important;
70+
background: var(--jp-layout-color0) !important;
71+
border: 1px solid var(--jp-ui-font-color2) !important;
7272
display: block !important;
7373
height: 36px;
7474
width: 100%;
@@ -88,9 +88,9 @@
8888
line-height: 13px;
8989
display: flex;
9090
align-items: center;
91-
color: #000000;
91+
color: var(--jp-ui-font-color0);
9292
position: absolute;
93-
background-color: #fff;
93+
background-color: var(--jp-layout-color0);
9494
padding-right: 4px;
9595
bottom: 34px;
9696
padding-left: 2px;
@@ -99,8 +99,8 @@
9999

100100
.region-select {
101101
box-sizing: border-box;
102-
background: #ffffff !important;
103-
border: 1px solid rgba(0, 0, 0, 0.38) !important;
102+
background: var(--jp-layout-color0) !important;
103+
border: 1px solid var(--jp-ui-font-color2) !important;
104104
display: block !important;
105105
height: 40px;
106106
width: 100%;
@@ -126,8 +126,8 @@
126126
.save-button {
127127
height: 32px;
128128
background: #3367d6;
129-
box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.12), 0px 2px 2px rgba(0, 0, 0, 0.2),
130-
0px 1px 1px rgba(0, 0, 0, 0.14);
129+
box-shadow: 0px 1px 5px var(--jp-layout-color4),
130+
0px 2px 2px rgba(0, 0, 0, 0.2), 0px 1px 1px var(--jp-layout-color4);
131131
border-radius: 4px;
132132
flex: none;
133133
width: 65px;
@@ -138,13 +138,13 @@
138138
align-items: center;
139139
text-align: center;
140140
text-transform: uppercase;
141-
color: #ffffff;
141+
color: var(--jp-layout-color0);
142142
border: none;
143143
cursor: pointer;
144144
}
145145
.save-button:disabled {
146146
background: lightgrey;
147-
color: black;
147+
color: var(--jp-ui-font-color0);
148148
}
149149
.save-loader {
150150
margin-top: 5px;
@@ -153,7 +153,7 @@
153153
box-sizing: border-box;
154154
width: 344px;
155155
height: fit-content;
156-
background: #ffffff;
156+
background: var(--jp-layout-color0);
157157
border: 1px solid #b0b0b0;
158158
border-radius: 27px;
159159
margin-left: 21%;
@@ -207,7 +207,7 @@
207207
font-weight: 500;
208208
font-size: 12px;
209209
line-height: 17px;
210-
color: #000000;
210+
color: var(--jp-ui-font-color0);
211211
padding-left: 30px;
212212
padding-top: 20px;
213213
justify-content: center;
@@ -249,13 +249,13 @@
249249
}
250250
.ui.dropdown .menu .selected.item,
251251
.ui.dropdown.selected {
252-
background: rgb(230, 236, 250) !important;
253-
color: rgb(28, 58, 169) !important;
252+
background: var(--jp-layout-color0) !important;
253+
color: var(--jp-brand-color0) !important;
254254
}
255255
.runtime-title-section {
256256
display: flex;
257257
justify-content: space-between;
258-
color: #000;
258+
color: var(--jp-ui-font-color0);
259259
font-size: 20px;
260260
font-style: normal;
261261
font-weight: 500;

style/base.css

+9-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616

1717
/*Changing Icon for category with image pyspark*/
18-
.f1hgkb35 svg[data-icon="launcher:pyspark-logo-icon"] {
18+
.f1hgkb35 svg[data-icon='launcher:pyspark-logo-icon'] {
1919
content-visibility: hidden;
2020
display: block;
2121
height: 32px;
@@ -25,7 +25,7 @@
2525
}
2626

2727
/*Changing Icon for category with image cluster*/
28-
.f1hgkb35 svg[data-icon="launcher:clusters-icon"] {
28+
.f1hgkb35 svg[data-icon='launcher:clusters-icon'] {
2929
content-visibility: hidden;
3030
display: block;
3131
height: 32px;
@@ -35,7 +35,7 @@
3535
}
3636

3737
/*Changing Icon for category with image python*/
38-
.f1hgkb35 svg[data-icon="launcher:python-logo-icon"] {
38+
.f1hgkb35 svg[data-icon='launcher:python-logo-icon'] {
3939
content-visibility: hidden;
4040
display: block;
4141
height: 32px;
@@ -45,7 +45,7 @@
4545
}
4646

4747
/*Changing Icon for category with image sparkR*/
48-
.f1hgkb35 svg[data-icon="launcher:sparkr-logo-icon"] {
48+
.f1hgkb35 svg[data-icon='launcher:sparkr-logo-icon'] {
4949
content-visibility: hidden;
5050
display: block;
5151
height: 32px;
@@ -55,7 +55,7 @@
5555
}
5656

5757
/*Changing Icon for category with image scala*/
58-
.f1hgkb35 svg[data-icon="launcher:scala-logo-icon"] {
58+
.f1hgkb35 svg[data-icon='launcher:scala-logo-icon'] {
5959
content-visibility: hidden;
6060
display: block;
6161
height: 32px;
@@ -70,15 +70,14 @@ h2 {
7070
margin: 15px 0px !important;
7171
}
7272

73-
.ui.dropdown:not(.button)>.default.text {
74-
color: rgba(0, 0, 0, 0.66) !important;
73+
.ui.dropdown:not(.button) > .default.text {
74+
color: var(--jp-ui-font-color2) !important;
7575
}
7676

7777
/* Highlight select dropdown field when focus */
7878
.ui.selection.active.dropdown:focus {
79-
border: 3px solid #3367D6 !important;
79+
border: 3px solid #3367d6 !important;
8080
}
8181
.ui.selection.dropdown {
82-
min-width:5em !important;
82+
min-width: 5em !important;
8383
}
84-

style/batches.css

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.batch-header-part {
22
display: flex;
3-
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
3+
border-bottom: 1px solid var(--jp-layout-color4);
44
}
55

66
.create-batch-overlay {
@@ -18,7 +18,7 @@
1818
line-height: 18px;
1919
width: 65%;
2020
padding-left: 30px;
21-
color: #000000;
21+
color: var(--jp-ui-font-color0);
2222
overflow-wrap: anywhere;
2323
}
2424

@@ -29,7 +29,7 @@
2929
line-height: 18px;
3030
width: 65%;
3131
padding-left: 45px;
32-
color: #000000;
32+
color: var(--jp-ui-font-color0);
3333
overflow-wrap: anywhere;
3434
}
3535

@@ -47,7 +47,7 @@
4747
font-size: 13px;
4848
line-height: 18px;
4949
width: 65%;
50-
color: #000000;
50+
color: var(--jp-ui-font-color0);
5151
}
5252
.batch-details-label-level-one {
5353
font-style: normal;
@@ -56,7 +56,7 @@
5656
line-height: 18px;
5757
width: 65%;
5858
padding-left: 15px;
59-
color: #000000;
59+
color: var(--jp-ui-font-color0);
6060
overflow-wrap: anywhere;
6161
}
6262
.details-value {
@@ -65,19 +65,17 @@
6565
font-size: 13px;
6666
line-height: 20px;
6767
width: 35%;
68-
color: rgba(0, 0, 0, 0.66);
68+
color: var(--jp-ui-font-color2);
6969
}
7070
.batch-details-row-label {
71-
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
71+
border-bottom: 1px solid var(--jp-layout-color4);
7272
display: flex;
7373
justify-content: flex-start;
7474
align-items: flex-start;
7575
min-height: 18px;
7676
margin-bottom: 6px;
7777
}
78-
.scroll-comp-batch{
79-
80-
overflow-y: auto;
81-
max-height: 85vh;
82-
83-
}
78+
.scroll-comp-batch {
79+
overflow-y: auto;
80+
max-height: 85vh;
81+
}

0 commit comments

Comments
 (0)