mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-07 23:00:54 +00:00
Change multi-badge tooltips to put two badges on each line for a nicer display. Fix replacing badges while also setting per-user badge overrides.
This commit is contained in:
parent
2efbd1ae59
commit
8e27f2e6a3
3 changed files with 38 additions and 14 deletions
|
@ -175,6 +175,8 @@ export default class Badges extends Module {
|
||||||
this.loadGlobalBadges();
|
this.loadGlobalBadges();
|
||||||
|
|
||||||
this.tooltips.types.badge = (target, tip) => {
|
this.tooltips.types.badge = (target, tip) => {
|
||||||
|
tip.add_class = 'ffz__tooltip--badges';
|
||||||
|
|
||||||
const show_previews = this.parent.context.get('tooltip.badge-images'),
|
const show_previews = this.parent.context.get('tooltip.badge-images'),
|
||||||
container = target.parentElement.parentElement,
|
container = target.parentElement.parentElement,
|
||||||
room_id = container.dataset.roomId,
|
room_id = container.dataset.roomId,
|
||||||
|
@ -202,9 +204,6 @@ export default class Badges extends Module {
|
||||||
show_previews && e('div', {
|
show_previews && e('div', {
|
||||||
className: 'preview-image ffz-badge',
|
className: 'preview-image ffz-badge',
|
||||||
style: {
|
style: {
|
||||||
height: '7.2rem',
|
|
||||||
width: '7.2rem',
|
|
||||||
backgroundSize: '7.2rem',
|
|
||||||
backgroundColor: d.color,
|
backgroundColor: d.color,
|
||||||
backgroundImage: `url("${d.image}")`
|
backgroundImage: `url("${d.image}")`
|
||||||
}
|
}
|
||||||
|
@ -279,6 +278,8 @@ export default class Badges extends Module {
|
||||||
slot = has(badge, 'slot') ? badge.slot : full_badge.slot,
|
slot = has(badge, 'slot') ? badge.slot : full_badge.slot,
|
||||||
old_badge = slotted[slot],
|
old_badge = slotted[slot],
|
||||||
urls = badge.urls || (badge.image ? {1: badge.image} : null),
|
urls = badge.urls || (badge.image ? {1: badge.image} : null),
|
||||||
|
color = badge.color || full_badge.color || 'transparent',
|
||||||
|
masked = color !== 'transparent' && is_mask,
|
||||||
|
|
||||||
bu = (urls || full_badge.urls || {1: full_badge.image}),
|
bu = (urls || full_badge.urls || {1: full_badge.image}),
|
||||||
bd = {
|
bd = {
|
||||||
|
@ -288,22 +289,26 @@ export default class Badges extends Module {
|
||||||
title: badge.title || full_badge.title
|
title: badge.title || full_badge.title
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let style;
|
||||||
|
|
||||||
if ( old_badge ) {
|
if ( old_badge ) {
|
||||||
|
old_badge.badges.push(bd);
|
||||||
|
|
||||||
const replaces = has(badge, 'replaces') ? badge.replaces : full_badge.replaces,
|
const replaces = has(badge, 'replaces') ? badge.replaces : full_badge.replaces,
|
||||||
replaces_type = badge.replaces_type || full_badge.replaces_type;
|
replaces_type = badge.replaces_type || full_badge.replaces_type;
|
||||||
if ( replaces && (!replaces_type || replaces_type === old_badge.id) )
|
if ( replaces && (!replaces_type || replaces_type === old_badge.id) )
|
||||||
old_badge.replaced = badge.id;
|
old_badge.replaced = badge.id;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
old_badge.badges.push(bd);
|
style = old_badge.props.style;
|
||||||
continue;
|
|
||||||
|
|
||||||
} else if ( ! slot )
|
} else if ( ! slot )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const style = {},
|
else {
|
||||||
color = badge.color || full_badge.color || 'transparent',
|
style = {};
|
||||||
masked = color !== 'transparent' && is_mask,
|
const props = {
|
||||||
props = {
|
|
||||||
className: 'ffz-tooltip ffz-badge',
|
className: 'ffz-tooltip ffz-badge',
|
||||||
'data-tooltip-type': 'badge',
|
'data-tooltip-type': 'badge',
|
||||||
'data-provider': 'ffz',
|
'data-provider': 'ffz',
|
||||||
|
@ -311,6 +316,9 @@ export default class Badges extends Module {
|
||||||
style
|
style
|
||||||
};
|
};
|
||||||
|
|
||||||
|
slotted[slot] = {id: badge.id, props, badges: [bd]}
|
||||||
|
}
|
||||||
|
|
||||||
if ( has_image && urls ) {
|
if ( has_image && urls ) {
|
||||||
let image_set, image = `url("${urls[1]}")`;
|
let image_set, image = `url("${urls[1]}")`;
|
||||||
if ( urls[2] || urls[4] )
|
if ( urls[2] || urls[4] )
|
||||||
|
@ -327,8 +335,6 @@ export default class Badges extends Module {
|
||||||
else
|
else
|
||||||
style.backgroundColor = badge.color;
|
style.backgroundColor = badge.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
slotted[slot] = { id: badge.id, props, badges: [bd] };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const slot in slotted)
|
for(const slot in slotted)
|
||||||
|
|
|
@ -217,6 +217,11 @@ export class Tooltip {
|
||||||
|
|
||||||
arrow.setAttribute('x-arrow', true);
|
arrow.setAttribute('x-arrow', true);
|
||||||
|
|
||||||
|
if ( tip.add_class ) {
|
||||||
|
inner.classList.add(tip.add_class);
|
||||||
|
tip.add_class = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const interactive = maybe_call(opts.interactive, null, target, tip);
|
const interactive = maybe_call(opts.interactive, null, target, tip);
|
||||||
el.classList.toggle('interactive', interactive || false);
|
el.classList.toggle('interactive', interactive || false);
|
||||||
|
|
||||||
|
|
|
@ -137,13 +137,14 @@ body {
|
||||||
.ffz__tooltip--inner {
|
.ffz__tooltip--inner {
|
||||||
display: block;
|
display: block;
|
||||||
max-width: 30rem;
|
max-width: 30rem;
|
||||||
padding: 3px 6px;
|
padding: .3rem .6rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
.preview-image {
|
.preview-image {
|
||||||
&.ffz-badge {
|
&.ffz-badge {
|
||||||
height: 72px;
|
height: 7.2rem;
|
||||||
width: 72px;
|
width: 7.2rem;
|
||||||
|
background-size: 7.2rem;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +162,18 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.ffz__tooltip--badges {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
max-width: 20rem;
|
||||||
|
padding: .1rem .2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ffz-badge-tip {
|
||||||
|
margin: .2rem .4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.ffz-rich-tip {
|
.ffz-rich-tip {
|
||||||
max-width: 340px;
|
max-width: 340px;
|
||||||
width: 340px;
|
width: 340px;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue