File tree Expand file tree Collapse file tree 4 files changed +109
-21
lines changed Expand file tree Collapse file tree 4 files changed +109
-21
lines changed Original file line number Diff line number Diff line change 1+ @mixin ImgContainer {
2+ display : block ;
3+ width : 100% ;
4+ height : auto ;
5+ position : relative ;
6+ overflow : hidden ;
7+ background-color : $gray30 ;
8+
9+ img {
10+ position : absolute ;
11+ width : 100% ;
12+ top : 0 ;
13+ left : 0 ;
14+ right : 0 ;
15+ bottom : 0 ;
16+ margin : auto ;
17+ }
18+ }
19+
20+ .ImgContainer--16by9 {
21+ @include ImgContainer ;
22+ padding-bottom : calc (100% / (16 / 9 ));
23+ }
24+
25+ .ImgContainer--3by4 {
26+ @include ImgContainer ;
27+ padding-bottom : calc (100% / (3 / 4 ));
28+ }
29+
30+ @mixin Background {
31+ display : block ;
32+ width : 100% ;
33+ height : auto ;
34+ background-color : $gray30 ;
35+ background-size : cover ;
36+ background-position : center ;
37+ background-repeat : no-repeat ;
38+ }
39+
40+ .Background--16by9 {
41+ @include Background ;
42+ padding-bottom : calc (100% / (16 / 9 ));
43+ }
44+
45+ .Background--3by4 {
46+ @include Background ;
47+ padding-bottom : calc (100% / (3 / 4 ));
48+ }
Original file line number Diff line number Diff line change 99@import ' typography' ;
1010@import ' forms' ;
1111@import ' card' ;
12-
12+ @import ' image ' ;
1313@import ' buttons' ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { storiesOf } from '@storybook/react' ;
33
4- storiesOf ( 'Card' , module ) . addWithJSX ( 'All' , ( ) => (
5- < div
6- style = { {
7- padding : '1rem' ,
8- maxWidth : '400px'
9- } }
10- >
11- < div className = "card" >
12- < img
13- className = "responsive-image"
14- src = "https://source.unsplash.com/random/800x450"
15- />
4+ import withPadding from './util/withPadding' ;
165
17- < div className = "card__content" >
18- < h2 className = "h5" > Spacetravel guidelines</ h2 >
19- < p className = "copy5" >
20- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem
21- atque minima itaque sint! Doloremque odio quia saepe.
22- </ p >
6+ storiesOf ( 'Card' , module ) . addWithJSX ( 'All' , ( ) =>
7+ withPadding (
8+ < div
9+ style = { {
10+ maxWidth : '400px'
11+ } }
12+ >
13+ < div className = "card" >
14+ < div className = "ImgContainer--16by9" >
15+ < img src = "https://source.unsplash.com/random/800x450" />
16+ </ div >
17+
18+ < div className = "card__content" >
19+ < h2 className = "h5" > Spacetravel guidelines</ h2 >
20+ < p className = "copy5" >
21+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem
22+ atque minima itaque sint! Doloremque odio quia saepe.
23+ </ p >
24+ </ div >
2325 </ div >
2426 </ div >
25- </ div >
26- ) ) ;
27+ )
28+ ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { storiesOf } from '@storybook/react' ;
3+
4+ storiesOf ( 'Image' , module )
5+ . addWithJSX ( '16/9 img' , ( ) => (
6+ < div style = { { maxWidth : '500px' } } >
7+ < div className = "ImgContainer--16by9" >
8+ < img src = "https://source.unsplash.com/random/800x800" />
9+ </ div >
10+ </ div >
11+ ) )
12+ . addWithJSX ( '3/4 img' , ( ) => (
13+ < div style = { { maxWidth : '400px' } } >
14+ < div className = "ImgContainer--3by4" >
15+ < img src = "https://source.unsplash.com/random/800x1200" />
16+ </ div >
17+ </ div >
18+ ) )
19+ . addWithJSX ( '16/9 background' , ( ) => (
20+ < div style = { { maxWidth : '500px' } } >
21+ < div
22+ className = "Background--16by9"
23+ style = { {
24+ backgroundImage : `url(https://source.unsplash.com/random/800x800)`
25+ } }
26+ />
27+ </ div >
28+ ) )
29+ . addWithJSX ( '3/4 background' , ( ) => (
30+ < div style = { { maxWidth : '400px' } } >
31+ < div
32+ className = "Background--3by4"
33+ style = { {
34+ backgroundImage : `url(https://source.unsplash.com/random/800x1200)`
35+ } }
36+ />
37+ </ div >
38+ ) ) ;
You can’t perform that action at this time.
0 commit comments