@atlaskit/lozenge
Version:
A lozenge is a visual indicator used to highlight an item's status for quick recognition.
28 lines (26 loc) • 893 B
JavaScript
// Map legacy appearance to new color values
const legacyAppearanceMap = {
default: 'neutral',
removed: 'danger',
inprogress: 'information',
new: 'discovery',
moved: 'warning'
};
// Resolve the lozenge color based on the appearance
export const resolveLozengeColor = (appearance = 'neutral') => {
var _legacyAppearanceMap$;
if (appearance.startsWith('accent-')) {
return appearance;
}
return (_legacyAppearanceMap$ = legacyAppearanceMap[appearance]) !== null && _legacyAppearanceMap$ !== void 0 ? _legacyAppearanceMap$ : appearance;
};
// extract the category and key from the resolved color
export const getThemeStyles = resolvedColor => {
const isAccent = resolvedColor.startsWith('accent-');
const category = isAccent ? 'accent' : 'semantic';
const key = isAccent ? resolvedColor.replace('accent-', '') : resolvedColor;
return {
category,
key
};
};