Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sample_pdp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Praveen Reghunathan Nair
sample_pdp
Commits
3130d338
Commit
3130d338
authored
Feb 07, 2020
by
Praveen Reghunathan Nair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created Image carousel
parent
d415084a
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
165 additions
and
8 deletions
+165
-8
ImageCarousel.jsx
src/components/ImageCarousel/ImageCarousel.jsx
+63
-0
ImageCarousel.module.scss
src/components/ImageCarousel/ImageCarousel.module.scss
+34
-0
ImageCarousel.spec.js
src/components/ImageCarousel/ImageCarousel.spec.js
+0
-0
index.js
src/components/ImageCarousel/index.js
+3
-0
ModalDialog.jsx
src/components/ModalDialog/ModalDialog.jsx
+16
-6
ModalDialog.module.scss
src/components/ModalDialog/ModalDialog.module.scss
+27
-0
index.js
src/components/ModalDialog/index.js
+3
-0
PDP.jsx
src/pages/PDP/PDP.jsx
+19
-2
No files found.
src/components/ImageCarousel/ImageCarousel.jsx
0 → 100644
View file @
3130d338
import
React
,
{
Component
}
from
'react'
;
import
ModalDialog
from
'components/ModalDialog'
;
import
style
from
'./ImageCarousel.module.scss'
;
const
Arrow
=
({
onArrowClick
=
()
=>
{
},
glyph
})
=>
(
<
div
className=
{
style
.
slideArrow
}
onClick=
{
onArrowClick
}
>
{
glyph
}
</
div
>
);
class
ImageCarousel
extends
Component
{
state
=
{
currentImageIndex
:
0
};
previousSlide
=
()
=>
{
const
{
images
=
[]
}
=
this
.
props
;
const
lastIndex
=
images
.
length
-
1
;
const
{
currentImageIndex
}
=
this
.
state
;
const
isFirstImage
=
currentImageIndex
===
0
;
const
index
=
isFirstImage
?
lastIndex
:
currentImageIndex
-
1
;
this
.
setState
({
currentImageIndex
:
index
});
}
nextSlide
=
()
=>
{
const
{
images
=
[]
}
=
this
.
props
;
const
lastIndex
=
images
.
length
-
1
;
const
{
currentImageIndex
}
=
this
.
state
;
const
isLastImage
=
currentImageIndex
===
lastIndex
;
const
index
=
isLastImage
?
0
:
currentImageIndex
+
1
;
this
.
setState
({
currentImageIndex
:
index
});
}
render
()
{
const
{
show
=
false
,
images
=
[],
onClose
=
()
=>
{
}
}
=
this
.
props
;
const
{
currentImageIndex
}
=
this
.
state
;
const
curImage
=
images
[
currentImageIndex
]
||
{};
return
(
<
ModalDialog
className=
{
style
.
imageCarousel
}
show=
{
show
}
>
<
div
>
{
`Total images: ${images.length}`
}
</
div
>
<
div
className=
{
style
.
content
}
>
<
Arrow
onArrowClick=
{
this
.
previousSlide
}
glyph=
"◀"
/>
<
img
src=
{
curImage
.
url
}
/>
<
Arrow
onArrowClick=
{
this
.
nextSlide
}
glyph=
"▶"
/>
</
div
>
<
button
className=
{
style
.
closeButton
}
onClick=
{
onClose
}
>
Close
</
button
>
</
ModalDialog
>
);
}
}
export
default
ImageCarousel
;
\ No newline at end of file
src/components/ImageCarousel/ImageCarousel.module.scss
0 → 100644
View file @
3130d338
@import
'~styles/variables'
;
.imageCarousel
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
padding
:
10px
;
border-radius
:
5px
;
.content
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-around
;
width
:
100%
;
}
.closeButton
{
margin
:
10px
;
color
:
#fff
;
background-color
:
#6c757d
;
border-color
:
#6c757d
;
padding
:
.375rem
.75rem
;
border-radius
:
.25rem
;
cursor
:
pointer
;
}
.slideArrow
{
color
:
#14B6D4
;
cursor
:
pointer
;
font-size
:
2rem
;
}
}
\ No newline at end of file
src/components/ImageCarousel/ImageCarousel.spec.js
0 → 100644
View file @
3130d338
src/components/ImageCarousel/index.js
0 → 100644
View file @
3130d338
import
ImageCarousel
from
'./ImageCarousel'
;
export
default
ImageCarousel
;
\ No newline at end of file
src/components/ModalDialog/ModalDialog.jsx
View file @
3130d338
import
React
,
{
Component
}
from
'react'
;
import
style
s
from
'./ModalDialog.module.scss'
;
import
style
from
'./ModalDialog.module.scss'
;
class
ModalDialog
extends
Component
{
render
()
{
const
{
show
=
false
,
className
=
''
,
children
}
=
this
.
props
;
if
(
show
)
{
return
(
<
div
>
<
div
className=
{
style
.
modalDialog
}
>
<
div
className=
{
style
.
modelWrap
}
>
<
div
className=
{
`${style.modelContent} ${className}`
}
>
{
children
}
</
div
>
</
div
>
</
div
>
);
}
else
{
return
null
;
}
}
}
...
...
src/components/ModalDialog/ModalDialog.module.scss
View file @
3130d338
@import
'~styles/variables'
;
.modalDialog
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
position
:
fixed
;
top
:
0
;
right
:
0
;
left
:
0
;
bottom
:
0
;
padding
:
1rem
;
background-color
:
rgba
(
0
,
0
,
0
,
0
.7
);
z-index
:
100
;
opacity
:
1
;
overflow
:
hidden
;
.modelWrap
{
width
:
100%
;
}
.modelContent
{
background-color
:
$primary-white
;
max-width
:
500px
;
margin
:
0
auto
;
}
}
\ No newline at end of file
src/components/ModalDialog/index.js
View file @
3130d338
import
ModalDialog
from
'./ModalDialog'
;
export
default
ModalDialog
;
\ No newline at end of file
src/pages/PDP/PDP.jsx
View file @
3130d338
import
React
,
{
Component
}
from
'react'
;
import
style
from
'./PDP.module.scss'
;
import
ProductDetails
from
'models/productDetail'
;
import
ImageCarousel
from
'components/ImageCarousel'
;
class
PDPPage
extends
Component
{
state
=
{
showImageCarousel
:
false
}
componentDidMount
()
{
const
{
match
:
{
params
:
{
productId
}
}
}
=
this
.
props
;
this
.
props
.
getProductDetails
(
productId
);
}
toggleImageCarouselClose
=
()
=>
{
const
{
showImageCarousel
}
=
this
.
state
;
this
.
setState
({
showImageCarousel
:
!
showImageCarousel
});
}
render
()
{
const
{
product
}
=
this
.
props
;
const
{
name
,
image
,
sellingPrice
}
=
new
ProductDetails
(
product
);
const
{
showImageCarousel
}
=
this
.
state
;
const
{
name
,
image
,
sellingPrice
,
images
}
=
new
ProductDetails
(
product
);
return
(
<
section
className=
{
style
.
PDPPage
}
>
<
div
className=
{
style
.
content
}
>
<
div
className=
{
style
.
images
}
>
<
div
className=
{
style
.
images
}
onClick=
{
this
.
toggleImageCarouselClose
}
>
<
img
src=
{
image
.
url
}
alt=
{
image
.
alt
}
...
...
@@ -27,6 +39,11 @@ class PDPPage extends Component {
<
div
>
{
`Price: ${sellingPrice}`
}
</
div
>
</
div
>
</
div
>
<
ImageCarousel
show=
{
showImageCarousel
}
images=
{
images
}
onClose=
{
this
.
toggleImageCarouselClose
}
/>
</
section
>
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment