Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyterlab shows tables in black on black #1167

Open
horsto opened this issue Aug 14, 2024 · 3 comments
Open

Jupyterlab shows tables in black on black #1167

horsto opened this issue Aug 14, 2024 · 3 comments

Comments

@horsto
Copy link
Contributor

horsto commented Aug 14, 2024

In Jupyterlab table previews are suddenly unreadable in dark and dark-high-contrast themes. I am not sure what happened here, but I seem not to be able to revert it to showing the font in white. This might be a jupyter lab issue and not a datajoint issue.

OS: Mac OS
Jupyter lab: Version 4.2.4
Datajoint python: Version 0.14.1

Screenshot 2024-08-14 at 11 38 45
@horsto horsto added the bug label Aug 14, 2024
@CBroz1
Copy link
Contributor

CBroz1 commented Aug 20, 2024

The html table style is defined here, hardcoded for light themes. Not ideal, but running an editable install would allow you to adjust these values

@dimitri-yatsenko
Copy link
Member

@CBroz1 what would you suggest for a better solution?

@CBroz1
Copy link
Contributor

CBroz1 commented Aug 21, 2024

I can see a few possible paths...

  1. Determine theme and adjust html accordingly. Discussion
  • Pros: maintains status quo for light-mode users
  • Cons: maintenance burden of front-end variance
  1. Defer rendering to pandas html, which already adjusts for theme.
  • Pros: offloads maintenance to another package, no additional dependencies
  • Cons:
    • mismatch across versions
    • may require deprecation timeline for html in case someone uses this for other tools
    • minor edits to show primary keys and table header
  1. Add a config option that determines the html displayed
  • Pros: maintains status quo, no interface changes, minimal work
  • Cons: Additional config line item
Example Pandas adjustment for primary keys
import pandas as pd
from IPython.display import display

data = {
    'id': [1, 2, 3],
    'name': ['Alice', 'Bob', 'Charlie'],
    'age': [24, 27, 22],
    'email': ['[email protected]', '[email protected]', '[email protected]']
}
df = pd.DataFrame(data)
primary_key_cols = ['id', 'name']

def style_primary_keys(df, primary_key_cols):
    styled_cols = {col: f"*{col}" if col in primary_key_cols else col for col in df.columns}
    df = df.rename(columns=styled_cols)
    return df

styled_df = style_primary_keys(df, primary_key_cols)
display(styled_df.style)

I don't think 1 is worth the additional maintenance burden. 2 may be the most long-term solution, but 3 is an easier short-term solution. I lean toward 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants