Skip to content

Commit d0d2ddb

Browse files
committed
feat: enhance BlockTab component with dynamic color configuration
- Introduced a color configuration for the BlockTab component, allowing for customizable background and bevel colors based on the selected color prop. - Updated the Header component to utilize the new color prop for BlockTab instances, improving code readability and maintainability. - Adjusted the RandomSongButton component's background color for better visual consistency.
1 parent a5806e7 commit d0d2ddb

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

apps/frontend/src/app/globals.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,12 @@ body {
153153

154154
.bevel {
155155
position: relative;
156+
--bevel-after-bg: rgb(63 63 70); /* zinc-800 default */
157+
--bevel-before-bg: rgb(24 24 27); /* zinc-900 default */
156158
}
157159
.bevel:after,
158160
.bevel:before {
159161
content: '';
160-
background: grey;
161162
position: absolute;
162163
}
163164
.bevel:after {
@@ -166,13 +167,15 @@ body {
166167
left: 4px;
167168
top: 0;
168169
transform: translatey(-100%) skewx(-45deg);
170+
background: var(--bevel-after-bg);
169171
}
170172
.bevel:before {
171173
width: 8px;
172174
height: 100%;
173175
right: 0;
174176
transform: translatex(100%) skewy(-45deg);
175177
top: -4px;
178+
background: var(--bevel-before-bg);
176179
}
177180

178181
/************** Google AdSense **************/

apps/frontend/src/modules/shared/components/layout/BlockTab.tsx

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,65 @@ import { cn } from '@web/lib/utils';
66

77
import { MusicalNote } from './MusicalNote';
88

9+
type BlockTabColor = 'purple' | 'blue' | 'green' | 'cyan' | 'zinc';
10+
11+
const colorConfig: Record<
12+
BlockTabColor,
13+
{ bg: string; afterBg: string; beforeBg: string }
14+
> = {
15+
purple: {
16+
bg: 'bg-purple-700',
17+
afterBg: 'rgb(88 28 135)', // purple-900
18+
beforeBg: 'rgb(59 7 100)', // purple-950
19+
},
20+
blue: {
21+
bg: 'bg-blue-700',
22+
afterBg: 'rgb(30 58 138)', // blue-900
23+
beforeBg: 'rgb(23 37 84)', // blue-950
24+
},
25+
green: {
26+
bg: 'bg-green-700',
27+
afterBg: 'rgb(20 83 45)', // green-900
28+
beforeBg: 'rgb(5 46 22)', // green-950
29+
},
30+
cyan: {
31+
bg: 'bg-cyan-700',
32+
afterBg: 'rgb(22 78 99)', // cyan-900
33+
beforeBg: 'rgb(8 51 68)', // cyan-950
34+
},
35+
zinc: {
36+
bg: 'bg-zinc-600',
37+
afterBg: 'rgb(63 63 70)', // zinc-800
38+
beforeBg: 'rgb(24 24 27)', // zinc-900
39+
},
40+
};
41+
942
export const BlockTab = ({
1043
href,
1144
icon,
1245
label,
13-
className,
46+
color = 'zinc',
1447
}: {
1548
href: string;
1649
icon: IconDefinition;
1750
label: string;
18-
className?: string;
51+
color?: BlockTabColor;
1952
}) => {
53+
const colors = colorConfig[color];
54+
2055
return (
2156
<Link
2257
href={href}
2358
className={cn(
24-
'bevel p-2 flex-1 w-8 md:min-w-20 max-w-28 flex items-center justify-center gap-2 bg-zinc-600 after:bg-zinc-800 before:bg-zinc-900 translate-y-[11px] hover:translate-y-1.5 transition-all duration-150 hover:brightness-125',
25-
className,
59+
'bevel p-2 flex-1 w-8 md:min-w-20 max-w-28 flex items-center justify-center gap-2 translate-y-[11px] hover:translate-y-1.5 transition-all duration-150 hover:brightness-125',
60+
colors.bg,
2661
)}
62+
style={
63+
{
64+
'--bevel-after-bg': colors.afterBg,
65+
'--bevel-before-bg': colors.beforeBg,
66+
} as React.CSSProperties
67+
}
2768
>
2869
<FontAwesomeIcon icon={icon} />
2970
<span className='hidden sm:block'>{label}</span>

apps/frontend/src/modules/shared/components/layout/Header.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,20 @@ export async function Header() {
5959

6060
{/* Info pages */}
6161
<div className='flex flex-1 justify-center gap-1 h-8 text-center'>
62-
<BlockTab
63-
href='/'
64-
icon={faMusic}
65-
label='Songs'
66-
className='bg-purple-700 after:bg-purple-900 before:bg-purple-950'
67-
/>
62+
<BlockTab href='/' icon={faMusic} label='Songs' color='purple' />
6863
<BlockTab
6964
href='/help'
7065
icon={faQuestionCircle}
7166
label='Help'
72-
className='bg-blue-700 after:bg-blue-900 before:bg-blue-950'
67+
color='blue'
7368
/>
7469
<BlockTab
7570
href='/blog'
7671
icon={faNewspaper}
7772
label='Blog'
78-
className='bg-green-700 after:bg-green-900 before:bg-green-950'
79-
/>
80-
<BlockTab
81-
href='/about'
82-
icon={faUser}
83-
label='About'
84-
className='bg-cyan-700 after:bg-cyan-900 before:bg-cyan-950'
73+
color='green'
8574
/>
75+
<BlockTab href='/about' icon={faUser} label='About' color='cyan' />
8676
<RandomSongButton />
8777
</div>
8878

apps/frontend/src/modules/shared/components/layout/RandomSongButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const RandomSongButton = () => {
3636

3737
return (
3838
<button
39-
className='bevel p-2 flex-0 w-min flex items-center justify-center gap-2 bg-zinc-600 after:bg-zinc-700 before:bg-zinc-800 translate-y-[11px] hover:translate-y-1.5 transition-all duration-150 hover:brightness-125'
39+
className='bevel p-2 flex-0 w-min flex items-center justify-center gap-2 bg-zinc-500 after:bg-zinc-700 before:bg-zinc-800 translate-y-[11px] hover:translate-y-1.5 transition-all duration-150 hover:brightness-125'
4040
onClick={randomSong}
4141
>
4242
<FontAwesomeIcon icon={faDice} />

0 commit comments

Comments
 (0)