From 13f1a4754302483c23e1cee0c90992eb9a143e8e Mon Sep 17 00:00:00 2001 From: Andi Wilson Date: Wed, 3 Jun 2020 09:27:59 -0700 Subject: [PATCH 1/2] Add `textOnly` prop render without span --- src/Pluralize.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Pluralize.js b/src/Pluralize.js index 9543a37..77b8b8d 100644 --- a/src/Pluralize.js +++ b/src/Pluralize.js @@ -3,32 +3,37 @@ * Tom Smith (https://github.com/tsmith123) */ -import React from 'react' -import PropTypes from 'prop-types' -import { pluralize } from './utils' +import React from 'react'; +import PropTypes from 'prop-types'; +import { pluralize } from './utils'; -const Plural = ({ className, style, ...props }) => ( - - {pluralize(props)} - -) +const Plural = ({ className, style, ...props }) => + textOnly ? ( + pluralize(props) + ) : ( + + {pluralize(props)} + + ); Plural.propTypes = { singular: PropTypes.string.isRequired, plural: PropTypes.string, count: PropTypes.number, showCount: PropTypes.bool, + textOnly: PropTypes.bool, className: PropTypes.string, style: PropTypes.object, zero: PropTypes.string -} +}; Plural.defaultProps = { count: 1, showCount: true, + textOny: false, className: null, style: {}, zero: null -} +}; -export default Plural +export default Plural; From d29053a9eca311455db0bed2999edf0e07208096 Mon Sep 17 00:00:00 2001 From: Andi Wilson Date: Wed, 3 Jun 2020 14:49:13 -0700 Subject: [PATCH 2/2] Update Pluralize.js --- src/Pluralize.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Pluralize.js b/src/Pluralize.js index 77b8b8d..c202171 100644 --- a/src/Pluralize.js +++ b/src/Pluralize.js @@ -7,32 +7,33 @@ import React from 'react'; import PropTypes from 'prop-types'; import { pluralize } from './utils'; -const Plural = ({ className, style, ...props }) => - textOnly ? ( - pluralize(props) - ) : ( - + +const Plural = ({ className, style, tag: Tag, ...props }) => + Tag ? ( + {pluralize(props)} - + + ) : ( + pluralize(props) ); Plural.propTypes = { - singular: PropTypes.string.isRequired, - plural: PropTypes.string, + className: PropTypes.string, count: PropTypes.number, + plural: PropTypes.string, showCount: PropTypes.bool, - textOnly: PropTypes.bool, - className: PropTypes.string, + singular: PropTypes.string.isRequired, style: PropTypes.object, + tag: PropTypes.string, zero: PropTypes.string }; Plural.defaultProps = { + className: null, count: 1, showCount: true, - textOny: false, - className: null, - style: {}, + style: null, + tag: 'span', zero: null };