openhands commited on
Commit
acd5bf8
·
1 Parent(s): 0750050

Consolidate font definitions into single source of truth

Browse files

Create constants.py with FONT_FAMILY and FONT_FAMILY_SHORT.
All Python files now import and use these constants instead of
hardcoded font values.

Files changed (5) hide show
  1. app.py +3 -1
  2. constants.py +5 -0
  3. content.py +4 -3
  4. leaderboard_transformer.py +5 -4
  5. visualizations.py +3 -2
app.py CHANGED
@@ -3,6 +3,8 @@ import logging
3
  import sys
4
  import os
5
 
 
 
6
  logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
7
  logger = logging.getLogger(__name__)
8
 
@@ -202,7 +204,7 @@ theme = gr.themes.Base(
202
  c50="#F7F8FB", c100="#EBEDF3", c200="#D4D8E7", c300="#B1B9D3", c400="#82889B",
203
  c500="#525662", c600="#3A3C45", c700="#2F3137", c800="#222328", c900="#18191C", c950="#0D0D0F"
204
  ),
205
- font=['Arial', 'sans-serif'],
206
  font_mono=['monospace'],
207
  ).set(
208
  body_text_color='*neutral_950',
 
3
  import sys
4
  import os
5
 
6
+ from constants import FONT_FAMILY_SHORT
7
+
8
  logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
9
  logger = logging.getLogger(__name__)
10
 
 
204
  c50="#F7F8FB", c100="#EBEDF3", c200="#D4D8E7", c300="#B1B9D3", c400="#82889B",
205
  c500="#525662", c600="#3A3C45", c700="#2F3137", c800="#222328", c900="#18191C", c950="#0D0D0F"
206
  ),
207
+ font=[FONT_FAMILY_SHORT, 'sans-serif'],
208
  font_mono=['monospace'],
209
  ).set(
210
  body_text_color='*neutral_950',
constants.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Single source of truth for styling constants
2
+
3
+ # Font settings
4
+ FONT_FAMILY = "Arial, sans-serif"
5
+ FONT_FAMILY_SHORT = "Arial" # For places that don't accept fallbacks
content.py CHANGED
@@ -1,4 +1,5 @@
1
  import re
 
2
 
3
  def create_gradio_anchor_id(text: str, validation) -> str:
4
  """
@@ -233,7 +234,7 @@ def hf_uri_to_web_url(uri: str) -> str:
233
  return f"https://huggingface.co/datasets/{namespace}/{repo}/tree/main/{path}"
234
 
235
 
236
- css = """
237
  /* CSS Color Variables aligned with OpenHands brand (openhands-ui/tokens.css) */
238
  :root {
239
  /* Primary - Yellow */
@@ -400,7 +401,7 @@ thead.svelte-1e98i6s th {
400
  background: var(--color-background-dark) !important;
401
  }
402
  .cell-wrap.svelte-v1pjjd {
403
- font-family: Arial, sans-serif;
404
  }
405
  nav.svelte-ti537g.svelte-ti537g {
406
  justify-content: flex-start;
@@ -462,7 +463,7 @@ nav.svelte-ti537g.svelte-ti537g {
462
  line-height: 1.2 !important;
463
  vertical-align: top !important;
464
  font-size: 12px !important;
465
- font-family: Arial, sans-serif;
466
  }
467
  .wrap-header-df th {
468
  height: auto !important;
 
1
  import re
2
+ from constants import FONT_FAMILY
3
 
4
  def create_gradio_anchor_id(text: str, validation) -> str:
5
  """
 
234
  return f"https://huggingface.co/datasets/{namespace}/{repo}/tree/main/{path}"
235
 
236
 
237
+ css = f"""
238
  /* CSS Color Variables aligned with OpenHands brand (openhands-ui/tokens.css) */
239
  :root {
240
  /* Primary - Yellow */
 
401
  background: var(--color-background-dark) !important;
402
  }
403
  .cell-wrap.svelte-v1pjjd {
404
+ font-family: {FONT_FAMILY};
405
  }
406
  nav.svelte-ti537g.svelte-ti537g {
407
  justify-content: flex-start;
 
463
  line-height: 1.2 !important;
464
  vertical-align: top !important;
465
  font-size: 12px !important;
466
+ font-family: {FONT_FAMILY};
467
  }
468
  .wrap-header-df th {
469
  height: auto !important;
leaderboard_transformer.py CHANGED
@@ -8,6 +8,7 @@ import html
8
  import os
9
 
10
  import aliases
 
11
 
12
  logger = logging.getLogger(__name__)
13
 
@@ -55,7 +56,7 @@ URL_ANNOTATION = dict(
55
  yanchor="bottom",
56
  showarrow=False,
57
  font=dict(
58
- family="Arial, sans-serif",
59
  size=14,
60
  color="#82889B", # neutral-400
61
  ),
@@ -785,7 +786,7 @@ def _plot_scatter_plotly(
785
  font=dict(
786
  size=10,
787
  color='#0D0D0F', # neutral-950
788
- family='Arial'
789
  ),
790
  xanchor='center',
791
  yanchor='bottom'
@@ -816,13 +817,13 @@ def _plot_scatter_plotly(
816
  ),
817
  height=572,
818
  font=dict(
819
- family="Arial, sans-serif",
820
  color="#0D0D0F", # neutral-950
821
  ),
822
  hoverlabel=dict(
823
  bgcolor="#222328", # neutral-800
824
  font_size=12,
825
- font_family="Arial",
826
  font_color="#F7F8FB", # neutral-50
827
  ),
828
  # Add margin at bottom for logo and URL
 
8
  import os
9
 
10
  import aliases
11
+ from constants import FONT_FAMILY, FONT_FAMILY_SHORT
12
 
13
  logger = logging.getLogger(__name__)
14
 
 
56
  yanchor="bottom",
57
  showarrow=False,
58
  font=dict(
59
+ family=FONT_FAMILY,
60
  size=14,
61
  color="#82889B", # neutral-400
62
  ),
 
786
  font=dict(
787
  size=10,
788
  color='#0D0D0F', # neutral-950
789
+ family=FONT_FAMILY_SHORT
790
  ),
791
  xanchor='center',
792
  yanchor='bottom'
 
817
  ),
818
  height=572,
819
  font=dict(
820
+ family=FONT_FAMILY,
821
  color="#0D0D0F", # neutral-950
822
  ),
823
  hoverlabel=dict(
824
  bgcolor="#222328", # neutral-800
825
  font_size=12,
826
+ font_family=FONT_FAMILY_SHORT,
827
  font_color="#F7F8FB", # neutral-50
828
  ),
829
  # Add margin at bottom for logo and URL
visualizations.py CHANGED
@@ -8,6 +8,7 @@ from datetime import datetime
8
  import os
9
  import base64
10
  import aliases
 
11
 
12
  # Import company logo mapping from leaderboard_transformer
13
  from leaderboard_transformer import get_company_from_model
@@ -19,13 +20,13 @@ STANDARD_LAYOUT = dict(
19
  template="plotly_white",
20
  height=572,
21
  font=dict(
22
- family="Outfit, ui-sans-serif, sans-serif",
23
  color="#0D0D0F", # neutral-950
24
  ),
25
  hoverlabel=dict(
26
  bgcolor="#222328", # neutral-800
27
  font_size=12,
28
- font_family="Outfit",
29
  font_color="#F7F8FB", # neutral-50
30
  ),
31
  legend=dict(
 
8
  import os
9
  import base64
10
  import aliases
11
+ from constants import FONT_FAMILY, FONT_FAMILY_SHORT
12
 
13
  # Import company logo mapping from leaderboard_transformer
14
  from leaderboard_transformer import get_company_from_model
 
20
  template="plotly_white",
21
  height=572,
22
  font=dict(
23
+ family=FONT_FAMILY,
24
  color="#0D0D0F", # neutral-950
25
  ),
26
  hoverlabel=dict(
27
  bgcolor="#222328", # neutral-800
28
  font_size=12,
29
+ font_family=FONT_FAMILY_SHORT,
30
  font_color="#F7F8FB", # neutral-50
31
  ),
32
  legend=dict(