General ui improvements

This commit is contained in:
viktorstrate
2019-08-14 17:48:08 +02:00
parent c3d65c66ea
commit ddf06e3073
5 changed files with 27 additions and 10 deletions

2
ui/package-lock.json generated
View File

@@ -1,5 +1,5 @@
{
"name": "grand-stack-starter-ui",
"name": "photoview-ui",
"version": "0.0.1",
"lockfileVersion": 1,
"requires": true,

View File

@@ -46,15 +46,20 @@ export const AlbumBox = ({ album, ...props }) => {
)
}
let thumbnail =
album.photos[0] &&
album.photos[0].thumbnail &&
album.photos[0].thumbnail.url
thumbnail =
thumbnail ||
(album.subAlbums[0] &&
album.subAlbums[0].photos[0] &&
album.subAlbums[0].photos[0].thumbnail.url)
return (
<AlbumBoxLink {...props} to={`/album/${album.id}`}>
<AlbumBoxImage
src={
album.photos[0] &&
album.photos[0].thumbnail &&
album.photos[0].thumbnail.url
}
/>
<AlbumBoxImage src={thumbnail} />
<p>{album.title}</p>
</AlbumBoxLink>
)

View File

@@ -9,11 +9,18 @@ const getAlbumsQuery = gql`
myAlbums(filter: { parentAlbum: null }, orderBy: title_asc) {
id
title
photos {
photos(first: 1) {
thumbnail {
url
}
}
subAlbums(first: 1) {
photos(first: 1) {
thumbnail {
url
}
}
}
}
}
`

View File

@@ -2,6 +2,7 @@ import React, { Component } from 'react'
import Layout from '../../Layout'
import gql from 'graphql-tag'
import { Query } from 'react-apollo'
import { Link } from 'react-router-dom'
import PhotoGallery from '../../components/photoGallery/PhotoGallery'
import PhotoSidebar from '../../components/sidebar/PhotoSidebar'
@@ -95,7 +96,9 @@ class PhotosPage extends Component {
if (data.myAlbums) {
galleryGroups = data.myAlbums.map((album, index) => (
<div key={album.id}>
<h1>{album.title}</h1>
<Link to={`/album/${album.id}`}>
<h1>{album.title}</h1>
</Link>
<PhotoGallery
onSelectImage={photoIndex => {
this.setActiveImage(index, photoIndex)

View File

@@ -93,6 +93,8 @@ class PhotoGallery extends React.Component {
let photoElements = null
if (photos) {
photos.filter(photo => photo.thumbnail)
photoElements = photos.map((photo, index) => {
const active = activeIndex == index