Skip to content

Commit 869ce51

Browse files
committed
star colors
1 parent 402e1ca commit 869ce51

File tree

1 file changed

+179
-173
lines changed

1 file changed

+179
-173
lines changed

src/components/LogCard.js

Lines changed: 179 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,179 @@
1-
import React from 'react';
2-
import { Link } from 'react-router-dom';
3-
import colors from '../config/colors';
4-
import {
5-
BookOpen,
6-
FilmStrip,
7-
GameController,
8-
Article,
9-
MusicNote,
10-
Television,
11-
ForkKnife,
12-
Globe,
13-
Star,
14-
Wrench,
15-
} from '@phosphor-icons/react';
16-
17-
const categoryIcons = {
18-
Book: <BookOpen />,
19-
Movie: <FilmStrip />,
20-
Game: <GameController />,
21-
Article: <Article />,
22-
Music: <MusicNote />,
23-
Series: <Television />,
24-
Food: <ForkKnife />,
25-
Websites: <Globe />,
26-
Tools: <Wrench />,
27-
};
28-
29-
const categoryStyles = {
30-
Book: {
31-
backgroundColor: colors['book-alpha-10'],
32-
borderColor: colors['book-alpha-50'],
33-
textColor: colors.book,
34-
},
35-
Movie: {
36-
backgroundColor: colors['movie-alpha-10'],
37-
borderColor: colors['movie-alpha-50'],
38-
textColor: colors.movie,
39-
},
40-
Game: {
41-
backgroundColor: colors['game-alpha-10'],
42-
borderColor: colors['game-alpha-50'],
43-
textColor: colors.game,
44-
},
45-
Article: {
46-
backgroundColor: colors['article-alpha-10'],
47-
borderColor: colors['article-alpha-50'],
48-
textColor: colors.article,
49-
},
50-
Music: {
51-
backgroundColor: colors['music-alpha-10'],
52-
borderColor: colors['music-alpha-50'],
53-
textColor: colors.music,
54-
},
55-
Series: {
56-
backgroundColor: colors['series-alpha-10'],
57-
borderColor: colors['series-alpha-50'],
58-
textColor: colors.series,
59-
},
60-
Food: {
61-
backgroundColor: colors['food-alpha-10'],
62-
borderColor: colors['food-alpha-50'],
63-
textColor: colors.food,
64-
},
65-
Websites: {
66-
backgroundColor: colors['websites-alpha-10'],
67-
borderColor: colors['websites-alpha-50'],
68-
textColor: colors.websites,
69-
},
70-
Tools: {
71-
backgroundColor: colors['tools-alpha-10'],
72-
borderColor: colors['tools-alpha-50'],
73-
textColor: colors.tools,
74-
},
75-
};
76-
77-
const LogCard = ({ log, index, totalLogs }) => {
78-
const {
79-
title,
80-
category,
81-
author,
82-
director,
83-
platform,
84-
source,
85-
artist,
86-
year,
87-
creator,
88-
date,
89-
rating,
90-
slug,
91-
updated,
92-
} = log;
93-
94-
const cardStyle = categoryStyles[category] || {};
95-
const detailTextColor = colors[category.toLowerCase() + '-light'];
96-
97-
const renderStars = (rating) => {
98-
const stars = [];
99-
for (let i = 0; i < 5; i++) {
100-
if (i < rating) {
101-
stars.push(
102-
<Star key={i} size={16} weight="fill" className="text-yellow-400" />,
103-
);
104-
} else {
105-
stars.push(
106-
<Star key={i} size={16} weight="fill" className="text-gray-500" />,
107-
);
108-
}
109-
}
110-
return <div className="flex ml-1 mt-1">{stars}</div>;
111-
};
112-
113-
return (
114-
<Link to={`/logs/${slug}`} className="block">
115-
<div
116-
className="group bg-transparent border rounded-lg shadow-lg p-6 flex flex-col justify-between relative transform transition-all duration-300 ease-in-out hover:scale-105 hover:shadow-2xl overflow-hidden h-full"
117-
style={cardStyle}
118-
>
119-
<div className="absolute top-3 right-3 text-lg font-semibold px-2 py-1 rounded-md border overflow-hidden whitespace-nowrap" style={{ backgroundColor: 'rgba(0, 0, 0, 0.2)', color: cardStyle.textColor, borderColor: cardStyle.borderColor }}>
120-
#{totalLogs - index}
121-
</div>
122-
<div
123-
className="absolute top-0 left-0 w-full h-full opacity-0 group-hover:opacity-10 transition-opacity duration-500 ease-in-out"
124-
style={{
125-
backgroundImage:
126-
'radial-gradient(circle, white 1px, transparent 1px)',
127-
backgroundSize: '10px 10px',
128-
}}
129-
></div>
130-
<div>
131-
<div className="flex items-center justify-between mb-4 pr-10">
132-
<div className="flex items-center">
133-
<div className="text-2xl mr-4" style={{ color: detailTextColor }}>{categoryIcons[category]}</div>
134-
<h2
135-
className={`text-xl font-normal`}
136-
style={{ color: cardStyle.textColor }}
137-
>
138-
{title}
139-
</h2>
140-
</div>
141-
</div>
142-
<div className="text-sm mb-4" style={{ color: detailTextColor }}>
143-
{author && <div>Author: {author}</div>}
144-
{director && <div>Director: {director}</div>}
145-
{platform && <div>Platform: {platform}</div>}
146-
{source && <div>Source: {source}</div>}
147-
{artist && <div>Artist: {artist}</div>}
148-
{year && <div>Year: {year}</div>}
149-
{creator && <div>Creator: {creator}</div>}
150-
</div>
151-
</div>
152-
<div className="flex items-center justify-between">
153-
<div className="flex items-center">
154-
<div className="text-yellow-400">
155-
{renderStars(rating)}
156-
</div>
157-
<div className="text-gray-400 ml-2">({rating}/5)</div>
158-
</div>
159-
<div>
160-
{updated && (
161-
<div className="text-xs text-rose-300 text-right">
162-
(U): {updated}
163-
</div>
164-
)}
165-
<div className="text-sm text-blue-400 text-right">{date}</div>
166-
</div>
167-
</div>
168-
</div>
169-
</Link>
170-
);
171-
};
172-
173-
export default LogCard;
1+
import React from 'react';
2+
import { Link } from 'react-router-dom';
3+
import colors from '../config/colors';
4+
import {
5+
BookOpen,
6+
FilmStrip,
7+
GameController,
8+
Article,
9+
MusicNote,
10+
Television,
11+
ForkKnife,
12+
Globe,
13+
Star,
14+
Wrench,
15+
} from '@phosphor-icons/react';
16+
17+
const categoryIcons = {
18+
Book: <BookOpen />,
19+
Movie: <FilmStrip />,
20+
Game: <GameController />,
21+
Article: <Article />,
22+
Music: <MusicNote />,
23+
Series: <Television />,
24+
Food: <ForkKnife />,
25+
Websites: <Globe />,
26+
Tools: <Wrench />,
27+
};
28+
29+
const categoryStyles = {
30+
Book: {
31+
backgroundColor: colors['book-alpha-10'],
32+
borderColor: colors['book-alpha-50'],
33+
textColor: colors.book,
34+
},
35+
Movie: {
36+
backgroundColor: colors['movie-alpha-10'],
37+
borderColor: colors['movie-alpha-50'],
38+
textColor: colors.movie,
39+
},
40+
Game: {
41+
backgroundColor: colors['game-alpha-10'],
42+
borderColor: colors['game-alpha-50'],
43+
textColor: colors.game,
44+
},
45+
Article: {
46+
backgroundColor: colors['article-alpha-10'],
47+
borderColor: colors['article-alpha-50'],
48+
textColor: colors.article,
49+
},
50+
Music: {
51+
backgroundColor: colors['music-alpha-10'],
52+
borderColor: colors['music-alpha-50'],
53+
textColor: colors.music,
54+
},
55+
Series: {
56+
backgroundColor: colors['series-alpha-10'],
57+
borderColor: colors['series-alpha-50'],
58+
textColor: colors.series,
59+
},
60+
Food: {
61+
backgroundColor: colors['food-alpha-10'],
62+
borderColor: colors['food-alpha-50'],
63+
textColor: colors.food,
64+
},
65+
Websites: {
66+
backgroundColor: colors['websites-alpha-10'],
67+
borderColor: colors['websites-alpha-50'],
68+
textColor: colors.websites,
69+
},
70+
Tools: {
71+
backgroundColor: colors['tools-alpha-10'],
72+
borderColor: colors['tools-alpha-50'],
73+
textColor: colors.tools,
74+
},
75+
};
76+
77+
const LogCard = ({ log, index, totalLogs }) => {
78+
const {
79+
title,
80+
category,
81+
author,
82+
director,
83+
platform,
84+
source,
85+
artist,
86+
year,
87+
creator,
88+
date,
89+
rating,
90+
slug,
91+
updated,
92+
} = log;
93+
94+
const cardStyle = categoryStyles[category] || {};
95+
const detailTextColor = colors[category.toLowerCase() + '-light'];
96+
97+
const renderStars = (rating) => {
98+
const stars = [];
99+
const starColor = cardStyle.textColor;
100+
const emptyStarColor = colors[category.toLowerCase() + '-alpha-50'];
101+
for (let i = 0; i < 5; i++) {
102+
if (i < rating) {
103+
stars.push(
104+
<Star key={i} size={16} weight="fill" style={{ color: starColor }} />,
105+
);
106+
} else {
107+
stars.push(
108+
<Star
109+
key={i}
110+
size={16}
111+
weight="fill"
112+
style={{ color: emptyStarColor }}
113+
/>,
114+
);
115+
}
116+
}
117+
return <div className="flex ml-1 mt-1">{stars}</div>;
118+
};
119+
return (
120+
<Link to={`/logs/${slug}`} className="block">
121+
<div
122+
className="group bg-transparent border rounded-lg shadow-lg p-6 flex flex-col justify-between relative transform transition-all duration-300 ease-in-out hover:scale-105 hover:shadow-2xl overflow-hidden h-full"
123+
style={cardStyle}
124+
>
125+
<div className="absolute top-3 right-3 text-lg font-semibold px-2 py-1 rounded-md border overflow-hidden whitespace-nowrap" style={{ backgroundColor: 'rgba(0, 0, 0, 0.2)', color: cardStyle.textColor, borderColor: cardStyle.borderColor }}>
126+
#{totalLogs - index}
127+
</div>
128+
<div
129+
className="absolute top-0 left-0 w-full h-full opacity-0 group-hover:opacity-10 transition-opacity duration-500 ease-in-out"
130+
style={{
131+
backgroundImage:
132+
'radial-gradient(circle, white 1px, transparent 1px)',
133+
backgroundSize: '10px 10px',
134+
}}
135+
></div>
136+
<div>
137+
<div className="flex items-center justify-between mb-4 pr-10">
138+
<div className="flex items-center">
139+
<div className="text-2xl mr-4" style={{ color: detailTextColor }}>{categoryIcons[category]}</div>
140+
<h2
141+
className={`text-xl font-normal`}
142+
style={{ color: cardStyle.textColor }}
143+
>
144+
{title}
145+
</h2>
146+
</div>
147+
</div>
148+
<div className="text-sm mb-4" style={{ color: detailTextColor }}>
149+
{author && <div>Author: {author}</div>}
150+
{director && <div>Director: {director}</div>}
151+
{platform && <div>Platform: {platform}</div>}
152+
{source && <div>Source: {source}</div>}
153+
{artist && <div>Artist: {artist}</div>}
154+
{year && <div>Year: {year}</div>}
155+
{creator && <div>Creator: {creator}</div>}
156+
</div>
157+
</div>
158+
<div className="flex items-center justify-between">
159+
<div className="flex items-center">
160+
<div className="text-yellow-400">
161+
{renderStars(rating)}
162+
</div>
163+
<div className="text-gray-400 ml-2">({rating}/5)</div>
164+
</div>
165+
<div>
166+
{updated && (
167+
<div className="text-xs text-rose-300 text-right">
168+
(U): {updated}
169+
</div>
170+
)}
171+
<div className="text-sm text-blue-400 text-right">{date}</div>
172+
</div>
173+
</div>
174+
</div>
175+
</Link>
176+
);
177+
};
178+
179+
export default LogCard;

0 commit comments

Comments
 (0)