|
1 | 1 | import React from 'react'; |
2 | 2 | import { Box } from '../../base'; |
| 3 | +import { CommunityClassIcon, OfficialClassIcon, VerificationClassIcon } from '../../icons'; |
| 4 | +import { KEPPEL, useTheme } from '../../theme'; |
3 | 5 | import { InfoTooltip } from '../CustomTooltip'; |
4 | 6 | import { ContentDetailsPoints, ContentDetailsText } from '../Typography'; |
5 | | -import { CONTENT_CLASS, formatToTitleCase } from './helper'; |
6 | | -import { Class } from './types'; |
| 7 | +import { formatToTitleCase } from './helper'; |
| 8 | +import { Class, ContentClassType } from './types'; |
7 | 9 |
|
8 | 10 | interface ContentClassInfoProps { |
9 | 11 | contentClass: string; |
10 | 12 | classes: Class[]; |
11 | 13 | } |
12 | 14 |
|
13 | | -const ClassIcon: React.FC<{ className: string }> = ({ className }) => { |
14 | | - const Icon = CONTENT_CLASS[className]?.icon; |
15 | | - return Icon ? <Icon width="25px" height="25px" /> : null; |
16 | | -}; |
17 | | - |
18 | 15 | const ContentClassInfo: React.FC<ContentClassInfoProps> = ({ contentClass, classes }) => { |
19 | | - const classDescription = (className: string): string | undefined => { |
| 16 | + const _classDescription = (className: string): string | undefined => { |
20 | 17 | const classObj = classes && classes.find((classObj) => classObj.class === className); |
21 | 18 | return classObj?.description; |
22 | 19 | }; |
23 | 20 |
|
| 21 | + const theme = useTheme(); |
| 22 | + |
| 23 | + const CONTENT_CLASS: ContentClassType = { |
| 24 | + community: { |
| 25 | + icon: CommunityClassIcon, |
| 26 | + color: theme.palette.icon.secondary |
| 27 | + }, |
| 28 | + official: { |
| 29 | + icon: OfficialClassIcon, |
| 30 | + color: '#EBC017' |
| 31 | + }, |
| 32 | + verified: { |
| 33 | + icon: VerificationClassIcon, |
| 34 | + color: theme.palette.primary.brand?.default || KEPPEL |
| 35 | + } |
| 36 | + } as const; |
| 37 | + |
| 38 | + const ClassIcon: React.FC<{ className: string }> = ({ className }) => { |
| 39 | + const Icon = CONTENT_CLASS[className]?.icon; |
| 40 | + const fill = CONTENT_CLASS[className]?.color; |
| 41 | + return Icon ? <Icon width="25px" height="25px" fill={fill} /> : null; |
| 42 | + }; |
| 43 | + |
24 | 44 | return ( |
25 | 45 | <div> |
26 | 46 | <Box style={{ display: 'flex', alignItems: 'center', gap: '0.3rem' }}> |
27 | | - <ContentDetailsPoints>CLASS</ContentDetailsPoints> |
| 47 | + <ContentDetailsPoints style={{ fontFamily: 'inherit', fontWeight: 'bold' }}> |
| 48 | + CLASS |
| 49 | + </ContentDetailsPoints> |
28 | 50 | <InfoTooltip |
29 | 51 | variant="standard" |
30 | | - helpText={classDescription(contentClass)} |
| 52 | + helpText={_classDescription(contentClass)} |
31 | 53 | style={{ marginBottom: '0.2rem' }} |
32 | 54 | /> |
33 | 55 | </Box> |
34 | 56 | <ContentDetailsText |
35 | 57 | style={{ |
36 | 58 | display: 'flex', |
37 | 59 | alignItems: 'center', |
38 | | - gap: '0.4rem' |
| 60 | + gap: '0.4rem', |
| 61 | + fontFamily: 'inherit' |
39 | 62 | }} |
40 | 63 | > |
41 | 64 | <ClassIcon className={contentClass} /> |
|
0 commit comments