diff --git a/.coveragerc b/.coveragerc index 8b178e16..6c7436f6 100644 --- a/.coveragerc +++ b/.coveragerc @@ -9,6 +9,7 @@ omit = sanic/simple.py sanic/utils.py sanic/cli + sanic/pages [html] directory = coverage diff --git a/codecov.yml b/codecov.yml index bd0afc47..9b6fb373 100644 --- a/codecov.yml +++ b/codecov.yml @@ -17,7 +17,8 @@ ignore: - "sanic/compat.py" - "sanic/simple.py" - "sanic/utils.py" - - "sanic/cli" + - "sanic/cli/" + - "sanic/pages/" - ".github/" - "changelogs/" - "docker/" diff --git a/sanic/pages/autoindex.py b/sanic/pages/autoindex.py index efe99eb0..26d61875 100644 --- a/sanic/pages/autoindex.py +++ b/sanic/pages/autoindex.py @@ -13,22 +13,34 @@ class FileInfo(TypedDict): file_size: str -class AutoIndex(BasePage): +class AutoIndex(BasePage): # no cov EXTRA_STYLE = dedent( """ + #breadcrumbs a { text-decoration: none; } #breadcrumbs .path-0 a::before { content: "🏠"; } #breadcrumbs span:has(> a:hover, > a:focus) * { color: #ff0d68; text-shadow: 0 0 1rem; } main a { color: inherit; font-weight: bold; } + table.autoindex { width: 100%; } table.autoindex tr { display: flex; } + table.autoindex tr:hover { background-color: #eee; } table.autoindex td { margin: 0 0.5rem; } table.autoindex td:first-child { flex: 1; } table.autoindex td:nth-child(2) { text-align: right; } table.autoindex td:last-child { text-align: right; } + @media (min-width: 915px) { + table.autoindex { font-size: 1.75vw; } + } + @media (min-width: 1600px) { + table.autoindex { font-size: 1.75rem; } + } + @media (prefers-color-scheme: dark) { + table.autoindex tr:hover { background-color: #222; } + } """ ) - TITLE = "File browser" + TITLE = "File Browser" def __init__( self, files: Iterable[FileInfo], url: str, debug: bool @@ -59,7 +71,7 @@ class AutoIndex(BasePage): self.doc.__exit__(None, None, None) def _file_table(self, files: Iterable[FileInfo]): - with self.doc.table(class_="autoindex"): + with self.doc.table(class_="autoindex container"): for f in files: self._file_row(**f) diff --git a/sanic/pages/base.py b/sanic/pages/base.py index 0fd90cbe..08be2cd9 100644 --- a/sanic/pages/base.py +++ b/sanic/pages/base.py @@ -7,20 +7,28 @@ from sanic import __version__ as VERSION from sanic.application.logo import SVG_LOGO -class BasePage(ABC): +class BasePage(ABC): # no cov BASE_STYLE = dedent( """ - body { margin: 0; font: 16px sans-serif; } - body > * { padding: 0 2rem; } + html { font: 16px monospace; } + body { margin: 0; font-size: 1.25rem; } + body > * { padding: 1rem 2vw; } + @media (max-width: 1200px) { + body > * { padding: 0.5rem 1.5vw;} + body { font-size: 1rem; } + } + .container { min-width: 600px; max-width: 1600px; } header { - display: flex; align-items: center; justify-content: space-between; background: #111; color: #e1e1e1; border-bottom: 1px solid #272727; } + header .container { + display: flex; align-items: center; justify-content: space-between; + } + h1 { text-align: left; } a:visited { color: inherit; } a { text-decoration: none; color: #88f; } a:hover, a:focus { text-decoration: underline; outline: none; } #logo { height: 2.75rem; padding: 0.25rem 0; } - table { width: 100%; max-width: 1200px; } span.icon { margin-right: 1rem; } @media (prefers-color-scheme: dark) { html { background: #111; color: #ccc; } @@ -45,11 +53,13 @@ class BasePage(ABC): def _head(self) -> None: self.doc.style(HTML(self.style)) - if self.debug: - with self.doc.header: - self.doc(HTML(SVG_LOGO)).div(self.TITLE, id="hdrtext").div( - f"Version {VERSION}", id="hdrver" - ) + with self.doc.header: + with self.doc.div(class_="container"): + if self.debug: + self.doc(HTML(SVG_LOGO)) + self.doc.div(self.TITLE, id="hdrtext") + if self.debug: + self.doc.div(f"Version {VERSION}", id="hdrver") @abstractmethod def _body(self) -> None: