kcarnold commited on
Commit
5a64f8e
·
1 Parent(s): 17c6afc

styling tweaks

Browse files

My Claude prompt was:
I'm looking for a color scheme that presents highlights / alternatives as opportunities, not judgments. They should be clearly distinguished from the non-highlighted text, but not stand out too much, and the non-highlighted text should still be very easy to read. Currently I'm using stroke color for this, but we could consider background coloring instead or in addition.

Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -156,8 +156,8 @@ def highlights_component(spans, show_alternatives, min_loss, show_all_on_hover=F
156
  alternative_to_show = next(token for token in span['topk_tokens'] if token != span['token'])
157
  show_alternative = show and show_alternatives
158
  hover = f'<span class="alternative">{show_token(alternative_to_show, escape_markdown=False)}</span>'
159
- html_out += '<span style="color: {color}" >{hover}{orig_token}</span>'.format(
160
- color="grey" if show else "black",
161
  orig_token=html.escape(span["token"]).replace('\n', '<br>'),
162
  hover=hover if show_all_on_hover or show_alternative else ''
163
  )
@@ -166,9 +166,19 @@ def highlights_component(spans, show_alternatives, min_loss, show_all_on_hover=F
166
  p.highlights-container {{
167
  background: white;
168
  line-height: 2.5;
 
169
  }}
170
  p.highlights-container > span {{
171
  position: relative;
 
 
 
 
 
 
 
 
 
172
  }}
173
  p.highlights-container .alternative {{
174
  display: none;
@@ -176,11 +186,18 @@ def highlights_component(spans, show_alternatives, min_loss, show_all_on_hover=F
176
  p.highlights-container > span:hover .alternative {{
177
  display: inline;
178
  position: absolute;
179
- top: -12px;
180
- left: 5px;
 
181
  min-width: 6em;
182
- line-height: 1;
183
- color: blue;
 
 
 
 
 
 
184
  }}
185
  </style>
186
  <p class="highlights-container">{html_out}</p>
 
156
  alternative_to_show = next(token for token in span['topk_tokens'] if token != span['token'])
157
  show_alternative = show and show_alternatives
158
  hover = f'<span class="alternative">{show_token(alternative_to_show, escape_markdown=False)}</span>'
159
+ html_out += '<span class="{cls}">{hover}{orig_token}</span>'.format(
160
+ cls="highlight" if show else "regular",
161
  orig_token=html.escape(span["token"]).replace('\n', '<br>'),
162
  hover=hover if show_all_on_hover or show_alternative else ''
163
  )
 
166
  p.highlights-container {{
167
  background: white;
168
  line-height: 2.5;
169
+ color: #2C3E50; /* Dark blue-grey for main text */
170
  }}
171
  p.highlights-container > span {{
172
  position: relative;
173
+ padding: 2px 1px;
174
+ border-radius: 3px;
175
+ }}
176
+ p.highlights-container > span.highlight {{
177
+ background-color: #E8F5E9; /* Very light green */
178
+ border-bottom: 2px solid #81C784; /* Medium green */
179
+ }}
180
+ p.highlights-container > span.regular {{
181
+ color: #546E7A; /* Muted blue-grey */
182
  }}
183
  p.highlights-container .alternative {{
184
  display: none;
 
186
  p.highlights-container > span:hover .alternative {{
187
  display: inline;
188
  position: absolute;
189
+ top: -24px;
190
+ left: 50%;
191
+ transform: translateX(-50%);
192
  min-width: 6em;
193
+ text-align: center;
194
+ line-height: 1.2;
195
+ color: #1976D2; /* Clear blue */
196
+ background: white;
197
+ padding: 4px 8px;
198
+ border-radius: 4px;
199
+ border: 1px solid #E0E0E0;
200
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
201
  }}
202
  </style>
203
  <p class="highlights-container">{html_out}</p>