Skip to content

Commit 6be88f3

Browse files
committed
Fixed main page image carousel
1 parent 25f383d commit 6be88f3

File tree

2 files changed

+73
-24
lines changed

2 files changed

+73
-24
lines changed

components/Carousel.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import Image from 'next/legacy/image';
1+
// import Image from 'next/legacy/image';
22
import { useState, useEffect } from 'react';
33

4-
// width of each img in px
4+
// width of each frame in px
55
// needs to be updated if style.scss changes
6-
const IMAGE_WIDTH = 360;
6+
const FRAME_WIDTH = 450;
7+
// const FRAME_HEIGHT = 240;
78
const ITEMS_PER_SECTION = 4;
89

910
const Carousel = ({ images }) => {
1011
const [sections, setSections] = useState([]);
11-
const sectionWidth = (IMAGE_WIDTH * ITEMS_PER_SECTION) / 2;
12+
const sectionWidth = (FRAME_WIDTH * ITEMS_PER_SECTION) / 2;
1213

1314
useEffect(() => {
1415
const numItems = images.length;
@@ -19,15 +20,17 @@ const Carousel = ({ images }) => {
1920
left: (i / ITEMS_PER_SECTION) * sectionWidth,
2021
width: sectionWidth,
2122
items: images.slice(i, i + ITEMS_PER_SECTION).map((item, index) => (
22-
<a
23-
href={item}
24-
target="_blank"
25-
rel="noreferrer noopener"
26-
key={index}
27-
tabIndex="-1"
28-
>
29-
<Image src={item} width={IMAGE_WIDTH} height={IMAGE_WIDTH} alt="" />
30-
</a>
23+
<div className="image-frame" key={index}>
24+
<a
25+
href={item}
26+
target="_blank"
27+
rel="noreferrer noopener"
28+
tabIndex="-1"
29+
className="image-link"
30+
>
31+
<img src={item} alt="" className="framed-image" />
32+
</a>
33+
</div>
3134
)),
3235
});
3336
}

styles/components/Carousel.scss

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,80 @@
22

33
#carousel {
44
background: #FAFAFA;
5-
height: 480px;
5+
height: 660px;
66
min-width: 100%;
77
overflow: hidden;
88
position: relative;
99

1010
#carousel-inner {
11-
width: 1600px;
11+
height: 100%;
1212
}
1313

1414
.carousel-sect {
1515
background: linear-gradient(rgba(variables.$acm-black, 0.8), rgba(variables.$acm-black, 1));
1616
position: absolute;
1717
top: 0;
1818
width: 1600px;
19+
height: 100%;
20+
display: flex;
21+
flex-wrap: wrap;
22+
align-content: flex-start;
1923

20-
div {
21-
background-size: cover;
22-
display: inline-block;
23-
height: 240px;
24+
.image-frame {
25+
width: 450px;
26+
height: 330px;
2427
margin: 0;
25-
opacity: 0.9;
26-
padding: 0;
28+
padding: 4px;
29+
background: #ffffff;
30+
border: 1px solid #d0d0d0;
31+
box-shadow:
32+
0 2px 8px rgba(0, 0, 0, 0.1),
33+
inset 0 0 0 1px rgba(255, 255, 255, 0.8);
34+
box-sizing: border-box;
35+
display: flex;
36+
align-items: center;
37+
justify-content: center;
38+
position: relative;
2739
transition: 0.35s cubic-bezier(0.05, 1.04, 0.72, 0.98);
28-
vertical-align: top;
29-
width: 360px;
40+
41+
// Photo frame texture effect
42+
&::before {
43+
content: '';
44+
position: absolute;
45+
top: 0;
46+
left: 0;
47+
right: 0;
48+
bottom: 0;
49+
}
3050

3151
&:hover {
32-
opacity: 0.6;
52+
transform: translateY(-4px);
53+
box-shadow:
54+
0 6px 16px rgba(0, 0, 0, 0.15),
55+
inset 0 0 0 1px rgba(255, 255, 255, 0.9);
56+
}
57+
58+
.image-link {
59+
width: 100%;
60+
height: 100%;
61+
display: flex;
62+
align-items: center;
63+
justify-content: center;
64+
overflow: hidden;
65+
66+
.framed-image {
67+
max-width: 100%;
68+
max-height: 100%;
69+
width: auto;
70+
height: auto;
71+
object-fit: contain;
72+
display: block;
73+
transition: 0.35s cubic-bezier(0.05, 1.04, 0.72, 0.98);
74+
}
75+
}
76+
77+
&:hover .framed-image {
78+
transform: scale(1.05);
3379
}
3480
}
3581
}

0 commit comments

Comments
 (0)