Skip to content

Commit 58a0e18

Browse files
committed
added basic gallery feature
1 parent 6c3fd4c commit 58a0e18

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react-helmet": "^6.1.0",
2222
"react-hook-form": "^6.3.2",
2323
"react-i18next": "^11.5.0",
24+
"react-image-gallery": "^1.2.5",
2425
"react-markdown": "^5.0.2",
2526
"react-markdown-editor-lite": "^1.2.4",
2627
"react-promise-tracker": "^2.1.0",

src/assets/scss/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
@import './modules/index';
66
@import './components/index';
77
@import './pages/index';
8+
@import '~react-image-gallery/styles/scss/image-gallery.scss';

src/pages/Story.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
TwitterIcon,
77
LinkedinIcon
88
} from 'react-share'
9+
import ImageGallery from 'react-image-gallery'
910

1011
import { Helmet } from 'react-helmet'
1112

@@ -93,6 +94,19 @@ const Story = (props) => {
9394
const hashtagsArray = ['EOS', 'userstory']
9495
const title = 'EOS User Story - POST Stories. GET Features.'
9596

97+
const displayImages = () => {
98+
const images = []
99+
for (let i = 0; i < 3; i++) {
100+
images.push({
101+
original: story.Attachment[`${i}`].url,
102+
thumbnail: story.Attachment[`${i}`].url
103+
})
104+
}
105+
return images
106+
}
107+
108+
const images = [].concat(displayImages())
109+
96110
return (
97111
<>
98112
<Helmet>
@@ -225,15 +239,12 @@ const Story = (props) => {
225239
)}
226240
</div>
227241
<div>
228-
{story.Attachment &&
229-
story.Attachment.map((obj) => (
230-
<img
231-
key={obj.id}
232-
src={obj.url}
233-
alt='attachment'
234-
height='100'
235-
/>
236-
))}
242+
<ImageGallery
243+
items={images}
244+
showBullets={true}
245+
originalClass={'galleryoriginal'}
246+
thumbnailClass={'galleryThumbnail'}
247+
/>
237248
</div>
238249
<Comments storyId={storyId} />
239250
</div>

0 commit comments

Comments
 (0)