Skip to content

Commit f5420d2

Browse files
committed
change to hoveble dot
1 parent 021d35a commit f5420d2

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

bigframes/display/table_widget.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@
5959

6060
.bigframes-widget th {
6161
background-color: var(--colab-primary-surface-color, var(--jp-layout-color0));
62-
cursor: default; /* Default cursor for non-sortable columns */
6362
position: sticky;
6463
top: 0;
6564
z-index: 1;
6665
}
6766

67+
.bigframes-widget th .sort-indicator {
68+
padding-left: 4px;
69+
visibility: hidden;
70+
}
71+
72+
.bigframes-widget th:hover .sort-indicator {
73+
visibility: visible;
74+
}
75+
6876
.bigframes-widget button {
6977
cursor: pointer;
7078
display: inline-block;

bigframes/display/table_widget.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,30 @@ function render({ model, el }) {
144144
// Add click handlers to column headers for sorting
145145
const headers = tableContainer.querySelectorAll("th");
146146
headers.forEach((header) => {
147-
const columnName = header.querySelector("div").textContent.trim();
147+
const headerDiv = header.querySelector("div");
148+
const columnName = headerDiv.textContent.trim();
148149

149150
// Only add sorting UI for sortable columns
150151
if (columnName && sortableColumns.includes(columnName)) {
151152
header.style.cursor = "pointer";
152153

154+
// Create a span for the indicator
155+
const indicatorSpan = document.createElement("span");
156+
indicatorSpan.classList.add("sort-indicator");
157+
153158
// Determine sort indicator
154-
let indicator = " ●"; // Default: unsorted (dot)
159+
let indicator = "●"; // Default: unsorted (dot)
155160
if (currentSortColumn === columnName) {
156-
indicator = currentSortAscending ? " ▲" : " ▼";
161+
indicator = currentSortAscending ? "▲" : "▼";
162+
}
163+
indicatorSpan.textContent = indicator;
164+
165+
// Add indicator to the header, replacing the old one if it exists
166+
const existingIndicator = header.querySelector(".sort-indicator");
167+
if (existingIndicator) {
168+
header.removeChild(existingIndicator);
157169
}
158-
header.textContent = columnName + indicator;
170+
header.appendChild(indicatorSpan);
159171

160172
// Add click handler for three-state toggle
161173
header.addEventListener(Event.CLICK, () => {

notebooks/dataframes/anywidget_mode.ipynb

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
"id": "04406a4d",
4646
"metadata": {},
4747
"source": [
48-
"Set the display option to use anywidget mode and partial ordering mode"
48+
"This notebook demonstrates the anywidget display mode, which provides an interactive table experience.\n",
49+
"Key features include:\n",
50+
"- **Column Sorting:** Click on column headers to sort data in ascending, descending, or unsorted states.\n",
51+
"- **Adjustable Column Widths:** Drag the dividers between column headers to resize columns."
4952
]
5053
},
5154
{
@@ -154,7 +157,7 @@
154157
{
155158
"data": {
156159
"application/vnd.jupyter.widget-view+json": {
157-
"model_id": "9325bb92815d4fa787c1ebda94121c84",
160+
"model_id": "46e7c5b5b5c64f92b445a6a30c4a44fe",
158161
"version_major": 2,
159162
"version_minor": 1
160163
},
@@ -189,12 +192,21 @@
189192
"### Sorting by Column\n",
190193
"You can sort the table by clicking on the headers of columns that have orderable data types (like numbers, strings, and dates). Non-orderable columns (like arrays or structs) do not have sorting controls.\n",
191194
"\n",
192-
"The sorting control cycles through three states:\n",
195+
"**Sorting indicators (●, ▲, ▼) are only visible when you hover over a column header.** The sorting control cycles through three states:\n",
193196
"- **Unsorted (●):** The default state. Click the header to sort in ascending order.\n",
194197
"- **Ascending (▲):** The data is sorted from smallest to largest. Click again to sort in descending order.\n",
195198
"- **Descending (▼):** The data is sorted from largest to smallest. Click again to return to the unsorted state."
196199
]
197200
},
201+
{
202+
"cell_type": "markdown",
203+
"id": "adjustable-width-intro",
204+
"metadata": {},
205+
"source": [
206+
"### Adjustable Column Widths\n",
207+
"You can easily adjust the width of any column in the table. Simply hover your mouse over the vertical dividers between column headers. When the cursor changes to a resize icon, click and drag to expand or shrink the column to your desired width. This allows for better readability and customization of your table view."
208+
]
209+
},
198210
{
199211
"cell_type": "markdown",
200212
"id": "bb15bab6",
@@ -243,7 +255,7 @@
243255
{
244256
"data": {
245257
"application/vnd.jupyter.widget-view+json": {
246-
"model_id": "f0d137094cab410f8b79726ea41b9b37",
258+
"model_id": "cc4b1c62308f4871be28c951737e5407",
247259
"version_major": 2,
248260
"version_minor": 1
249261
},
@@ -357,7 +369,7 @@
357369
{
358370
"data": {
359371
"application/vnd.jupyter.widget-view+json": {
360-
"model_id": "57fc0b7ec7004891b82ea930cb15abb0",
372+
"model_id": "e3fbdff6dd1641aaaf6ed0b0fc4ca372",
361373
"version_major": 2,
362374
"version_minor": 1
363375
},
@@ -397,7 +409,7 @@
397409
"data": {
398410
"text/html": [
399411
"✅ Completed. \n",
400-
" Query processed 85.9 kB in 20 seconds of slot time.\n",
412+
" Query processed 85.9 kB in 22 seconds of slot time.\n",
401413
" "
402414
],
403415
"text/plain": [
@@ -444,7 +456,7 @@
444456
{
445457
"data": {
446458
"application/vnd.jupyter.widget-view+json": {
447-
"model_id": "ac021154201b4b1caf43324d7baf0e44",
459+
"model_id": "8d3a5c29025848779533a64dadf8edb1",
448460
"version_major": 2,
449461
"version_minor": 1
450462
},

0 commit comments

Comments
 (0)