@@ -31,55 +31,56 @@ export const shapeTpc = function (tpc: Topic, nodeObj: NodeObj) {
3131 if ( nodeObj . image ) {
3232 const img = nodeObj . image
3333 if ( img . url && img . width && img . height ) {
34- const imgContainer = $d . createElement ( 'img' )
35- imgContainer . src = img . url
36- imgContainer . style . width = img . width + 'px'
37- imgContainer . style . height = img . height + 'px'
38- tpc . appendChild ( imgContainer )
39- tpc . image = imgContainer
34+ const imgEl = $d . createElement ( 'img' )
35+ imgEl . src = img . url
36+ imgEl . style . width = img . width + 'px'
37+ imgEl . style . height = img . height + 'px'
38+ if ( img . fit ) imgEl . style . objectFit = img . fit
39+ tpc . appendChild ( imgEl )
40+ tpc . image = imgEl
4041 } else {
41- console . warn ( 'image url/width/height are required' )
42+ console . warn ( 'Image url/width/height are required' )
4243 }
4344 } else if ( tpc . image ) {
4445 tpc . image = undefined
4546 }
4647
4748 {
48- const textContainer = $d . createElement ( 'span' )
49- textContainer . className = 'text'
50- textContainer . textContent = nodeObj . topic
51- tpc . appendChild ( textContainer )
52- tpc . text = textContainer
49+ const textEl = $d . createElement ( 'span' )
50+ textEl . className = 'text'
51+ textEl . textContent = nodeObj . topic
52+ tpc . appendChild ( textEl )
53+ tpc . text = textEl
5354 }
5455
5556 if ( nodeObj . hyperLink ) {
56- const linkContainer = $d . createElement ( 'a' )
57- linkContainer . className = 'hyper-link'
58- linkContainer . target = '_blank'
59- linkContainer . innerText = '🔗'
60- linkContainer . href = nodeObj . hyperLink
61- tpc . appendChild ( linkContainer )
62- tpc . linkContainer = linkContainer
63- } else if ( tpc . linkContainer ) {
64- tpc . linkContainer = undefined
57+ const linkEl = $d . createElement ( 'a' )
58+ linkEl . className = 'hyper-link'
59+ linkEl . target = '_blank'
60+ linkEl . innerText = '🔗'
61+ linkEl . href = nodeObj . hyperLink
62+ tpc . appendChild ( linkEl )
63+ tpc . link = linkEl
64+ } else if ( tpc . link ) {
65+ tpc . link = undefined
6566 }
6667
6768 if ( nodeObj . icons && nodeObj . icons . length ) {
68- const iconsContainer = $d . createElement ( 'span' )
69- iconsContainer . className = 'icons'
70- iconsContainer . innerHTML = nodeObj . icons . map ( icon => `<span>${ encodeHTML ( icon ) } </span>` ) . join ( '' )
71- tpc . appendChild ( iconsContainer )
72- tpc . icons = iconsContainer
69+ const iconsEl = $d . createElement ( 'span' )
70+ iconsEl . className = 'icons'
71+ iconsEl . innerHTML = nodeObj . icons . map ( icon => `<span>${ encodeHTML ( icon ) } </span>` ) . join ( '' )
72+ tpc . appendChild ( iconsEl )
73+ tpc . icons = iconsEl
7374 } else if ( tpc . icons ) {
7475 tpc . icons = undefined
7576 }
7677
7778 if ( nodeObj . tags && nodeObj . tags . length ) {
78- const tagsContainer = $d . createElement ( 'div' )
79- tagsContainer . className = 'tags'
80- tagsContainer . innerHTML = nodeObj . tags . map ( tag => `<span>${ encodeHTML ( tag ) } </span>` ) . join ( '' )
81- tpc . appendChild ( tagsContainer )
82- tpc . tags = tagsContainer
79+ const tagsEl = $d . createElement ( 'div' )
80+ tagsEl . className = 'tags'
81+ tagsEl . innerHTML = nodeObj . tags . map ( tag => `<span>${ encodeHTML ( tag ) } </span>` ) . join ( '' )
82+ tpc . appendChild ( tagsEl )
83+ tpc . tags = tagsEl
8384 } else if ( tpc . tags ) {
8485 tpc . tags = undefined
8586 }
0 commit comments