Skip to content

Commit f345f5e

Browse files
committed
chore: remove try catch
1 parent 5889ad5 commit f345f5e

File tree

2 files changed

+35
-43
lines changed

2 files changed

+35
-43
lines changed

bigframes/display/table_widget.css

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
.bigframes-widget {
17+
/* Increase specificity to override framework styles without !important */
18+
.bigframes-widget.bigframes-widget {
1819
/* Default Light Mode Variables */
1920
--bf-bg: white;
2021
--bf-border-color: #ccc;
@@ -27,15 +28,15 @@
2728
--bf-row-even-bg: #f5f5f5;
2829
--bf-row-odd-bg: white;
2930

30-
background-color: var(--bf-bg) !important;
31+
background-color: var(--bf-bg);
3132
box-sizing: border-box;
32-
color: var(--bf-fg) !important;
33+
color: var(--bf-fg);
3334
display: flex;
3435
flex-direction: column;
3536
font-family:
3637
"-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", sans-serif;
37-
margin: 0 !important;
38-
padding: 0 !important;
38+
margin: 0;
39+
padding: 0;
3940
}
4041

4142
.bigframes-widget * {
@@ -44,7 +45,7 @@
4445

4546
/* Dark Mode Overrides via Media Query */
4647
@media (prefers-color-scheme: dark) {
47-
.bigframes-widget {
48+
.bigframes-widget.bigframes-widget {
4849
--bf-bg: var(--vscode-editor-background, #202124);
4950
--bf-border-color: #444;
5051
--bf-error-bg: #511;
@@ -123,29 +124,28 @@
123124
margin-right: 8px;
124125
}
125126

126-
.bigframes-widget table,
127+
.bigframes-widget table.bigframes-widget-table,
127128
.bigframes-widget table.dataframe {
128-
background-color: var(--bf-bg) !important;
129-
/* Explicitly override border="1" defaults */
130-
border: 1px solid var(--bf-border-color) !important;
131-
border-collapse: collapse !important;
132-
border-spacing: 0 !important;
133-
box-shadow: none !important;
134-
color: var(--bf-fg) !important;
135-
margin: 0 !important;
136-
outline: none !important;
129+
background-color: var(--bf-bg);
130+
border: 1px solid var(--bf-border-color);
131+
border-collapse: collapse;
132+
border-spacing: 0;
133+
box-shadow: none;
134+
color: var(--bf-fg);
135+
margin: 0;
136+
outline: none;
137137
text-align: left;
138-
width: auto !important; /* Fix stretching */
138+
width: auto; /* Fix stretching */
139139
}
140140

141141
.bigframes-widget tr {
142-
border: none !important;
142+
border: none;
143143
}
144144

145145
.bigframes-widget th {
146-
background-color: var(--bf-header-bg) !important;
147-
border: 1px solid var(--bf-border-color) !important;
148-
color: var(--bf-fg) !important;
146+
background-color: var(--bf-header-bg);
147+
border: 1px solid var(--bf-border-color);
148+
color: var(--bf-fg);
149149
padding: 0;
150150
position: sticky;
151151
text-align: left;
@@ -154,19 +154,19 @@
154154
}
155155

156156
.bigframes-widget td {
157-
border: 1px solid var(--bf-border-color) !important;
158-
color: var(--bf-fg) !important;
157+
border: 1px solid var(--bf-border-color);
158+
color: var(--bf-fg);
159159
padding: 0.5em;
160160
}
161161

162162
.bigframes-widget table tbody tr:nth-child(odd),
163163
.bigframes-widget table tbody tr:nth-child(odd) td {
164-
background-color: var(--bf-row-odd-bg) !important;
164+
background-color: var(--bf-row-odd-bg);
165165
}
166166

167167
.bigframes-widget table tbody tr:nth-child(even),
168168
.bigframes-widget table tbody tr:nth-child(even) td {
169-
background-color: var(--bf-row-even-bg) !important;
169+
background-color: var(--bf-row-even-bg);
170170
}
171171

172172
.bigframes-widget .bf-header-content {
@@ -229,5 +229,5 @@
229229
}
230230

231231
.bigframes-widget .debug-info {
232-
border-top: 1px solid var(--bf-border-color) !important;
232+
border-top: 1px solid var(--bf-border-color);
233233
}

bigframes/display/table_widget.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,20 @@ function render({ model, el }) {
6262
function setContainerStyles(isDark) {
6363
const body = document.body;
6464
if (isDark) {
65-
// Clear ancestor backgrounds to reveal the dark body background
66-
try {
67-
let parent = el.parentElement;
68-
while (parent && parent !== body) {
69-
parent.style.setProperty(
70-
"background-color",
71-
"transparent",
72-
"important",
73-
);
74-
parent.style.setProperty("padding", "0", "important");
75-
parent = parent.parentElement;
76-
}
77-
} catch (e) {}
65+
// Clear background of ancestors to remove "white frame" from containers.
66+
let parent = el.parentElement;
67+
while (parent && parent !== document.body) {
68+
parent.style.setProperty("background-color", "transparent");
69+
parent.style.setProperty("padding", "0");
70+
parent = parent.parentElement;
71+
}
7872

79-
// Force body and html to dark background to cover full iframe area
8073
if (body) {
81-
body.style.setProperty("background-color", "#202124", "important");
82-
body.style.setProperty("margin", "0", "important");
74+
body.style.setProperty("background-color", "#202124");
75+
body.style.setProperty("margin", "0");
8376
document.documentElement.style.setProperty(
8477
"background-color",
8578
"#202124",
86-
"important",
8779
);
8880
}
8981
} else {

0 commit comments

Comments
 (0)