Skip to content

Commit 1590a8e

Browse files
committed
notebook 4
1 parent cf0f6fe commit 1590a8e

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

public/notebooks/notebooks.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
[
22
{
33
"id": "my-first-notebook",
4-
"title": "My First Notebook"
4+
"title": "My First Notebook",
5+
"backgroundColor": "#9EC5AB",
6+
"fontFamily": "font-playfairDisplay",
7+
"textColor": "#1f2937",
8+
"hoverBackgroundColor": "#7a9e8a",
9+
"hoverTextColor": "#ffffff"
510
}
611
]
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
2+
3+
const NotebookCover = ({ title, backgroundColor, fontFamily, textColor, hoverBackgroundColor, hoverTextColor }) => {
4+
const [isHovered, setIsHovered] = useState(false);
5+
6+
const currentBackgroundColor = isHovered ? hoverBackgroundColor : backgroundColor;
7+
const currentTextColor = isHovered ? hoverTextColor : textColor;
28

3-
const NotebookCover = ({ title }) => {
49
return (
5-
<div className="relative w-full pb-[141.4%] bg-white rounded-lg shadow-lg border border-gray-200 overflow-hidden hover:shadow-xl hover:scale-105 transition-all duration-300">
6-
<div className="absolute inset-0 p-4"> {/* Added padding here to create space for the inner border */}
7-
<div className="w-full h-full border-2 border-gray-300 flex items-center justify-center p-2"> {/* Inner border div */}
8-
<h2 className="text-gray-800 text-xl font-bold text-center font-playfairDisplay">{title}</h2>
10+
<div
11+
className="relative w-full pb-[141.4%] rounded-lg shadow-lg border border-gray-200 overflow-hidden transition-all duration-300"
12+
style={{ backgroundColor: currentBackgroundColor }}
13+
onMouseEnter={() => setIsHovered(true)}
14+
onMouseLeave={() => setIsHovered(false)}
15+
>
16+
<div className="absolute inset-0 p-4">
17+
<div className="w-full h-full border-2 border-gray-300 flex items-center justify-center p-2">
18+
<h2 className={`text-xl font-bold text-center ${fontFamily}`} style={{ color: currentTextColor }}>{title}</h2>
919
</div>
1020
</div>
1121
</div>
1222
);
1323
};
1424

15-
export default NotebookCover;
25+
export default NotebookCover;

src/pages/notebooks/NotebooksPage.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,16 @@ const NotebooksPage = () => {
7777
</div>
7878
<div className="mt-16">
7979
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
80-
{notebooks.map(notebook => (
80+
{notebooks.map((notebook) => (
8181
<Link key={notebook.id} to={`/notebooks/${notebook.id}`}>
82-
<NotebookCover title={notebook.title} />
82+
<NotebookCover
83+
title={notebook.title}
84+
backgroundColor={notebook.backgroundColor}
85+
fontFamily={notebook.fontFamily}
86+
textColor={notebook.textColor}
87+
hoverBackgroundColor={notebook.hoverBackgroundColor}
88+
hoverTextColor={notebook.hoverTextColor}
89+
/>
8390
</Link>
8491
))}
8592
</div>

0 commit comments

Comments
 (0)