11import {
22 FeaturedBadge ,
33 ProjectBadge ,
4- FeaturedBadgeNames ,
4+ FeaturedBadgeName ,
55} from 'formidable-oss-badges' ;
66import React from 'react' ;
77
@@ -19,7 +19,7 @@ export const DEFAULT_BADGE_COLOR_OPTIONS = [
1919 '#166BFF' ,
2020] ;
2121
22- function isFeaturedBadgeName ( value : string ) : value is FeaturedBadgeNames {
22+ function isFeaturedBadgeName ( name : string ) : name is FeaturedBadgeName {
2323 return [
2424 'envy' ,
2525 'figlog' ,
@@ -32,7 +32,7 @@ function isFeaturedBadgeName(value: string): value is FeaturedBadgeNames {
3232 'nuka' ,
3333 'owl' ,
3434 'groqd' ,
35- ] . includes ( value ) ;
35+ ] . includes ( name ) ;
3636}
3737
3838export const LandingFeaturedProjects = < Name extends string > ( {
@@ -42,7 +42,7 @@ export const LandingFeaturedProjects = <Name extends string>({
4242} : {
4343 heading : string ;
4444 projects : {
45- name : FeaturedBadgeNames | Name ;
45+ name : FeaturedBadgeName | Name ;
4646 link : string ;
4747 description : string ;
4848 title ?: string ;
@@ -53,35 +53,38 @@ export const LandingFeaturedProjects = <Name extends string>({
5353 { showDivider && < Divider /> }
5454 < h2 className = "my-8 text-4xl font-semibold" > { heading } </ h2 >
5555 < div className = "grid grid-cols-2 gap-8" >
56- { projects . map ( ( { name, link, description, title } ) => (
57- < a
58- href = { link }
59- key = { link }
60- className = "col-span-2 sm:col-span-1 block grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 align-center items-center text-theme-2 hover:text-theme-2 dark:text-white dark:hover:text-white" >
61- { isFeaturedBadgeName ( name . toLocaleLowerCase ( ) ) ? (
62- < FeaturedBadge
63- name = { name as FeaturedBadgeNames }
64- isHoverable
65- className = "col-span-1"
66- />
67- ) : (
68- < ProjectBadge
69- color = {
70- DEFAULT_BADGE_COLOR_OPTIONS [ Math . floor ( Math . random ( ) * 5 ) + 1 ]
71- }
72- isHoverable
73- abbreviation = { name . charAt ( 0 ) . toUpperCase ( ) + name . slice ( 1 , 2 ) }
74- description = { name }
75- />
76- ) }
77- < span className = "flex flex-col col-span-1 lg:col-span-2" >
78- < span className = "text-xl font-semibold capitalize" >
79- { title || name }
56+ { projects . map ( ( { name, link, description, title } ) => {
57+ const lowerCaseName = name . toLocaleLowerCase ( ) ;
58+ return (
59+ < a
60+ href = { link }
61+ key = { link }
62+ className = "col-span-2 sm:col-span-1 block grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 align-center items-center text-theme-2 hover:text-theme-2 dark:text-white dark:hover:text-white" >
63+ { isFeaturedBadgeName ( lowerCaseName ) ? (
64+ < FeaturedBadge
65+ name = { lowerCaseName }
66+ isHoverable
67+ className = "col-span-1"
68+ />
69+ ) : (
70+ < ProjectBadge
71+ color = {
72+ DEFAULT_BADGE_COLOR_OPTIONS [ Math . floor ( Math . random ( ) * 5 ) + 1 ]
73+ }
74+ isHoverable
75+ abbreviation = { name . charAt ( 0 ) . toUpperCase ( ) + name . slice ( 1 , 2 ) }
76+ description = { name }
77+ />
78+ ) }
79+ < span className = "flex flex-col col-span-1 lg:col-span-2" >
80+ < span className = "text-xl font-semibold capitalize" >
81+ { title || name }
82+ </ span >
83+ < span className = "text-sm " > { description } </ span >
8084 </ span >
81- < span className = "text-sm " > { description } </ span >
82- </ span >
83- </ a >
84- ) ) }
85+ </ a >
86+ ) ;
87+ } ) }
8588 </ div >
8689
8790 < div className = "my-8 pt-8 align-center" >
0 commit comments