olahol / react-social

Simple React components for social buttons (Facebook, Twitter and Pinterest) and social counts.
177 stars 60 forks source link

ButtonGroup #23

Open dstuecken opened 8 years ago

dstuecken commented 8 years ago

I think of a ButtonGroup component that is capable of displaying all the buttons you want with just one single component. Because usually you want to share the same url with the same message at one time. So what you basically can do with a button group would be something like that:

render() {
  const url = "https://github.com/olahol/react-socia", message = "So cool!";
  const buttonsToShow = [{
       button: 'Facebook',
       style: BUTTON_WITH_COUNTER,
       appId: 'my-facebook-app-id'
    }, {
       button: 'Google',
       style: BUTTON_WITHOUT_COUNTER
    }, {
       button: 'Reddit'
    }
  ];

  return (
    <div className="btn-group">
      <ButtonGroup url={url} message={message} buttons={buttonsToShow} />
    </div>
  )
}

url and message are directly passed down to every button props since it is always the same. appId is only passed if available and needed. And there can be a button style that can display a button itself or one with a couter.

What do you guys think of that approach?

olahol commented 8 years ago

This sounds like a great idea, I've also been wanting incorporate styles.