Skip to content

Commit 59cd66c

Browse files
feat(app-rfi): only include space if icon present
1 parent 56f6a92 commit 59cd66c

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

packages/app-rfi/src/components/controls/RfiRadioGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Field } from "formik";
55
import PropTypes from "prop-types";
66
import React from "react";
77

8-
import {RfiError, RfiLabel, RfiLegend} from "./controls-helpers";
8+
import { RfiError, RfiLegend } from "./controls-helpers";
99

1010
const RfiRadioGroup = ({ name, id, options, label, onBlur }) => {
1111
return (

packages/app-rfi/src/components/controls/controls-helpers.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,41 @@ const GaEventPropTypes = {
1717

1818
const RfiLabel = ({ label, name, id, requiredIcon }) => (
1919
<label htmlFor={id || name}>
20-
{requiredIcon ? (
21-
<span title="Required">
22-
<i className="fas fa-circle uds-field-required" aria-hidden="true" />
23-
</span>
24-
) : null}
25-
&nbsp;
20+
{requiredIcon && (
21+
<>
22+
<span title="Required">
23+
<i className="fas fa-circle uds-field-required" aria-hidden="true" />
24+
</span>
25+
&nbsp;
26+
</>
27+
)}
2628
{label}
2729
</label>
2830
);
2931

3032
const RfiLegend = ({ label, requiredIcon }) => (
3133
<legend className="fw-bold">
32-
{requiredIcon ? (
33-
<span title="Required">
34-
<i className="fas fa-circle uds-field-required" aria-hidden="true" />
35-
</span>
36-
) : null}
37-
&nbsp;
34+
{requiredIcon && (
35+
<>
36+
<span title="Required">
37+
<i className="fas fa-circle uds-field-required" aria-hidden="true" />
38+
</span>
39+
&nbsp;
40+
</>
41+
)}
3842
{label}
3943
</legend>
4044
);
4145

4246
const RfiError = ({ isError, metaError }) => (
4347
<div role="alert">
44-
{isError ? (
48+
{isError && (
4549
<small className="form-text invalid-feedback">
4650
<i className="fas fa-exclamation-triangle" aria-hidden="true" />
4751
&nbsp;
4852
{metaError}
4953
</small>
50-
) : null}
54+
)}
5155
</div>
5256
);
5357

@@ -67,6 +71,16 @@ RfiLabel.propTypes = {
6771
requiredIcon: PropTypes.bool,
6872
};
6973

74+
RfiLegend.defaultProps = {
75+
label: undefined,
76+
requiredIcon: undefined,
77+
};
78+
79+
RfiLegend.propTypes = {
80+
label: PropTypes.string.isRequired,
81+
requiredIcon: PropTypes.bool,
82+
};
83+
7084
RfiError.defaultProps = {
7185
isError: undefined,
7286
metaError: undefined,

0 commit comments

Comments
 (0)