|
3 | 3 | * SPDX-License-Identifier: AGPL-3.0-or-later
|
4 | 4 | */
|
5 | 5 |
|
6 |
| -import styled from 'styled-components'; |
7 |
| -import useTranslation from 'web/hooks/useTranslation'; |
8 |
| -import PropTypes from 'web/utils/proptypes'; |
| 6 | +import createLabel from 'web/components/label/label'; |
9 | 7 | import Theme from 'web/utils/theme';
|
10 | 8 |
|
11 |
| -const Label = styled.div` |
12 |
| - text-align: center; |
13 |
| - font-weight: normal; |
14 |
| - font-style: normal; |
15 |
| - color: white; |
16 |
| - padding: 1px; |
17 |
| - display: inline-block; |
18 |
| - width: 70px; |
19 |
| - height: 1.5em; |
20 |
| - font-size: 0.8em; |
21 |
| - background-color: ${props => props.$backgroundColor}; |
22 |
| - border-color: ${props => props.$borderColor}; |
23 |
| -`; |
24 |
| - |
25 |
| -const ComplianceLabel = ({text, color, ...props}) => { |
26 |
| - const [_] = useTranslation(); |
27 |
| - return ( |
28 |
| - <Label |
29 |
| - {...props} |
30 |
| - $backgroundColor={Theme[color]} |
31 |
| - $borderColor={Theme[color]} |
32 |
| - data-testid={`compliance-state-${text}`} |
33 |
| - > |
34 |
| - {_(text)} |
35 |
| - </Label> |
36 |
| - ); |
37 |
| -}; |
38 |
| - |
39 |
| -ComplianceLabel.propTypes = { |
40 |
| - text: PropTypes.string, |
41 |
| - color: PropTypes.string, |
42 |
| -}; |
43 |
| - |
44 |
| -const YesLabel = props => ( |
45 |
| - <ComplianceLabel {...props} color="complianceYes" data-testid="compliance-state-yes" text="Yes"/> |
| 9 | +const YesLabel = createLabel( |
| 10 | + Theme.complianceYes, |
| 11 | + Theme.complianceYes, |
| 12 | + Theme.white, |
| 13 | + 'compliance-state-yes', |
| 14 | + // _('Yes') |
| 15 | + 'Yes', |
46 | 16 | );
|
47 |
| -const NoLabel = props => ( |
48 |
| - <ComplianceLabel {...props} color="complianceNo" data-testid="compliance-state-no" text="No"/> |
| 17 | + |
| 18 | +const NoLabel = createLabel( |
| 19 | + Theme.complianceNo, |
| 20 | + Theme.complianceNo, |
| 21 | + Theme.white, |
| 22 | + 'compliance-state-no', |
| 23 | + // _('No') |
| 24 | + 'No', |
49 | 25 | );
|
50 |
| -const IncompleteLabel = props => ( |
51 |
| - <ComplianceLabel {...props} color="complianceIncomplete" data-testid="compliance-state-incomplete" text="Incomplete"/> |
| 26 | +const IncompleteLabel = createLabel( |
| 27 | + Theme.complianceIncomplete, |
| 28 | + Theme.complianceIncomplete, |
| 29 | + Theme.white, |
| 30 | + 'compliance-state-incomplete', |
| 31 | + // _('Incomplete') |
| 32 | + 'Incomplete', |
52 | 33 | );
|
53 |
| -const UndefinedLabel = props => ( |
54 |
| - <ComplianceLabel {...props} color="complianceUndefined" data-testid="compliance-state-undefined" text="Undefined"/> |
| 34 | +const UndefinedLabel = createLabel( |
| 35 | + Theme.complianceUndefined, |
| 36 | + Theme.complianceUndefined, |
| 37 | + Theme.white, |
| 38 | + 'compliance-state-undefined', |
| 39 | + // _('Undefined') |
| 40 | + 'Undefined', |
55 | 41 | );
|
56 | 42 |
|
57 | 43 | export const ComplianceStateLabels = {
|
|
0 commit comments