Skip to content

Commit

Permalink
chore: v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jessy1092 committed Apr 11, 2017
1 parent a965caf commit 5eb27b1
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 88 deletions.
67 changes: 22 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,31 @@ React GitHub Fork Ribbon

Pure inline style github fork ribbon on React component. The inline style css is from ["Fork me on GitHub" CSS ribbon](http://simonwhitaker.github.io/github-fork-ribbon-css/).

| | React = 0.12 | React >= 0.13 |
| ------- | ------------ | ------------- |
| Version | <= 0.2 | >= 0.3 |
| | React = 0.12 | React = 0.13 | React >= 0.14 |
| ------- | ------------ | ------------- | ------------- |
| Version | <= 0.2 | >= 0.3 < 0.5 | >= 0.5 |

## Usage

```sh
npm install react-github-fork-ribbon
```

Ex. React 0.14
Ex. React 15.5
```js
var React = require('react');
var ReactDOM = require('react-dom');
var GitHubForkRibbon = require('react-github-fork-ribbon');

var Content = React.createClass({

render: function () {
return (
<GitHubForkRibbon href="//www.google.com"
target="_blank"
position="right">
Fork me on GitHub
</GitHubForkRibbon>
);
}
});

ReactDOM.render(
<Content />,
document.getElementById('content')
import React from 'react';
import ReactDOM from 'react-dom';
import GitHubForkRibbon from 'react-github-fork-ribbon';

const Content = () => (
<GitHubForkRibbon href="//www.google.com"
target="_blank"
position="right">
Fork me on GitHub
</GitHubForkRibbon>
);
```

Ex. React 0.13
```js
var React = require('react');
var GitHubForkRibbon = require('react-github-fork-ribbon');

var Content = React.createClass({

render: function () {
return (
<GitHubForkRibbon href="//www.google.com"
target="_blank"
position="right">
Fork me on GitHub
</GitHubForkRibbon>
);
}
});

React.render(
ReactDOM.render(
<Content />,
document.getElementById('content')
);
Expand Down Expand Up @@ -91,6 +62,12 @@ It has four color.

## Release Notes

### Version 0.5.0 - 2017/04/11

- Drop react 0.13 support
- Support react 15.5 for preparing upgrade to react 16
- Add jest for snapshot testing

### Version 0.4.5 - 2017/03/11

- Refactor position and color set function
Expand Down Expand Up @@ -148,7 +125,7 @@ It has four color.

The MIT License (MIT)

Copyright (c) 2015 Lee < [email protected] >
Copyright (c) 2015-2017 Lee < [email protected] >

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
85 changes: 44 additions & 41 deletions dst/react-github-fork-ribbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,61 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var positionMapping = {
left: [_ribbonStyle.GitHubForkRibbon.leftStyle, _ribbonStyle.GitHubForkRibbonWrapper.leftStyle],
right: [_ribbonStyle.GitHubForkRibbon.rightStyle, _ribbonStyle.GitHubForkRibbonWrapper.rightStyle],
'left-bottom': [_ribbonStyle.GitHubForkRibbon.leftBottomStyle, _ribbonStyle.GitHubForkRibbonWrapper.leftBottomStyle],
'right-bottom': [_ribbonStyle.GitHubForkRibbon.rightBottomStyle, _ribbonStyle.GitHubForkRibbonWrapper.rightBottomStyle]
left: [_ribbonStyle.RibbonStyle.leftStyle, _ribbonStyle.RibbonStyleWrapper.leftStyle],
right: [_ribbonStyle.RibbonStyle.rightStyle, _ribbonStyle.RibbonStyleWrapper.rightStyle],
'left-bottom': [_ribbonStyle.RibbonStyle.leftBottomStyle, _ribbonStyle.RibbonStyleWrapper.leftBottomStyle],
'right-bottom': [_ribbonStyle.RibbonStyle.rightBottomStyle, _ribbonStyle.RibbonStyleWrapper.rightBottomStyle]
};

var colorMapping = {
red: _ribbonStyle.GitHubForkRibbon.redColor,
orange: _ribbonStyle.GitHubForkRibbon.orangeColor,
black: _ribbonStyle.GitHubForkRibbon.blackColor,
green: _ribbonStyle.GitHubForkRibbon.greenColor
red: _ribbonStyle.RibbonStyle.redColor,
orange: _ribbonStyle.RibbonStyle.orangeColor,
black: _ribbonStyle.RibbonStyle.blackColor,
green: _ribbonStyle.RibbonStyle.greenColor
};

exports.default = global.GitHubForkRibbon = _react2.default.createClass({
displayName: 'GitHubForkRibbon',
render: function render() {
var _props = this.props,
_props$position = _props.position,
position = _props$position === undefined ? 'right' : _props$position,
href = _props.href,
target = _props.target,
_props$color = _props.color,
color = _props$color === undefined ? 'red' : _props$color,
other = _objectWithoutProperties(_props, ['position', 'href', 'target', 'color']);

var positionStyle = positionMapping[position] || [_ribbonStyle.GitHubForkRibbon.rightStyle, _ribbonStyle.GitHubForkRibbonWrapper.rightStyle];
var colorStyle = colorMapping[color] || _ribbonStyle.GitHubForkRibbon.redColor;
var GitHubForkRibbon = function GitHubForkRibbon() {
var _props = undefined.props,
_props$position = _props.position,
position = _props$position === undefined ? 'right' : _props$position,
href = _props.href,
target = _props.target,
_props$color = _props.color,
color = _props$color === undefined ? 'red' : _props$color,
other = _objectWithoutProperties(_props, ['position', 'href', 'target', 'color']);

var positionStyle = positionMapping[position] || [_ribbonStyle.RibbonStyle.rightStyle, _ribbonStyle.RibbonStyleWrapper.rightStyle];
var colorStyle = colorMapping[color] || _ribbonStyle.RibbonStyle.redColor;

if (positionStyle[0] === _ribbonStyle.RibbonStyle.rightStyle) {
position = 'right';
}

this.ribbonStyle = _extends({}, _ribbonStyle.GitHubForkRibbon.baseStyle, positionStyle[0], colorStyle);
undefined.ribbonStyle = _extends({}, _ribbonStyle.RibbonStyle.baseStyle, positionStyle[0], colorStyle);

this.wrapperStyle = _extends({}, _ribbonStyle.GitHubForkRibbonWrapper.baseStyle, positionStyle[1]);
undefined.wrapperStyle = _extends({}, _ribbonStyle.RibbonStyleWrapper.baseStyle, positionStyle[1]);

return _react2.default.createElement(
return _react2.default.createElement(
'div',
_extends({}, other, {
className: 'github-fork-ribbon-wrapper ' + position,
style: undefined.wrapperStyle }),
_react2.default.createElement(
'div',
_extends({}, other, {
className: 'github-fork-ribbon-wrapper ' + position,
style: this.wrapperStyle }),
{ className: 'github-fork-ribbon',
style: undefined.ribbonStyle },
_react2.default.createElement(
'div',
{ className: 'github-fork-ribbon',
style: this.ribbonStyle },
_react2.default.createElement(
'a',
{ href: href,
target: target,
style: _ribbonStyle.GitHubForkRibbon.urlStyle },
this.props.children
)
'a',
{ href: href,
target: target,
style: _ribbonStyle.RibbonStyle.urlStyle },
undefined.props.children
)
);
}
});
)
);
};

exports.default = global.RibbonStyle = GitHubForkRibbon;

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./ribbonStyle":2}],2:[function(require,module,exports){
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-github-fork-ribbon",
"description": "Pure inline style github fork ribbon on React component",
"version": "0.4.5",
"version": "0.5.0",
"keywords": [
"fork",
"GitHub",
Expand Down

0 comments on commit 5eb27b1

Please sign in to comment.