Skip to content

Commit 8c0b769

Browse files
committed
rework styling and add image stories
1 parent 61069d0 commit 8c0b769

18 files changed

+412
-300
lines changed

.storybook/webpack.config.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,31 @@ const path = require('path');
1010
const SRC = path.resolve('./src');
1111
const STORIES = path.resolve('./stories');
1212

13-
module.exports = {
14-
resolve: {
15-
alias: {
16-
'react-scroll-parallax': SRC,
17-
components: path.resolve(SRC + 'components'),
18-
},
19-
},
13+
// Export a function. Accept the base config as the only param.
14+
module.exports = async ({ config, mode }) => {
15+
// `mode` has a value of 'DEVELOPMENT' or 'PRODUCTION'
16+
// You can change the configuration based on that.
17+
// 'PRODUCTION' is used when building the static version of storybook.
2018

21-
module: {
22-
rules: [
19+
// Make whatever fine-grained changes you need
20+
config.module.rules.push({
21+
test: /\.scss|.css$/,
22+
use: [
23+
'style-loader',
2324
{
24-
test: /\.scss|.css$/,
25-
use: [
26-
'style-loader',
27-
{
28-
loader: 'css-loader',
29-
options: { importLoaders: 1, modules: true },
30-
},
31-
'sass-loader',
32-
],
33-
include: STORIES,
25+
loader: 'css-loader',
26+
options: { importLoaders: 1, modules: true },
3427
},
28+
'sass-loader',
3529
],
36-
},
30+
include: STORIES,
31+
});
32+
33+
config.resolve.alias = {
34+
'react-scroll-parallax': SRC,
35+
components: path.resolve(SRC + 'components'),
36+
};
37+
38+
// Return the altered config
39+
return config;
3740
};

stories/Container.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import { ParallaxProvider } from 'react-scroll-parallax';
33

4-
const Container = ({ children, scrollAxis }) => (
4+
const Container = ({ children, scrollAxis, className }) => (
55
<ParallaxProvider scrollAxis={scrollAxis}>
66
<div className={scrollAxis}>
7-
<div className="elements">{children}</div>
7+
<div className={className}>{children}</div>
88
</div>
99
</ParallaxProvider>
1010
);

stories/Element/Element.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
display: flex;
1717
align-items: center;
1818
justify-content: center;
19+
background: slateblue;
1920
}
2021

2122
.box {

stories/Image/Image.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { withController } from 'react-scroll-parallax';
4+
import style from './Image.scss';
5+
6+
class Image extends Component {
7+
static propTypes = {
8+
parallaxController: PropTypes.object.isRequired,
9+
src: PropTypes.string.isRequired,
10+
};
11+
12+
handleLoad = () => {
13+
// updates cached values after image dimensions have loaded
14+
this.props.parallaxController.update();
15+
};
16+
17+
render() {
18+
return (
19+
<div className={style.image}>
20+
<img src={this.props.src} onLoad={this.handleLoad} />
21+
</div>
22+
);
23+
}
24+
}
25+
26+
export default withController(Image);

stories/Image/Image.scss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.images {
2+
padding: 20% 10%;
3+
display: flex;
4+
flex-flow: row wrap;
5+
justify-content: space-between;
6+
align-content: center;
7+
}
8+
9+
.parallaxImage {
10+
margin: 10% 0;
11+
width: 45%;
12+
background: none;
13+
}
14+
15+
.parallaxImage2 {
16+
margin: 10% auto 10%;
17+
width: 65%;
18+
background: none;
19+
}
20+
21+
.image {
22+
img {
23+
display: block;
24+
width: 100%;
25+
height: auto;
26+
}
27+
}

0 commit comments

Comments
 (0)