(
textStyle: TooltipOption['textStyle'],
renderMode: TooltipRenderMode
)
| 56 | } |
| 57 | // TODO: more textStyle option |
| 58 | function getTooltipTextStyle( |
| 59 | textStyle: TooltipOption['textStyle'], |
| 60 | renderMode: TooltipRenderMode |
| 61 | ): { |
| 62 | nameStyle: TextStyle |
| 63 | valueStyle: TextStyle |
| 64 | } { |
| 65 | const nameFontColor = textStyle.color || tokens.color.tertiary; |
| 66 | const nameFontSize = textStyle.fontSize || 12; |
| 67 | const nameFontWeight = textStyle.fontWeight || '400'; |
| 68 | const valueFontColor = textStyle.color || tokens.color.secondary; |
| 69 | const valueFontSize = textStyle.fontSize || 14; |
| 70 | const valueFontWeight = textStyle.fontWeight || '900'; |
| 71 | |
| 72 | if (renderMode === 'html') { |
| 73 | // `textStyle` is probably from user input, should be encoded to reduce security risk. |
| 74 | return { |
| 75 | // eslint-disable-next-line max-len |
| 76 | nameStyle: `font-size:${encodeHTML(nameFontSize + '')}px;color:${encodeHTML(nameFontColor)};font-weight:${encodeHTML(nameFontWeight + '')}`, |
| 77 | // eslint-disable-next-line max-len |
| 78 | valueStyle: `font-size:${encodeHTML(valueFontSize + '')}px;color:${encodeHTML(valueFontColor)};font-weight:${encodeHTML(valueFontWeight + '')}` |
| 79 | }; |
| 80 | } |
| 81 | else { |
| 82 | return { |
| 83 | nameStyle: { |
| 84 | fontSize: nameFontSize, |
| 85 | fill: nameFontColor, |
| 86 | fontWeight: nameFontWeight |
| 87 | }, |
| 88 | valueStyle: { |
| 89 | fontSize: valueFontSize, |
| 90 | fill: valueFontColor, |
| 91 | fontWeight: valueFontWeight |
| 92 | } |
| 93 | }; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | // 0: no gap in this block. |
| 98 | // 1: has max gap in level 1 in this block. |
no test coverage detected