-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: icon primitive & recent modules collapsing
- Loading branch information
Showing
4 changed files
with
34 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
import { convertHexToRGBA } from '@/lib/colors'; | ||
import { Icon, type IconNames } from '@/primitives/icon'; | ||
import Link from 'next/link'; | ||
import { type FC } from 'react'; | ||
import colors, { zinc } from 'tailwindcss/colors'; | ||
|
||
interface ModuleCardProps { | ||
color: string; | ||
id: string; | ||
name: string; | ||
icon: string; | ||
icon: IconNames; | ||
credits: number; | ||
} | ||
|
||
export const ModuleCard: FC<ModuleCardProps> = ({ | ||
export function ModuleCard({ | ||
id, | ||
color, | ||
name, | ||
icon, | ||
credits, | ||
}) => { | ||
}: ModuleCardProps) { | ||
const moduleColor = | ||
color === 'default' ? zinc : colors[color as keyof typeof colors]; | ||
|
||
return ( | ||
<li className="shrink-0 basis-full lg:basis-[240px]"> | ||
<li className="shrink-0 basis-full lg:basis-[250px]"> | ||
<Link | ||
href={`/app/module/${id}`} | ||
className="flex w-full flex-col gap-2 rounded-xl p-6" | ||
style={{ | ||
background: `linear-gradient(135deg, ${convertHexToRGBA( | ||
moduleColor['500'], | ||
0.075, | ||
0.08, | ||
)} 0%, ${convertHexToRGBA(moduleColor['700'], 0.05)} 100%)`, | ||
border: `1px solid ${convertHexToRGBA(moduleColor['500'], 0.1)}`, | ||
}} | ||
> | ||
{icon} | ||
<h3 className="mt-2 font-medium">{name}</h3> | ||
<Icon name={icon} strokeWidth={2} size={20} /> | ||
<h3 className="mt-2 text-lg font-medium">{name}</h3> | ||
<p className="text-xs text-gray-foreground-muted">{credits} Credits</p> | ||
</Link> | ||
</li> | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { icons } from 'lucide-react'; | ||
|
||
interface Props { | ||
name: keyof typeof icons; | ||
color?: string; | ||
size?: number; | ||
strokeWidth?: number; | ||
} | ||
|
||
export const Icon: React.FC<Props> = ({ name, color, size, strokeWidth }) => { | ||
// eslint-disable-next-line security/detect-object-injection | ||
const LucideIcon = icons[name]; | ||
|
||
return ( | ||
<LucideIcon strokeWidth={strokeWidth} color={color} size={size ?? 24} /> | ||
); | ||
}; | ||
|
||
export type IconNames = keyof typeof icons; | ||
export const iconNames = Object.keys(icons) as IconNames[]; |