Skip to content

Commit 68df256

Browse files
committed
Add comments and aria values
1 parent 012b752 commit 68df256

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

templates/v3/examples/_v3_example_section.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h3>{{ section_title }}</h3>
7373
{% static "img/v3/badges/badge-gold-medal.png" as icon_src %}
7474
<div class="v3-examples-section__example-box">
7575
{% include "v3/includes/_badge_button.html" with name="badge-select" value="gold" icon_src=icon_src only %}
76-
{% include "v3/includes/_badge_button.html" with name="badge-select" value="gold" icon_src=icon_src checked=True only %}
76+
{% include "v3/includes/_badge_button.html" with name="badge-select" value="gold" icon_src=icon_src radio_checked=True only %}
7777
{% include "v3/includes/_badge_button.html" with name="badge-select" value="gold" icon_src=icon_src only %}
7878
</div>
7979
</div>
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
{% comment %}
2+
Badges Button Component. Intended to be used as part of a group of inputs to select a badge.
3+
4+
Inputs:
5+
name: str, required: group name for the radios. Should be the same for all components
6+
value: str, required: radio value for selection
7+
icon_src: str, required: full src link for icon for badge
8+
id: str, optional: id for linking the label to the radio button. Will be auto generated if not provided
9+
radio_checked: bool, optional: Set to true if the value should be preselected
10+
11+
Usage:
12+
Checked:
13+
{% include "v3/includes/_badge_button.html" with name="badge-select" value="gold" icon_src=icon_src radio_checked=True only %}
14+
Unchecked
15+
{% include "v3/includes/_badge_button.html" with name="badge-select" value="gold" icon_src=icon_src only %}
216
{% endcomment %}
317
{% load core_tags %}
418

519
{% generate_uuid as uuid %}
620
<div class="badge-button">
7-
<input class="badge-button__radio" type="radio" name="{{name}}" value="{{value}}" id="{{id|default:uuid}}" {% if checked %}checked{% endif %} />
8-
<label for="{{id|default:uuid}}"><img src="{{ icon_src }}" alt="" width="32" height="32"></label>
21+
<input
22+
class="badge-button__radio"
23+
type="radio"
24+
name="{{name}}"
25+
value="{{value}}"
26+
id="{{id|default:uuid}}"
27+
aria-checked="{{radio_checked|yesno:"true,false"|default:"false"}}"
28+
{% if radio_checked %} checked {% endif %}
29+
/>
30+
<label for="{{id|default:uuid}}"><img src="{{ icon_src }}" alt="" width="32" height="32"></label>
931
</div>

0 commit comments

Comments
 (0)