Skip to content

Commit

Permalink
fix: minor UI fixes and add mypy compliance
Browse files Browse the repository at this point in the history
Description of this commit:
    - This commit brings some fixes to minor UI issues which were
      identified in the UX testing. These include the changes to the
      carousel buttons not working when hovered over mini-sidebar.
    - It also covers and patches over the mypy issues resolving them
      without disabling the error codes explictly.

Signed-off-by: Akshay Mestry <[email protected]>
  • Loading branch information
xames3 committed Nov 20, 2024
1 parent a7745ef commit b32cf1b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 40 deletions.
6 changes: 3 additions & 3 deletions coeus_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def fix(module: types.ModuleType) -> type[nodes.Element]:
.. versionadded:: 2024.09.01
"""
node = module.node
node: type[nodes.Element] = module.node
node.__name__ = "".join(_.capitalize() for _ in module.name.split("-"))
return node

Expand Down Expand Up @@ -274,8 +274,8 @@ def setup(app: Sphinx) -> dict[str, t.Any]:
"html_coeus_socials": ({}, dict),
"html_coeus_version": (config.release, str),
}
for name, (default, types) in coeus_theme_configurations.items():
app.add_config_value(name, default, "html", types)
for name, (default, dtypes) in coeus_theme_configurations.items():
app.add_config_value(name, default, "html", dtypes)
for default, new in coeus_theme_default_mapping.items():
setattr(config, default, getattr(config, new))
app.add_html_theme(name=theme_name, theme_path=here)
Expand Down
11 changes: 6 additions & 5 deletions coeus_sphinx_theme/contributors.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Coeus Sphinx Theme Contributors Template
Author: Akshay Mestry <[email protected]>
Created on: Tuesday, October 29 2024
Last updated on: Wednesday, October 30 2024
Last updated on: Wednesday, November 20 2024
-->
{% block contributors_metadata %}
{%- if people %}
Expand Down Expand Up @@ -46,11 +46,12 @@ Last updated on: Wednesday, October 30 2024
{% endif %}
<div class="project-socials">
{% for key, value in socials | dictsort %}
<a class="{{ value[1]|e }}" href="{{ value[0]|e }}" {% if value[0]|e !='#' %}target="_blank" {% endif
%}aria-label="Share this article via {{ key|title }} (opens a new tab)"></a>
<a class="{{ value[1]|e }}" href="{{ value[0]|d('#') }}" target="_blank"
aria-label="Share this article via {{ key|title }} (opens a new tab)"
rel="noopener noreferrer"></a>
{% endfor %}
<a class="fa-brands fa-github" href="{{ github }}" {% if github !='#' %}target="_blank" {% endif
%}aria-label="Check out source on GitHub"></a>
<a class="fa-brands fa-github" href="{{ github|d('#') }}" target="_blank"
aria-label="Check out source on GitHub" rel="noopener noreferrer"></a>
<a class="fa-solid fa-envelope" href="mailto:{{ email }}?subject={{ subject }}"
aria-label="Ask team via email" style="font-weight: 900;"></a>
</div>
Expand Down
13 changes: 7 additions & 6 deletions coeus_sphinx_theme/extensions/contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
"contributors.html.jinja",
)

options_re: t.Pattern = re.compile(r"(-\s:.*:\s)(.*)")
relpath_re: t.Pattern = re.compile(r"^(\.|\/)*")
options_re: t.Pattern[str] = re.compile(r"(-\s:.*:\s)(.*)")
relpath_re: t.Pattern[str] = re.compile(r"^(\.|\/)*")

socials: dict[str, str] = {
"twitter": "fa-brands fa-x-twitter",
Expand Down Expand Up @@ -145,8 +145,8 @@ def run(self) -> list[nodes.Node]:
build = os.path.dirname(e.doctreedir)
if not os.path.exists((images := os.path.join(build, "_images"))):
os.makedirs(images, exist_ok=True)
person = 0
people = [{}]
person: int = 0
people: list[dict[str, str]] = [{}]
for content in self.content:
if not content:
people.append({})
Expand All @@ -161,11 +161,12 @@ def run(self) -> list[nodes.Node]:
people[person]["email"] = value
case "headshot":
if not value.startswith(("http://", "https://")):
r = relpath_re.match(value).group()
if r := relpath_re.match(value):
x = r.group()
s = os.path.join(e.srcdir, value.lstrip("./"))
_ = os.path.basename(s)
d = os.path.join("_images", _)
people[person]["headshot"] = os.path.join(r, d)
people[person]["headshot"] = os.path.join(x, d)
shutil.copyfile(s, os.path.join(build, d))
else:
people[person]["headshot"] = value
Expand Down
1 change: 0 additions & 1 deletion coeus_sphinx_theme/extensions/headshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from __future__ import annotations

import typing as t
from itertools import groupby

import docutils.nodes as nodes
import docutils.parsers.rst as rst
Expand Down
5 changes: 2 additions & 3 deletions coeus_sphinx_theme/extensions/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ def run(self) -> list[nodes.Node]:
if not self.content:
url = f"../{base}/repl/index.html?"
flags += "kernel=python&toolbar=1"
flags += (
f"&theme={self.options.get('theme', 'jupyterlab_coeus_theme')}"
)
theme = self.options.get("theme", "jupyterlab_coeus_theme")
flags += f"&theme={theme}"
url += flags
self.options["url"] = url
attributes: dict[str, str] = {}
Expand Down
4 changes: 2 additions & 2 deletions coeus_sphinx_theme/extensions/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def stylize_role(
text: str,
lineno: int,
inliner: t.Any,
options: dict | None = None,
content: list | None = None,
options: dict[str, t.Any] | None = None,
content: list[t.Any] | None = None,
) -> tuple[list[nodes.Node], list[nodes.system_message]]:
"""Apply inline styling to text.
Expand Down
23 changes: 7 additions & 16 deletions coeus_sphinx_theme/static/coeus.css
Original file line number Diff line number Diff line change
Expand Up @@ -3750,34 +3750,25 @@ details.sd-dropdown .sd-summary-content .sd-tab-set {
}

.scbs-carousel-control-prev {
left: -4rem;
left: 0rem;
}

.scbs-carousel-control-next,
.scbs-carousel-control-prev {
top: 45%;
transform: translateY(-45%);
background-color: #e2e2e5;
background-color: transparent;
cursor: pointer;
padding: 0.5rem;
width: 3rem;
height: 3rem;
border-radius: 50%;
opacity: 1;
width: 50%;
height: 100%;
}

.scbs-carousel-control-next {
right: -4rem;
}

.scbs-carousel-control-prev-icon {
width: 50%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path fill="%23636365" d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"/></svg>');
right: 0rem;
}

.scbs-carousel-control-prev-icon,
.scbs-carousel-control-next-icon {
width: 50%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path fill="%23636365" d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>');
display: none;
}

.scbs-carousel-item img {
Expand Down
9 changes: 5 additions & 4 deletions coeus_sphinx_theme/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
if t.TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
from sphinx_tags import Tag


def make_toc_collapsible(tree: bs4.BeautifulSoup) -> None:
Expand Down Expand Up @@ -196,7 +197,7 @@ def add_title_hero(
[1] Added native support for mangling `sphinx_tags` tags with
custom embedding for `title-hero` directive.
"""
tags = list(tags.values())
_tags = list(tags.values())
if "md" in extension:
content = []
content.append("(tagoverview)=")
Expand All @@ -208,7 +209,7 @@ def add_title_hero(
content.append(f"caption: {tags_index_head}")
content.append("maxdepth: 1")
content.append("---")
for tag in sorted(tags, key=lambda t: t.name):
for tag in sorted(_tags, key=lambda t: t.name):
content.append(
f"{tag.name} ({len(tag.items)}) <{tag.file_basename}>"
)
Expand All @@ -233,7 +234,7 @@ def add_title_hero(
content.append(f" :caption: {tags_index_head}")
content.append(" :maxdepth: 1")
content.append("")
for tag in sorted(tags, key=lambda t: t.name):
for tag in sorted(_tags, key=lambda t: t.name):
content.append(
f" {tag.name} ({len(tag.items)}) <{tag.file_basename}.rst>"
)
Expand All @@ -244,7 +245,7 @@ def add_title_hero(


def create_file_with_title_hero(
self,
self: Tag,
items: list[str],
extension: t.Any,
output_dir: str,
Expand Down

0 comments on commit b32cf1b

Please sign in to comment.