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