mirror of
https://github.com/flarum/framework.git
synced 2025-01-20 19:20:46 +08:00
fix: custom contrast color affected by parents
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
parent
253a3d281d
commit
577890d89c
|
@ -28,7 +28,7 @@ export default class Badge<CustomAttrs extends IBadgeAttrs = IBadgeAttrs> extend
|
|||
view() {
|
||||
const { type, icon: iconName, label, color, style = {}, ...attrs } = this.attrs;
|
||||
|
||||
const className = classList('Badge', [type && `Badge--${type}`], attrs.className, color && textContrastClass(color));
|
||||
const className = classList('Badge', [type && `Badge--${type}`], attrs.className, textContrastClass(color));
|
||||
|
||||
const iconChild = iconName ? icon(iconName, { className: 'Badge-icon' }) : m.trust(' ');
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import isDark from '../utils/isDark';
|
||||
|
||||
export default function textContrastClass(hexcolor: string | null): string {
|
||||
export default function textContrastClass(hexcolor: string | null | undefined): string {
|
||||
if (!hexcolor) return 'text-contrast--unchanged';
|
||||
|
||||
return isDark(hexcolor) ? 'text-contrast--light' : 'text-contrast--dark';
|
||||
}
|
||||
|
|
|
@ -176,4 +176,10 @@ blockquote ol:last-child {
|
|||
--contrast-color: var(--text-on-dark);
|
||||
color: var(--contrast-color);
|
||||
}
|
||||
|
||||
// This exists to prevent inheriting the contrast color from a parent element.
|
||||
// Like when a badge is inside a tag hero.
|
||||
&--unchanged {
|
||||
--contrast-color: var(--unchanged-color);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user