Skip to content

Commit d2c63ca

Browse files
feat(talks/photo-highlights-section): dark mode support
1 parent 1f9513b commit d2c63ca

File tree

2 files changed

+43
-28
lines changed

2 files changed

+43
-28
lines changed
Loading

src/components/pages/talks/photo-highlights-section-item.tsx

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
1+
import { useTheme } from 'next-themes';
12
import { FunctionComponent, PropsWithChildren } from 'react';
23

34
import { FeaturedTalk } from 'services/content/talks';
45

5-
import Link from 'components/shared/link';
66
import { randomElement } from 'utils/array';
77

8+
import Typography from 'components/shared/typography';
9+
810
// ---------------------------------------------------------------------------
911
// UTILS
1012
// ---------------------------------------------------------------------------
1113

1214
const getGradientClass = () => {
1315
const gradients = [
14-
'bg-gradient-to-br from-purple-600 via-pink-500 to-blue-600',
15-
'bg-gradient-to-tr from-blue-600 via-teal-500 to-purple-600',
16-
'bg-gradient-to-bl from-orange-500 via-pink-500 to-blue-600',
17-
'bg-gradient-to-r from-green-500 via-teal-500 to-blue-500',
18-
'bg-gradient-to-tl from-yellow-500 via-red-500 to-pink-500',
19-
'bg-gradient-to-l from-indigo-500 via-purple-500 to-pink-500',
20-
'bg-gradient-to-tr from-green-500 via-blue-500 to-purple-500',
21-
'bg-gradient-to-br from-red-500 via-orange-500 to-yellow-500',
22-
'bg-gradient-to-bl from-blue-500 via-cyan-500 to-teal-500',
23-
'bg-gradient-to-r from-purple-500 via-pink-500 to-red-500',
24-
'bg-gradient-to-tr from-green-500 via-yellow-500 to-orange-500',
25-
'bg-gradient-to-bl from-blue-500 via-indigo-500 to-violet-500',
16+
'from-purple-700 via-pink-600 to-blue-700',
17+
'from-blue-700 via-teal-600 to-purple-700',
18+
'from-orange-600 via-pink-600 to-blue-700',
19+
'from-green-600 via-teal-600 to-blue-600',
20+
'from-yellow-600 via-red-600 to-pink-600',
21+
'from-indigo-600 via-purple-600 to-pink-600',
22+
'from-green-600 via-blue-600 to-purple-600',
23+
'from-red-600 via-orange-600 to-yellow-600',
24+
'from-blue-600 via-cyan-600 to-teal-600',
25+
'from-purple-600 via-pink-600 to-red-600',
26+
'from-green-600 via-yellow-600 to-orange-600',
27+
'from-blue-600 via-indigo-600 to-violet-600',
28+
'from-rose-600 via-pink-600 to-fuchsia-600',
29+
'from-emerald-600 via-green-600 to-teal-600',
30+
'from-amber-600 via-orange-600 to-yellow-600',
31+
'from-sky-600 via-blue-600 to-indigo-600',
32+
'from-violet-600 via-purple-600 to-indigo-600',
33+
'from-lime-600 via-green-600 to-emerald-600',
34+
'from-fuchsia-600 via-pink-600 to-rose-600',
35+
'from-cyan-600 via-teal-600 to-sky-600',
36+
'from-orange-600 via-amber-600 to-yellow-600',
37+
'from-indigo-600 via-blue-600 to-cyan-600',
38+
'from-red-600 via-rose-600 to-pink-600',
39+
'from-teal-600 via-cyan-600 to-sky-600',
2640
];
2741

2842
return randomElement(gradients);
@@ -34,28 +48,29 @@ const getGradientClass = () => {
3448

3549
const PhotoHighlightsSectionItem: FunctionComponent<PropsWithChildren<FeaturedTalk>> = (props) => {
3650
const { photoURL, talkSlug, talkTitle, eventName, eventLocation } = props;
51+
const { resolvedTheme } = useTheme();
52+
const isDarkMode = resolvedTheme === 'dark';
3753

3854
return (
39-
<div className="group relative h-[280px] w-full overflow-hidden rounded-2xl">
40-
<div className="absolute inset-0 z-10 bg-black/40"></div>
41-
<div className={`absolute inset-0 z-20 opacity-60 mix-blend-soft-light ${getGradientClass()}`}></div>
42-
<div
43-
className="absolute inset-0 z-30 bg-black/50 bg-[radial-gradient(#fff_1px,transparent_1px)]
44-
mix-blend-multiply [background-size:16px_16px]"
45-
></div>
55+
<div className="group relative h-[280px] w-full overflow-hidden rounded-2xl text-white">
4656
<img
4757
src={photoURL}
4858
alt={eventName}
4959
className="absolute inset-0 z-0 h-full w-full object-cover object-center transition-transform duration-300 group-hover:scale-110"
5060
/>
51-
<div className="relative z-40 flex h-full flex-col justify-end p-6">
52-
<span className="mb-2 text-sm text-gray-300">{eventLocation}</span>
53-
<Link key={talkSlug} href={talkSlug} className="block">
54-
<h3 className="mb-2 text-2xl font-bold text-white transition-colors duration-200 group-hover:text-gray-300">
55-
{eventName}
56-
</h3>
57-
</Link>
58-
<p className="text-sm text-gray-300">{talkTitle}</p>
61+
62+
<div
63+
className={`absolute inset-0 opacity-50 ${isDarkMode ? 'bg-black/50' : 'bg-gray-600/10'} z-5
64+
bg-[radial-gradient(#fff_1px,transparent_1px)] [background-size:16px_16px]`}
65+
></div>
66+
<div className={`absolute inset-0 ${isDarkMode ? 'bg-black/30' : 'bg-white/30'} z-10`}></div>
67+
<div className={`absolute inset-0 bg-gradient-to-br ${getGradientClass()} z-20 opacity-20`}></div>
68+
69+
<div className="absolute inset-0 z-40 bg-gradient-to-t from-black/70 via-black/40 to-transparent"></div>
70+
<div className="relative z-50 flex h-full flex-col justify-end p-6">
71+
<Typography.a href={talkSlug}>{talkTitle}</Typography.a>
72+
<Typography.h3>{eventName}</Typography.h3>
73+
<Typography.subtle className="text-white">{eventLocation}</Typography.subtle>
5974
</div>
6075
</div>
6176
);

0 commit comments

Comments
 (0)