react-custom-share
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -52,2 +52,4 @@ 'use strict'; | ||
text: _propTypes2.default.string, | ||
longtext: _propTypes2.default.string, | ||
header: _propTypes2.default.string, | ||
className: _propTypes2.default.string | ||
@@ -54,0 +56,0 @@ }; |
@@ -93,5 +93,6 @@ 'use strict'; | ||
url: _propTypes2.default.string.isRequired, | ||
children: _propTypes2.default.node.isRequired, | ||
text: _propTypes2.default.string, | ||
children: _propTypes2.default.node, | ||
className: _propTypes2.default.string, | ||
longtext: _propTypes2.default.string, | ||
// media prop is required when network is set to 'Pinterest' | ||
media: function media(props, propName, componentName) { | ||
@@ -102,5 +103,6 @@ var key = props['network'].toLowerCase(); | ||
} | ||
} | ||
}, | ||
className: _propTypes2.default.string | ||
}; | ||
exports.default = ShareButton; |
@@ -40,7 +40,5 @@ 'use strict'; | ||
ShareButtonCircle.propTypes = { | ||
network: _propTypes2.default.string.isRequired, | ||
url: _propTypes2.default.string.isRequired, | ||
children: _propTypes2.default.node.isRequired | ||
className: _propTypes2.default.string | ||
}; | ||
exports.default = ShareButtonCircle; |
{ | ||
"name": "react-custom-share", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "Social sharing buttons for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -141,2 +141,87 @@ # react-custom-share | ||
## API | ||
```javascript | ||
import { | ||
// base components (unstyled) | ||
ShareButton, | ||
ShareBlock, | ||
// styled button components | ||
ShareButtonRoundSquare, | ||
ShareButtonRectangle, | ||
ShareButtonCircle, | ||
ShareButtonIconOnly, | ||
ShareButtonOutline, | ||
// styled block components | ||
ShareBlockStandard, | ||
} from 'react-custom-share'; | ||
``` | ||
### `ShareButton` props | ||
```javascript | ||
ShareButton.propTypes = { | ||
// required props | ||
network: PropTypes.string.isRequired, | ||
url: PropTypes.string.isRequired, | ||
children: PropTypes.node.isRequired, | ||
// media is a special 'prop' it's required is network's value is 'Pinterest' | ||
media: function(props, propName, componentName) { | ||
const key = props['network'].toLowerCase(); | ||
if (key === 'pinterest' && props[propName] === undefined) { | ||
return new Error( | ||
`The prop '${propName}' is marked as required in '${componentName}' for the 'Pinterest' network, but it's value is 'undefined'.` | ||
); | ||
} | ||
}, | ||
// optional props | ||
text: PropTypes.string, | ||
longtext: PropTypes.string, | ||
className: PropTypes.string, | ||
}; | ||
``` | ||
### `ShareBlock` props | ||
```javascript | ||
ShareBlock.propTypes = { | ||
// props applied to each one of the buttons rendered by the block | ||
url: PropTypes.string.isRequired, | ||
button: PropTypes.func.isRequired, | ||
buttons: PropTypes.array.isRequired, | ||
text: PropTypes.string, | ||
longtext: PropTypes.string, | ||
// block's own props | ||
header: PropTypes.string, | ||
className: PropTypes.string, | ||
}; | ||
``` | ||
### Built-in styled components | ||
Styled components have the same api as its base versions. They work as wrappers for the base components and set the value of the `className` prop of the inner component they wrap. | ||
Below is the simplified code of `ShareButtonCircle`, one of the built-in styled buttons. | ||
```javascript | ||
import { css } from 'emotion'; | ||
const ShareButtonCircle = props => { | ||
return ( | ||
<ShareButton | ||
className={css` | ||
border-radius: 50%; | ||
/* ... for the clarity most of the real CSS code was removed */ | ||
`} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
export default ShareButtonCircle; | ||
``` | ||
## License | ||
@@ -143,0 +228,0 @@ |
46951
518
265