Skip to content

Instantly share code, notes, and snippets.

@kitten
Created March 15, 2017 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitten/0064fdcc66af20fbb76c60e859a85205 to your computer and use it in GitHub Desktop.
Save kitten/0064fdcc66af20fbb76c60e859a85205 to your computer and use it in GitHub Desktop.
babel-plugin-styled-components test with styled-components.github.io's App.js
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _noParser = require('styled-components/no-parser');
var _noParser2 = _interopRequireDefault(_noParser);
var _logo = require('./logo.png');
var _logo2 = _interopRequireDefault(_logo);
var _constants = require('./constants');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Wrapper = _noParser2.default.div.withConfig({
displayName: 'App__Wrapper',
componentId: 's1p2uub3-0'
})([[' {width: 100%;min-height: calc(100vh - 5em);background-color: ', _constants.colors.secondary, ';;display:-webkit-box;display:-webkit-flex;-ms-flexbox;display:flex;-webkit-flex-direction: column;-ms-flex-direction: column;flex-direction: column;-webkit-box-align: center;-ms-flex-align: center;align-items: center;color: ', _constants.colors.primary, ';;font-family: "Avenir Next", sans-serif;padding-top: 5em;}']]);
var imageMargin = '1';
var Image = _noParser2.default.img.withConfig({
displayName: 'App__Image',
componentId: 's1p2uub3-1'
})([[' {width: calc(100% - ', imageMargin * 2, ';em);max-width: 600px;margin-bottom: 4em;border-radius: 2px;box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);margin-left: ', imageMargin, ';em;margin-right: ', imageMargin, ';em;}']]);
var Logo = _noParser2.default.img.withConfig({
displayName: 'App__Logo',
componentId: 's1p2uub3-2'
})([[' {width: 100%;max-width: 125px;}']]);
var Tagline = _noParser2.default.h1.withConfig({
displayName: 'App__Tagline',
componentId: 's1p2uub3-3'
})([[' {max-width: 90%;text-align: center;font-size: 1.15em;line-height: 1.5em;font-weight: 400;margin: 2em 0;}']]);
var Bold = _noParser2.default.span.withConfig({
displayName: 'App__Bold',
componentId: 's1p2uub3-4'
})([[' {font-weight: bold;}']]);
var Link = _noParser2.default.a.withConfig({
displayName: 'App__Link',
componentId: 's1p2uub3-5'
})([[' {color: ', _constants.colors.primary, ';;', function (props) {
return props.bold && 'font-weight: bold;';
}, ';}']]);
var Button = (0, _noParser2.default)(Link).withConfig({
displayName: 'App__Button',
componentId: 's1p2uub3-6'
})([[' {border: 2px solid ', _constants.colors.primary, ';;border-radius: 3px;padding: 0.5em 2em;text-decoration: none;font-size: 1em;margin: 0 1em;background: ', function (props) {
return props.primary && 'palevioletred';
}, ';;color: ', function (props) {
return props.primary ? 'white' : 'palevioletred';
}, ';;}']]);
var Footer = _noParser2.default.p.withConfig({
displayName: 'App__Footer',
componentId: 's1p2uub3-7'
})([[' {margin-top: auto;padding-top: 5em;}']]);
var App = function (_Component) {
_inherits(App, _Component);
function App() {
_classCallCheck(this, App);
return _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).apply(this, arguments));
}
_createClass(App, [{
key: 'render',
value: function render() {
return _react2.default.createElement(
Wrapper,
null,
_react2.default.createElement(Logo, { src: _logo2.default, alt: 'styled-components' }),
_react2.default.createElement(
Tagline,
null,
_react2.default.createElement(
Bold,
null,
'Visual primitives for the component age.'
),
_react2.default.createElement('br', null),
'Use the best bits of ES6 and CSS to style your apps without stress \uD83D\uDC85'
),
_react2.default.createElement(Image, { src: process.env.PUBLIC_URL + '/code-atom.png', alt: 'Code sample of styled-components' }),
_react2.default.createElement(
'div',
null,
_react2.default.createElement(
Button,
{ href: 'https://github.com/styled-components/styled-components', target: '_blank', primary: true },
'GitHub'
),
_react2.default.createElement(
Button,
{ href: 'http://www.webpackbin.com/V1VNoINA-', target: '_blank' },
'Try it out!'
)
),
_react2.default.createElement(
Footer,
null,
'Made by ',
_react2.default.createElement(
Link,
{ href: 'https://twitter.com/glenmaddern', bold: true, target: '_blank' },
'@glenmaddern'
),
' and ',
_react2.default.createElement(
Link,
{ href: 'https://twitter.com/mxstbr', bold: true, target: '_blank' },
'@mxstbr'
)
)
);
}
}]);
return App;
}(_react.Component);
exports.default = App;
import React, { Component } from 'react';
import styled from 'styled-components';
import logo from './logo.png';
import { colors } from './constants';
const Wrapper = styled.div`
width: 100%;
min-height: calc(100vh - 5em);
background-color: ${colors.secondary};
display: flex;
flex-direction: column;
align-items: center;
color: ${colors.primary};
font-family: "Avenir Next", sans-serif;
padding-top: 5em;
`;
const imageMargin = '1';
const Image = styled.img`
width: calc(100% - ${imageMargin * 2}em);
max-width: 600px;
margin-bottom: 4em;
border-radius: 2px;
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
margin-left: ${imageMargin}em;
margin-right: ${imageMargin}em;
`;
const Logo = styled.img`
width: 100%;
max-width: 125px;
`;
const Tagline = styled.h1`
max-width: 90%;
text-align: center;
font-size: 1.15em;
line-height: 1.5em;
font-weight: 400;
margin: 2em 0;
`;
const Bold = styled.span`
font-weight: bold;
`;
const Link = styled.a`
color: ${colors.primary};
${(props) => props.bold && 'font-weight: bold;'}
`;
const Button = styled(Link)`
border: 2px solid ${colors.primary};
border-radius: 3px;
padding: 0.5em 2em;
text-decoration: none;
font-size: 1em;
margin: 0 1em;
background: ${(props) => props.primary && 'palevioletred'};
color: ${(props) => props.primary ? 'white' : 'palevioletred'};
`;
const Footer = styled.p`
margin-top: auto;
padding-top: 5em;
`;
class App extends Component {
render() {
return (
<Wrapper>
<Logo src={logo} alt="styled-components" />
<Tagline><Bold>Visual primitives for the component age.</Bold><br />Use the best bits of ES6 and CSS to style your apps without stress 💅</Tagline>
<Image src={`${process.env.PUBLIC_URL}/code-atom.png`} alt="Code sample of styled-components" />
<div>
<Button href="https://github.com/styled-components/styled-components" target="_blank" primary>GitHub</Button>
<Button href="http://www.webpackbin.com/V1VNoINA-" target="_blank">Try it out!</Button>
</div>
<Footer>
Made by <Link href="https://twitter.com/glenmaddern" bold target="_blank">@glenmaddern</Link> and <Link href="https://twitter.com/mxstbr" bold target="_blank">@mxstbr</Link>
</Footer>
</Wrapper>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment