Richard commited on
Commit
2b894e4
·
1 Parent(s): 6ff3d12

Update with dark theme / light theme

Browse files
components/button.py CHANGED
@@ -64,7 +64,9 @@ def button_toggle(
64
  align_items="center",
65
  display="flex",
66
  # Handle selected case
67
- background=_SELECTED_BG if label == selected else "#FFF",
 
 
68
  padding=_SELECTED_PADDING if label == selected else _PADDING,
69
  cursor="default" if label == selected else "pointer",
70
  # Handle single button case (should just use a button in this case)
@@ -77,14 +79,14 @@ def button_toggle(
77
  me.text(label)
78
 
79
 
80
- _SELECTED_BG = "#DEE2F9"
81
 
82
  _PADDING = me.Padding(left=15, right=15, top=10, bottom=10)
83
  _SELECTED_PADDING = me.Padding(left=15, right=15, top=5, bottom=5)
84
 
85
  _BORDER_RADIUS = "20px"
86
 
87
- _DEFAULT_BORDER_STYLE = me.BorderSide(width=1, color="#74777E", style="solid")
88
  _BORDER = me.Border(
89
  left=_DEFAULT_BORDER_STYLE, top=_DEFAULT_BORDER_STYLE, bottom=_DEFAULT_BORDER_STYLE
90
  )
 
64
  align_items="center",
65
  display="flex",
66
  # Handle selected case
67
+ background=_SELECTED_BG
68
+ if label == selected
69
+ else me.theme_var("surface-container-lowest"),
70
  padding=_SELECTED_PADDING if label == selected else _PADDING,
71
  cursor="default" if label == selected else "pointer",
72
  # Handle single button case (should just use a button in this case)
 
79
  me.text(label)
80
 
81
 
82
+ _SELECTED_BG = me.theme_var("primary-container")
83
 
84
  _PADDING = me.Padding(left=15, right=15, top=10, bottom=10)
85
  _SELECTED_PADDING = me.Padding(left=15, right=15, top=5, bottom=5)
86
 
87
  _BORDER_RADIUS = "20px"
88
 
89
+ _DEFAULT_BORDER_STYLE = me.BorderSide(width=1, color=me.theme_var("outline"), style="solid")
90
  _BORDER = me.Border(
91
  left=_DEFAULT_BORDER_STYLE, top=_DEFAULT_BORDER_STYLE, bottom=_DEFAULT_BORDER_STYLE
92
  )
components/card.py CHANGED
@@ -62,9 +62,11 @@ def expanable_card(
62
 
63
 
64
  _DEFAULT_CARD_STYLE = me.Style(
65
- background="#FFF",
66
  border_radius=10,
67
- border=me.Border.all(me.BorderSide(width=1, color="#DEE2E6", style="solid")),
 
 
68
  padding=me.Padding.all(15),
69
  margin=me.Margin(bottom=15),
70
  )
 
62
 
63
 
64
  _DEFAULT_CARD_STYLE = me.Style(
65
+ background=me.theme_var("surface-container-lowest"),
66
  border_radius=10,
67
+ border=me.Border.all(
68
+ me.BorderSide(width=1, color=me.theme_var("outline-variant"), style="solid")
69
+ ),
70
  padding=me.Padding.all(15),
71
  margin=me.Margin(bottom=15),
72
  )
components/dialog.py CHANGED
@@ -17,7 +17,9 @@ def dialog(is_open: bool):
17
  """
18
  with me.box(
19
  style=me.Style(
20
- background="rgba(0,0,0,0.4)",
 
 
21
  display="block" if is_open else "none",
22
  height="100%",
23
  overflow_x="auto",
@@ -37,7 +39,7 @@ def dialog(is_open: bool):
37
  ):
38
  with me.box(
39
  style=me.Style(
40
- background="#fff",
41
  border_radius=20,
42
  box_sizing="content-box",
43
  box_shadow=("0 3px 1px -2px #0003, 0 2px 2px #00000024, 0 1px 5px #0000001f"),
 
17
  """
18
  with me.box(
19
  style=me.Style(
20
+ background="rgba(0, 0, 0, 0.4)"
21
+ if me.theme_brightness() == "light"
22
+ else "rgba(255, 255, 255, 0.4)",
23
  display="block" if is_open else "none",
24
  height="100%",
25
  overflow_x="auto",
 
39
  ):
40
  with me.box(
41
  style=me.Style(
42
+ background=me.theme_var("surface-container-lowest"),
43
  border_radius=20,
44
  box_sizing="content-box",
45
  box_shadow=("0 3px 1px -2px #0003, 0 2px 2px #00000024, 0 1px 5px #0000001f"),
components/header.py CHANGED
@@ -39,8 +39,14 @@ def header_section():
39
 
40
 
41
  _DEFAULT_STYLE = me.Style(
42
- background="#F5F8FC",
43
- border=me.Border.symmetric(vertical=me.BorderSide(width=1, style="solid", color="#DEE2E6")),
 
 
 
 
 
 
44
  padding=me.Padding.all(10),
45
  )
46
 
 
39
 
40
 
41
  _DEFAULT_STYLE = me.Style(
42
+ background=me.theme_var("surface-container"),
43
+ border=me.Border.symmetric(
44
+ vertical=me.BorderSide(
45
+ width=1,
46
+ style="solid",
47
+ color=me.theme_var("outline-variant"),
48
+ )
49
+ ),
50
  padding=me.Padding.all(10),
51
  )
52
 
components/sidebar.py CHANGED
@@ -12,8 +12,10 @@ def icon_sidebar():
12
  """
13
  with me.box(
14
  style=me.Style(
15
- background="#F5F8FC",
16
- border=me.Border.symmetric(horizontal=me.BorderSide(width=1, style="solid", color="#DEE2E6")),
 
 
17
  height="100%",
18
  )
19
  ):
@@ -31,7 +33,9 @@ def icon_menu_item(*, icon: str, tooltip: str, on_click: Callable | None = None,
31
  key=key,
32
  on_click=on_click,
33
  style=me.Style(
34
- border=me.Border(bottom=me.BorderSide(width=1, color="#DEE2E6", style="solid")),
 
 
35
  cursor="pointer",
36
  padding=me.Padding.all(15),
37
  ),
 
12
  """
13
  with me.box(
14
  style=me.Style(
15
+ background=me.theme_var("surface-container"),
16
+ border=me.Border.symmetric(
17
+ horizontal=me.BorderSide(width=1, style="solid", color=me.theme_var("outline-variant"))
18
+ ),
19
  height="100%",
20
  )
21
  ):
 
33
  key=key,
34
  on_click=on_click,
35
  style=me.Style(
36
+ border=me.Border(
37
+ bottom=me.BorderSide(width=1, color=me.theme_var("outline-variant"), style="solid")
38
+ ),
39
  cursor="pointer",
40
  padding=me.Padding.all(15),
41
  ),
dialogs/add_row.py CHANGED
@@ -25,7 +25,10 @@ def add_row():
25
  mex.button(
26
  "Generate",
27
  on_click=on_click_generate_variables,
28
- style=me.Style(background="#EBF1FD"),
 
 
 
29
  )
30
  variable_names = set(parse_variables(state.prompt))
31
  with me.box(style=me.Style(display="flex", flex_direction="column")):
 
25
  mex.button(
26
  "Generate",
27
  on_click=on_click_generate_variables,
28
+ style=me.Style(
29
+ background=me.theme_var("secondary-container"),
30
+ color=me.theme_var("on-secondary-container"),
31
+ ),
32
  )
33
  variable_names = set(parse_variables(state.prompt))
34
  with me.box(style=me.Style(display="flex", flex_direction="column")):
dialogs/prompt_variables.py CHANGED
@@ -23,7 +23,10 @@ def prompt_variables():
23
  mex.button(
24
  "Generate",
25
  on_click=on_click_generate_variables,
26
- style=me.Style(background="#EBF1FD"),
 
 
 
27
  )
28
  variable_names = set(parse_variables(state.prompt))
29
  with me.box(style=me.Style(display="flex", flex_direction="column")):
 
23
  mex.button(
24
  "Generate",
25
  on_click=on_click_generate_variables,
26
+ style=me.Style(
27
+ background=me.theme_var("secondary-container"),
28
+ color=me.theme_var("on-secondary-container"),
29
+ ),
30
  )
31
  variable_names = set(parse_variables(state.prompt))
32
  with me.box(style=me.Style(display="flex", flex_direction="column")):
eval_table.py CHANGED
@@ -35,12 +35,20 @@ def prompt_eval_table(
35
  if avg_rating is not None:
36
  with me.tooltip(message="Average rating"):
37
  me.text(
38
- f"{avg_rating:.2f}", style=me.Style(font_size=13, color="#666", text_align="center")
 
 
 
39
  )
40
  elif row["type"] == "variable":
41
- me.text(row.get("header_2", ""), style=me.Style(font_size=13, color="#0063FF"))
 
 
42
  else:
43
- me.text(row.get("header_2", ""), style=me.Style(font_size=13, color="#aaa"))
 
 
 
44
 
45
  # Render examples
46
  for row_index, example in enumerate(prompts[0].responses):
@@ -70,7 +78,11 @@ def prompt_eval_table(
70
  with me.content_button(
71
  key=f"run_{row['prompt'].version}_{response_index}_{selected_version_response_index}",
72
  on_click=on_click_run,
73
- style=me.Style(background="#EBF1FD", border_radius="10"),
 
 
 
 
74
  ):
75
  with me.tooltip(message="Run prompt"):
76
  me.icon("play_arrow")
@@ -159,30 +171,30 @@ def _calculate_avg_rating_from_prompt(prompt: Prompt) -> float | None:
159
  return None
160
 
161
 
162
- _BORDER_SIDE = me.BorderSide(width=1, style="solid", color="#DEE2E6")
163
 
164
  _HEADER_STYLE = me.Style(
165
- background="#FFF",
166
  border=me.Border.all(_BORDER_SIDE),
167
- color="#000",
168
  font_size=15,
169
  font_weight="bold",
170
  padding=me.Padding.all(10),
171
  )
172
 
173
  _INDEX_STYLE = me.Style(
174
- background="#FFF",
175
  border=me.Border.all(_BORDER_SIDE),
176
- color="#000",
177
  font_size=14,
178
  padding=me.Padding.all(10),
179
  text_align="center",
180
  )
181
 
182
  _MARKDOWN_BOX_STYLE = me.Style(
183
- background="#FFF",
184
  border=me.Border.all(_BORDER_SIDE),
185
- color="#000",
186
  font_size=14,
187
  padding=me.Padding.all(10),
188
  max_height=300,
@@ -191,8 +203,8 @@ _MARKDOWN_BOX_STYLE = me.Style(
191
  )
192
 
193
  _RATING_STYLE = me.Style(
194
- background="#FFF",
195
  border=me.Border.all(_BORDER_SIDE),
196
- color="#000",
197
  padding=me.Padding.all(10),
198
  )
 
35
  if avg_rating is not None:
36
  with me.tooltip(message="Average rating"):
37
  me.text(
38
+ f"{avg_rating:.2f}",
39
+ style=me.Style(
40
+ font_size=13, color=me.theme_var("on-surface-variant"), text_align="center"
41
+ ),
42
  )
43
  elif row["type"] == "variable":
44
+ me.text(
45
+ row.get("header_2", ""), style=me.Style(font_size=13, color=me.theme_var("primary"))
46
+ )
47
  else:
48
+ me.text(
49
+ row.get("header_2", ""),
50
+ style=me.Style(font_size=13, color=me.theme_var("on-surface-variant")),
51
+ )
52
 
53
  # Render examples
54
  for row_index, example in enumerate(prompts[0].responses):
 
78
  with me.content_button(
79
  key=f"run_{row['prompt'].version}_{response_index}_{selected_version_response_index}",
80
  on_click=on_click_run,
81
+ style=me.Style(
82
+ background=me.theme_var("secondary-container"),
83
+ color=me.theme_var("on-secondary-container"),
84
+ border_radius="10",
85
+ ),
86
  ):
87
  with me.tooltip(message="Run prompt"):
88
  me.icon("play_arrow")
 
171
  return None
172
 
173
 
174
+ _BORDER_SIDE = me.BorderSide(width=1, style="solid", color=me.theme_var("outline-variant"))
175
 
176
  _HEADER_STYLE = me.Style(
177
+ background=me.theme_var("surface-container-lowest"),
178
  border=me.Border.all(_BORDER_SIDE),
179
+ color=me.theme_var("on-surface"),
180
  font_size=15,
181
  font_weight="bold",
182
  padding=me.Padding.all(10),
183
  )
184
 
185
  _INDEX_STYLE = me.Style(
186
+ background=me.theme_var("surface-container-lowest"),
187
  border=me.Border.all(_BORDER_SIDE),
188
+ color=me.theme_var("on-surface"),
189
  font_size=14,
190
  padding=me.Padding.all(10),
191
  text_align="center",
192
  )
193
 
194
  _MARKDOWN_BOX_STYLE = me.Style(
195
+ background=me.theme_var("surface-container-lowest"),
196
  border=me.Border.all(_BORDER_SIDE),
197
+ color=me.theme_var("on-surface"),
198
  font_size=14,
199
  padding=me.Padding.all(10),
200
  max_height=300,
 
203
  )
204
 
205
  _RATING_STYLE = me.Style(
206
+ background=me.theme_var("surface-container-lowest"),
207
  border=me.Border.all(_BORDER_SIDE),
208
+ color=me.theme_var("on-surface"),
209
  padding=me.Padding.all(10),
210
  )
main.py CHANGED
@@ -43,7 +43,7 @@ def app():
43
 
44
  with me.box(
45
  style=me.Style(
46
- background="#FDFDFD",
47
  display="grid",
48
  grid_template_columns="50fr 50fr 1fr",
49
  grid_template_rows="1fr 50fr",
@@ -111,7 +111,10 @@ def app():
111
  mex.button(
112
  "Generate prompt",
113
  disabled=bool(state.prompt),
114
- style=me.Style(background="#EBF1FD"),
 
 
 
115
  on_click=handlers.on_open_dialog,
116
  key="dialog_show_generate_prompt",
117
  )
@@ -266,6 +269,8 @@ def on_select_rating(e: me.SelectSelectionChangeEvent):
266
  # Style helpers
267
 
268
  _STYLE_INVISIBLE_TEXTAREA = me.Style(
 
 
269
  overflow_y="hidden",
270
  width="100%",
271
  outline="none",
 
43
 
44
  with me.box(
45
  style=me.Style(
46
+ background=me.theme_var("surface-container-lowest"),
47
  display="grid",
48
  grid_template_columns="50fr 50fr 1fr",
49
  grid_template_rows="1fr 50fr",
 
111
  mex.button(
112
  "Generate prompt",
113
  disabled=bool(state.prompt),
114
+ style=me.Style(
115
+ background=me.theme_var("secondary-container"),
116
+ color=me.theme_var("on-secondary-container"),
117
+ ),
118
  on_click=handlers.on_open_dialog,
119
  key="dialog_show_generate_prompt",
120
  )
 
269
  # Style helpers
270
 
271
  _STYLE_INVISIBLE_TEXTAREA = me.Style(
272
+ background=me.theme_var("surface-container-lowest"),
273
+ color=me.theme_var("on-surface"),
274
  overflow_y="hidden",
275
  width="100%",
276
  outline="none",
tool_sidebar.py CHANGED
@@ -55,10 +55,22 @@ def tool_sidebar():
55
  mex.icon_menu_item(
56
  icon="download",
57
  tooltip="Download prompt data",
58
- key="dialog_show_download",
59
  on_click=on_click_download,
60
  )
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  def on_click_download(e: me.ClickEvent):
64
  state = me.state(State)
 
55
  mex.icon_menu_item(
56
  icon="download",
57
  tooltip="Download prompt data",
 
58
  on_click=on_click_download,
59
  )
60
 
61
+ mex.icon_menu_item(
62
+ icon="light_mode" if me.theme_brightness() == "dark" else "dark_mode",
63
+ tooltip="Switch to " + ("light mode" if me.theme_brightness() == "dark" else "dark mode"),
64
+ on_click=on_click_theme_brightness,
65
+ )
66
+
67
+
68
+ def on_click_theme_brightness(e: me.ClickEvent):
69
+ if me.theme_brightness() == "light":
70
+ me.set_theme_mode("dark")
71
+ else:
72
+ me.set_theme_mode("light")
73
+
74
 
75
  def on_click_download(e: me.ClickEvent):
76
  state = me.state(State)