File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import styles from './styles.module.css' ;
3+
4+
5+ // Predefined label colors
6+ const labelColors = {
7+ beta : '#9912ec' ,
8+ // example to add other labels
9+ // bug: '#d73a49',
10+ // feature: '#28a745',
11+ } ;
12+
13+ // Utility function to generate random colors
14+ const generateRandomColor = ( ) => {
15+ const letters = '0123456789ABCDEF' ;
16+ let color = '#' ;
17+ for ( let i = 0 ; i < 6 ; i ++ ) {
18+ color += letters [ Math . floor ( Math . random ( ) * 16 ) ] ;
19+ }
20+ return color ;
21+ } ;
22+
23+ const Label = ( { value } ) => {
24+ // Determine the color for the label
25+ const color = labelColors [ value . toLowerCase ( ) ] || generateRandomColor ( ) ;
26+
27+ return (
28+ < span
29+ className = { styles . label }
30+ style = { { backgroundColor : color } }
31+ >
32+ { value . toUpperCase ( ) }
33+ </ span >
34+ ) ;
35+ } ;
36+
37+ export default Label ;
Original file line number Diff line number Diff line change 1+ /* General Label Style */
2+ .label {
3+ display : inline-block;
4+ font-size : 12px ; /* Similar to GitHub's small text */
5+ font-weight : 600 ; /* Bold text */
6+ color : # ffffff ; /* Default text color (white) */
7+ background-color : # 6e5494 ; /* Default background color */
8+ padding : 0.2em 0.6em ; /* Padding for compact sizing */
9+ border-radius : 2em ; /* Rounded corners */
10+ text-align : center;
11+ white-space : nowrap; /* Prevent text wrapping */
12+ vertical-align : middle;
13+ }
14+
15+ /* Example hover effect */
16+ .label : hover {
17+ opacity : 0.9 ; /* Slightly dim on hover */
18+ }
You can’t perform that action at this time.
0 commit comments