Skip to content

Commit 4b07d8a

Browse files
committed
add video and custom layer children stories #22
1 parent 73b1a16 commit 4b07d8a

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

stories/ParallaxBanner/ParallaxBanner.scss

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,32 @@
1717
}
1818

1919
:local(.bannerBg) {
20-
background: #333;
20+
background: #fff;
21+
}
22+
23+
:local(.customChild) {
24+
position: absolute;
25+
top: 0;
26+
left: 0;
27+
right: 0;
28+
bottom: 0;
29+
text-align: center;
30+
}
31+
32+
:local(.red) {
33+
background-color: rgba(#f74c36, 0.8);
34+
}
35+
36+
:local(.green) {
37+
background-color: rgba(#35f783, 0.8);
38+
}
39+
40+
:local(.blue) {
41+
background-color: rgba(#42a7f4, 0.8);
42+
}
43+
44+
:local(.video) {
45+
width: 100%;
46+
height: 100%;
47+
object-fit: cover;
2148
}

stories/ParallaxBanner/ParallaxBanner.stories.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,72 @@ storiesOf('<ParallaxBanner>', module)
8181
/>
8282
);
8383
})
84+
.add('with a video', () => (
85+
<ParallaxBanner
86+
className={styles.bannerBg}
87+
layers={[
88+
{
89+
amount: 0.3,
90+
children: (
91+
<video
92+
className={styles.video}
93+
autoPlay
94+
loop
95+
playsInline
96+
preload="auto"
97+
muted
98+
poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/105988/boats-at-sea.jpg"
99+
src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/105988/boats-at-sea-720.mp4"
100+
/>
101+
),
102+
slowerScrollRate: true,
103+
},
104+
]}
105+
>
106+
<div className={styles.parallaxChildren}>
107+
<h1>Video Background</h1>
108+
</div>
109+
</ParallaxBanner>
110+
))
111+
.add('with custom layer children', () => (
112+
<ParallaxBanner
113+
className={styles.bannerBg}
114+
layers={[
115+
{
116+
children: (
117+
<div className={`${styles.customChild} ${styles.red}`}>
118+
Red
119+
</div>
120+
),
121+
amount: 0.2,
122+
expanded: false,
123+
slowerScrollRate: false,
124+
},
125+
{
126+
children: (
127+
<div
128+
className={`${styles.customChild} ${styles.green}`}
129+
>
130+
Green
131+
</div>
132+
),
133+
amount: 0.4,
134+
expanded: false,
135+
slowerScrollRate: false,
136+
},
137+
{
138+
children: (
139+
<div className={`${styles.customChild} ${styles.blue}`}>
140+
Blue
141+
</div>
142+
),
143+
amount: 0.6,
144+
expanded: false,
145+
slowerScrollRate: false,
146+
},
147+
]}
148+
/>
149+
))
84150
.add('with parallax disabled', () => (
85151
<ParallaxBanner
86152
className={styles.bannerBg}

0 commit comments

Comments
 (0)