Skip to content

Commit

Permalink
fix: Allow empty string props to Lable and LinkLabel (#319)
Browse files Browse the repository at this point in the history
Allow empty string props to Lable and LinkLabel to modify the propTypes warning
  • Loading branch information
HoonBaek authored Sep 27, 2022
1 parent 71d3605 commit 31ce483
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
26 changes: 2 additions & 24 deletions src/ui/Label/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,8 @@ Label.propTypes = {
PropTypes.string,
PropTypes.arrayOf(PropTypes.string),
]),
type: PropTypes.oneOf([
'H_1',
'H_2',
'SUBTITLE_1',
'SUBTITLE_2',
'BODY_1',
'BODY_2',
'BUTTON_1',
'BUTTON_2',
'CAPTION_1',
'CAPTION_2',
'CAPTION_3',
]),
color: PropTypes.oneOf([
'ONBACKGROUND_1',
'ONBACKGROUND_2',
'ONBACKGROUND_3',
'ONBACKGROUND_4',
'ONCONTENT_1',
'ONCONTENT_2',
'PRIMARY',
'ERROR',
'SECONDARY_3',
]),
type: PropTypes.string,
color: PropTypes.string,
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/Label/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function changeTypographyToClassName(type) {
case Typography.CAPTION_1: return 'sendbird-label--caption-1';
case Typography.CAPTION_2: return 'sendbird-label--caption-2';
case Typography.CAPTION_3: return 'sendbird-label--caption-3';
default: return null;
default: return '';
}
}

Expand All @@ -28,6 +28,6 @@ export function changeColorToClassName(color) {
case Colors.PRIMARY: return 'sendbird-label--color-primary'; // should be Primary-3 fix me
case Colors.ERROR: return 'sendbird-label--color-error';
case Colors.SECONDARY_3: return 'sendbird-label--color-secondary-3';
default: return null;
default: return '';
}
}
6 changes: 4 additions & 2 deletions src/ui/LinkLabel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ LinkLabel.propTypes = {
PropTypes.arrayOf(PropTypes.string),
]),
src: PropTypes.string.isRequired,
type: PropTypes.oneOf(Object.keys(LabelTypography)).isRequired,
color: PropTypes.oneOf(Object.keys(LabelColors)).isRequired,
type: PropTypes.string,
color: PropTypes.string,
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.element,
Expand All @@ -56,6 +56,8 @@ LinkLabel.propTypes = {

LinkLabel.defaultProps = {
className: '',
type: '',
color: '',
};

export const LinkLabelTypography = LabelTypography;
Expand Down

0 comments on commit 31ce483

Please sign in to comment.