openhands commited on
Commit
bc09902
·
1 Parent(s): 3ea4450

Use separate logos for light and dark mode in plots

Browse files

- Added get_openhands_logo_images() that returns both light and dark logos
- Light mode uses openhands_logo_color_forwhite.png
- Dark mode uses openhands_logo_color_forblack.png
- CSS shows/hides appropriate logo based on .dark class
- Dark mode logo doesn't get inverted (uses actual dark logo file)

Files changed (3) hide show
  1. content.py +24 -0
  2. leaderboard_transformer.py +35 -13
  3. visualizations.py +35 -13
content.py CHANGED
@@ -1149,6 +1149,30 @@ h3 .header-link-icon {
1149
  filter: invert(1) hue-rotate(180deg);
1150
  }
1151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1152
  /* Modebar icons need re-inversion */
1153
  .dark .js-plotly-plot .modebar {
1154
  filter: invert(1) hue-rotate(180deg);
 
1149
  filter: invert(1) hue-rotate(180deg);
1150
  }
1151
 
1152
+ /* OpenHands logo visibility - light mode logo hidden in dark mode */
1153
+ .dark .js-plotly-plot image[href*="openhands=lightlogo"],
1154
+ .dark .js-plotly-plot image[xlink\\:href*="openhands=lightlogo"] {
1155
+ display: none !important;
1156
+ }
1157
+
1158
+ /* OpenHands logo visibility - dark mode logo uses the actual dark logo file, no inversion needed */
1159
+ .dark .js-plotly-plot image[href*="openhands=darklogo"],
1160
+ .dark .js-plotly-plot image[xlink\\:href*="openhands=darklogo"] {
1161
+ filter: none !important;
1162
+ }
1163
+
1164
+ /* Light mode: hide the dark logo */
1165
+ .js-plotly-plot image[href*="openhands=darklogo"],
1166
+ .js-plotly-plot image[xlink\\:href*="openhands=darklogo"] {
1167
+ display: none;
1168
+ }
1169
+
1170
+ /* Light mode: show the light logo (this is the default, but being explicit) */
1171
+ .dark .js-plotly-plot image[href*="openhands=darklogo"],
1172
+ .dark .js-plotly-plot image[xlink\\:href*="openhands=darklogo"] {
1173
+ display: block !important;
1174
+ }
1175
+
1176
  /* Modebar icons need re-inversion */
1177
  .dark .js-plotly-plot .modebar {
1178
  filter: invert(1) hue-rotate(180deg);
leaderboard_transformer.py CHANGED
@@ -62,19 +62,21 @@ URL_ANNOTATION = dict(
62
  )
63
 
64
 
65
- def get_openhands_logo_image():
66
- """Get the OpenHands logo as a Plotly image dict for chart branding.
67
 
68
- Uses a special MIME type parameter (;openhands=logo) to allow CSS targeting.
69
- This enables CSS attribute selectors to identify this specific image.
70
  """
 
 
 
71
  if os.path.exists(OPENHANDS_LOGO_PATH_LIGHT):
72
  try:
73
  with open(OPENHANDS_LOGO_PATH_LIGHT, "rb") as f:
74
  logo_data = base64.b64encode(f.read()).decode('utf-8')
75
- # Add openhands=logo parameter to MIME type for CSS targeting
76
- return dict(
77
- source=f"data:image/png;openhands=logo;base64,{logo_data}",
78
  xref="paper",
79
  yref="paper",
80
  x=0,
@@ -83,19 +85,39 @@ def get_openhands_logo_image():
83
  sizey=0.15,
84
  xanchor="left",
85
  yanchor="bottom",
86
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  except Exception:
88
  pass
89
- return None
 
90
 
91
 
92
  def add_branding_to_figure(fig: go.Figure) -> go.Figure:
93
  """Add OpenHands logo and URL to a Plotly figure."""
94
- # Add logo image
95
- logo_image = get_openhands_logo_image()
96
- if logo_image:
97
  existing_images = list(fig.layout.images) if fig.layout.images else []
98
- existing_images.append(logo_image)
99
  fig.update_layout(images=existing_images)
100
 
101
  # Add URL annotation
 
62
  )
63
 
64
 
65
+ def get_openhands_logo_images():
66
+ """Get both light and dark mode OpenHands logos as Plotly image dicts.
67
 
68
+ Returns two images - one for light mode (forwhite) and one for dark mode (forblack).
69
+ CSS is used to show/hide the appropriate logo based on the current mode.
70
  """
71
+ images = []
72
+
73
+ # Light mode logo (visible in light mode, hidden in dark mode)
74
  if os.path.exists(OPENHANDS_LOGO_PATH_LIGHT):
75
  try:
76
  with open(OPENHANDS_LOGO_PATH_LIGHT, "rb") as f:
77
  logo_data = base64.b64encode(f.read()).decode('utf-8')
78
+ images.append(dict(
79
+ source=f"data:image/png;openhands=lightlogo;base64,{logo_data}",
 
80
  xref="paper",
81
  yref="paper",
82
  x=0,
 
85
  sizey=0.15,
86
  xanchor="left",
87
  yanchor="bottom",
88
+ ))
89
+ except Exception:
90
+ pass
91
+
92
+ # Dark mode logo (hidden in light mode, visible in dark mode)
93
+ if os.path.exists(OPENHANDS_LOGO_PATH_DARK):
94
+ try:
95
+ with open(OPENHANDS_LOGO_PATH_DARK, "rb") as f:
96
+ logo_data = base64.b64encode(f.read()).decode('utf-8')
97
+ images.append(dict(
98
+ source=f"data:image/png;openhands=darklogo;base64,{logo_data}",
99
+ xref="paper",
100
+ yref="paper",
101
+ x=0,
102
+ y=-0.15,
103
+ sizex=0.15,
104
+ sizey=0.15,
105
+ xanchor="left",
106
+ yanchor="bottom",
107
+ ))
108
  except Exception:
109
  pass
110
+
111
+ return images
112
 
113
 
114
  def add_branding_to_figure(fig: go.Figure) -> go.Figure:
115
  """Add OpenHands logo and URL to a Plotly figure."""
116
+ # Add both light and dark mode logo images
117
+ logo_images = get_openhands_logo_images()
118
+ if logo_images:
119
  existing_images = list(fig.layout.images) if fig.layout.images else []
120
+ existing_images.extend(logo_images)
121
  fig.update_layout(images=existing_images)
122
 
123
  # Add URL annotation
visualizations.py CHANGED
@@ -63,19 +63,21 @@ URL_ANNOTATION = dict(
63
  )
64
 
65
 
66
- def get_openhands_logo_image():
67
- """Get the OpenHands logo as a Plotly image dict for chart branding.
68
 
69
- Uses a special MIME type parameter (;openhands=logo) to allow CSS targeting.
70
- This enables CSS attribute selectors to identify this specific image.
71
  """
 
 
 
72
  if os.path.exists(OPENHANDS_LOGO_PATH_LIGHT):
73
  try:
74
  with open(OPENHANDS_LOGO_PATH_LIGHT, "rb") as f:
75
  logo_data = base64.b64encode(f.read()).decode('utf-8')
76
- # Add openhands=logo parameter to MIME type for CSS targeting
77
- return dict(
78
- source=f"data:image/png;openhands=logo;base64,{logo_data}",
79
  xref="paper",
80
  yref="paper",
81
  x=0,
@@ -84,19 +86,39 @@ def get_openhands_logo_image():
84
  sizey=0.15,
85
  xanchor="left",
86
  yanchor="bottom",
87
- )
88
  except Exception:
89
  pass
90
- return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
 
93
  def add_branding_to_figure(fig: go.Figure) -> go.Figure:
94
  """Add OpenHands logo and URL to a Plotly figure."""
95
- # Add logo image
96
- logo_image = get_openhands_logo_image()
97
- if logo_image:
98
  existing_images = list(fig.layout.images) if fig.layout.images else []
99
- existing_images.append(logo_image)
100
  fig.update_layout(images=existing_images)
101
 
102
  # Add URL annotation
 
63
  )
64
 
65
 
66
+ def get_openhands_logo_images():
67
+ """Get both light and dark mode OpenHands logos as Plotly image dicts.
68
 
69
+ Returns two images - one for light mode (forwhite) and one for dark mode (forblack).
70
+ CSS is used to show/hide the appropriate logo based on the current mode.
71
  """
72
+ images = []
73
+
74
+ # Light mode logo (visible in light mode, hidden in dark mode)
75
  if os.path.exists(OPENHANDS_LOGO_PATH_LIGHT):
76
  try:
77
  with open(OPENHANDS_LOGO_PATH_LIGHT, "rb") as f:
78
  logo_data = base64.b64encode(f.read()).decode('utf-8')
79
+ images.append(dict(
80
+ source=f"data:image/png;openhands=lightlogo;base64,{logo_data}",
 
81
  xref="paper",
82
  yref="paper",
83
  x=0,
 
86
  sizey=0.15,
87
  xanchor="left",
88
  yanchor="bottom",
89
+ ))
90
  except Exception:
91
  pass
92
+
93
+ # Dark mode logo (hidden in light mode, visible in dark mode)
94
+ if os.path.exists(OPENHANDS_LOGO_PATH_DARK):
95
+ try:
96
+ with open(OPENHANDS_LOGO_PATH_DARK, "rb") as f:
97
+ logo_data = base64.b64encode(f.read()).decode('utf-8')
98
+ images.append(dict(
99
+ source=f"data:image/png;openhands=darklogo;base64,{logo_data}",
100
+ xref="paper",
101
+ yref="paper",
102
+ x=0,
103
+ y=-0.15,
104
+ sizex=0.15,
105
+ sizey=0.15,
106
+ xanchor="left",
107
+ yanchor="bottom",
108
+ ))
109
+ except Exception:
110
+ pass
111
+
112
+ return images
113
 
114
 
115
  def add_branding_to_figure(fig: go.Figure) -> go.Figure:
116
  """Add OpenHands logo and URL to a Plotly figure."""
117
+ # Add both light and dark mode logo images
118
+ logo_images = get_openhands_logo_images()
119
+ if logo_images:
120
  existing_images = list(fig.layout.images) if fig.layout.images else []
121
+ existing_images.extend(logo_images)
122
  fig.update_layout(images=existing_images)
123
 
124
  # Add URL annotation