newrelic / nr1-community

An open-source library of useful components for building on New Relic One's programmability platform.
https://developer.newrelic.com
Apache License 2.0
11 stars 12 forks source link

feat(EmptyState): allow props to be functions for maximum flexibility #60

Closed devfreddy closed 4 years ago

devfreddy commented 4 years ago

Summary

The current prop list for <EmptyState> looks like:

    heading: PropTypes.string,
    description: PropTypes.string,
    buttonText: PropTypes.string,
    buttonOnClick: PropTypes.func,
    buttonUrl: PropTypes.string,
    className: PropTypes.string,
    featuredImage: PropTypes.string,
    footer: PropTypes.func

Desired Behavior

More flexible options for customization. For example:

    <EmptyState description={() => {
        return (
            <React.Fragment>
                <p>Paragraph 1</p>
                <br/>
                <p>Paragraph 2</p>
            </React.fragment>
        )
      }}
    </EmptyState>

Possible Solution

Let's investigate and make a change to allow for any of them to be a function OR a string, like this:

    heading: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    description: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    buttonText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    buttonOnClick: PropTypes.func,
    buttonUrl: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    className: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    featuredImage: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
    footer: PropTypes.func

Additional context

danielgolden commented 4 years ago

@devfreddy Do you have a use case in mind for providing a function to buttonUrl and className? Wouldn't we always want them to be a string?

tangollama commented 4 years ago

Closed by #74