Skip to content

Commit 31ce483

Browse files
authored
fix: Allow empty string props to Lable and LinkLabel (#319)
Allow empty string props to Lable and LinkLabel to modify the propTypes warning
1 parent 71d3605 commit 31ce483

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

src/ui/Label/index.jsx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,8 @@ Label.propTypes = {
3131
PropTypes.string,
3232
PropTypes.arrayOf(PropTypes.string),
3333
]),
34-
type: PropTypes.oneOf([
35-
'H_1',
36-
'H_2',
37-
'SUBTITLE_1',
38-
'SUBTITLE_2',
39-
'BODY_1',
40-
'BODY_2',
41-
'BUTTON_1',
42-
'BUTTON_2',
43-
'CAPTION_1',
44-
'CAPTION_2',
45-
'CAPTION_3',
46-
]),
47-
color: PropTypes.oneOf([
48-
'ONBACKGROUND_1',
49-
'ONBACKGROUND_2',
50-
'ONBACKGROUND_3',
51-
'ONBACKGROUND_4',
52-
'ONCONTENT_1',
53-
'ONCONTENT_2',
54-
'PRIMARY',
55-
'ERROR',
56-
'SECONDARY_3',
57-
]),
34+
type: PropTypes.string,
35+
color: PropTypes.string,
5836
children: PropTypes.oneOfType([
5937
PropTypes.string,
6038
PropTypes.number,

src/ui/Label/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function changeTypographyToClassName(type) {
1313
case Typography.CAPTION_1: return 'sendbird-label--caption-1';
1414
case Typography.CAPTION_2: return 'sendbird-label--caption-2';
1515
case Typography.CAPTION_3: return 'sendbird-label--caption-3';
16-
default: return null;
16+
default: return '';
1717
}
1818
}
1919

@@ -28,6 +28,6 @@ export function changeColorToClassName(color) {
2828
case Colors.PRIMARY: return 'sendbird-label--color-primary'; // should be Primary-3 fix me
2929
case Colors.ERROR: return 'sendbird-label--color-error';
3030
case Colors.SECONDARY_3: return 'sendbird-label--color-secondary-3';
31-
default: return null;
31+
default: return '';
3232
}
3333
}

src/ui/LinkLabel/index.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ LinkLabel.propTypes = {
4444
PropTypes.arrayOf(PropTypes.string),
4545
]),
4646
src: PropTypes.string.isRequired,
47-
type: PropTypes.oneOf(Object.keys(LabelTypography)).isRequired,
48-
color: PropTypes.oneOf(Object.keys(LabelColors)).isRequired,
47+
type: PropTypes.string,
48+
color: PropTypes.string,
4949
children: PropTypes.oneOfType([
5050
PropTypes.string,
5151
PropTypes.element,
@@ -56,6 +56,8 @@ LinkLabel.propTypes = {
5656

5757
LinkLabel.defaultProps = {
5858
className: '',
59+
type: '',
60+
color: '',
5961
};
6062

6163
export const LinkLabelTypography = LabelTypography;

0 commit comments

Comments
 (0)