kcarnold commited on
Commit
212669f
·
1 Parent(s): c95fdb0

refactor: move more to styles instead of inline CSS

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -147,7 +147,7 @@ def highlights_component(spans, show_alternatives, min_loss):
147
  for span in spans:
148
  show = span['token'] != span['most_likely_token'] and span['loss_ratio'] >= min_loss
149
  show_alternative = show and show_alternatives
150
- hover = f'<span style="position: absolute; top: -10px; left: 5px; font-size: 10px; min-width:6em; line-height: 1; color: grey; transform-origin: left; transform: rotate(-15deg)">{span["most_likely_token"]}</span>'
151
  html_out += '<span style="position: relative; color: {color}" title="{title}">{hover}{orig_token}</span>'.format(
152
  color="green" if show else "black",
153
  title=html.escape(span["most_likely_token"]).replace('\n', ' ') if show_alternative else '',
@@ -160,6 +160,17 @@ def highlights_component(spans, show_alternatives, min_loss):
160
  background: white;
161
  line-height: 2.5;
162
  }}
 
 
 
 
 
 
 
 
 
 
 
163
  </style>
164
  <p class="highlights-container">{html_out}</p>
165
  """
 
147
  for span in spans:
148
  show = span['token'] != span['most_likely_token'] and span['loss_ratio'] >= min_loss
149
  show_alternative = show and show_alternatives
150
+ hover = f'<span class="alternative">{span["most_likely_token"]}</span>'
151
  html_out += '<span style="position: relative; color: {color}" title="{title}">{hover}{orig_token}</span>'.format(
152
  color="green" if show else "black",
153
  title=html.escape(span["most_likely_token"]).replace('\n', ' ') if show_alternative else '',
 
160
  background: white;
161
  line-height: 2.5;
162
  }}
163
+ p.highlights-container .alternative {{
164
+ position: absolute;
165
+ top: -10px;
166
+ left: 5px;
167
+ font-size: 10px;
168
+ min-width:6em;
169
+ line-height: 1;
170
+ color: grey;
171
+ transform-origin:
172
+ left; transform: rotate(-15deg);
173
+ }}
174
  </style>
175
  <p class="highlights-container">{html_out}</p>
176
  """