Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions hypha/apply/review/templatetags/review_tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import template
from django.utils.safestring import mark_safe
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _

from ..models import MAYBE, NO, YES
Expand All @@ -8,25 +8,31 @@
register = template.Library()


TRAFFIC_LIGHT_COLORS = {
YES: {
"color": "green",
"value": "Y",
},
MAYBE: {
"color": "amber",
"value": "M",
},
NO: {"color": "red", "value": "N"},
}

TRAFFIC_LIGHT_TEMPLATE = '<span class="traffic-light traffic-light--{color}"></span>'


@register.filter()
def traffic_light(value):
mapping = {
YES: {
"label": _("Overall recommendation: Yes"),
"class": "triangle-up text-success",
},
MAYBE: {
"label": _("Overall recommendation: Maybe"),
"class": "circle text-warning",
},
NO: {
"label": _("Overall recommendation: No"),
"class": "triangle-down text-error",
},
}

try:
return mark_safe(TRAFFIC_LIGHT_TEMPLATE.format(**TRAFFIC_LIGHT_COLORS[value]))
html = """
<div class="flex items-center">
<span class="size-3 {class}" aria-hidden=true></span>
<span class="sr-only">{label}</span>
</div>
"""
return format_html(html, **mapping[value])
except KeyError:
return ""

Expand Down
26 changes: 0 additions & 26 deletions hypha/static_src/sass/components/_traffic-light.scss

This file was deleted.

1 change: 0 additions & 1 deletion hypha/static_src/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@use "components/reviews-sidebar";
@use "components/reviews-summary";
@use "components/sidebar";
@use "components/traffic-light";
@use "components/two-factor";
@use "components/wrapper";

Expand Down
17 changes: 17 additions & 0 deletions hypha/static_src/tailwind/utilities/misc.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,20 @@
@utility js-hidden {
@apply hidden noscript:block;
}

@utility triangle-up {
@apply size-4 inline-block aspect-square;
background-color: currentColor;
clip-path: polygon(50% 0, 0 100%, 100% 100%);
}

@utility triangle-down {
@apply size-4 inline-block aspect-square;
background-color: currentColor;
clip-path: polygon(100% 0, 0 0, 50% 100%);
}

@utility circle {
@apply size-4 inline-block aspect-square rounded-full;
background-color: currentColor;
}
Loading