fix: closes #13256, allow keyboard access to icon colors

This commit is contained in:
Barış Soner Uşaklı
2025-03-19 20:49:04 -04:00
parent c9e0198de4
commit c662017033
4 changed files with 27 additions and 67 deletions

View File

@@ -108,7 +108,7 @@
"nodebb-plugin-spam-be-gone": "2.3.1", "nodebb-plugin-spam-be-gone": "2.3.1",
"nodebb-plugin-web-push": "0.7.3", "nodebb-plugin-web-push": "0.7.3",
"nodebb-rewards-essentials": "1.0.1", "nodebb-rewards-essentials": "1.0.1",
"nodebb-theme-harmony": "2.0.40", "nodebb-theme-harmony": "2.0.41",
"nodebb-theme-lavender": "7.1.18", "nodebb-theme-lavender": "7.1.18",
"nodebb-theme-peace": "2.2.39", "nodebb-theme-peace": "2.2.39",
"nodebb-theme-persona": "14.0.16", "nodebb-theme-persona": "14.0.16",

View File

@@ -1,59 +1,17 @@
.picture-switcher { .picture-switcher {
h4 {
line-height: 46px;
margin: 0;
}
.modal-body .btn { [data-bg-color] {
padding: 10px 5px; position: relative;
font-size: 13px; border-radius: 50%;
} &.selected::after {
content: '';
label { position: absolute;
vertical-align: top; top: -2px; left: -2px;
line-height: 26px; right: -2px; bottom: -2px;
> input[type="radio"] {
display: none;
&:checked {
+ span:before {
border-radius: 50%;
border: 2px solid $primary;
position: relative;
top: -4px;
left: -4px;
}
}
&[value="transparent"] {
&:checked + span:before {
padding-top: 2px;
padding-left: 2px;
}
+ span:before {
content: '\f05e';
font-family: FontAwesome;
color: $gray-200;
font-size: 28px;
}
}
}
span {
display: inline-block;
width: 24px;
height: 24px;
border-radius: 50%; border-radius: 50%;
margin-right: .5em; border: 2px solid $primary;
pointer-events: none;
&:before { z-index: 1;
content: '';
display: inline-block;
width: 32px;
height: 32px;
}
} }
} }
} }

View File

@@ -60,8 +60,10 @@ define('accounts/picture', [
modal.find('.list-group-item').removeClass('active'); modal.find('.list-group-item').removeClass('active');
$(this).addClass('active'); $(this).addClass('active');
}); });
modal.on('change', 'input[type="radio"][name="icon:bgColor"]', (e) => {
const value = e.target.value; modal.on('click', '[data-bg-color]', function () {
const value = $(this).attr('data-bg-color');
$(this).addClass('selected').siblings().removeClass('selected');
modal.find('[component="avatar/icon"]').css('background-color', value); modal.find('[component="avatar/icon"]').css('background-color', value);
}); });
@@ -80,18 +82,17 @@ define('accounts/picture', [
} }
// Update avatar background colour // Update avatar background colour
const radioEl = document.querySelector(`.modal input[type="radio"][value="${ajaxify.data['icon:bgColor']}"]`); const iconbgEl = modal.find(`[data-bg-color="${ajaxify.data['icon:bgColor']}"]`);
if (radioEl) { if (iconbgEl.length) {
radioEl.checked = true; iconbgEl.addClass('selected');
} else { } else {
// Check the first one modal.find('[data-bg-color="transparent"]').addClass('selected');
document.querySelector('.modal input[type="radio"]').checked = true;
} }
} }
function saveSelection() { function saveSelection() {
const type = modal.find('.list-group-item.active').attr('data-type'); const type = modal.find('.list-group-item.active').attr('data-type');
const iconBgColor = document.querySelector('.modal.picture-switcher input[type="radio"]:checked').value || 'transparent'; const iconBgColor = modal.find('[data-bg-color].selected').attr('data-bg-color') || 'transparent';
changeUserPicture(type, iconBgColor).then(() => { changeUserPicture(type, iconBgColor).then(() => {
Picture.updateHeader( Picture.updateHeader(

View File

@@ -35,8 +35,9 @@
<hr /> <hr />
<h4>[[user:avatar-background-colour]]</h4> <h4>[[user:avatar-background-colour]]</h4>
<div class="d-flex gap-2">
<label><input type="radio" name="icon:bgColor" value="transparent" /><span></span></label> <a href="#" class="lh-1 p-1" data-bg-color="transparent"><i class="fa-solid fa-2x fa-ban text-secondary"></i></a>
{{{ each iconBackgrounds }}} {{{ each iconBackgrounds }}}
<label><input type="radio" name="icon:bgColor" value="{@value}" /><span style="background-color: {@value};"></span></label> <a href="#" class="lh-1 p-1" data-bg-color="{@value}" style="color: {@value};"><i class="fa-solid fa-2x fa-circle"></i></a>
{{{ end }}} {{{ end }}}
</div>