Skip to content

Commit 5497f56

Browse files
Add footer with copyright, license, and link to GitHub (#153)
Co-authored-by: ElliottKasoar <[email protected]>
1 parent 9507705 commit 5497f56

File tree

2 files changed

+105
-5
lines changed

2 files changed

+105
-5
lines changed

ml_peg/app/build_app.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from ml_peg.analysis.utils.utils import calc_table_scores, get_table_style
1515
from ml_peg.app import APP_ROOT
16-
from ml_peg.app.utils.build_components import build_weight_components
16+
from ml_peg.app.utils.build_components import build_footer, build_weight_components
1717
from ml_peg.app.utils.register_callbacks import register_benchmark_to_category_callback
1818
from ml_peg.app.utils.utils import calculate_column_widths, sig_fig_format
1919
from ml_peg.models.get_models import get_model_names
@@ -262,12 +262,21 @@ def build_tabs(
262262
]
263263

264264
tabs_layout = [
265-
H1("ML-PEG"),
266-
Tabs(id="all-tabs", value="summary-tab", children=all_tabs),
267-
Div(id="tabs-content"),
265+
Div(
266+
[
267+
H1("ML-PEG"),
268+
Tabs(id="all-tabs", value="summary-tab", children=all_tabs),
269+
Div(id="tabs-content"),
270+
],
271+
style={"flex": "1", "marginBottom": "40px"},
272+
),
273+
build_footer(),
268274
]
269275

270-
full_app.layout = Div(tabs_layout)
276+
full_app.layout = Div(
277+
tabs_layout,
278+
style={"display": "flex", "flexDirection": "column", "minHeight": "100vh"},
279+
)
271280

272281
@callback(Output("tabs-content", "children"), Input("all-tabs", "value"))
273282
def select_tab(tab) -> Div:

ml_peg/app/utils/build_components.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
from __future__ import annotations
44

5+
from importlib import metadata
6+
import time
7+
58
from dash import html
69
from dash.dash_table import DataTable
710
from dash.dcc import Checklist, Store
@@ -283,6 +286,94 @@ def build_weight_components(
283286
return Div(layout)
284287

285288

289+
def build_footer() -> html.Footer:
290+
"""
291+
Build shared footer with author, copyright, and repository link.
292+
293+
Returns
294+
-------
295+
html.Footer
296+
Styled footer component rendered at the bottom of each tab.
297+
"""
298+
copyright_first_year = "2025"
299+
current_year = str(time.localtime().tm_year)
300+
copyright_owners = metadata.metadata("ml-peg")["author"]
301+
302+
copyright_year_string = (
303+
current_year
304+
if current_year == copyright_first_year
305+
else f"{copyright_first_year}-{current_year}"
306+
)
307+
copyright_txt = (
308+
f"Copyright © {copyright_year_string}, {copyright_owners}. All rights reserved"
309+
)
310+
311+
return html.Footer(
312+
[
313+
Div(
314+
[
315+
html.Span(copyright_txt, style={"fontWeight": "800"}),
316+
],
317+
style={
318+
"display": "flex",
319+
"justifyContent": "center",
320+
"flexWrap": "wrap",
321+
"gap": "6px",
322+
},
323+
),
324+
Div(
325+
html.A(
326+
"GPL-3.0 license",
327+
href="https://github.com/ddmms/ml-peg/blob/main/LICENSE",
328+
target="_blank",
329+
),
330+
style={"marginTop": "4px", "fontWeight": "800"},
331+
),
332+
Div(
333+
html.A(
334+
[
335+
html.Img(
336+
src=(
337+
"https://github.githubassets.com/images/modules/logos_page/"
338+
"GitHub-Mark.png"
339+
),
340+
alt="GitHub",
341+
width="16",
342+
height="16",
343+
style={
344+
"marginRight": "6px",
345+
"verticalAlign": "middle",
346+
"display": "block",
347+
},
348+
),
349+
html.Span("View on GitHub"),
350+
],
351+
href="https://github.com/ddmms/ml-peg",
352+
target="_blank",
353+
style={
354+
"color": "#0d6efd",
355+
"textDecoration": "none",
356+
"fontWeight": "800",
357+
"display": "inline-flex",
358+
"alignItems": "center",
359+
},
360+
),
361+
style={"marginTop": "6px"},
362+
),
363+
],
364+
style={
365+
"marginTop": "24px",
366+
"padding": "14px 12px",
367+
"color": "#343a40",
368+
"fontSize": "12px",
369+
"textAlign": "center",
370+
"borderTop": "1px solid #dee2e6",
371+
"background": "#f8f9fa",
372+
"borderRadius": "6px",
373+
},
374+
)
375+
376+
286377
def build_test_layout(
287378
name: str,
288379
description: str,

0 commit comments

Comments
 (0)