Skip to content

Commit 9597f55

Browse files
authored
refactor: move inline styles to table_widget.css and use cla… (#2357)
This update refactors how the interactive DataFrame widget (anywidget mode) handles styling. It moves styling logic from Python code into dedicated CSS classes, making the display system cleaner and more robust. Fixes #<issue_number_goes_here> 🦕
1 parent 92661f3 commit 9597f55

File tree

1 file changed

+73
-68
lines changed

1 file changed

+73
-68
lines changed

bigframes/display/table_widget.css

Lines changed: 73 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -15,133 +15,138 @@
1515
*/
1616

1717
.bigframes-widget {
18-
display: flex;
19-
flex-direction: column;
18+
display: flex;
19+
flex-direction: column;
2020
}
2121

2222
.bigframes-widget .table-container {
23-
max-height: 620px;
24-
overflow: auto;
23+
max-height: 620px;
24+
overflow: auto;
2525
}
2626

2727
.bigframes-widget .footer {
28-
align-items: center;
29-
/* TODO(b/460861328): We will support dark mode in a media selector once we
30-
* determine how to override the background colors as well. */
31-
color: black;
32-
display: flex;
33-
font-family:
34-
"-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", sans-serif;
35-
font-size: 0.8rem;
36-
justify-content: space-between;
37-
padding: 8px;
28+
align-items: center;
29+
/* TODO(b/460861328): We will support dark mode in a media selector once we
30+
* determine how to override the background colors as well. */
31+
color: black;
32+
display: flex;
33+
font-family:
34+
"-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", sans-serif;
35+
font-size: 0.8rem;
36+
justify-content: space-between;
37+
padding: 8px;
3838
}
3939

4040
.bigframes-widget .footer > * {
41-
flex: 1;
41+
flex: 1;
4242
}
4343

4444
.bigframes-widget .pagination {
45-
align-items: center;
46-
display: flex;
47-
flex-direction: row;
48-
gap: 4px;
49-
justify-content: center;
50-
padding: 4px;
45+
align-items: center;
46+
display: flex;
47+
flex-direction: row;
48+
gap: 4px;
49+
justify-content: center;
50+
padding: 4px;
5151
}
5252

5353
.bigframes-widget .page-indicator {
54-
margin: 0 8px;
54+
margin: 0 8px;
5555
}
5656

5757
.bigframes-widget .row-count {
58-
margin: 0 8px;
58+
margin: 0 8px;
5959
}
6060

6161
.bigframes-widget .page-size {
62-
align-items: center;
63-
display: flex;
64-
flex-direction: row;
65-
gap: 4px;
66-
justify-content: end;
62+
align-items: center;
63+
display: flex;
64+
flex-direction: row;
65+
gap: 4px;
66+
justify-content: end;
6767
}
6868

6969
.bigframes-widget .page-size label {
70-
margin-right: 8px;
70+
margin-right: 8px;
7171
}
7272

7373
.bigframes-widget table {
74-
border-collapse: collapse;
75-
/* TODO(b/460861328): We will support dark mode in a media selector once we
76-
* determine how to override the background colors as well. */
77-
color: black;
78-
text-align: left;
74+
border-collapse: collapse;
75+
/* TODO(b/460861328): We will support dark mode in a media selector once we
76+
* determine how to override the background colors as well. */
77+
color: black;
78+
text-align: left;
7979
}
8080

8181
.bigframes-widget th {
82-
background-color: var(--colab-primary-surface-color, var(--jp-layout-color0));
83-
padding: 0;
84-
position: sticky;
85-
top: 0;
86-
z-index: 1;
82+
background-color: var(--colab-primary-surface-color, var(--jp-layout-color0));
83+
padding: 0;
84+
position: sticky;
85+
text-align: left;
86+
top: 0;
87+
z-index: 1;
8788
}
8889

8990
.bigframes-widget .bf-header-content {
90-
box-sizing: border-box;
91-
height: 100%;
92-
overflow: auto;
93-
padding: 0.5em;
94-
resize: horizontal;
95-
width: 100%;
91+
box-sizing: border-box;
92+
height: 100%;
93+
overflow: auto;
94+
padding: 0.5em;
95+
resize: horizontal;
96+
width: 100%;
9697
}
9798

9899
.bigframes-widget th .sort-indicator {
99-
padding-left: 4px;
100-
visibility: hidden;
100+
padding-left: 4px;
101+
visibility: hidden;
101102
}
102103

103104
.bigframes-widget th:hover .sort-indicator {
104-
visibility: visible;
105+
visibility: visible;
105106
}
106107

107108
.bigframes-widget button {
108-
cursor: pointer;
109-
display: inline-block;
110-
text-align: center;
111-
text-decoration: none;
112-
user-select: none;
113-
vertical-align: middle;
109+
cursor: pointer;
110+
display: inline-block;
111+
text-align: center;
112+
text-decoration: none;
113+
user-select: none;
114+
vertical-align: middle;
114115
}
115116

116117
.bigframes-widget button:disabled {
117-
opacity: 0.65;
118-
pointer-events: none;
118+
opacity: 0.65;
119+
pointer-events: none;
119120
}
120121

121122
.bigframes-widget .bigframes-error-message {
122-
background-color: #fbe;
123-
border: 1px solid red;
124-
border-radius: 4px;
125-
font-family:
126-
"-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", sans-serif;
127-
font-size: 14px;
128-
margin-bottom: 8px;
129-
padding: 8px;
123+
background-color: #fbe;
124+
border: 1px solid red;
125+
border-radius: 4px;
126+
font-family:
127+
"-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", sans-serif;
128+
font-size: 14px;
129+
margin-bottom: 8px;
130+
padding: 8px;
130131
}
131132

132133
.bigframes-widget .cell-align-right {
133-
text-align: right;
134+
text-align: right;
134135
}
135136

136137
.bigframes-widget .cell-align-left {
137-
text-align: left;
138+
text-align: left;
139+
}
140+
141+
.bigframes-widget .null-value {
142+
color: gray;
138143
}
139144

140145
.bigframes-widget td {
141-
padding: 0.5em;
146+
padding: 0.5em;
142147
}
143148

144149
.bigframes-widget tr:hover td,
145150
.bigframes-widget td.row-hover {
146-
background-color: var(--colab-hover-surface-color, var(--jp-layout-color2));
151+
background-color: var(--colab-hover-surface-color, var(--jp-layout-color2));
147152
}

0 commit comments

Comments
 (0)