Skip to content

Commit ff59ad3

Browse files
committed
fix(ui): adjust styles for authentication name display
1 parent cfaf8de commit ff59ad3

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

weblate/accounts/templatetags/authnames.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from django.conf import settings
1313
from django.contrib.staticfiles.storage import staticfiles_storage
1414
from django.utils.html import format_html
15-
from django.utils.safestring import mark_safe
1615
from django.utils.translation import gettext_lazy
1716

1817
from weblate.accounts.utils import get_key_name
@@ -59,15 +58,11 @@
5958
"recovery": gettext_lazy("Use recovery codes"),
6059
}
6160

62-
IMAGE_SOCIAL_TEMPLATE = """
63-
<img class="auth-image" src="{image}" />
64-
"""
61+
IMAGE_SOCIAL_TEMPLATE = (
62+
"""<img class="auth-image" src="{image}" alt="" aria-hidden="true" />"""
63+
)
6564

66-
SOCIAL_TEMPLATE = """
67-
{icon}
68-
{separator}
69-
{name}
70-
"""
65+
SOCIAL_TEMPLATE = """{icon}<span class="auth-name">{name}</span>"""
7166

7267

7368
def get_auth_params(auth: str) -> dict[str, StrOrPromise]:
@@ -92,22 +87,19 @@ def get_auth_params(auth: str) -> dict[str, StrOrPromise]:
9287
return params
9388

9489

95-
auth_name_default_separator = mark_safe("<br />")
96-
97-
9890
@register.simple_tag
99-
def auth_name(auth: str, separator: str = auth_name_default_separator, only: str = ""):
91+
def auth_name(auth: str, only: str = ""):
10092
"""Create HTML markup for social authentication method."""
10193
params = get_auth_params(auth)
10294

10395
if not params["image"].startswith(("http", "data:")):
10496
params["image"] = staticfiles_storage.url(f"auth/{params['image']}")
105-
params["icon"] = format_html(IMAGE_SOCIAL_TEMPLATE, separator=separator, **params)
97+
params["icon"] = format_html(IMAGE_SOCIAL_TEMPLATE, **params)
10698

10799
if only:
108100
return params[only]
109101

110-
return format_html(SOCIAL_TEMPLATE, separator=separator, **params)
102+
return format_html(SOCIAL_TEMPLATE, **params)
111103

112104

113105
def get_auth_name(auth: str):
@@ -117,7 +109,7 @@ def get_auth_name(auth: str):
117109

118110
@register.simple_tag
119111
def key_name(device: Device) -> str:
120-
return format_html('<span class="auth-name">{}</span>', get_key_name(device))
112+
return format_html('<span class="key-name">{}</span>', get_key_name(device))
121113

122114

123115
@register.simple_tag

weblate/static/styles/main.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ th:hover .sort-icon.sort-up {
569569
text-align: left;
570570
}
571571

572+
.btn-auth a:hover {
573+
text-decoration: none;
574+
}
575+
572576
.dir-rtl .btn-auth a {
573577
text-align: right;
574578
}
@@ -2327,6 +2331,11 @@ tbody.warning {
23272331
}
23282332

23292333
.auth-name {
2334+
margin-inline-start: 8px;
2335+
vertical-align: middle;
2336+
}
2337+
2338+
.key-name {
23302339
margin: 8px 0;
23312340
display: inline-block;
23322341
}

weblate/templates/accounts/login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h5 class="login-label">{% translate "Sign in with:" %}</h5>
5252
<a href=""
5353
class="btn btn-outline-primary link-post"
5454
data-href="{% url 'social:begin' name %}"
55-
{% if next %}data-params='{"next": "{{ next|escapejs }}"}'{% endif %}>{% auth_name name " " %}</a>
55+
{% if next %}data-params='{"next": "{{ next|escapejs }}"}'{% endif %}>{% auth_name name %}</a>
5656
</div>
5757
{% endfor %}
5858
</div>

weblate/templates/accounts/profile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ <h4 class="card-title">{% translate "Add new user identity" %}</h4>
246246
{% for name in new_backends %}
247247
<a href=""
248248
class="btn btn-link link-post"
249-
data-href="{% url 'social:begin' name %}?next={% url 'profile' %}%23account">{% auth_name name %}</a>
249+
data-href="{% url 'social:begin' name %}?next={% url 'profile' %}%23account">{% auth_name name only="icon" %}<br />{% auth_name name only="name" %}</a>
250250
{% endfor %}
251251
</div>
252252
</div>

weblate/templates/accounts/redirect.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<a href=""
2020
class="btn btn-link link-auto link-post"
2121
data-href="{% url 'social:begin' backend %}"
22-
{% if next %}data-params='{"next": "{{ next|escapejs }}"}'{% endif %}>{% auth_name backend " " %}</a>
22+
{% if next %}data-params='{"next": "{{ next|escapejs }}"}'{% endif %}>{% auth_name backend %}</a>
2323
</div>
2424

2525
</div>

weblate/templates/accounts/register.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h5 class="login-label">{% translate "Create an account using:" %}</h5>
6060
<a href=""
6161
class="btn btn-outline-primary link-post"
6262
data-href="{% url 'social:begin' name %}"
63-
{% if next %}data-params='{"next": "{{ next|escapejs }}"}'{% endif %}>{% auth_name name " " %}</a>
63+
{% if next %}data-params='{"next": "{{ next|escapejs }}"}'{% endif %}>{% auth_name name %}</a>
6464
</div>
6565
{% endfor %}
6666
</div>

weblate/templates/accounts/user.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ <h3>{{ page_user }}</h3>
250250
<tbody>
251251
{% for social in page_user.social_auth.all %}
252252
<tr>
253-
<th>{% auth_name social.provider ' ' %}</th>
253+
<th>{% auth_name social.provider %}</th>
254254
<td>{{ social.uid }}</td>
255255
<td>
256256
{% for verified in social.verifiedemail_set.all %}

0 commit comments

Comments
 (0)