cdpearlman commited on
Commit
1cce926
·
1 Parent(s): 2800225

Fixed glossary UI to be cleaner

Browse files
Files changed (3) hide show
  1. app.py +5 -5
  2. assets/style.css +53 -0
  3. components/glossary.py +8 -27
app.py CHANGED
@@ -159,11 +159,11 @@ app.layout = html.Div([
159
  # ============================================================================
160
 
161
  @app.callback(
162
- [Output("glossary-modal-overlay", "style"),
163
- Output("glossary-modal-content", "style")],
164
  [Input("open-glossary-btn", "n_clicks"),
165
  Input("close-glossary-btn", "n_clicks"),
166
- Input("glossary-modal-overlay", "n_clicks")],
167
  prevent_initial_call=True
168
  )
169
  def toggle_glossary(open_clicks, close_clicks, overlay_clicks):
@@ -172,9 +172,9 @@ def toggle_glossary(open_clicks, close_clicks, overlay_clicks):
172
  return no_update, no_update
173
  trigger_id = ctx.triggered[0]["prop_id"].split(".")[0]
174
  if trigger_id == "open-glossary-btn":
175
- return {'display': 'flex'}, {'display': 'block'}
176
  else:
177
- return {'display': 'none'}, {'display': 'none'}
178
 
179
 
180
  # ============================================================================
 
159
  # ============================================================================
160
 
161
  @app.callback(
162
+ [Output("glossary-overlay-bg", "className"),
163
+ Output("glossary-drawer-content", "className")],
164
  [Input("open-glossary-btn", "n_clicks"),
165
  Input("close-glossary-btn", "n_clicks"),
166
+ Input("glossary-overlay-bg", "n_clicks")],
167
  prevent_initial_call=True
168
  )
169
  def toggle_glossary(open_clicks, close_clicks, overlay_clicks):
 
172
  return no_update, no_update
173
  trigger_id = ctx.triggered[0]["prop_id"].split(".")[0]
174
  if trigger_id == "open-glossary-btn":
175
+ return "glossary-overlay open", "glossary-drawer open"
176
  else:
177
+ return "glossary-overlay", "glossary-drawer"
178
 
179
 
180
  # ============================================================================
assets/style.css CHANGED
@@ -1513,4 +1513,57 @@ details[open].transformer-layers-container .transformer-layers-summary::before {
1513
  font-size: 16px;
1514
  /* Prevents zoom on iOS */
1515
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1516
  }
 
1513
  font-size: 16px;
1514
  /* Prevents zoom on iOS */
1515
  }
1516
+ }
1517
+
1518
+ /* Glossary Drawer Styles */
1519
+ .glossary-overlay {
1520
+ position: fixed;
1521
+ top: 0;
1522
+ left: 0;
1523
+ width: 100%;
1524
+ height: 100%;
1525
+ background-color: rgba(0, 0, 0, 0.5);
1526
+ z-index: 1000;
1527
+ opacity: 0;
1528
+ visibility: hidden;
1529
+ transition: opacity 0.3s ease, visibility 0.3s ease;
1530
+ }
1531
+
1532
+ .glossary-overlay.open {
1533
+ opacity: 1;
1534
+ visibility: visible;
1535
+ }
1536
+
1537
+ .glossary-drawer {
1538
+ position: fixed;
1539
+ top: 0;
1540
+ right: 0;
1541
+ height: 100vh;
1542
+ width: 100%;
1543
+ max-width: 500px;
1544
+ background-color: white;
1545
+ box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
1546
+ z-index: 1001;
1547
+ transform: translateX(100%);
1548
+ transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
1549
+ display: flex;
1550
+ flex-direction: column;
1551
+ }
1552
+
1553
+ .glossary-drawer.open {
1554
+ transform: translateX(0);
1555
+ }
1556
+
1557
+ .glossary-header {
1558
+ padding: 20px 25px;
1559
+ border-bottom: 1px solid #e2e8f0;
1560
+ display: flex;
1561
+ justify-content: space-between;
1562
+ align-items: center;
1563
+ }
1564
+
1565
+ .glossary-content-area {
1566
+ padding: 25px;
1567
+ overflow-y: auto;
1568
+ flex: 1;
1569
  }
components/glossary.py CHANGED
@@ -9,13 +9,14 @@ def create_glossary_modal():
9
  Create the hidden glossary modal that appears when the Help button is clicked.
10
  """
11
  return html.Div([
 
 
12
  html.Div([
13
  html.Div([
14
- html.H2("Transformer Concept Glossary", style={'marginTop': '0', 'color': '#2d3748'}),
15
  html.Button('×', id='close-glossary-btn', className='close-button',
16
- style={'position': 'absolute', 'right': '15px', 'top': '15px',
17
- 'background': 'none', 'border': 'none', 'fontSize': '24px', 'cursor': 'pointer'})
18
- ], style={'position': 'relative', 'borderBottom': '1px solid #e2e8f0', 'paddingBottom': '15px', 'marginBottom': '15px'}),
19
 
20
  html.Div([
21
  _create_term_entry(
@@ -64,30 +65,10 @@ def create_glossary_modal():
64
  "Digital Brain Surgery",
65
  "A technique used to understand which parts of a model are responsible for certain behaviors. By artificially modifying or 'turning off' specific attention heads or activations, we can measure how much the model's output changes, revealing the importance of those components."
66
  )
67
- ], className="glossary-content", style={'maxHeight': '70vh', 'overflowY': 'auto', 'padding': '0 20px 10px 10px'}),
68
 
69
- ], id='glossary-modal-content', className="modal-content", style={
70
- 'backgroundColor': 'white',
71
- 'padding': '30px',
72
- 'borderRadius': '8px',
73
- 'maxWidth': '900px', # Increased to fit videos
74
- 'width': '95%',
75
- 'boxShadow': '0 4px 6px rgba(0,0,0,0.1)',
76
- 'position': 'relative',
77
- 'display': 'block'
78
- })
79
- ], id='glossary-modal-overlay', style={
80
- 'position': 'fixed',
81
- 'top': '0',
82
- 'left': '0',
83
- 'width': '100%',
84
- 'height': '100%',
85
- 'backgroundColor': 'rgba(0,0,0,0.5)',
86
- 'zIndex': '1000',
87
- 'display': 'none',
88
- 'alignItems': 'center',
89
- 'justifyContent': 'center'
90
- })
91
 
92
  def _create_term_entry(term, analogy, definition, video_url=None):
93
  content = [
 
9
  Create the hidden glossary modal that appears when the Help button is clicked.
10
  """
11
  return html.Div([
12
+ html.Div(id='glossary-overlay-bg', className='glossary-overlay'),
13
+
14
  html.Div([
15
  html.Div([
16
+ html.H2("Transformer Concept Glossary"),
17
  html.Button('×', id='close-glossary-btn', className='close-button',
18
+ style={'background': 'none', 'border': 'none', 'fontSize': '28px', 'cursor': 'pointer', 'color': '#a0aec0'})
19
+ ], className='glossary-header'),
 
20
 
21
  html.Div([
22
  _create_term_entry(
 
65
  "Digital Brain Surgery",
66
  "A technique used to understand which parts of a model are responsible for certain behaviors. By artificially modifying or 'turning off' specific attention heads or activations, we can measure how much the model's output changes, revealing the importance of those components."
67
  )
68
+ ], className="glossary-content-area"),
69
 
70
+ ], id='glossary-drawer-content', className="glossary-drawer")
71
+ ], id='glossary-container')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  def _create_term_entry(term, analogy, definition, video_url=None):
74
  content = [