forked from CGM_Public/pretix_original
[A11y] make text "required" visible in labels (#5042)
This commit is contained in:
committed by
GitHub
parent
c53d44238c
commit
f09e9590a8
@@ -33,6 +33,7 @@ def render_label(content, label_for=None, label_class=None, label_title='', labe
|
|||||||
"""
|
"""
|
||||||
Render a label with content
|
Render a label with content
|
||||||
"""
|
"""
|
||||||
|
tag = 'label'
|
||||||
attrs = attrs or {}
|
attrs = attrs or {}
|
||||||
if label_for:
|
if label_for:
|
||||||
attrs['for'] = label_for
|
attrs['for'] = label_for
|
||||||
@@ -58,15 +59,16 @@ def render_label(content, label_for=None, label_class=None, label_title='', labe
|
|||||||
attrs['class'] += ' label-empty'
|
attrs['class'] += ' label-empty'
|
||||||
# usually checkboxes have overall empty labels and special labels per checkbox
|
# usually checkboxes have overall empty labels and special labels per checkbox
|
||||||
# => remove for-attribute as well as "required"-text appended to label
|
# => remove for-attribute as well as "required"-text appended to label
|
||||||
|
tag = 'div'
|
||||||
if 'for' in attrs:
|
if 'for' in attrs:
|
||||||
del attrs['for']
|
del attrs['for']
|
||||||
elif not optional:
|
elif not optional:
|
||||||
opt += '<i class="sr-only label-required">, {}</i>'.format(pgettext('form', 'required'))
|
opt += '<i class="label-required">{}</i>'.format(pgettext('form', 'required'))
|
||||||
|
|
||||||
builder = '<{tag}{attrs}>{content}{opt}</{tag}>'
|
builder = '<{tag}{attrs}>{content}{opt}</{tag}>'
|
||||||
return format_html(
|
return format_html(
|
||||||
builder,
|
builder,
|
||||||
tag='label',
|
tag=tag,
|
||||||
attrs=mark_safe(flatatt(attrs)) if attrs else '',
|
attrs=mark_safe(flatatt(attrs)) if attrs else '',
|
||||||
opt=mark_safe(opt),
|
opt=mark_safe(opt),
|
||||||
content=text_value(content),
|
content=text_value(content),
|
||||||
|
|||||||
@@ -145,10 +145,23 @@ output {
|
|||||||
color: $brand-primary;
|
color: $brand-primary;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.form-group.required .control-label:after {
|
.label-required {
|
||||||
content: '*';
|
color: $text-muted;
|
||||||
color: $brand-primary;
|
display: block;
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 85%;
|
||||||
}
|
}
|
||||||
|
.checkbox .label-required {
|
||||||
|
display: inline;
|
||||||
|
&:before {
|
||||||
|
content: " (";
|
||||||
|
}
|
||||||
|
&:after {
|
||||||
|
content: ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.form-control-text {
|
.form-control-text {
|
||||||
padding-top: 7px;
|
padding-top: 7px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user