11import { FC } from "react" ;
22
3- import { getAppName } from "@/lib/data" ;
4- import { formatTitle , formatTitleWithMissing } from "@/lib/format" ;
3+ import { getAppName , getColors } from "@/lib/data" ;
4+ import { formatTitleWithMissing , limitTextLength } from "@/lib/format" ;
5+ import { Ring } from "@/lib/types" ;
56
67interface ItemInfoProps {
78 size : { height : number ; width : number } ;
89 name ?: string ;
910 segment ?: string ;
10- ring ?: string ;
11+ ring ?: Ring ;
1112 description ?: string ;
1213}
1314
@@ -18,6 +19,11 @@ export const ItemInfo: FC<ItemInfoProps> = ({
1819 ring,
1920 description,
2021} ) => {
22+ const colors = getColors ( ) ;
23+ const descTextSize = 28 ;
24+ const descLineHeight = 32 ;
25+ const descPaddingVert = 20 ;
26+
2127 return (
2228 < div
2329 style = { {
@@ -26,40 +32,75 @@ export const ItemInfo: FC<ItemInfoProps> = ({
2632 width : "100%" ,
2733 height : "100%" ,
2834 flex : 1 ,
29- padding : 50 ,
35+ padding : "30px 50px" ,
3036 } }
3137 >
3238 < h2
3339 style = { {
3440 display : "block" ,
3541 fontWeight : "bold" ,
36- width : `${ size . width * 0.65 } px` ,
37- } }
38- >
39- { formatTitleWithMissing ( name , getAppName ( ) ) }
40- </ h2 >
41- < span
42- style = { {
43- fontSize : 32 ,
44- width : `${ size . width * 0.65 } px` ,
45- flex : 1 ,
46- } }
47- >
48- { formatTitleWithMissing ( segment , ring ) }
49- </ span >
50- < p
51- style = { {
52- display : "block" ,
53- textOverflow : "ellipsis" ,
54- overflow : "hidden" ,
55- whiteSpace : "wrap" ,
56- height : "17%" ,
5742 width : `${ size . width * 0.75 } px` ,
58- fontSize : 32 ,
5943 } }
6044 >
61- { description }
62- </ p >
45+ { limitTextLength ( formatTitleWithMissing ( name , getAppName ( ) ) , 50 ) }
46+ </ h2 >
47+ { segment && (
48+ < span
49+ style = { {
50+ fontSize : 32 ,
51+ width : `${ size . width * 0.65 } px` ,
52+ flex : 1 ,
53+ } }
54+ >
55+ { limitTextLength ( segment , 80 ) }
56+ </ span >
57+ ) }
58+ { description && (
59+ < p
60+ style = { {
61+ display : "flex" ,
62+ maxHeight : `${ 48 + 2 * descPaddingVert + 2 * descLineHeight } px` ,
63+ width : `${ size . width * 0.75 } px` ,
64+ padding : `${ 24 + descPaddingVert } px 24px` ,
65+ borderRadius : "12px" ,
66+ backgroundColor : colors . foreground ,
67+ whiteSpace : "wrap" ,
68+ textAlign : "left" ,
69+ fontSize : `${ descTextSize } px` ,
70+ lineHeight : `${ descLineHeight } px` ,
71+ color : colors . text ,
72+ } }
73+ >
74+ { limitTextLength ( description , 100 ) }
75+ { ring && (
76+ < div
77+ style = { {
78+ display : "flex" ,
79+ position : "absolute" ,
80+ top : `-${ descPaddingVert } px` ,
81+ left : "32px" ,
82+ } }
83+ >
84+ < span
85+ style = { {
86+ borderRadius : "100px" ,
87+ background : ring . color ,
88+ color : colors . content ,
89+ width : "auto" ,
90+ padding : "12px 32px" ,
91+ textTransform : "uppercase" ,
92+ alignItems : "center" ,
93+ fontSize : "28px" ,
94+ lineHeight : "28px" ,
95+ flexShrink : 0 ,
96+ } }
97+ >
98+ { ring . title }
99+ </ span >
100+ </ div >
101+ ) }
102+ </ p >
103+ ) }
63104 </ div >
64105 ) ;
65106} ;
0 commit comments