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