mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-07 08:31:05 +00:00
Add icon template tag with accessibility options (PoC) (#4381)
This commit is contained in:
parent
5d638e3284
commit
4e7ccdcdc9
6 changed files with 31 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ Changelog
|
|||
* Add request parameter to edit handlers (Rajeev J Sebastian)
|
||||
* ImageChooser now sets a default title based on filename (Coen van der Kamp)
|
||||
* Added error handling to the Draftail editor (Thibaud Colas)
|
||||
* Add new `wagtail_icon` template tag to facilitate making admin icons accessible (Sander Tuit)
|
||||
* Fix: Status button on 'edit page' now links to the correct URL when live and draft slug differ (LB (Ben Johnston))
|
||||
* Fix: Image title text in the gallery and in the chooser now wraps for long filenames (LB (Ben Johnston), Luiz Boaretto)
|
||||
* Fix: Move image editor action buttons to the bottom of the form on mobile (Julian Gallo)
|
||||
|
|
|
|||
|
|
@ -291,6 +291,7 @@ Contributors
|
|||
* Alejandro Garza
|
||||
* Rajeev J Sebastian
|
||||
* Coen van der Kamp
|
||||
* Sander Tuit
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ Other features
|
|||
* Add request parameter to edit handlers (Rajeev J Sebastian)
|
||||
* ImageChooser now sets a default title based on filename (Coen van der Kamp)
|
||||
* Added error handling to the Draftail editor (Thibaud Colas)
|
||||
* Add new `wagtail_icon` template tag to facilitate making admin icons accessible (Sander Tuit)
|
||||
|
||||
Bug fixes
|
||||
~~~~~~~~~
|
||||
|
|
|
|||
2
wagtail/admin/templates/wagtailadmin/shared/icon.html
Normal file
2
wagtail/admin/templates/wagtailadmin/shared/icon.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<span class="{{ classnames }}" {% if decorative %}aria-hidden="true"{% else %}title="{{ title }}"{% endif %}></span>
|
||||
{% if show_label %}{{ title }}{% elif not decorative %}<span class="sr-only">{{ title }}</span>{% endif %}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{% spaceless %}
|
||||
{# Reference implementation: components/Icon.js #}
|
||||
<span>
|
||||
<span class="icon icon-{{ name }} {{ className }}" aria-hidden="true"></span>
|
||||
{% if title %}
|
||||
<span class="visuallyhidden">{{ title }}</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endspaceless %}
|
||||
17
wagtail/admin/templatetags/wagtailui_tags.py
Normal file
17
wagtail/admin/templatetags/wagtailui_tags.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.inclusion_tag("wagtailadmin/shared/wagtail_icon.html", takes_context=False)
|
||||
def wagtail_icon(name=None, classname='', title=None):
|
||||
"""
|
||||
Usage: {% wagtail_icon name="cogs" classname="icon--red" title="Settings" %}
|
||||
|
||||
First load the tags with {% load wagtailui_tags %}
|
||||
"""
|
||||
return {
|
||||
'name': name,
|
||||
'classname': classname,
|
||||
'title': title,
|
||||
}
|
||||
Loading…
Reference in a new issue