(options: ControlOptions)
| 286 | * The text can optionally wrap, aligning the icon with the first line of text. |
| 287 | */ |
| 288 | export function control(options: ControlOptions): ControlResult { |
| 289 | let paddingX = options.shape === 'pill' ? ('pill' as const) : ('edge-to-text' as const); |
| 290 | let result: ControlResult = { |
| 291 | font: controlFont(), |
| 292 | display: 'flex', |
| 293 | alignItems: 'center', |
| 294 | boxSizing: 'border-box', |
| 295 | paddingX: paddingX, |
| 296 | minWidth: controlSize() |
| 297 | }; |
| 298 | |
| 299 | if (options.shape === 'pill') { |
| 300 | result.borderRadius = 'pill'; |
| 301 | } else { |
| 302 | Object.assign(result, controlBorderRadius()); |
| 303 | } |
| 304 | |
| 305 | if (options.icon) { |
| 306 | result.columnGap = 'text-to-visual'; |
| 307 | result.paddingX = { |
| 308 | default: paddingX, |
| 309 | [iconOnly]: 0 |
| 310 | }; |
| 311 | result['--iconMargin'] = { |
| 312 | type: 'marginStart', |
| 313 | value: { |
| 314 | default: fontRelative(-2), |
| 315 | [iconOnly]: 0 |
| 316 | } |
| 317 | }; |
| 318 | } |
| 319 | |
| 320 | if (options.wrap) { |
| 321 | result.minHeight = controlSize(); |
| 322 | |
| 323 | if (options.icon) { |
| 324 | result.paddingY = 0; |
| 325 | result['--labelPadding'] = { |
| 326 | type: 'paddingTop', |
| 327 | value: centerPadding() |
| 328 | }; |
| 329 | result.alignItems = { |
| 330 | default: 'baseline', |
| 331 | [iconOnly]: 'center' |
| 332 | }; |
| 333 | } else { |
| 334 | result.paddingY = centerPadding(); |
| 335 | } |
| 336 | } else { |
| 337 | result.height = controlSize(); |
| 338 | } |
| 339 | |
| 340 | return result; |
| 341 | } |
| 342 | |
| 343 | const allowedOverrides = [ |
| 344 | 'margin', |
no test coverage detected