Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDD27_2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc Taylor
TDDD27_2024
Commits
81f6b48a
Commit
81f6b48a
authored
11 months ago
by
Maximilian Sjöström
Browse files
Options
Downloads
Patches
Plain Diff
added some animation
parent
3559e697
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
theme-costume-app/src/components/Carousel.js
+12
-6
12 additions, 6 deletions
theme-costume-app/src/components/Carousel.js
theme-costume-app/src/components/Product.js
+11
-2
11 additions, 2 deletions
theme-costume-app/src/components/Product.js
with
23 additions
and
8 deletions
theme-costume-app/src/components/Carousel.js
+
12
−
6
View file @
81f6b48a
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
const
NavigationComponent
=
({
goToNextPage
,
goToPreviousPage
,
currentPage
,
totalPages
})
=>
{
const
renderDots
=
()
=>
{
...
...
@@ -33,7 +33,7 @@ const MoviesDisplay = ({ setOfMovies }) => {
return
(
<
div
style
=
{
styles
.
movies
}
>
{
setOfMovies
.
map
((
movie
,
index
)
=>
(
<
div
key
=
{
index
}
style
=
{
styles
.
movie
}
>
<
div
key
=
{
index
}
style
=
{
styles
.
movie
}
>
<
img
src
=
{
movie
.
source
}
alt
=
{
movie
.
name
}
style
=
{
styles
.
image
}
/
>
{
/* <p style={styles.movieText}>{movie.name}</p> */
}
<
/div
>
...
...
@@ -42,10 +42,15 @@ const MoviesDisplay = ({ setOfMovies }) => {
);
};
const
Carousel
=
({
showingItems
,
items
})
=>
{
const
Carousel
=
({
showingItems
,
items
,
autoScrollInterval
=
3000
})
=>
{
const
[
currentPage
,
setCurrentPage
]
=
useState
(
1
);
const
TOTAL_PAGES
=
Math
.
ceil
(
items
.
length
/
showingItems
);
useEffect
(()
=>
{
const
intervalId
=
setInterval
(
nextPage
,
autoScrollInterval
);
return
()
=>
clearInterval
(
intervalId
);
},
[
currentPage
]);
const
previousPage
=
()
=>
{
if
(
currentPage
===
1
)
{
setCurrentPage
(
TOTAL_PAGES
);
...
...
@@ -61,7 +66,7 @@ const Carousel = ({ showingItems, items }) => {
setCurrentPage
(
currentPage
+
1
);
}
};
const
groupingMovies
=
[];
for
(
let
i
=
0
;
i
<
items
.
length
;
i
+=
showingItems
)
{
groupingMovies
.
push
(
items
.
slice
(
i
,
i
+
showingItems
));
...
...
@@ -80,7 +85,8 @@ const Carousel = ({ showingItems, items }) => {
/
>
<
/div
>
<
/div
>
<
MoviesDisplay
setOfMovies
=
{
groupingMovies
[
currentPage
-
1
]}
/
>
<
MoviesDisplay
setOfMovies
=
{
groupingMovies
[
currentPage
-
1
]}
/
>
<
/div
>
);
};
...
...
@@ -88,7 +94,7 @@ const Carousel = ({ showingItems, items }) => {
const
styles
=
{
container
:
{
backgroundColor
:
'
#fff
'
,
width
:
'
100
vw
'
,
width
:
'
100
%
'
,
},
topRow
:
{
display
:
'
flex
'
,
...
...
This diff is collapsed.
Click to expand it.
theme-costume-app/src/components/Product.js
+
11
−
2
View file @
81f6b48a
...
...
@@ -2,6 +2,15 @@
import
React
,
{
useState
}
from
'
react
'
;
import
{
Card
,
CardContent
,
CardMedia
,
Typography
,
Dialog
,
DialogContent
,
Button
}
from
'
@mui/material
'
;
import
{
styled
}
from
'
@mui/system
'
;
const
AnimatedCard
=
styled
(
Card
)({
transition
:
'
transform 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940)
'
,
'
&:hover
'
:
{
transform
:
'
scale(1.05)
'
,
boxShadow
:
'
0px 10px 10px rgba(0, 0, 0, 0.10)
'
,
},
});
const
Product
=
({
imageUrl
,
price
})
=>
{
const
[
open
,
setOpen
]
=
useState
(
false
);
...
...
@@ -22,7 +31,7 @@ const Product = ({ imageUrl, price }) => {
return
(
<>
<
Card
sx
=
{{
maxWidth
:
345
,
cursor
:
'
pointer
'
}}
onClick
=
{
handleOpen
}
>
<
Animated
Card
sx
=
{{
maxWidth
:
345
,
cursor
:
'
pointer
'
}}
onClick
=
{
handleOpen
}
>
<
CardMedia
component
=
"
img
"
height
=
"
280
"
...
...
@@ -34,7 +43,7 @@ const Product = ({ imageUrl, price }) => {
Price
:
$
{
price
}
<
/Typography
>
<
/CardContent
>
<
/Card
>
<
/
Animated
Card
>
<
Dialog
open
=
{
open
}
onClose
=
{
handleClose
}
>
<
DialogContent
>
<
img
src
=
{
imageUrl
}
alt
=
"
Product Image
"
style
=
{{
maxWidth
:
'
100%
'
}}
/
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment