mirror of
https://github.com/flarum/framework.git
synced 2025-02-17 02:02:47 +08:00
fix: unreadable badge icon on certain colors (#3810)
This commit is contained in:
parent
af3f91ca5b
commit
7ebeb9c0a5
|
@ -2,6 +2,7 @@ import Tooltip from './Tooltip';
|
|||
import Component, { ComponentAttrs } from '../Component';
|
||||
import icon from '../helpers/icon';
|
||||
import classList from '../utils/classList';
|
||||
import textContrastClass from '../helpers/textContrastClass';
|
||||
|
||||
export interface IBadgeAttrs extends ComponentAttrs {
|
||||
icon: string;
|
||||
|
@ -27,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);
|
||||
const className = classList('Badge', [type && `Badge--${type}`], attrs.className, color && textContrastClass(color));
|
||||
|
||||
const iconChild = iconName ? icon(iconName, { className: 'Badge-icon' }) : m.trust(' ');
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
height: var(--size);
|
||||
border-radius: calc(~"var(--size) / 2");
|
||||
background: var(--badge-bg);
|
||||
color: var(--badge-color);
|
||||
color: var(--contrast-color, var(--badge-color));
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
|
Loading…
Reference in New Issue
Block a user