MCPcopy Index your code
hub / github.com/codeaashu/claude-code / applyFlexStyles

Function applyFlexStyles

src/ink/styles.ts:514–628  ·  view source on GitHub ↗
(node: LayoutNode, style: Styles)

Source from the content-addressed store, hash-verified

512}
513
514const applyFlexStyles = (node: LayoutNode, style: Styles): void => {
515 if ('flexGrow' in style) {
516 node.setFlexGrow(style.flexGrow ?? 0)
517 }
518
519 if ('flexShrink' in style) {
520 node.setFlexShrink(
521 typeof style.flexShrink === 'number' ? style.flexShrink : 1,
522 )
523 }
524
525 if ('flexWrap' in style) {
526 if (style.flexWrap === 'nowrap') {
527 node.setFlexWrap(LayoutWrap.NoWrap)
528 }
529
530 if (style.flexWrap === 'wrap') {
531 node.setFlexWrap(LayoutWrap.Wrap)
532 }
533
534 if (style.flexWrap === 'wrap-reverse') {
535 node.setFlexWrap(LayoutWrap.WrapReverse)
536 }
537 }
538
539 if ('flexDirection' in style) {
540 if (style.flexDirection === 'row') {
541 node.setFlexDirection(LayoutFlexDirection.Row)
542 }
543
544 if (style.flexDirection === 'row-reverse') {
545 node.setFlexDirection(LayoutFlexDirection.RowReverse)
546 }
547
548 if (style.flexDirection === 'column') {
549 node.setFlexDirection(LayoutFlexDirection.Column)
550 }
551
552 if (style.flexDirection === 'column-reverse') {
553 node.setFlexDirection(LayoutFlexDirection.ColumnReverse)
554 }
555 }
556
557 if ('flexBasis' in style) {
558 if (typeof style.flexBasis === 'number') {
559 node.setFlexBasis(style.flexBasis)
560 } else if (typeof style.flexBasis === 'string') {
561 node.setFlexBasisPercent(Number.parseInt(style.flexBasis, 10))
562 } else {
563 node.setFlexBasis(Number.NaN)
564 }
565 }
566
567 if ('alignItems' in style) {
568 if (style.alignItems === 'stretch' || !style.alignItems) {
569 node.setAlignItems(LayoutAlign.Stretch)
570 }
571

Callers 1

stylesFunction · 0.85

Calls 9

setFlexGrowMethod · 0.45
setFlexShrinkMethod · 0.45
setFlexWrapMethod · 0.45
setFlexDirectionMethod · 0.45
setFlexBasisMethod · 0.45
setFlexBasisPercentMethod · 0.45
setAlignItemsMethod · 0.45
setAlignSelfMethod · 0.45
setJustifyContentMethod · 0.45

Tested by

no test coverage detected