|
| 1 | +import React from 'react'; |
| 2 | +import PropTypes from 'prop-types'; |
| 3 | +import Styled from 'rsg-components/Styled'; |
| 4 | + |
| 5 | +export const styles = ({ color, space, fontSize, fontFamily }) => ({ |
| 6 | + root: { |
| 7 | + position: 'fixed', |
| 8 | + top: 0, |
| 9 | + right: 0, |
| 10 | + width: 149, |
| 11 | + height: 149, |
| 12 | + zIndex: 999, |
| 13 | + }, |
| 14 | + link: { |
| 15 | + fontFamily: fontFamily.base, |
| 16 | + position: 'relative', |
| 17 | + right: -37, |
| 18 | + top: -22, |
| 19 | + display: 'block', |
| 20 | + width: 190, |
| 21 | + padding: [[space[0], space[2]]], |
| 22 | + textAlign: 'center', |
| 23 | + color: color.ribbonText, |
| 24 | + fontSize: fontSize.base, |
| 25 | + background: color.ribbonBackground, |
| 26 | + textDecoration: 'none', |
| 27 | + textShadow: [[0, '-1px', 0, 'rgba(0,0,0,.15)']], |
| 28 | + transformOrigin: [[0, 0]], |
| 29 | + transform: 'rotate(45deg)', |
| 30 | + cursor: 'pointer', |
| 31 | + }, |
| 32 | +}); |
| 33 | + |
| 34 | +export function RibbonRenderer({ classes, url, text }) { |
| 35 | + return ( |
| 36 | + <div className={classes.root}> |
| 37 | + <a href={url} className={classes.link}> |
| 38 | + {text} |
| 39 | + </a> |
| 40 | + </div> |
| 41 | + ); |
| 42 | +} |
| 43 | + |
| 44 | +RibbonRenderer.defaultProps = { |
| 45 | + text: 'Fork me on GitHub', |
| 46 | +}; |
| 47 | + |
| 48 | +RibbonRenderer.propTypes = { |
| 49 | + classes: PropTypes.object.isRequired, |
| 50 | + url: PropTypes.string.isRequired, |
| 51 | + text: PropTypes.string, |
| 52 | +}; |
| 53 | + |
| 54 | +export default Styled(styles)(RibbonRenderer); |
0 commit comments