Skip to content

Commit cb172fa

Browse files
committed
base card
1 parent 8313f1d commit cb172fa

File tree

6 files changed

+70
-5
lines changed

6 files changed

+70
-5
lines changed

package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
},
4343
"dependencies": {
4444
"babel-eslint": "^8.2.3",
45+
"classnames": "^2.2.6",
4546
"react": "^16.3.2",
47+
"react-css-themr": "^2.1.2",
4648
"react-dom": "^16.3.2"
4749
}
4850
}

src/card/defaultTheme.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
:local(.card) {
2+
background: #AEAEAE;
3+
border-radius: 6;
4+
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
5+
0 3px 1px -2px rgba(0, 0, 0, 0.2),
6+
0 1px 5px 0 rgba(0, 0, 0, 0.12);
7+
display: flex;
8+
flex-direction: column;
9+
font-size: 12;
10+
overflow: hidden;
11+
width: 100%;
12+
13+
// @apply --reset;
14+
15+
&.raised {
16+
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
17+
0 3px 1px -2px rgba(0, 0, 0, 0.2),
18+
0 1px 5px 0 rgba(0, 0, 0, 0.12);
19+
}
20+
}

src/card/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { themr } from 'react-css-themr';
4+
import classnames from 'classnames';
5+
// import { CARD } from '../identifiers';
6+
import defaultTheme from './defaultTheme.scss';
7+
8+
const Card = ({ children, className, raised, theme }) => {
9+
const classes = classnames(theme.card, {
10+
[theme.raised]: raised,
11+
}, className);
12+
13+
return (
14+
<div data-react-toolbox="card" className={classes}>
15+
{children}
16+
</div>
17+
);
18+
};
19+
20+
export default themr('CBCard', defaultTheme)(Card);

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3+
import Card from './card';
34

45
const Index = () => (
56
<div>
6-
Hello React!
7+
<Card>
8+
<span>SomeContent</span>
9+
</Card>
710
</div>
811
);
912

webpack.common.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const HtmlWebPackPlugin = require('html-webpack-plugin');
22
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
33
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4-
4+
const path = require('path');
55
const devMode = process.env.NODE_ENV !== 'production';
66
const htmlWebpackPlugin = new HtmlWebPackPlugin({
77
template: './src/index.html',
@@ -33,9 +33,10 @@ module.exports = {
3333
],
3434
},
3535
{
36-
test: /\.s?[ac]ss$/,
36+
test: /\.scss$/,
37+
include: path.resolve(__dirname, './src'),
3738
use: [
38-
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
39+
'style-loader',
3940
'css-loader',
4041
'sass-loader',
4142
],
@@ -44,7 +45,7 @@ module.exports = {
4445
},
4546
plugins: [
4647
htmlWebpackPlugin,
47-
new BundleAnalyzerPlugin(),
48+
// new BundleAnalyzerPlugin(),
4849
new MiniCssExtractPlugin({
4950
filename: devMode ? '[name].css' : '[name].[hash].css',
5051
chunkFilename: devMode ? '[id].css' : '[id].[hash].css',

0 commit comments

Comments
 (0)