diff --git a/packages/ray/lib/_image.scss b/packages/ray/lib/_image.scss new file mode 100644 index 00000000..76a4ce28 --- /dev/null +++ b/packages/ray/lib/_image.scss @@ -0,0 +1,48 @@ +@mixin ImgContainer { + display: block; + width: 100%; + height: auto; + position: relative; + overflow: hidden; + background-color: $gray30; + + img { + position: absolute; + width: 100%; + top: 0; + left: 0; + right: 0; + bottom: 0; + margin: auto; + } +} + +.ImgContainer--16by9 { + @include ImgContainer; + padding-bottom: calc(100% / (16 / 9)); +} + +.ImgContainer--3by4 { + @include ImgContainer; + padding-bottom: calc(100% / (3 / 4)); +} + +@mixin Background { + display: block; + width: 100%; + height: auto; + background-color: $gray30; + background-size: cover; + background-position: center; + background-repeat: no-repeat; +} + +.Background--16by9 { + @include Background; + padding-bottom: calc(100% / (16 / 9)); +} + +.Background--3by4 { + @include Background; + padding-bottom: calc(100% / (3 / 4)); +} diff --git a/packages/ray/lib/application.scss b/packages/ray/lib/application.scss index 5c2cfee0..c80448e4 100644 --- a/packages/ray/lib/application.scss +++ b/packages/ray/lib/application.scss @@ -9,5 +9,5 @@ @import 'typography'; @import 'forms'; @import 'card'; - +@import 'image'; @import 'buttons'; diff --git a/packages/ray/stories/card.stories.js b/packages/ray/stories/card.stories.js index d1fd1c66..2637dd9b 100644 --- a/packages/ray/stories/card.stories.js +++ b/packages/ray/stories/card.stories.js @@ -1,26 +1,28 @@ import React from 'react'; import { storiesOf } from '@storybook/react'; -storiesOf('Card', module).addWithJSX('All', () => ( -
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem - atque minima itaque sint! Doloremque odio quia saepe. -
+storiesOf('Card', module).addWithJSX('All', () => + withPadding( ++ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem + atque minima itaque sint! Doloremque odio quia saepe. +
+