Skip to content

Commit

Permalink
Add label map
Browse files Browse the repository at this point in the history
  • Loading branch information
Iurii Golovinskii committed Feb 25, 2025
1 parent 19ffdcf commit 2ec6942
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/diff-block/src/DiffBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useAtom } from 'jotai';
import React, { CSSProperties } from 'react';
import ReactDOM from 'react-dom';

import { DIFF_TYPE_COLOR_MAP } from './constants';
import { CHANGE_SEVERITY_NAME_MAP, DIFF_TYPE_COLOR_MAP } from './constants'
import { useDiffBlockIdPrefixContext } from './DiffBlockIdPrefixContext';
import { useDiffContext } from './DiffContext';
import { diffBlockHeight, diffBlockTop } from './state';
Expand Down Expand Up @@ -87,7 +87,7 @@ export const DiffBlock: React.FunctionComponent<{
return (
<Box
className="diff-block-type"
data-diff-type={`${type === 'semi-breaking'? 'risky': type}${cause ? ', ' + cause : ''}`}
data-diff-type={`${CHANGE_SEVERITY_NAME_MAP[type]}${cause ? ', ' + cause : ''}`}
style={{
minHeight,
background,
Expand Down
15 changes: 15 additions & 0 deletions packages/diff-block/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export const syntheticTitleFlag = Symbol('syntheticTitleFlag');

export const DIFF_TYPES: DiffType[] = keys(ClassifierType) as DiffType[];

export const BREAKING_CHANGE_SEVERITY = 'breaking'
export const NON_BREAKING_CHANGE_SEVERITY = 'non-breaking'
export const SEMI_BREAKING_CHANGE_SEVERITY = 'semi-breaking'
export const DEPRECATED_CHANGE_SEVERITY = 'deprecated'
export const ANNOTATION_CHANGE_SEVERITY = 'annotation'
export const UNCLASSIFIED_CHANGE_SEVERITY = 'unclassified'

export const DIFF_TYPE_COLOR_MAP = {
breaking: '#ED4A54',
deprecated: '#F4B24D',
Expand All @@ -27,6 +34,14 @@ export const DIFF_BUDGES_COLOR_MAP = {
unclassified: '#70A9EC',
};

export const CHANGE_SEVERITY_NAME_MAP: Record<DiffType, string> = {
[BREAKING_CHANGE_SEVERITY]: 'breaking',
[SEMI_BREAKING_CHANGE_SEVERITY]: 'risky',
[DEPRECATED_CHANGE_SEVERITY]: 'deprecated',
[NON_BREAKING_CHANGE_SEVERITY]: 'non-breaking',
[UNCLASSIFIED_CHANGE_SEVERITY]: 'unclassified',
[ANNOTATION_CHANGE_SEVERITY]: 'annotation',
}
export type WithDiffMetaKey<T> = T & {
[diffMetaKey]: any;
};

0 comments on commit 2ec6942

Please sign in to comment.