Last active
December 20, 2017 12:42
-
-
Save gaganjakhotiya/6a431568fd2c1e30ff256612cc481090 to your computer and use it in GitHub Desktop.
Styled Components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react' | |
import { StyledComponent } from './StyledComponent' | |
function Spinner(props) { | |
return ( | |
<div className={'w--spinner ' + props.customClass}> | |
<div className="bounce1" /> | |
<div className="bounce2" /> | |
<div className="bounce3" /> | |
</div> | |
) | |
} | |
export default StyledComponent(Spinner, require('path/to/file.css')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react' | |
export function StyledComponent(ComponentClass, style) { | |
return class Wrapper extends React.Component { | |
componentWillMount() { | |
style.use() | |
} | |
componentWillUnmount() { | |
style.unuse() | |
} | |
render() { | |
return React.createElement(ComponentClass, this.props) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack') | |
const OUTPUT_PATH = path.join(__dirname, 'build'); | |
const PUBLIC_PATH = process.env.STATIC_URL; | |
module.exports = { | |
entry: 'index.tsx', | |
output: { | |
path: OUTPUT_PATH, | |
filename: '[name].[hash].bundle.js', | |
publicPath: PUBLIC_PATH, | |
}, | |
watch: false, | |
watchOptions: { | |
aggregateTimeout: 300, | |
poll: 1000, | |
ignored: /node_modules/, | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\/pcss\/.*\.css$/, | |
use: [ | |
'style-loader/useable', | |
'css-loader', | |
'postcss-loader', | |
], | |
}, | |
{ | |
test: /\.tsx?$/, | |
use: [ | |
'ts-loader', | |
] | |
}, | |
] | |
}, | |
resolve: { | |
modules: ['node_modules'], | |
extensions: [ | |
'.ts', | |
'.tsx', | |
'.css', | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment