( modelName: string, billingType: string, availableWidth: number, )
| 272 | * Determines how to display model and billing information based on available width |
| 273 | */ |
| 274 | export function formatModelAndBilling( |
| 275 | modelName: string, |
| 276 | billingType: string, |
| 277 | availableWidth: number, |
| 278 | ): { |
| 279 | shouldSplit: boolean |
| 280 | truncatedModel: string |
| 281 | truncatedBilling: string |
| 282 | } { |
| 283 | const separator = ' · ' |
| 284 | const combinedWidth = |
| 285 | stringWidth(modelName) + separator.length + stringWidth(billingType) |
| 286 | const shouldSplit = combinedWidth > availableWidth |
| 287 | |
| 288 | if (shouldSplit) { |
| 289 | return { |
| 290 | shouldSplit: true, |
| 291 | truncatedModel: truncate(modelName, availableWidth), |
| 292 | truncatedBilling: truncate(billingType, availableWidth), |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | return { |
| 297 | shouldSplit: false, |
| 298 | truncatedModel: truncate( |
| 299 | modelName, |
| 300 | Math.max( |
| 301 | availableWidth - stringWidth(billingType) - separator.length, |
| 302 | 10, |
| 303 | ), |
| 304 | ), |
| 305 | truncatedBilling: billingType, |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * Gets recent release notes for Logo v2 display |
no test coverage detected