Skip to content

Commit

Permalink
chore: Add support for custom class names.
Browse files Browse the repository at this point in the history
  • Loading branch information
lquixada committed May 22, 2018
1 parent 58bb114 commit 0b5319b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ It has four color.
- `black`
- `green`

#### className

It would be an html tag's attribute `class`.

## Release Notes

### Version 0.5.1 - 2017/10/05
Expand Down
7 changes: 4 additions & 3 deletions dst/react-github-fork-ribbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ var GitHubForkRibbon = function GitHubForkRibbon(_ref) {
target = _ref.target,
_ref$color = _ref.color,
color = _ref$color === undefined ? 'red' : _ref$color,
className = _ref.className,
children = _ref.children,
other = _objectWithoutProperties(_ref, ['position', 'href', 'target', 'color', 'children']);
other = _objectWithoutProperties(_ref, ['position', 'href', 'target', 'color', 'className', 'children']);

var positionStyle = positionMapping[position] || [_ribbonStyle.RibbonStyle.rightStyle, _ribbonStyle.RibbonStyleWrapper.rightStyle];
var colorStyle = colorMapping[color] || _ribbonStyle.RibbonStyle.redColor;
Expand All @@ -56,7 +57,7 @@ var GitHubForkRibbon = function GitHubForkRibbon(_ref) {
return _react2.default.createElement(
'div',
_extends({}, other, {
className: 'github-fork-ribbon-wrapper ' + position,
className: 'github-fork-ribbon-wrapper ' + position + ' ' + className,
style: wrapperStyle }),
_react2.default.createElement(
'div',
Expand Down Expand Up @@ -138,7 +139,7 @@ var RibbonStyle = exports.RibbonStyle = {

/* Add "stitching" effect */
borderWidth: '1px 0',
borderStyle: 'dotted',
borderStyle: 'dashed',
// borderColor: '#fff',
borderColor: 'rgba(255, 255, 255, 0.7)'
},
Expand Down
2 changes: 1 addition & 1 deletion dst/react-github-fork-ribbon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const colorMapping = {
green: RibbonStyle.greenColor,
};

const GitHubForkRibbon = ({position = 'right', href, target, color = 'red', children, ...other}) => {
const GitHubForkRibbon = ({position = 'right', href, target, color = 'red', className = '', children, ...other}) => {

const positionStyle = positionMapping[position] || [RibbonStyle.rightStyle, RibbonStyleWrapper.rightStyle];
const colorStyle = colorMapping[color] || RibbonStyle.redColor;
Expand All @@ -41,7 +41,7 @@ const GitHubForkRibbon = ({position = 'right', href, target, color = 'red', chil

return (
<div {...other}
className={`github-fork-ribbon-wrapper ${position}`}
className={`github-fork-ribbon-wrapper ${position} ${className}`}
style={wrapperStyle}>
<div className="github-fork-ribbon"
style={ribbonStyle}>
Expand Down
22 changes: 22 additions & 0 deletions storybook/__tests__/GithubForkRibbon.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,25 @@ storiesOf('GitHub fork ribbon/color', module)

return component;
});

storiesOf('GitHub fork ribbon/className', module)
.add('hidden on small devices up to 576px', () => {
const component = (
<div>
<style>
{`
@media (max-width: 576px) {
.custom-class {
display: none;
}
}
`}
</style>
<GitHubForkRibbon href="//www.google.com" target="_blank" className="custom-class">
Fork me on GitHub
</GitHubForkRibbon>
</div>
);

return component;
});

0 comments on commit 0b5319b

Please sign in to comment.