From 46d7e9c7e19dd6a03cf259d0dac941bb36a0cafe Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Mon, 15 May 2017 19:20:40 +0300 Subject: [PATCH] No image icon and aspect ratio to 3:2 --- src/containers/ListingPage/ListingPage.css | 20 ++++++++++++++-- src/containers/ListingPage/ListingPage.js | 23 +++++++++++++++++-- .../ListingPage/images/noImageIcon.svg | 1 + 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 src/containers/ListingPage/images/noImageIcon.svg diff --git a/src/containers/ListingPage/ListingPage.css b/src/containers/ListingPage/ListingPage.css index 79e9922d..34281f4f 100644 --- a/src/containers/ListingPage/ListingPage.css +++ b/src/containers/ListingPage/ListingPage.css @@ -26,6 +26,7 @@ .mainImage { width: 100%; + position: relative; } .thumbnailContainer { @@ -34,7 +35,8 @@ padding: 1rem; } -.squareWrapper { +/* Reserves a correct size of painting area for the image before it has been downloaded */ +.thumbnailWrapper { display: block; position: relative; width: 100px; @@ -43,9 +45,10 @@ /* Firefox doesn't support image aspect ratio inside flexbox */ .aspectWrapper { - padding-bottom: 75%; /* 4:3 Aspect Ratio */ + padding-bottom: 66.67%; /* Aspect Ratio: 3:2 = 100%/(w/h) */ } +.noImageContainer, .thumbnail { position: absolute; top: 0; @@ -56,6 +59,19 @@ height: 100%; } +.noImageContainer, +.noImageWrapper { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + background-color: #eee; +} + +.noImageText { + color: #666; +} + .description { margin: 1rem; } diff --git a/src/containers/ListingPage/ListingPage.js b/src/containers/ListingPage/ListingPage.js index 633af67d..b1e4987f 100644 --- a/src/containers/ListingPage/ListingPage.js +++ b/src/containers/ListingPage/ListingPage.js @@ -14,7 +14,9 @@ import { Button, Map, ModalInMobile, PageLayout } from '../../components'; import { BookingDatesForm } from '../../containers'; import { getListingsById } from '../../ducks/marketplaceData.duck'; import { showListing } from './ListingPage.duck'; + import css from './ListingPage.css'; +import noImageIcon from './images/noImageIcon.svg'; // This defines when ModalInMobile shows content as Modal const MODAL_BREAKPOINT = 2500; @@ -115,13 +117,30 @@ export class ListingPageComponent extends Component { ? currentListing.images.map(i => ({ id: i.id, sizes: i.attributes.sizes })) : []; + + // TODO: svg should have own loading strategy + // Now noImageIcon is imported with default configuration (gives url) + // This should be handled by ResponsiveImage or separate ImagePlaceholder component + const noListingImage = ( +
+
+
+
+ No images added +
No image
+
+
+
+
+ ); + // TODO componentize const imageCarousel = images.length > 0 ?
{title}
{images.slice(1).map(image => ( -
+
- : null; + : noListingImage; const userAndListingAuthorAvailable = currentUser && currentListing && currentListing.author; const isOwnListing = userAndListingAuthorAvailable && diff --git a/src/containers/ListingPage/images/noImageIcon.svg b/src/containers/ListingPage/images/noImageIcon.svg new file mode 100644 index 00000000..c168d5cd --- /dev/null +++ b/src/containers/ListingPage/images/noImageIcon.svg @@ -0,0 +1 @@ +